[project @ 2001-08-04 06:11:24 by ken]
[ghc-hetmet.git] / ghc / compiler / prelude / primops.txt.pp
1 -----------------------------------------------------------------------
2 -- $Id: primops.txt.pp,v 1.1 2001/08/04 06:19:54 ken Exp $
3 --
4 -- Primitive Operations
5 --
6 -----------------------------------------------------------------------
7
8 -- To add a new primop, you currently need to update the following files:
9 --
10 --      - this file (ghc/compiler/prelude/primops.txt.pp), which includes
11 --        the type of the primop, and various other properties (its
12 --        strictness attributes, whether it is defined as a macro
13 --        or as out-of-line code, etc.)
14 --
15 --      - ghc/lib/std/PrelGHC.hi-boot.pp, to declare the primop
16 --
17 --      - if the primop is inline (i.e. a macro), then:
18 --              ghc/includes/PrimOps.h
19 --              ghc/compiler/nativeGen/StixPrim.lhs
20 --
21 --      - or, for an out-of-line primop:
22 --              ghc/includes/PrimOps.h (just add the declaration)
23 --              ghc/rts/PrimOps.hc     (define it here)
24 --
25 --      - the User's Guide
26 --
27
28 #include "config.h"
29 #include "Derived.h"
30
31 -- The default attribute values which apply if you don't specify
32 -- other ones.  Attribute values can be True, False, or arbitrary
33 -- text between curly brackets.  This is a kludge to enable 
34 -- processors of this file to easily get hold of simple info
35 -- (eg, out_of_line), whilst avoiding parsing complex expressions
36 -- needed for strictness and usage info.
37
38 defaults
39    has_side_effects = False
40    out_of_line      = False
41    commutable       = False
42    needs_wrapper    = False
43    can_fail         = False
44    strictness       = { \ arity -> StrictnessInfo (replicate arity wwPrim) False }
45    usage            = { nomangle other }
46
47
48 ------------------------------------------------------------------------
49 --- Support for the bytecode interpreter and linker                  ---
50 ------------------------------------------------------------------------
51
52 -- Convert an Addr# to a followable type
53 primop   AddrToHValueOp "addrToHValue#" GenPrimOp
54    Addr# -> (# a #)
55
56 primop   MkApUpd0_Op "mkApUpd0#" GenPrimOp
57    a -> (# a #)
58    with
59    out_of_line = True
60
61 primop  NewBCOOp "newBCO#" GenPrimOp
62    ByteArr# -> ByteArr# -> Array# a -> ByteArr# -> State# s -> (# State# s, BCO# #)
63    with
64    has_side_effects = True
65    out_of_line      = True
66
67
68 ------------------------------------------------------------------------
69 --- Addr#                                                            ---
70 ------------------------------------------------------------------------
71
72 primop   AddrGtOp  "gtAddr#"   Compare   Addr# -> Addr# -> Bool
73 primop   AddrGeOp  "geAddr#"   Compare   Addr# -> Addr# -> Bool
74 primop   AddrEqOp  "eqAddr#"   Compare   Addr# -> Addr# -> Bool
75 primop   AddrNeOp  "neAddr#"   Compare   Addr# -> Addr# -> Bool
76 primop   AddrLtOp  "ltAddr#"   Compare   Addr# -> Addr# -> Bool
77 primop   AddrLeOp  "leAddr#"   Compare   Addr# -> Addr# -> Bool
78
79 primop   Addr2IntOp  "addr2Int#"     GenPrimOp   Addr# -> Int#
80
81
82 ------------------------------------------------------------------------
83 --- Char#                                                            ---
84 ------------------------------------------------------------------------
85
86 primop   CharGtOp  "gtChar#"   Compare   Char# -> Char# -> Bool
87 primop   CharGeOp  "geChar#"   Compare   Char# -> Char# -> Bool
88
89 primop   CharEqOp  "eqChar#"   Compare
90    Char# -> Char# -> Bool
91    with commutable = True
92
93 primop   CharNeOp  "neChar#"   Compare
94    Char# -> Char# -> Bool
95    with commutable = True
96
97 primop   CharLtOp  "ltChar#"   Compare   Char# -> Char# -> Bool
98 primop   CharLeOp  "leChar#"   Compare   Char# -> Char# -> Bool
99
100 primop   OrdOp   "ord#"  GenPrimOp   Char# -> Int#
101
102 ------------------------------------------------------------------------
103 --- Double#                                                          ---
104 ------------------------------------------------------------------------
105
106 primop   DoubleGtOp ">##"   Compare   Double# -> Double# -> Bool
107 primop   DoubleGeOp ">=##"   Compare   Double# -> Double# -> Bool
108
109 primop DoubleEqOp "==##"   Compare
110    Double# -> Double# -> Bool
111    with commutable = True
112
113 primop DoubleNeOp "/=##"   Compare
114    Double# -> Double# -> Bool
115    with commutable = True
116
117 primop   DoubleLtOp "<##"   Compare   Double# -> Double# -> Bool
118 primop   DoubleLeOp "<=##"   Compare   Double# -> Double# -> Bool
119
120 primop   DoubleAddOp   "+##"   Dyadic
121    Double# -> Double# -> Double#
122    with commutable = True
123
124 primop   DoubleSubOp   "-##"   Dyadic   Double# -> Double# -> Double#
125
126 primop   DoubleMulOp   "*##"   Dyadic
127    Double# -> Double# -> Double#
128    with commutable = True
129
130 primop   DoubleDivOp   "/##"   Dyadic
131    Double# -> Double# -> Double#
132    with can_fail = True
133
134 primop   DoubleNegOp   "negateDouble#"  Monadic   Double# -> Double#
135
136 primop   Double2IntOp   "double2Int#"          GenPrimOp  Double# -> Int#
137 primop   Double2FloatOp   "double2Float#" GenPrimOp Double# -> Float#
138
139 primop   DoubleExpOp   "expDouble#"      Monadic
140    Double# -> Double#
141    with needs_wrapper = True
142
143 primop   DoubleLogOp   "logDouble#"      Monadic         
144    Double# -> Double#
145    with
146    needs_wrapper = True
147    can_fail = True
148
149 primop   DoubleSqrtOp   "sqrtDouble#"      Monadic  
150    Double# -> Double#
151    with needs_wrapper = True
152
153 primop   DoubleSinOp   "sinDouble#"      Monadic          
154    Double# -> Double#
155    with needs_wrapper = True
156
157 primop   DoubleCosOp   "cosDouble#"      Monadic          
158    Double# -> Double#
159    with needs_wrapper = True
160
161 primop   DoubleTanOp   "tanDouble#"      Monadic          
162    Double# -> Double#
163    with needs_wrapper = True
164
165 primop   DoubleAsinOp   "asinDouble#"      Monadic 
166    Double# -> Double#
167    with
168    needs_wrapper = True
169    can_fail = True
170
171 primop   DoubleAcosOp   "acosDouble#"      Monadic  
172    Double# -> Double#
173    with
174    needs_wrapper = True
175    can_fail = True
176
177 primop   DoubleAtanOp   "atanDouble#"      Monadic  
178    Double# -> Double#
179    with
180    needs_wrapper = True
181
182 primop   DoubleSinhOp   "sinhDouble#"      Monadic  
183    Double# -> Double#
184    with needs_wrapper = True
185
186 primop   DoubleCoshOp   "coshDouble#"      Monadic  
187    Double# -> Double#
188    with needs_wrapper = True
189
190 primop   DoubleTanhOp   "tanhDouble#"      Monadic  
191    Double# -> Double#
192    with needs_wrapper = True
193
194 primop   DoublePowerOp   "**##" Dyadic  
195    Double# -> Double# -> Double#
196    with needs_wrapper = True
197
198 primop   DoubleDecodeOp   "decodeDouble#" GenPrimOp    
199    Double# -> (# Int#, Int#, ByteArr# #)
200    with out_of_line = True
201
202 ------------------------------------------------------------------------
203 --- Float#                                                            ---
204 ------------------------------------------------------------------------
205
206 primop   FloatGtOp  "gtFloat#"   Compare   Float# -> Float# -> Bool
207 primop   FloatGeOp  "geFloat#"   Compare   Float# -> Float# -> Bool
208
209 primop   FloatEqOp  "eqFloat#"   Compare
210    Float# -> Float# -> Bool
211    with commutable = True
212
213 primop   FloatNeOp  "neFloat#"   Compare
214    Float# -> Float# -> Bool
215    with commutable = True
216
217 primop   FloatLtOp  "ltFloat#"   Compare   Float# -> Float# -> Bool
218 primop   FloatLeOp  "leFloat#"   Compare   Float# -> Float# -> Bool
219
220 primop   FloatAddOp   "plusFloat#"      Dyadic            
221    Float# -> Float# -> Float#
222    with commutable = True
223
224 primop   FloatSubOp   "minusFloat#"      Dyadic      Float# -> Float# -> Float#
225
226 primop   FloatMulOp   "timesFloat#"      Dyadic    
227    Float# -> Float# -> Float#
228    with commutable = True
229
230 primop   FloatDivOp   "divideFloat#"      Dyadic  
231    Float# -> Float# -> Float#
232    with can_fail = True
233
234 primop   FloatNegOp   "negateFloat#"      Monadic    Float# -> Float#
235
236 primop   Float2IntOp   "float2Int#"      GenPrimOp  Float# -> Int#
237
238 primop   FloatExpOp   "expFloat#"      Monadic          
239    Float# -> Float#
240    with needs_wrapper = True
241
242 primop   FloatLogOp   "logFloat#"      Monadic          
243    Float# -> Float#
244    with needs_wrapper = True
245         can_fail = True
246
247 primop   FloatSqrtOp   "sqrtFloat#"      Monadic          
248    Float# -> Float#
249    with needs_wrapper = True
250
251 primop   FloatSinOp   "sinFloat#"      Monadic          
252    Float# -> Float#
253    with needs_wrapper = True
254
255 primop   FloatCosOp   "cosFloat#"      Monadic          
256    Float# -> Float#
257    with needs_wrapper = True
258
259 primop   FloatTanOp   "tanFloat#"      Monadic          
260    Float# -> Float#
261    with needs_wrapper = True
262
263 primop   FloatAsinOp   "asinFloat#"      Monadic          
264    Float# -> Float#
265    with needs_wrapper = True
266         can_fail = True
267
268 primop   FloatAcosOp   "acosFloat#"      Monadic          
269    Float# -> Float#
270    with needs_wrapper = True
271         can_fail = True
272
273 primop   FloatAtanOp   "atanFloat#"      Monadic          
274    Float# -> Float#
275    with needs_wrapper = True
276
277 primop   FloatSinhOp   "sinhFloat#"      Monadic          
278    Float# -> Float#
279    with needs_wrapper = True
280
281 primop   FloatCoshOp   "coshFloat#"      Monadic          
282    Float# -> Float#
283    with needs_wrapper = True
284
285 primop   FloatTanhOp   "tanhFloat#"      Monadic          
286    Float# -> Float#
287    with needs_wrapper = True
288
289 primop   FloatPowerOp   "powerFloat#"      Dyadic   
290    Float# -> Float# -> Float#
291    with needs_wrapper = True
292
293 primop   Float2DoubleOp   "float2Double#" GenPrimOp  Float# -> Double#
294
295 primop   FloatDecodeOp   "decodeFloat#" GenPrimOp
296    Float# -> (# Int#, Int#, ByteArr# #)
297    with out_of_line = True
298
299 ------------------------------------------------------------------------
300 --- Int#                                                             ---
301 ------------------------------------------------------------------------
302
303 primop   IntAddOp    "+#"    Dyadic
304    Int# -> Int# -> Int#
305    with commutable = True
306
307 primop   IntSubOp    "-#"    Dyadic   Int# -> Int# -> Int#
308
309 primop   IntMulOp    "*#" 
310    Dyadic   Int# -> Int# -> Int#
311    with commutable = True
312
313 primop   IntQuotOp    "quotInt#"    Dyadic
314    Int# -> Int# -> Int#
315    with can_fail = True
316
317 primop   IntRemOp    "remInt#"    Dyadic
318    Int# -> Int# -> Int#
319    with can_fail = True
320
321 primop   IntGcdOp    "gcdInt#"    Dyadic   Int# -> Int# -> Int#
322 primop   IntNegOp    "negateInt#"    Monadic   Int# -> Int#
323 primop   IntAddCOp   "addIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
324 primop   IntSubCOp   "subIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
325 primop   IntMulCOp   "mulIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
326 primop   IntGtOp  ">#"   Compare   Int# -> Int# -> Bool
327 primop   IntGeOp  ">=#"   Compare   Int# -> Int# -> Bool
328
329 primop   IntEqOp  "==#"   Compare
330    Int# -> Int# -> Bool
331    with commutable = True
332
333 primop   IntNeOp  "/=#"   Compare
334    Int# -> Int# -> Bool
335    with commutable = True
336
337 primop   IntLtOp  "<#"   Compare   Int# -> Int# -> Bool
338 primop   IntLeOp  "<=#"   Compare   Int# -> Int# -> Bool
339
340 primop   ChrOp   "chr#"   GenPrimOp   Int# -> Char#
341
342 primop   Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
343 primop   Int2AddrOp   "int2Addr#"GenPrimOp  Int# -> Addr#
344 primop   Int2FloatOp   "int2Float#"      GenPrimOp  Int# -> Float#
345 primop   Int2DoubleOp   "int2Double#"          GenPrimOp  Int# -> Double#
346
347 primop   Int2IntegerOp    "int2Integer#"
348    GenPrimOp Int# -> (# Int#, ByteArr# #)
349    with out_of_line = True
350
351 primop   ISllOp   "iShiftL#" GenPrimOp  Int# -> Int# -> Int#
352 primop   ISraOp   "iShiftRA#" GenPrimOp Int# -> Int# -> Int#
353 primop   ISrlOp   "iShiftRL#" GenPrimOp Int# -> Int# -> Int#
354
355 ------------------------------------------------------------------------
356 --- Int64#                                                           ---
357 ------------------------------------------------------------------------
358
359 #ifdef SUPPORT_LONG_LONGS
360 primop   Int64ToIntegerOp   "int64ToInteger#" GenPrimOp 
361    Int64# -> (# Int#, ByteArr# #)
362    with out_of_line = True
363 #endif
364
365
366 ------------------------------------------------------------------------
367 --- Integer#                                                         ---
368 ------------------------------------------------------------------------
369
370 primop   IntegerAddOp   "plusInteger#" GenPrimOp   
371    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
372    with commutable = True
373         out_of_line = True
374
375 primop   IntegerSubOp   "minusInteger#" GenPrimOp  
376    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
377    with out_of_line = True
378
379 primop   IntegerMulOp   "timesInteger#" GenPrimOp   
380    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
381    with commutable = True
382         out_of_line = True
383
384 primop   IntegerGcdOp   "gcdInteger#" GenPrimOp    
385    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
386    with commutable = True
387         out_of_line = True
388
389 primop   IntegerIntGcdOp   "gcdIntegerInt#" GenPrimOp
390    Int# -> ByteArr# -> Int# -> Int#
391    with commutable = True
392
393 primop   IntegerDivExactOp   "divExactInteger#" GenPrimOp
394    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
395    with out_of_line = True
396
397 primop   IntegerQuotOp   "quotInteger#" GenPrimOp
398    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
399    with out_of_line = True
400
401 primop   IntegerRemOp   "remInteger#" GenPrimOp
402    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
403    with out_of_line = True
404
405 primop   IntegerCmpOp   "cmpInteger#"   GenPrimOp  
406    Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
407    with needs_wrapper = True
408
409 primop   IntegerCmpIntOp   "cmpIntegerInt#" GenPrimOp
410    Int# -> ByteArr# -> Int# -> Int#
411    with needs_wrapper = True
412
413 primop   IntegerQuotRemOp   "quotRemInteger#" GenPrimOp
414    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
415    with can_fail = True
416         out_of_line = True
417
418 primop   IntegerDivModOp    "divModInteger#"  GenPrimOp
419    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
420    with can_fail = True
421         out_of_line = True
422
423 primop   Integer2IntOp   "integer2Int#"    GenPrimOp
424    Int# -> ByteArr# -> Int#
425    with needs_wrapper = True
426
427 primop   Integer2WordOp   "integer2Word#"   GenPrimOp
428    Int# -> ByteArr# -> Word#
429    with needs_wrapper = True
430
431 #ifdef SUPPORT_LONG_LONGS
432 primop   IntegerToInt64Op   "integerToInt64#" GenPrimOp
433    Int# -> ByteArr# -> Int64#
434
435 primop   IntegerToWord64Op   "integerToWord64#" GenPrimOp
436    Int# -> ByteArr# -> Word64#
437 #endif
438
439 primop   IntegerAndOp  "andInteger#" GenPrimOp
440    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
441    with out_of_line = True
442
443 primop   IntegerOrOp  "orInteger#" GenPrimOp
444    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
445    with out_of_line = True
446
447 primop   IntegerXorOp  "xorInteger#" GenPrimOp
448    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
449    with out_of_line = True
450
451 primop   IntegerComplementOp  "complementInteger#" GenPrimOp
452    Int# -> ByteArr# -> (# Int#, ByteArr# #)
453    with out_of_line = True
454
455 ------------------------------------------------------------------------
456 --- Word#                                                            ---
457 ------------------------------------------------------------------------
458
459 primop   WordAddOp   "plusWord#"   Dyadic   Word# -> Word# -> Word#
460    with commutable = True
461
462 primop   WordSubOp   "minusWord#"   Dyadic   Word# -> Word# -> Word#
463
464 primop   WordMulOp   "timesWord#"   Dyadic   Word# -> Word# -> Word#
465    with commutable = True
466
467 primop   WordQuotOp   "quotWord#"   Dyadic   Word# -> Word# -> Word#
468    with can_fail = True
469
470 primop   WordRemOp   "remWord#"   Dyadic   Word# -> Word# -> Word#
471    with can_fail = True
472
473 primop   AndOp   "and#"   Dyadic   Word# -> Word# -> Word#
474    with commutable = True
475
476 primop   OrOp   "or#"   Dyadic   Word# -> Word# -> Word#
477    with commutable = True
478
479 primop   XorOp   "xor#"   Dyadic   Word# -> Word# -> Word#
480    with commutable = True
481
482 primop   NotOp   "not#"   Monadic   Word# -> Word#
483
484 primop   SllOp   "shiftL#"   GenPrimOp   Word# -> Int# -> Word#
485
486 primop   SrlOp   "shiftRL#"   GenPrimOp   Word# -> Int# -> Word#
487
488 primop   Word2IntOp   "word2Int#"   GenPrimOp   Word# -> Int#
489
490 primop   Word2IntegerOp   "word2Integer#"   GenPrimOp 
491    Word# -> (# Int#, ByteArr# #)
492    with out_of_line = True
493
494 primop   WordGtOp   "gtWord#"   Compare   Word# -> Word# -> Bool
495 primop   WordGeOp   "geWord#"   Compare   Word# -> Word# -> Bool
496 primop   WordEqOp   "eqWord#"   Compare   Word# -> Word# -> Bool
497 primop   WordNeOp   "neWord#"   Compare   Word# -> Word# -> Bool
498 primop   WordLtOp   "ltWord#"   Compare   Word# -> Word# -> Bool
499 primop   WordLeOp   "leWord#"   Compare   Word# -> Word# -> Bool
500
501 ------------------------------------------------------------------------
502 --- Word64#                                                          ---
503 ------------------------------------------------------------------------
504
505 #ifdef SUPPORT_LONG_LONGS
506 primop   Word64ToIntegerOp   "word64ToInteger#" GenPrimOp
507    Word64# -> (# Int#, ByteArr# #)
508    with out_of_line = True
509 #endif
510
511 ------------------------------------------------------------------------
512 --- Explicitly sized Int# and Word#                                  ---
513 ------------------------------------------------------------------------
514
515 primop   IntToInt8Op       "intToInt8#"       Monadic   Int# -> Int#
516 primop   IntToInt16Op      "intToInt16#"      Monadic   Int# -> Int#
517 primop   IntToInt32Op      "intToInt32#"      Monadic   Int# -> Int#
518 primop   WordToWord8Op     "wordToWord8#"     Monadic   Word# -> Word#
519 primop   WordToWord16Op    "wordToWord16#"    Monadic   Word# -> Word#
520 primop   WordToWord32Op    "wordToWord32#"    Monadic   Word# -> Word#
521
522 ------------------------------------------------------------------------
523 --- Arrays                                                           ---
524 ------------------------------------------------------------------------
525
526 primop  NewArrayOp "newArray#" GenPrimOp
527    Int# -> a -> State# s -> (# State# s, MutArr# s a #)
528    with
529    strictness  = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
530    usage       = { mangle NewArrayOp [mkP, mkM, mkP] mkM }
531    out_of_line = True
532
533 primop  NewByteArrayOp_Char "newByteArray#" GenPrimOp
534    Int# -> State# s -> (# State# s, MutByteArr# s #)
535    with out_of_line = True
536
537
538 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
539    ByteArr# -> Int# -> Char#
540
541 primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp
542    ByteArr# -> Int# -> Char#
543
544 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
545    ByteArr# -> Int# -> Int#
546
547 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
548    ByteArr# -> Int# -> Word#
549
550 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
551    ByteArr# -> Int# -> Addr#
552
553 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
554    ByteArr# -> Int# -> Float#
555
556 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
557    ByteArr# -> Int# -> Double#
558
559 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
560    ByteArr# -> Int# -> StablePtr# a
561
562 primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
563    ByteArr# -> Int# -> Int#
564
565 primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
566    ByteArr# -> Int# -> Int#
567
568 primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
569    ByteArr# -> Int# -> Int#
570
571 #ifdef SUPPORT_LONG_LONGS
572 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
573    ByteArr# -> Int# -> Int64#
574 #endif
575
576 primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
577    ByteArr# -> Int# -> Word#
578
579 primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
580    ByteArr# -> Int# -> Word#
581
582 primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
583    ByteArr# -> Int# -> Word#
584
585 #ifdef SUPPORT_LONG_LONGS
586 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
587    ByteArr# -> Int# -> Word64#
588 #endif
589
590
591 primop  ReadByteArrayOp_Char "readCharArray#" GenPrimOp
592    MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
593
594 primop  ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp
595    MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
596
597 primop  ReadByteArrayOp_Int "readIntArray#" GenPrimOp
598    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
599
600 primop  ReadByteArrayOp_Word "readWordArray#" GenPrimOp
601    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
602
603 primop  ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
604    MutByteArr# s -> Int# -> State# s -> (# State# s, Addr# #)
605
606 primop  ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
607    MutByteArr# s -> Int# -> State# s -> (# State# s, Float# #)
608
609 primop  ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
610    MutByteArr# s -> Int# -> State# s -> (# State# s, Double# #)
611
612 primop  ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
613    MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
614
615 primop  ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
616    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
617
618 primop  ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
619    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
620
621 primop  ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
622    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
623
624 #ifdef SUPPORT_LONG_LONGS
625 primop  ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
626    MutByteArr# s -> Int# -> State# s -> (# State# s, Int64# #)
627 #endif
628
629 primop  ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
630    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
631
632 primop  ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
633    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
634
635 primop  ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
636    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
637
638 #ifdef SUPPORT_LONG_LONGS
639 primop  ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
640    MutByteArr# s -> Int# -> State# s -> (# State# s, Word64# #)
641 #endif
642
643
644
645 primop  WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
646    MutByteArr# s -> Int# -> Char# -> State# s -> State# s
647    with has_side_effects = True
648
649 primop  WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp
650    MutByteArr# s -> Int# -> Char# -> State# s -> State# s
651    with has_side_effects = True
652
653 primop  WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
654    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
655    with has_side_effects = True
656
657 primop  WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
658    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
659    with has_side_effects = True
660
661 primop  WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
662    MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
663    with has_side_effects = True
664
665 primop  WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
666    MutByteArr# s -> Int# -> Float# -> State# s -> State# s
667    with has_side_effects = True
668
669 primop  WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
670    MutByteArr# s -> Int# -> Double# -> State# s -> State# s
671    with has_side_effects = True
672
673 primop  WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
674    MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
675    with has_side_effects = True
676
677 primop  WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
678    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
679    with has_side_effects = True
680
681 primop  WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
682    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
683    with has_side_effects = True
684
685 primop  WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
686    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
687    with has_side_effects = True
688
689 #ifdef SUPPORT_LONG_LONGS
690 primop  WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
691    MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
692    with has_side_effects = True
693 #endif
694
695 primop  WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
696    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
697    with has_side_effects = True
698
699 primop  WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
700    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
701    with has_side_effects = True
702
703 primop  WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
704    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
705    with has_side_effects = True
706
707 #ifdef SUPPORT_LONG_LONGS
708 primop  WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
709    MutByteArr# s -> Int# -> Word64# -> State# s -> State# s
710    with has_side_effects = True
711 #endif
712
713
714 primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
715    Addr# -> Int# -> Char#
716
717 primop IndexOffAddrOp_WideChar "indexWideCharOffAddr#" GenPrimOp
718    Addr# -> Int# -> Char#
719
720 primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
721    Addr# -> Int# -> Int#
722
723 primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
724    Addr# -> Int# -> Word#
725
726 primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
727    Addr# -> Int# -> Addr#
728
729 primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
730    Addr# -> Int# -> Float#
731
732 primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
733    Addr# -> Int# -> Double#
734
735 primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
736    Addr# -> Int# -> StablePtr# a
737
738 primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
739    Addr# -> Int# -> Int#
740
741 primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
742    Addr# -> Int# -> Int#
743
744 primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
745    Addr# -> Int# -> Int#
746
747 #ifdef SUPPORT_LONG_LONGS
748 primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
749    Addr# -> Int# -> Int64#
750 #endif
751
752 primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
753    Addr# -> Int# -> Word#
754
755 primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
756    Addr# -> Int# -> Word#
757
758 primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
759    Addr# -> Int# -> Word#
760
761 #ifdef SUPPORT_LONG_LONGS
762 primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
763    Addr# -> Int# -> Word64#
764 #endif
765
766
767 primop EqForeignObj "eqForeignObj#" GenPrimOp
768    ForeignObj# -> ForeignObj# -> Bool
769    with commutable = True
770
771 primop IndexOffForeignObjOp_Char "indexCharOffForeignObj#" GenPrimOp
772    ForeignObj# -> Int# -> Char#
773
774 primop IndexOffForeignObjOp_WideChar "indexWideCharOffForeignObj#" GenPrimOp
775    ForeignObj# -> Int# -> Char#
776
777 primop IndexOffForeignObjOp_Int "indexIntOffForeignObj#" GenPrimOp
778    ForeignObj# -> Int# -> Int#
779
780 primop IndexOffForeignObjOp_Word "indexWordOffForeignObj#" GenPrimOp
781    ForeignObj# -> Int# -> Word#
782
783 primop IndexOffForeignObjOp_Addr "indexAddrOffForeignObj#" GenPrimOp
784    ForeignObj# -> Int# -> Addr#
785
786 primop IndexOffForeignObjOp_Float "indexFloatOffForeignObj#" GenPrimOp
787    ForeignObj# -> Int# -> Float#
788
789 primop IndexOffForeignObjOp_Double "indexDoubleOffForeignObj#" GenPrimOp
790    ForeignObj# -> Int# -> Double#
791
792 primop IndexOffForeignObjOp_StablePtr "indexStablePtrOffForeignObj#" GenPrimOp
793    ForeignObj# -> Int# -> StablePtr# a
794
795 primop IndexOffForeignObjOp_Int8 "indexInt8OffForeignObj#" GenPrimOp
796    ForeignObj# -> Int# -> Int#
797
798 primop IndexOffForeignObjOp_Int16 "indexInt16OffForeignObj#" GenPrimOp
799    ForeignObj# -> Int# -> Int#
800
801 primop IndexOffForeignObjOp_Int32 "indexInt32OffForeignObj#" GenPrimOp
802    ForeignObj# -> Int# -> Int#
803
804 #ifdef SUPPORT_LONG_LONGS
805 primop IndexOffForeignObjOp_Int64 "indexInt64OffForeignObj#" GenPrimOp
806    ForeignObj# -> Int# -> Int64#
807 #endif
808
809 primop IndexOffForeignObjOp_Word8 "indexWord8OffForeignObj#" GenPrimOp
810    ForeignObj# -> Int# -> Word#
811
812 primop IndexOffForeignObjOp_Word16 "indexWord16OffForeignObj#" GenPrimOp
813    ForeignObj# -> Int# -> Word#
814
815 primop IndexOffForeignObjOp_Word32 "indexWord32OffForeignObj#" GenPrimOp
816    ForeignObj# -> Int# -> Word#
817
818 #ifdef SUPPORT_LONG_LONGS
819 primop IndexOffForeignObjOp_Word64 "indexWord64OffForeignObj#" GenPrimOp
820    ForeignObj# -> Int# -> Word64#
821 #endif
822
823 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
824    Addr# -> Int# -> State# s -> (# State# s, Char# #)
825
826 primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp
827    Addr# -> Int# -> State# s -> (# State# s, Char# #)
828
829 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
830    Addr# -> Int# -> State# s -> (# State# s, Int# #)
831
832 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
833    Addr# -> Int# -> State# s -> (# State# s, Word# #)
834
835 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
836    Addr# -> Int# -> State# s -> (# State# s, Addr# #)
837
838 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
839    Addr# -> Int# -> State# s -> (# State# s, Float# #)
840
841 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
842    Addr# -> Int# -> State# s -> (# State# s, Double# #)
843
844 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
845    Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
846
847 primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
848    Addr# -> Int# -> State# s -> (# State# s, Int# #)
849
850 primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
851    Addr# -> Int# -> State# s -> (# State# s, Int# #)
852
853 primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
854    Addr# -> Int# -> State# s -> (# State# s, Int# #)
855
856 #ifdef SUPPORT_LONG_LONGS
857 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
858    Addr# -> Int# -> State# s -> (# State# s, Int64# #)
859 #endif
860
861 primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
862    Addr# -> Int# -> State# s -> (# State# s, Word# #)
863
864 primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
865    Addr# -> Int# -> State# s -> (# State# s, Word# #)
866
867 primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
868    Addr# -> Int# -> State# s -> (# State# s, Word# #)
869
870 #ifdef SUPPORT_LONG_LONGS
871 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
872    Addr# -> Int# -> State# s -> (# State# s, Word64# #)
873 #endif
874
875
876 primop  WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
877    Addr# -> Int# -> Char# -> State# s -> State# s
878    with has_side_effects = True
879
880 primop  WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp
881    Addr# -> Int# -> Char# -> State# s -> State# s
882    with has_side_effects = True
883
884 primop  WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
885    Addr# -> Int# -> Int# -> State# s -> State# s
886    with has_side_effects = True
887
888 primop  WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
889    Addr# -> Int# -> Word# -> State# s -> State# s
890    with has_side_effects = True
891
892 primop  WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
893    Addr# -> Int# -> Addr# -> State# s -> State# s
894    with has_side_effects = True
895
896 primop  WriteOffAddrOp_ForeignObj "writeForeignObjOffAddr#" GenPrimOp
897    Addr# -> Int# -> ForeignObj# -> State# s -> State# s
898    with has_side_effects = True
899
900 primop  WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
901    Addr# -> Int# -> Float# -> State# s -> State# s
902    with has_side_effects = True
903
904 primop  WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
905    Addr# -> Int# -> Double# -> State# s -> State# s
906    with has_side_effects = True
907
908 primop  WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
909    Addr# -> Int# -> StablePtr# a -> State# s -> State# s
910    with has_side_effects = True
911
912 primop  WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
913    Addr# -> Int# -> Int# -> State# s -> State# s
914    with has_side_effects = True
915
916 primop  WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
917    Addr# -> Int# -> Int# -> State# s -> State# s
918    with has_side_effects = True
919
920 primop  WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
921    Addr# -> Int# -> Int# -> State# s -> State# s
922    with has_side_effects = True
923
924 #ifdef SUPPORT_LONG_LONGS
925 primop  WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
926    Addr# -> Int# -> Int64# -> State# s -> State# s
927    with has_side_effects = True
928 #endif
929
930 primop  WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
931    Addr# -> Int# -> Word# -> State# s -> State# s
932    with has_side_effects = True
933
934 primop  WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
935    Addr# -> Int# -> Word# -> State# s -> State# s
936    with has_side_effects = True
937
938 primop  WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
939    Addr# -> Int# -> Word# -> State# s -> State# s
940    with has_side_effects = True
941
942 #ifdef SUPPORT_LONG_LONGS
943 primop  WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
944    Addr# -> Int# -> Word64# -> State# s -> State# s
945    with has_side_effects = True
946 #endif
947
948
949
950 primop  SameMutableArrayOp "sameMutableArray#" GenPrimOp
951    MutArr# s a -> MutArr# s a -> Bool
952    with
953    usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
954
955 primop  SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
956    MutByteArr# s -> MutByteArr# s -> Bool
957
958 primop  ReadArrayOp "readArray#" GenPrimOp
959    MutArr# s a -> Int# -> State# s -> (# State# s, a #)
960    with
961    usage = { mangle ReadArrayOp [mkM, mkP, mkP] mkM }
962
963 primop  WriteArrayOp "writeArray#" GenPrimOp
964    MutArr# s a -> Int# -> a -> State# s -> State# s
965    with
966    usage            = { mangle WriteArrayOp [mkM, mkP, mkM, mkP] mkR }
967    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwPrim, wwLazy, wwPrim] False }
968    has_side_effects = True
969
970 primop  IndexArrayOp "indexArray#" GenPrimOp
971    Array# a -> Int# -> (# a #)
972    with
973    usage = { mangle  IndexArrayOp [mkM, mkP] mkM }
974
975 primop  UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
976    MutArr# s a -> State# s -> (# State# s, Array# a #)
977    with
978    usage            = { mangle UnsafeFreezeArrayOp [mkM, mkP] mkM }
979    has_side_effects = True
980
981 primop  UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
982    MutByteArr# s -> State# s -> (# State# s, ByteArr# #)
983    with
984    has_side_effects = True
985
986 primop  UnsafeThawArrayOp  "unsafeThawArray#" GenPrimOp
987    Array# a -> State# s -> (# State# s, MutArr# s a #)
988    with
989    usage       = { mangle UnsafeThawArrayOp [mkM, mkP] mkM }
990    out_of_line = True
991
992 primop  SizeofByteArrayOp "sizeofByteArray#" GenPrimOp  
993    ByteArr# -> Int#
994
995 primop  SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
996    MutByteArr# s -> Int#
997
998 ------------------------------------------------------------------------
999 --- Mutable variables                                                ---
1000 ------------------------------------------------------------------------
1001
1002 primop  NewMutVarOp "newMutVar#" GenPrimOp
1003    a -> State# s -> (# State# s, MutVar# s a #)
1004    with
1005    usage       = { mangle NewMutVarOp [mkM, mkP] mkM }
1006    strictness  = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1007    out_of_line = True
1008
1009 primop  ReadMutVarOp "readMutVar#" GenPrimOp
1010    MutVar# s a -> State# s -> (# State# s, a #)
1011    with
1012    usage = { mangle ReadMutVarOp [mkM, mkP] mkM }
1013
1014 primop  WriteMutVarOp "writeMutVar#"  GenPrimOp
1015    MutVar# s a -> a -> State# s -> State# s
1016    with
1017    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
1018    usage            = { mangle WriteMutVarOp [mkM, mkM, mkP] mkR }
1019    has_side_effects = True
1020
1021 primop  SameMutVarOp "sameMutVar#" GenPrimOp
1022    MutVar# s a -> MutVar# s a -> Bool
1023    with
1024    usage = { mangle SameMutVarOp [mkP, mkP] mkM }
1025
1026 ------------------------------------------------------------------------
1027 --- Exceptions                                                       ---
1028 ------------------------------------------------------------------------
1029
1030 primop  CatchOp "catch#" GenPrimOp
1031           (State# RealWorld -> (# State# RealWorld, a #) )
1032        -> (b -> State# RealWorld -> (# State# RealWorld, a #) ) 
1033        -> State# RealWorld
1034        -> (# State# RealWorld, a #)
1035    with
1036    strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwPrim] False }
1037         -- Catch is actually strict in its first argument
1038         -- but we don't want to tell the strictness
1039         -- analyser about that!
1040    usage = { mangle CatchOp [mkM, mkM . (inFun CatchOp mkM mkM), mkP] mkM }
1041         --     [mkO, mkO . (inFun mkM mkO)] mkO
1042         -- might use caught action multiply
1043    out_of_line = True
1044
1045 primop  RaiseOp "raise#" GenPrimOp
1046    a -> b
1047    with
1048    strictness  = { \ arity -> StrictnessInfo [wwLazy] True }
1049       -- NB: True => result is bottom
1050    usage       = { mangle RaiseOp [mkM] mkM }
1051    out_of_line = True
1052
1053 primop  BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
1054         (State# RealWorld -> (# State# RealWorld, a #))
1055      -> (State# RealWorld -> (# State# RealWorld, a #))
1056    with
1057    strictness  = { \ arity -> StrictnessInfo [wwLazy,wwPrim] False }
1058    out_of_line = True
1059
1060 primop  UnblockAsyncExceptionsOp "unblockAsyncExceptions#" GenPrimOp
1061         (State# RealWorld -> (# State# RealWorld, a #))
1062      -> (State# RealWorld -> (# State# RealWorld, a #))
1063    with
1064    strictness  = { \ arity -> StrictnessInfo [wwLazy,wwPrim] False }
1065    out_of_line = True
1066
1067 ------------------------------------------------------------------------
1068 --- MVars (not the same as mutable variables!)                       ---
1069 ------------------------------------------------------------------------
1070
1071 primop  NewMVarOp "newMVar#"  GenPrimOp
1072    State# s -> (# State# s, MVar# s a #)
1073    with
1074    usage       = { mangle NewMVarOp [mkP] mkR }
1075    out_of_line = True
1076
1077 primop  TakeMVarOp "takeMVar#" GenPrimOp
1078    MVar# s a -> State# s -> (# State# s, a #)
1079    with
1080    usage            = { mangle TakeMVarOp [mkM, mkP] mkM }
1081    has_side_effects = True
1082    out_of_line      = True
1083
1084 primop  TryTakeMVarOp "tryTakeMVar#" GenPrimOp
1085    MVar# s a -> State# s -> (# State# s, Int#, a #)
1086    with
1087    usage            = { mangle TryTakeMVarOp [mkM, mkP] mkM }
1088    has_side_effects = True
1089    out_of_line      = True
1090
1091 primop  PutMVarOp "putMVar#" GenPrimOp
1092    MVar# s a -> a -> State# s -> State# s
1093    with
1094    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
1095    usage            = { mangle PutMVarOp [mkM, mkM, mkP] mkR }
1096    has_side_effects = True
1097    out_of_line      = True
1098
1099 primop  TryPutMVarOp "tryPutMVar#" GenPrimOp
1100    MVar# s a -> a -> State# s -> (# State# s, Int# #)
1101    with
1102    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
1103    usage            = { mangle TryPutMVarOp [mkM, mkM, mkP] mkR }
1104    has_side_effects = True
1105    out_of_line      = True
1106
1107 primop  SameMVarOp "sameMVar#" GenPrimOp
1108    MVar# s a -> MVar# s a -> Bool
1109    with
1110    usage = { mangle SameMVarOp [mkP, mkP] mkM }
1111
1112 primop  IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
1113    MVar# s a -> State# s -> (# State# s, Int# #)
1114    with
1115    usage = { mangle IsEmptyMVarOp [mkP, mkP] mkM }
1116
1117
1118 ------------------------------------------------------------------------
1119 --- delay/wait operations                                            ---
1120 ------------------------------------------------------------------------
1121
1122 primop  DelayOp "delay#" GenPrimOp
1123    Int# -> State# s -> State# s
1124    with
1125    needs_wrapper    = True
1126    has_side_effects = True
1127    out_of_line      = True
1128
1129 primop  WaitReadOp "waitRead#" GenPrimOp
1130    Int# -> State# s -> State# s
1131    with
1132    needs_wrapper    = True
1133    has_side_effects = True
1134    out_of_line      = True
1135
1136 primop  WaitWriteOp "waitWrite#" GenPrimOp
1137    Int# -> State# s -> State# s
1138    with
1139    needs_wrapper    = True
1140    has_side_effects = True
1141    out_of_line      = True
1142
1143 ------------------------------------------------------------------------
1144 --- concurrency primitives                                           ---
1145 ------------------------------------------------------------------------
1146
1147 primop  ForkOp "fork#" GenPrimOp
1148    a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
1149    with
1150    usage            = { mangle ForkOp [mkO, mkP] mkR }
1151    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1152    has_side_effects = True
1153    out_of_line      = True
1154
1155 primop  KillThreadOp "killThread#"  GenPrimOp
1156    ThreadId# -> a -> State# RealWorld -> State# RealWorld
1157    with
1158    usage            = { mangle KillThreadOp [mkP, mkM, mkP] mkR }
1159    has_side_effects = True
1160    out_of_line      = True
1161
1162 primop  YieldOp "yield#" GenPrimOp
1163    State# RealWorld -> State# RealWorld
1164    with
1165    has_side_effects = True
1166    out_of_line      = True
1167
1168 primop  MyThreadIdOp "myThreadId#" GenPrimOp
1169     State# RealWorld -> (# State# RealWorld, ThreadId# #)
1170
1171 ------------------------------------------------------------------------
1172 --- foreign objects                                                  ---
1173 ------------------------------------------------------------------------
1174
1175 primop  MkForeignObjOp "mkForeignObj#" GenPrimOp
1176    Addr# -> State# RealWorld -> (# State# RealWorld, ForeignObj# #)
1177    with
1178    has_side_effects = True
1179    out_of_line      = True
1180
1181 primop  WriteForeignObjOp "writeForeignObj#" GenPrimOp
1182    ForeignObj# -> Addr# -> State# s -> State# s
1183    with
1184    has_side_effects = True
1185
1186 primop ForeignObjToAddrOp "foreignObjToAddr#" GenPrimOp
1187    ForeignObj# -> Addr#
1188
1189 primop TouchOp "touch#" GenPrimOp
1190    o -> State# RealWorld -> State# RealWorld
1191    with
1192    has_side_effects = True
1193    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1194
1195 ------------------------------------------------------------------------
1196 --- Weak pointers                                                    ---
1197 ------------------------------------------------------------------------
1198
1199 -- note that tyvar "o" denotes openAlphaTyVar
1200
1201 primop  MkWeakOp "mkWeak#" GenPrimOp
1202    o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
1203    with
1204    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwLazy, wwPrim] False }
1205    usage            = { mangle MkWeakOp [mkZ, mkM, mkM, mkP] mkM }
1206    has_side_effects = True
1207    out_of_line      = True
1208
1209 primop  DeRefWeakOp "deRefWeak#" GenPrimOp
1210    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
1211    with
1212    usage            = { mangle DeRefWeakOp [mkM, mkP] mkM }
1213    has_side_effects = True
1214
1215 primop  FinalizeWeakOp "finalizeWeak#" GenPrimOp
1216    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, 
1217               (State# RealWorld -> (# State# RealWorld, Unit #)) #)
1218    with
1219    usage            = { mangle FinalizeWeakOp [mkM, mkP] 
1220                                (mkR . (inUB FinalizeWeakOp 
1221                                             [id,id,inFun FinalizeWeakOp mkR mkM])) }
1222    has_side_effects = True
1223    out_of_line      = True
1224
1225 ------------------------------------------------------------------------
1226 --- Stable pointers and names                                        ---
1227 ------------------------------------------------------------------------
1228
1229 primop  MakeStablePtrOp "makeStablePtr#" GenPrimOp
1230    a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
1231    with
1232    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1233    usage            = { mangle MakeStablePtrOp [mkM, mkP] mkM }
1234    has_side_effects = True
1235
1236 primop  DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
1237    StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
1238    with
1239    usage            = { mangle DeRefStablePtrOp [mkM, mkP] mkM }
1240    needs_wrapper    = True
1241    has_side_effects = True
1242
1243 primop  EqStablePtrOp "eqStablePtr#" GenPrimOp
1244    StablePtr# a -> StablePtr# a -> Int#
1245    with
1246    usage            = { mangle EqStablePtrOp [mkP, mkP] mkR }
1247    has_side_effects = True
1248
1249 primop  MakeStableNameOp "makeStableName#" GenPrimOp
1250    a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
1251    with
1252    usage            = { mangle MakeStableNameOp [mkZ, mkP] mkR }
1253    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1254    needs_wrapper    = True
1255    has_side_effects = True
1256    out_of_line      = True
1257
1258 primop  EqStableNameOp "eqStableName#" GenPrimOp
1259    StableName# a -> StableName# a -> Int#
1260    with
1261    usage = { mangle EqStableNameOp [mkP, mkP] mkR }
1262
1263 primop  StableNameToIntOp "stableNameToInt#" GenPrimOp
1264    StableName# a -> Int#
1265    with
1266    usage = { mangle StableNameToIntOp [mkP] mkR }
1267
1268 ------------------------------------------------------------------------
1269 --- Unsafe pointer equality (#1 Bad Guy: Alistair Reid :)            ---
1270 ------------------------------------------------------------------------
1271
1272 primop  ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
1273    a -> a -> Int#
1274    with
1275    usage = { mangle ReallyUnsafePtrEqualityOp [mkZ, mkZ] mkR }
1276
1277 ------------------------------------------------------------------------
1278 --- Parallelism                                                      ---
1279 ------------------------------------------------------------------------
1280
1281 primop  SeqOp "seq#" GenPrimOp
1282    a -> Int#
1283    with
1284    usage            = { mangle  SeqOp [mkO] mkR }
1285    strictness       = { \ arity -> StrictnessInfo [wwStrict] False }
1286       -- Seq is strict in its argument; see notes in ConFold.lhs
1287    has_side_effects = True
1288
1289 primop  ParOp "par#" GenPrimOp
1290    a -> Int#
1291    with
1292    usage            = { mangle ParOp [mkO] mkR }
1293    strictness       = { \ arity -> StrictnessInfo [wwLazy] False }
1294       -- Note that Par is lazy to avoid that the sparked thing
1295       -- gets evaluted strictly, which it should *not* be
1296    has_side_effects = True
1297
1298 -- HWL: The first 4 Int# in all par... annotations denote:
1299 --   name, granularity info, size of result, degree of parallelism
1300 --      Same  structure as _seq_ i.e. returns Int#
1301 -- KSW: v, the second arg in parAt# and parAtForNow#, is used only to determine
1302 --   `the processor containing the expression v'; it is not evaluated
1303
1304 primop  ParGlobalOp  "parGlobal#"  GenPrimOp
1305    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1306    with
1307    usage            = { mangle ParGlobalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1308    has_side_effects = True
1309
1310 primop  ParLocalOp  "parLocal#"  GenPrimOp
1311    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1312    with
1313    usage            = { mangle ParLocalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1314    has_side_effects = True
1315
1316 primop  ParAtOp  "parAt#"  GenPrimOp
1317    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1318    with
1319    usage            = { mangle ParAtOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1320    has_side_effects = True
1321
1322 primop  ParAtAbsOp  "parAtAbs#"  GenPrimOp
1323    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1324    with
1325    usage            = { mangle ParAtAbsOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1326    has_side_effects = True
1327
1328 primop  ParAtRelOp  "parAtRel#" GenPrimOp
1329    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1330    with
1331    usage            = { mangle ParAtRelOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1332    has_side_effects = True
1333
1334 primop  ParAtForNowOp  "parAtForNow#" GenPrimOp
1335    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1336    with
1337    usage            = { mangle ParAtForNowOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1338    has_side_effects = True
1339
1340 -- copyable# and noFollow# are yet to be implemented (for GpH)
1341 --
1342 --primop  CopyableOp  "copyable#" GenPrimOp
1343 --   a -> Int#
1344 --   with
1345 --   usage            = { mangle CopyableOp [mkZ] mkR }
1346 --   has_side_effects = True
1347 --
1348 --primop  NoFollowOp "noFollow#" GenPrimOp
1349 --   a -> Int#
1350 --   with
1351 --   usage            = { mangle NoFollowOp [mkZ] mkR }
1352 --   has_side_effects = True
1353
1354
1355 ------------------------------------------------------------------------
1356 --- tag to enum stuff                                                ---
1357 ------------------------------------------------------------------------
1358
1359 primop  DataToTagOp "dataToTag#" GenPrimOp
1360    a -> Int#
1361    with
1362    strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1363
1364 primop  TagToEnumOp "tagToEnum#" GenPrimOp     
1365    Int# -> a
1366
1367
1368 thats_all_folks
1369
1370 ------------------------------------------------------------------------
1371 ---                                                                  ---
1372 ------------------------------------------------------------------------
1373