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