1 -----------------------------------------------------------------------
2 -- $Id: primops.txt,v 1.3 2000/09/11 11:17:09 sewardj Exp $
4 -- Primitive Operations
6 -----------------------------------------------------------------------
8 -- To add a new primop, you currently need to update the following files:
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.)
15 -- - ghc/lib/std/PrelGHC.hi-boot, to declare the primop
17 -- - if the primop is inline (i.e. a macro), then:
18 -- ghc/includes/PrimOps.h
19 -- ghc/compiler/nativeGen/StixPrim.lhs
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)
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.
36 has_side_effects = False
41 strictness = { \ arity -> StrictnessInfo (replicate arity wwPrim) False }
42 usage = { nomangle other }
45 ------------------------------------------------------------------------
46 --- Support for the metacircular interpreter ---
47 ------------------------------------------------------------------------
49 primop IndexOffClosureOp_Ptr "indexPtrOffClosure#" GenPrimOp
51 primop IndexOffClosureOp_Word "indexWordOffClosure#" GenPrimOp
55 ------------------------------------------------------------------------
57 ------------------------------------------------------------------------
59 primop AddrGtOp "gtAddr#" Compare Addr# -> Addr# -> Bool
60 primop AddrGeOp "geAddr#" Compare Addr# -> Addr# -> Bool
61 primop AddrEqOp "eqAddr#" Compare Addr# -> Addr# -> Bool
62 primop AddrNeOp "neAddr#" Compare Addr# -> Addr# -> Bool
63 primop AddrLtOp "ltAddr#" Compare Addr# -> Addr# -> Bool
64 primop AddrLeOp "leAddr#" Compare Addr# -> Addr# -> Bool
66 primop Addr2IntOp "addr2Int#" GenPrimOp Addr# -> Int#
68 primop Addr2IntegerOp "addr2Integer#" GenPrimOp
69 Addr# -> (# Int#, ByteArr# #)
70 with out_of_line = True
73 ------------------------------------------------------------------------
75 ------------------------------------------------------------------------
77 primop CharGtOp "gtChar#" Compare Char# -> Char# -> Bool
78 primop CharGeOp "geChar#" Compare Char# -> Char# -> Bool
80 primop CharEqOp "eqChar#" Compare
81 Char# -> Char# -> Bool
82 with commutable = True
84 primop CharNeOp "neChar#" Compare
85 Char# -> Char# -> Bool
86 with commutable = True
88 primop CharLtOp "ltChar#" Compare Char# -> Char# -> Bool
89 primop CharLeOp "leChar#" Compare Char# -> Char# -> Bool
91 primop OrdOp "ord#" GenPrimOp Char# -> Int#
93 ------------------------------------------------------------------------
95 ------------------------------------------------------------------------
97 primop DoubleGtOp ">##" Compare Double# -> Double# -> Bool
98 primop DoubleGeOp ">=##" Compare Double# -> Double# -> Bool
100 primop DoubleEqOp "==##" Compare
101 Double# -> Double# -> Bool
102 with commutable = True
104 primop DoubleNeOp "/=##" Compare
105 Double# -> Double# -> Bool
106 with commutable = True
108 primop DoubleLtOp "<##" Compare Double# -> Double# -> Bool
109 primop DoubleLeOp "<=##" Compare Double# -> Double# -> Bool
111 primop DoubleAddOp "+##" Dyadic
112 Double# -> Double# -> Double#
113 with commutable = True
115 primop DoubleSubOp "-##" Dyadic Double# -> Double# -> Double#
117 primop DoubleMulOp "*##" Dyadic
118 Double# -> Double# -> Double#
119 with commutable = True
121 primop DoubleDivOp "/##" Dyadic
122 Double# -> Double# -> Double#
125 primop DoubleNegOp "negateDouble#" Monadic Double# -> Double#
127 primop Double2IntOp "double2Int#" GenPrimOp Double# -> Int#
128 primop Double2FloatOp "double2Float#" GenPrimOp Double# -> Float#
130 primop DoubleExpOp "expDouble#" Monadic
132 with needs_wrapper = True
134 primop DoubleLogOp "logDouble#" Monadic
140 primop DoubleSqrtOp "sqrtDouble#" Monadic
142 with needs_wrapper = True
144 primop DoubleSinOp "sinDouble#" Monadic
146 with needs_wrapper = True
148 primop DoubleCosOp "cosDouble#" Monadic
150 with needs_wrapper = True
152 primop DoubleTanOp "tanDouble#" Monadic
154 with needs_wrapper = True
156 primop DoubleAsinOp "asinDouble#" Monadic
162 primop DoubleAcosOp "acosDouble#" Monadic
168 primop DoubleAtanOp "atanDouble#" Monadic
173 primop DoubleSinhOp "sinhDouble#" Monadic
175 with needs_wrapper = True
177 primop DoubleCoshOp "coshDouble#" Monadic
179 with needs_wrapper = True
181 primop DoubleTanhOp "tanhDouble#" Monadic
183 with needs_wrapper = True
185 primop DoublePowerOp "**##" Dyadic
186 Double# -> Double# -> Double#
187 with needs_wrapper = True
189 primop DoubleDecodeOp "decodeDouble#" GenPrimOp
190 Double# -> (# Int#, Int#, ByteArr# #)
191 with out_of_line = True
193 ------------------------------------------------------------------------
195 ------------------------------------------------------------------------
197 primop FloatGtOp "gtFloat#" Compare Float# -> Float# -> Bool
198 primop FloatGeOp "geFloat#" Compare Float# -> Float# -> Bool
200 primop FloatEqOp "eqFloat#" Compare
201 Float# -> Float# -> Bool
202 with commutable = True
204 primop FloatNeOp "neFloat#" Compare
205 Float# -> Float# -> Bool
206 with commutable = True
208 primop FloatLtOp "ltFloat#" Compare Float# -> Float# -> Bool
209 primop FloatLeOp "leFloat#" Compare Float# -> Float# -> Bool
211 primop FloatAddOp "plusFloat#" Dyadic
212 Float# -> Float# -> Float#
213 with commutable = True
215 primop FloatSubOp "minusFloat#" Dyadic Float# -> Float# -> Float#
217 primop FloatMulOp "timesFloat#" Dyadic
218 Float# -> Float# -> Float#
219 with commutable = True
221 primop FloatDivOp "divideFloat#" Dyadic
222 Float# -> Float# -> Float#
225 primop FloatNegOp "negateFloat#" Monadic Float# -> Float#
227 primop Float2IntOp "float2Int#" GenPrimOp Float# -> Int#
229 primop FloatExpOp "expFloat#" Monadic
231 with needs_wrapper = True
233 primop FloatLogOp "logFloat#" Monadic
235 with needs_wrapper = True
238 primop FloatSqrtOp "sqrtFloat#" Monadic
240 with needs_wrapper = True
242 primop FloatSinOp "sinFloat#" Monadic
244 with needs_wrapper = True
246 primop FloatCosOp "cosFloat#" Monadic
248 with needs_wrapper = True
250 primop FloatTanOp "tanFloat#" Monadic
252 with needs_wrapper = True
254 primop FloatAsinOp "asinFloat#" Monadic
256 with needs_wrapper = True
259 primop FloatAcosOp "acosFloat#" Monadic
261 with needs_wrapper = True
264 primop FloatAtanOp "atanFloat#" Monadic
266 with needs_wrapper = True
268 primop FloatSinhOp "sinhFloat#" Monadic
270 with needs_wrapper = True
272 primop FloatCoshOp "coshFloat#" Monadic
274 with needs_wrapper = True
276 primop FloatTanhOp "tanhFloat#" Monadic
278 with needs_wrapper = True
280 primop FloatPowerOp "powerFloat#" Dyadic
281 Float# -> Float# -> Float#
282 with needs_wrapper = True
284 primop Float2DoubleOp "float2Double#" GenPrimOp Float# -> Double#
286 primop FloatDecodeOp "decodeFloat#" GenPrimOp
287 Float# -> (# Int#, Int#, ByteArr# #)
288 with out_of_line = True
290 ------------------------------------------------------------------------
292 ------------------------------------------------------------------------
294 primop IntAddOp "+#" Dyadic
296 with commutable = True
298 primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
301 Dyadic Int# -> Int# -> Int#
302 with commutable = True
304 primop IntQuotOp "quotInt#" Dyadic
308 primop IntRemOp "remInt#" Dyadic
312 primop IntGcdOp "gcdInt#" Dyadic Int# -> Int# -> Int#
313 primop IntNegOp "negateInt#" Monadic Int# -> Int#
314 primop IntAddCOp "addIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
315 primop IntSubCOp "subIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
316 primop IntMulCOp "mulIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
317 primop IntGtOp ">#" Compare Int# -> Int# -> Bool
318 primop IntGeOp ">=#" Compare Int# -> Int# -> Bool
320 primop IntEqOp "==#" Compare
322 with commutable = True
324 primop IntNeOp "/=#" Compare
326 with commutable = True
328 primop IntLtOp "<#" Compare Int# -> Int# -> Bool
329 primop IntLeOp "<=#" Compare Int# -> Int# -> Bool
331 primop ChrOp "chr#" GenPrimOp Int# -> Char#
333 primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
334 primop Int2AddrOp "int2Addr#"GenPrimOp Int# -> Addr#
335 primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
336 primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
338 primop Int2IntegerOp "int2Integer#"
339 GenPrimOp Int# -> (# Int#, ByteArr# #)
340 with out_of_line = True
342 primop ISllOp "iShiftL#" GenPrimOp Int# -> Int# -> Int#
343 primop ISraOp "iShiftRA#" GenPrimOp Int# -> Int# -> Int#
344 primop ISrlOp "iShiftRL#" GenPrimOp Int# -> Int# -> Int#
346 ------------------------------------------------------------------------
348 ------------------------------------------------------------------------
350 primop Int64ToIntegerOp "int64ToInteger#" GenPrimOp
351 Int64# -> (# Int#, ByteArr# #)
352 with out_of_line = True
355 ------------------------------------------------------------------------
357 ------------------------------------------------------------------------
359 primop IntegerNegOp "negateInteger#" GenPrimOp
360 Int# -> ByteArr# -> (# Int#, ByteArr# #)
362 primop IntegerAddOp "plusInteger#" GenPrimOp
363 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
364 with commutable = True
367 primop IntegerSubOp "minusInteger#" GenPrimOp
368 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
369 with out_of_line = True
371 primop IntegerMulOp "timesInteger#" GenPrimOp
372 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
373 with commutable = True
376 primop IntegerGcdOp "gcdInteger#" GenPrimOp
377 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
378 with commutable = True
381 primop IntegerIntGcdOp "gcdIntegerInt#" GenPrimOp
382 Int# -> ByteArr# -> Int# -> Int#
383 with commutable = True
385 primop IntegerDivExactOp "divExactInteger#" GenPrimOp
386 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
387 with out_of_line = True
389 primop IntegerQuotOp "quotInteger#" GenPrimOp
390 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
391 with out_of_line = True
393 primop IntegerRemOp "remInteger#" GenPrimOp
394 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
395 with out_of_line = True
397 primop IntegerCmpOp "cmpInteger#" GenPrimOp
398 Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
399 with needs_wrapper = True
401 primop IntegerCmpIntOp "cmpIntegerInt#" GenPrimOp
402 Int# -> ByteArr# -> Int# -> Int#
403 with needs_wrapper = True
405 primop IntegerQuotRemOp "quotRemInteger#" GenPrimOp
406 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
410 primop IntegerDivModOp "divModInteger#" GenPrimOp
411 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
415 primop Integer2IntOp "integer2Int#" GenPrimOp
416 Int# -> ByteArr# -> Int#
417 with needs_wrapper = True
419 primop Integer2WordOp "integer2Word#" GenPrimOp
420 Int# -> ByteArr# -> Word#
421 with needs_wrapper = True
423 primop IntegerToInt64Op "integerToInt64#" GenPrimOp
424 Int# -> ByteArr# -> Int64#
426 primop IntegerToWord64Op "integerToWord64#" GenPrimOp
427 Int# -> ByteArr# -> Word64#
429 ------------------------------------------------------------------------
431 ------------------------------------------------------------------------
433 primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word#
434 primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word#
436 primop AndOp "and#" Dyadic
437 Word# -> Word# -> Word#
438 with commutable = True
440 primop OrOp "or#" Dyadic
441 Word# -> Word# -> Word#
442 with commutable = True
444 primop XorOp "xor#" Dyadic
445 Word# -> Word# -> Word#
446 with commutable = True
448 primop NotOp "not#" Monadic Word# -> Word#
450 primop SllOp "shiftL#" GenPrimOp Word# -> Int# -> Word#
451 primop SrlOp "shiftRL#" GenPrimOp Word# -> Int# -> Word#
454 primop Word2IntOp "word2Int#" GenPrimOp Word# -> Int#
456 primop Word2IntegerOp "word2Integer#" GenPrimOp
457 Word# -> (# Int#, ByteArr# #)
458 with out_of_line = True
460 primop WordGtOp "gtWord#" Compare Word# -> Word# -> Bool
461 primop WordGeOp "geWord#" Compare Word# -> Word# -> Bool
462 primop WordEqOp "eqWord#" Compare Word# -> Word# -> Bool
463 primop WordNeOp "neWord#" Compare Word# -> Word# -> Bool
464 primop WordLtOp "ltWord#" Compare Word# -> Word# -> Bool
465 primop WordLeOp "leWord#" Compare Word# -> Word# -> Bool
467 ------------------------------------------------------------------------
469 ------------------------------------------------------------------------
471 primop Word64ToIntegerOp "word64ToInteger#" GenPrimOp
472 Word64# -> (# Int#, ByteArr# #)
473 with out_of_line = True
476 ------------------------------------------------------------------------
478 ------------------------------------------------------------------------
480 primop NewByteArrayOp_Char "newCharArray#" GenPrimOp
481 Int# -> State# s -> (# State# s, MutByteArr# s #)
482 with out_of_line = True
484 primop NewByteArrayOp_Int "newIntArray#" GenPrimOp
485 Int# -> State# s -> (# State# s, MutByteArr# s #)
486 with out_of_line = True
488 primop NewByteArrayOp_Word "newWordArray#" GenPrimOp
489 Int# -> State# s -> (# State# s, MutByteArr# s #)
490 with out_of_line = True
492 primop NewByteArrayOp_Addr "newAddrArray#" GenPrimOp
493 Int# -> State# s -> (# State# s, MutByteArr# s #)
494 with out_of_line = True
496 primop NewByteArrayOp_Float "newFloatArray#" GenPrimOp
497 Int# -> State# s -> (# State# s, MutByteArr# s #)
498 with out_of_line = True
500 primop NewByteArrayOp_Double "newDoubleArray#" GenPrimOp
501 Int# -> State# s -> (# State# s, MutByteArr# s #)
502 with out_of_line = True
504 primop NewByteArrayOp_StablePtr "newStablePtrArray#" GenPrimOp
505 Int# -> State# s -> (# State# s, MutByteArr# s #)
506 with out_of_line = True
510 primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
511 MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
513 primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp
514 MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
516 primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp
517 MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
519 primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
520 MutByteArr# s -> Int# -> State# s -> (# State# s, Addr# #)
522 primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
523 MutByteArr# s -> Int# -> State# s -> (# State# s, Float# #)
525 primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
526 MutByteArr# s -> Int# -> State# s -> (# State# s, Double# #)
528 primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
529 MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
531 primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
532 MutByteArr# s -> Int# -> State# s -> (# State# s, Int64# #)
534 primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
535 MutByteArr# s -> Int# -> State# s -> (# State# s, Word64# #)
539 primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
540 MutByteArr# s -> Int# -> Char# -> State# s -> State# s
541 with has_side_effects = True
543 primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
544 MutByteArr# s -> Int# -> Int# -> State# s -> State# s
545 with has_side_effects = True
547 primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
548 MutByteArr# s -> Int# -> Word# -> State# s -> State# s
549 with has_side_effects = True
551 primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
552 MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
553 with has_side_effects = True
555 primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
556 MutByteArr# s -> Int# -> Float# -> State# s -> State# s
557 with has_side_effects = True
559 primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
560 MutByteArr# s -> Int# -> Double# -> State# s -> State# s
561 with has_side_effects = True
563 primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
564 MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
565 with has_side_effects = True
567 primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
568 MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
569 with has_side_effects = True
571 primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
572 MutByteArr# s -> Int# -> Word64# -> State# s -> State# s
573 with has_side_effects = True
576 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
577 ByteArr# -> Int# -> Char#
579 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
580 ByteArr# -> Int# -> Int#
582 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
583 ByteArr# -> Int# -> Word#
585 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
586 ByteArr# -> Int# -> Addr#
588 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
589 ByteArr# -> Int# -> Float#
591 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
592 ByteArr# -> Int# -> Double#
594 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
595 ByteArr# -> Int# -> StablePtr# a
597 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
598 ByteArr# -> Int# -> Int64#
600 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
601 ByteArr# -> Int# -> Word64#
604 primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
605 Addr# -> Int# -> Char#
607 primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
608 Addr# -> Int# -> Int#
610 primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
611 Addr# -> Int# -> Word#
613 primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
614 Addr# -> Int# -> Addr#
616 primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
617 Addr# -> Int# -> Float#
619 primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
620 Addr# -> Int# -> Double#
622 primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
623 Addr# -> Int# -> StablePtr# a
625 primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
626 Addr# -> Int# -> Int64#
628 primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
629 Addr# -> Int# -> Word64#
632 primop IndexOffForeignObjOp_Char "indexCharOffForeignObj#" GenPrimOp
633 ForeignObj# -> Int# -> Char#
635 primop IndexOffForeignObjOp_Int "indexIntOffForeignObj#" GenPrimOp
636 ForeignObj# -> Int# -> Int#
638 primop IndexOffForeignObjOp_Word "indexWordOffForeignObj#" GenPrimOp
639 ForeignObj# -> Int# -> Word#
641 primop IndexOffForeignObjOp_Addr "indexAddrOffForeignObj#" GenPrimOp
642 ForeignObj# -> Int# -> Addr#
644 primop IndexOffForeignObjOp_Float "indexFloatOffForeignObj#" GenPrimOp
645 ForeignObj# -> Int# -> Float#
647 primop IndexOffForeignObjOp_Double "indexDoubleOffForeignObj#" GenPrimOp
648 ForeignObj# -> Int# -> Double#
650 primop IndexOffForeignObjOp_StablePtr "indexStablePtrOffForeignObj#" GenPrimOp
651 ForeignObj# -> Int# -> StablePtr# a
653 primop IndexOffForeignObjOp_Int64 "indexInt64OffForeignObj#" GenPrimOp
654 ForeignObj# -> Int# -> Int64#
656 primop IndexOffForeignObjOp_Word64 "indexWord64OffForeignObj#" GenPrimOp
657 ForeignObj# -> Int# -> Word64#
661 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
662 Addr# -> Int# -> State# s -> (# State# s, Char# #)
664 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
665 Addr# -> Int# -> State# s -> (# State# s, Int# #)
667 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
668 Addr# -> Int# -> State# s -> (# State# s, Word# #)
670 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
671 Addr# -> Int# -> State# s -> (# State# s, Addr# #)
673 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
674 Addr# -> Int# -> State# s -> (# State# s, Float# #)
676 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
677 Addr# -> Int# -> State# s -> (# State# s, Double# #)
679 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
680 Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
682 primop ReadOffAddrOp_ForeignObj "readForeignObjOffAddr#" GenPrimOp
683 Addr# -> Int# -> State# s -> (# State# s, ForeignObj# #)
685 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
686 Addr# -> Int# -> State# s -> (# State# s, Int64# #)
688 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
689 Addr# -> Int# -> State# s -> (# State# s, Word64# #)
692 primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
693 Addr# -> Int# -> Char# -> State# s -> State# s
694 with has_side_effects = True
696 primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
697 Addr# -> Int# -> Int# -> State# s -> State# s
698 with has_side_effects = True
700 primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
701 Addr# -> Int# -> Word# -> State# s -> State# s
702 with has_side_effects = True
704 primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
705 Addr# -> Int# -> Addr# -> State# s -> State# s
706 with has_side_effects = True
708 primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
709 Addr# -> Int# -> Float# -> State# s -> State# s
710 with has_side_effects = True
712 primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
713 Addr# -> Int# -> Double# -> State# s -> State# s
714 with has_side_effects = True
716 primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
717 Addr# -> Int# -> StablePtr# a -> State# s -> State# s
718 with has_side_effects = True
720 primop WriteOffAddrOp_ForeignObj "writeForeignObjOffAddr#" GenPrimOp
721 Addr# -> Int# -> ForeignObj# -> State# s -> State# s
722 with has_side_effects = True
724 primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
725 Addr# -> Int# -> Int64# -> State# s -> State# s
726 with has_side_effects = True
728 primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
729 Addr# -> Int# -> Word64# -> State# s -> State# s
730 with has_side_effects = True
734 primop NewArrayOp "newArray#" GenPrimOp
735 Int# -> a -> State# s -> (# State# s, MutArr# s a #)
737 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
738 usage = { mangle NewArrayOp [mkP, mkM, mkP] mkM }
741 primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
742 MutArr# s a -> MutArr# s a -> Bool
744 usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
746 primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
747 MutByteArr# s -> MutByteArr# s -> Bool
749 primop ReadArrayOp "readArray#" GenPrimOp
750 MutArr# s a -> Int# -> State# s -> (# State# s, a #)
752 usage = { mangle ReadArrayOp [mkM, mkP, mkP] mkM }
754 primop WriteArrayOp "writeArray#" GenPrimOp
755 MutArr# s a -> Int# -> a -> State# s -> State# s
757 usage = { mangle WriteArrayOp [mkM, mkP, mkM, mkP] mkR }
758 strictness = { \ arity -> StrictnessInfo [wwPrim, wwPrim, wwLazy, wwPrim] False }
759 has_side_effects = True
761 primop IndexArrayOp "indexArray#" GenPrimOp
762 Array# a -> Int# -> (# a #)
764 usage = { mangle IndexArrayOp [mkM, mkP] mkM }
766 primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
767 MutArr# s a -> State# s -> (# State# s, Array# a #)
769 usage = { mangle UnsafeFreezeArrayOp [mkM, mkP] mkM }
770 has_side_effects = True
772 primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
773 MutByteArr# s -> State# s -> (# State# s, ByteArr# #)
775 has_side_effects = True
777 primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
778 Array# a -> State# s -> (# State# s, MutArr# s a #)
780 usage = { mangle UnsafeThawArrayOp [mkM, mkP] mkM }
783 primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
786 primop SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
787 MutByteArr# s -> Int#
789 ------------------------------------------------------------------------
790 --- Mutable variables ---
791 ------------------------------------------------------------------------
793 primop NewMutVarOp "newMutVar#" GenPrimOp
794 a -> State# s -> (# State# s, MutVar# s a #)
796 usage = { mangle NewMutVarOp [mkM, mkP] mkM }
797 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
800 primop ReadMutVarOp "readMutVar#" GenPrimOp
801 MutVar# s a -> State# s -> (# State# s, a #)
803 usage = { mangle ReadMutVarOp [mkM, mkP] mkM }
805 primop WriteMutVarOp "writeMutVar#" GenPrimOp
806 MutVar# s a -> a -> State# s -> State# s
808 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
809 usage = { mangle WriteMutVarOp [mkM, mkM, mkP] mkR }
810 has_side_effects = True
812 primop SameMutVarOp "sameMutVar#" GenPrimOp
813 MutVar# s a -> MutVar# s a -> Bool
815 usage = { mangle SameMutVarOp [mkP, mkP] mkM }
817 ------------------------------------------------------------------------
819 ------------------------------------------------------------------------
821 primop CatchOp "catch#" GenPrimOp
822 (State# RealWorld -> (# State# RealWorld, a #) )
823 -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
825 -> (# State# RealWorld, a #)
827 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwPrim] False }
828 -- Catch is actually strict in its first argument
829 -- but we don't want to tell the strictness
830 -- analyser about that!
831 usage = { mangle CatchOp [mkM, mkM . (inFun CatchOp mkM mkM), mkP] mkM }
832 -- [mkO, mkO . (inFun mkM mkO)] mkO
833 -- might use caught action multiply
836 primop RaiseOp "raise#" GenPrimOp
839 strictness = { \ arity -> StrictnessInfo [wwLazy] True }
840 -- NB: True => result is bottom
841 usage = { mangle RaiseOp [mkM] mkM }
844 primop BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
845 (State# RealWorld -> (# State# RealWorld, a #))
846 -> (State# RealWorld -> (# State# RealWorld, a #))
848 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
851 primop UnblockAsyncExceptionsOp "unblockAsyncExceptions#" GenPrimOp
852 (State# RealWorld -> (# State# RealWorld, a #))
853 -> (State# RealWorld -> (# State# RealWorld, a #))
855 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
858 ------------------------------------------------------------------------
859 --- MVars (not the same as mutable variables!) ---
860 ------------------------------------------------------------------------
862 primop NewMVarOp "newMVar#" GenPrimOp
863 State# s -> (# State# s, MVar# s a #)
865 usage = { mangle NewMVarOp [mkP] mkR }
868 primop TakeMVarOp "takeMVar#" GenPrimOp
869 MVar# s a -> State# s -> (# State# s, a #)
871 usage = { mangle TakeMVarOp [mkM, mkP] mkM }
872 has_side_effects = True
875 primop PutMVarOp "putMVar#" GenPrimOp
876 MVar# s a -> a -> State# s -> State# s
878 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
879 usage = { mangle PutMVarOp [mkM, mkM, mkP] mkR }
880 has_side_effects = True
883 primop SameMVarOp "sameMVar#" GenPrimOp
884 MVar# s a -> MVar# s a -> Bool
886 usage = { mangle SameMVarOp [mkP, mkP] mkM }
888 primop TryTakeMVarOp "tryTakeMVar#" GenPrimOp
889 MVar# s a -> State# s -> (# State# s, Int#, a #)
891 usage = { mangle TryTakeMVarOp [mkM, mkP] mkM }
892 has_side_effects = True
895 primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
896 MVar# s a -> State# s -> (# State# s, Int# #)
898 usage = { mangle IsEmptyMVarOp [mkP, mkP] mkM }
901 ------------------------------------------------------------------------
902 --- delay/wait operations ---
903 ------------------------------------------------------------------------
905 primop DelayOp "delay#" GenPrimOp
906 Int# -> State# s -> State# s
909 has_side_effects = True
912 primop WaitReadOp "waitRead#" GenPrimOp
913 Int# -> State# s -> State# s
916 has_side_effects = True
919 primop WaitWriteOp "waitWrite#" GenPrimOp
920 Int# -> State# s -> State# s
923 has_side_effects = True
926 ------------------------------------------------------------------------
927 --- concurrency primitives ---
928 ------------------------------------------------------------------------
930 primop ForkOp "fork#" GenPrimOp
931 a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
933 usage = { mangle ForkOp [mkO, mkP] mkR }
934 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
935 has_side_effects = True
938 primop KillThreadOp "killThread#" GenPrimOp
939 ThreadId# -> a -> State# RealWorld -> State# RealWorld
941 usage = { mangle KillThreadOp [mkP, mkM, mkP] mkR }
942 has_side_effects = True
945 primop YieldOp "yield#" GenPrimOp
946 State# RealWorld -> State# RealWorld
948 has_side_effects = True
951 primop MyThreadIdOp "myThreadId#" GenPrimOp
952 State# RealWorld -> (# State# RealWorld, ThreadId# #)
954 ------------------------------------------------------------------------
955 --- foreign objects ---
956 ------------------------------------------------------------------------
958 primop MkForeignObjOp "mkForeignObj#" GenPrimOp
959 Addr# -> State# RealWorld -> (# State# RealWorld, ForeignObj# #)
961 has_side_effects = True
964 primop WriteForeignObjOp "writeForeignObj#" GenPrimOp
965 ForeignObj# -> Addr# -> State# s -> State# s
967 has_side_effects = True
969 primop ForeignObjToAddrOp "foreignObjToAddr#" GenPrimOp
972 primop TouchOp "touch#" GenPrimOp
973 o -> State# RealWorld -> State# RealWorld
975 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
977 ------------------------------------------------------------------------
978 --- Bytecode objects ---
979 ------------------------------------------------------------------------
981 primop NewBCOOp "newBCO#" GenPrimOp
982 Int# -> Int# -> Int# -> a -> State# RealWorld -> (# State# RealWorld, BCO# #)
984 has_side_effects = True
987 primop WriteBCOPtrOp "writeBCOPtr#" GenPrimOp
988 BCO# -> Int# -> o -> State# RealWorld -> State# RealWorld
990 usage = { mangle WriteBCOPtrOp [mkP, mkP, mkM] mkR }
991 has_side_effects = True
993 primop WriteBCONonPtrOp "writeBCONonPtr#" GenPrimOp
994 BCO# -> Int# -> Word# -> State# RealWorld -> State# RealWorld
996 has_side_effects = True
998 primop WriteBCOInstrOp "writeBCOInstr#" GenPrimOp
999 BCO# -> Int# -> Word# -> State# RealWorld -> State# RealWorld
1001 has_side_effects = True
1003 primop ReadBCOPtrOp "readBCOPtr#" GenPrimOp
1004 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
1006 usage = { mangle ReadBCOPtrOp [mkP, mkP] mkM }
1008 primop ReadBCONonPtrOp "readBCONonPtr#" GenPrimOp
1009 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
1011 primop ReadBCOInstrOp "readBCOInstr#" GenPrimOp
1012 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
1014 ------------------------------------------------------------------------
1015 --- Weak pointers ---
1016 ------------------------------------------------------------------------
1018 -- note that tyvar "o" denoted openAlphaTyVar
1020 primop MkWeakOp "mkWeak#" GenPrimOp
1021 o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
1023 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwLazy, wwPrim] False }
1024 usage = { mangle MkWeakOp [mkZ, mkM, mkM, mkP] mkM }
1025 has_side_effects = True
1028 primop DeRefWeakOp "deRefWeak#" GenPrimOp
1029 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
1031 usage = { mangle DeRefWeakOp [mkM, mkP] mkM }
1032 has_side_effects = True
1034 primop FinalizeWeakOp "finalizeWeak#" GenPrimOp
1035 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#,
1036 (State# RealWorld -> (# State# RealWorld, Unit #)) #)
1038 usage = { mangle FinalizeWeakOp [mkM, mkP]
1039 (mkR . (inUB FinalizeWeakOp
1040 [id,id,inFun FinalizeWeakOp mkR mkM])) }
1041 has_side_effects = True
1045 ------------------------------------------------------------------------
1046 --- Stable pointers and names ---
1047 ------------------------------------------------------------------------
1049 primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
1050 a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
1052 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1053 usage = { mangle MakeStablePtrOp [mkM, mkP] mkM }
1054 has_side_effects = True
1056 primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
1057 StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
1059 usage = { mangle DeRefStablePtrOp [mkM, mkP] mkM }
1060 needs_wrapper = True
1061 has_side_effects = True
1063 primop EqStablePtrOp "eqStablePtr#" GenPrimOp
1064 StablePtr# a -> StablePtr# a -> Int#
1066 usage = { mangle EqStablePtrOp [mkP, mkP] mkR }
1067 has_side_effects = True
1069 primop MakeStableNameOp "makeStableName#" GenPrimOp
1070 a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
1072 usage = { mangle MakeStableNameOp [mkZ, mkP] mkR }
1073 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1074 needs_wrapper = True
1075 has_side_effects = True
1078 primop EqStableNameOp "eqStableName#" GenPrimOp
1079 StableName# a -> StableName# a -> Int#
1081 usage = { mangle EqStableNameOp [mkP, mkP] mkR }
1083 primop StableNameToIntOp "stableNameToInt#" GenPrimOp
1084 StableName# a -> Int#
1086 usage = { mangle StableNameToIntOp [mkP] mkR }
1088 ------------------------------------------------------------------------
1089 --- Unsafe pointer equality (#1 Bad Guy: Alistair Reid :) ---
1090 ------------------------------------------------------------------------
1092 primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
1095 usage = { mangle ReallyUnsafePtrEqualityOp [mkZ, mkZ] mkR }
1097 ------------------------------------------------------------------------
1099 ------------------------------------------------------------------------
1101 primop SeqOp "seq#" GenPrimOp
1104 usage = { mangle SeqOp [mkO] mkR }
1105 strictness = { \ arity -> StrictnessInfo [wwStrict] False }
1106 -- Seq is strict in its argument; see notes in ConFold.lhs
1107 has_side_effects = True
1109 primop ParOp "par#" GenPrimOp
1112 usage = { mangle ParOp [mkO] mkR }
1113 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1114 -- Note that Par is lazy to avoid that the sparked thing
1115 -- gets evaluted strictly, which it should *not* be
1116 has_side_effects = True
1118 -- HWL: The first 4 Int# in all par... annotations denote:
1119 -- name, granularity info, size of result, degree of parallelism
1120 -- Same structure as _seq_ i.e. returns Int#
1121 -- KSW: v, the second arg in parAt# and parAtForNow#, is used only to determine
1122 -- `the processor containing the expression v'; it is not evaluated
1124 primop ParGlobalOp "parGlobal#" GenPrimOp
1125 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1127 usage = { mangle ParGlobalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1128 has_side_effects = True
1130 primop ParLocalOp "parLocal#" GenPrimOp
1131 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1133 usage = { mangle ParLocalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1134 has_side_effects = True
1136 primop ParAtOp "parAt#" GenPrimOp
1137 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1139 usage = { mangle ParAtOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1140 has_side_effects = True
1142 primop ParAtAbsOp "parAtAbs#" GenPrimOp
1143 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1145 usage = { mangle ParAtAbsOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1146 has_side_effects = True
1148 primop ParAtRelOp "parAtRel#" GenPrimOp
1149 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1151 usage = { mangle ParAtRelOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1152 has_side_effects = True
1154 primop ParAtForNowOp "parAtForNow#" GenPrimOp
1155 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1157 usage = { mangle ParAtForNowOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1158 has_side_effects = True
1160 primop CopyableOp "copyable#" GenPrimOp
1163 usage = { mangle CopyableOp [mkZ] mkR }
1164 has_side_effects = True
1166 primop NoFollowOp "noFollow#" GenPrimOp
1169 usage = { mangle NoFollowOp [mkZ] mkR }
1170 has_side_effects = True
1173 ------------------------------------------------------------------------
1174 --- tag to enum stuff ---
1175 ------------------------------------------------------------------------
1177 primop DataToTagOp "dataToTag#" GenPrimOp
1180 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1182 primop TagToEnumOp "tagToEnum#" GenPrimOp
1188 ------------------------------------------------------------------------
1190 ------------------------------------------------------------------------