1 -----------------------------------------------------------------------
2 -- $Id: primops.txt,v 1.6 2000/11/07 15:21:40 simonmar 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#
69 ------------------------------------------------------------------------
71 ------------------------------------------------------------------------
73 primop CharGtOp "gtChar#" Compare Char# -> Char# -> Bool
74 primop CharGeOp "geChar#" Compare Char# -> Char# -> Bool
76 primop CharEqOp "eqChar#" Compare
77 Char# -> Char# -> Bool
78 with commutable = True
80 primop CharNeOp "neChar#" Compare
81 Char# -> Char# -> Bool
82 with commutable = True
84 primop CharLtOp "ltChar#" Compare Char# -> Char# -> Bool
85 primop CharLeOp "leChar#" Compare Char# -> Char# -> Bool
87 primop OrdOp "ord#" GenPrimOp Char# -> Int#
89 ------------------------------------------------------------------------
91 ------------------------------------------------------------------------
93 primop DoubleGtOp ">##" Compare Double# -> Double# -> Bool
94 primop DoubleGeOp ">=##" Compare Double# -> Double# -> Bool
96 primop DoubleEqOp "==##" Compare
97 Double# -> Double# -> Bool
98 with commutable = True
100 primop DoubleNeOp "/=##" Compare
101 Double# -> Double# -> Bool
102 with commutable = True
104 primop DoubleLtOp "<##" Compare Double# -> Double# -> Bool
105 primop DoubleLeOp "<=##" Compare Double# -> Double# -> Bool
107 primop DoubleAddOp "+##" Dyadic
108 Double# -> Double# -> Double#
109 with commutable = True
111 primop DoubleSubOp "-##" Dyadic Double# -> Double# -> Double#
113 primop DoubleMulOp "*##" Dyadic
114 Double# -> Double# -> Double#
115 with commutable = True
117 primop DoubleDivOp "/##" Dyadic
118 Double# -> Double# -> Double#
121 primop DoubleNegOp "negateDouble#" Monadic Double# -> Double#
123 primop Double2IntOp "double2Int#" GenPrimOp Double# -> Int#
124 primop Double2FloatOp "double2Float#" GenPrimOp Double# -> Float#
126 primop DoubleExpOp "expDouble#" Monadic
128 with needs_wrapper = True
130 primop DoubleLogOp "logDouble#" Monadic
136 primop DoubleSqrtOp "sqrtDouble#" Monadic
138 with needs_wrapper = True
140 primop DoubleSinOp "sinDouble#" Monadic
142 with needs_wrapper = True
144 primop DoubleCosOp "cosDouble#" Monadic
146 with needs_wrapper = True
148 primop DoubleTanOp "tanDouble#" Monadic
150 with needs_wrapper = True
152 primop DoubleAsinOp "asinDouble#" Monadic
158 primop DoubleAcosOp "acosDouble#" Monadic
164 primop DoubleAtanOp "atanDouble#" Monadic
169 primop DoubleSinhOp "sinhDouble#" Monadic
171 with needs_wrapper = True
173 primop DoubleCoshOp "coshDouble#" Monadic
175 with needs_wrapper = True
177 primop DoubleTanhOp "tanhDouble#" Monadic
179 with needs_wrapper = True
181 primop DoublePowerOp "**##" Dyadic
182 Double# -> Double# -> Double#
183 with needs_wrapper = True
185 primop DoubleDecodeOp "decodeDouble#" GenPrimOp
186 Double# -> (# Int#, Int#, ByteArr# #)
187 with out_of_line = True
189 ------------------------------------------------------------------------
191 ------------------------------------------------------------------------
193 primop FloatGtOp "gtFloat#" Compare Float# -> Float# -> Bool
194 primop FloatGeOp "geFloat#" Compare Float# -> Float# -> Bool
196 primop FloatEqOp "eqFloat#" Compare
197 Float# -> Float# -> Bool
198 with commutable = True
200 primop FloatNeOp "neFloat#" Compare
201 Float# -> Float# -> Bool
202 with commutable = True
204 primop FloatLtOp "ltFloat#" Compare Float# -> Float# -> Bool
205 primop FloatLeOp "leFloat#" Compare Float# -> Float# -> Bool
207 primop FloatAddOp "plusFloat#" Dyadic
208 Float# -> Float# -> Float#
209 with commutable = True
211 primop FloatSubOp "minusFloat#" Dyadic Float# -> Float# -> Float#
213 primop FloatMulOp "timesFloat#" Dyadic
214 Float# -> Float# -> Float#
215 with commutable = True
217 primop FloatDivOp "divideFloat#" Dyadic
218 Float# -> Float# -> Float#
221 primop FloatNegOp "negateFloat#" Monadic Float# -> Float#
223 primop Float2IntOp "float2Int#" GenPrimOp Float# -> Int#
225 primop FloatExpOp "expFloat#" Monadic
227 with needs_wrapper = True
229 primop FloatLogOp "logFloat#" Monadic
231 with needs_wrapper = True
234 primop FloatSqrtOp "sqrtFloat#" Monadic
236 with needs_wrapper = True
238 primop FloatSinOp "sinFloat#" Monadic
240 with needs_wrapper = True
242 primop FloatCosOp "cosFloat#" Monadic
244 with needs_wrapper = True
246 primop FloatTanOp "tanFloat#" Monadic
248 with needs_wrapper = True
250 primop FloatAsinOp "asinFloat#" Monadic
252 with needs_wrapper = True
255 primop FloatAcosOp "acosFloat#" Monadic
257 with needs_wrapper = True
260 primop FloatAtanOp "atanFloat#" Monadic
262 with needs_wrapper = True
264 primop FloatSinhOp "sinhFloat#" Monadic
266 with needs_wrapper = True
268 primop FloatCoshOp "coshFloat#" Monadic
270 with needs_wrapper = True
272 primop FloatTanhOp "tanhFloat#" Monadic
274 with needs_wrapper = True
276 primop FloatPowerOp "powerFloat#" Dyadic
277 Float# -> Float# -> Float#
278 with needs_wrapper = True
280 primop Float2DoubleOp "float2Double#" GenPrimOp Float# -> Double#
282 primop FloatDecodeOp "decodeFloat#" GenPrimOp
283 Float# -> (# Int#, Int#, ByteArr# #)
284 with out_of_line = True
286 ------------------------------------------------------------------------
288 ------------------------------------------------------------------------
290 primop IntAddOp "+#" Dyadic
292 with commutable = True
294 primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
297 Dyadic Int# -> Int# -> Int#
298 with commutable = True
300 primop IntQuotOp "quotInt#" Dyadic
304 primop IntRemOp "remInt#" Dyadic
308 primop IntGcdOp "gcdInt#" Dyadic Int# -> Int# -> Int#
309 primop IntNegOp "negateInt#" Monadic Int# -> Int#
310 primop IntAddCOp "addIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
311 primop IntSubCOp "subIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
312 primop IntMulCOp "mulIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
313 primop IntGtOp ">#" Compare Int# -> Int# -> Bool
314 primop IntGeOp ">=#" Compare Int# -> Int# -> Bool
316 primop IntEqOp "==#" Compare
318 with commutable = True
320 primop IntNeOp "/=#" Compare
322 with commutable = True
324 primop IntLtOp "<#" Compare Int# -> Int# -> Bool
325 primop IntLeOp "<=#" Compare Int# -> Int# -> Bool
327 primop ChrOp "chr#" GenPrimOp Int# -> Char#
329 primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
330 primop Int2AddrOp "int2Addr#"GenPrimOp Int# -> Addr#
331 primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
332 primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
334 primop Int2IntegerOp "int2Integer#"
335 GenPrimOp Int# -> (# Int#, ByteArr# #)
336 with out_of_line = True
338 primop ISllOp "iShiftL#" GenPrimOp Int# -> Int# -> Int#
339 primop ISraOp "iShiftRA#" GenPrimOp Int# -> Int# -> Int#
340 primop ISrlOp "iShiftRL#" GenPrimOp Int# -> Int# -> Int#
342 ------------------------------------------------------------------------
344 ------------------------------------------------------------------------
346 primop Int64ToIntegerOp "int64ToInteger#" GenPrimOp
347 Int64# -> (# Int#, ByteArr# #)
348 with out_of_line = True
351 ------------------------------------------------------------------------
353 ------------------------------------------------------------------------
355 primop IntegerNegOp "negateInteger#" GenPrimOp
356 Int# -> ByteArr# -> (# Int#, ByteArr# #)
358 primop IntegerAddOp "plusInteger#" GenPrimOp
359 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
360 with commutable = True
363 primop IntegerSubOp "minusInteger#" GenPrimOp
364 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
365 with out_of_line = True
367 primop IntegerMulOp "timesInteger#" GenPrimOp
368 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
369 with commutable = True
372 primop IntegerGcdOp "gcdInteger#" GenPrimOp
373 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
374 with commutable = True
377 primop IntegerIntGcdOp "gcdIntegerInt#" GenPrimOp
378 Int# -> ByteArr# -> Int# -> Int#
379 with commutable = True
381 primop IntegerDivExactOp "divExactInteger#" GenPrimOp
382 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
383 with out_of_line = True
385 primop IntegerQuotOp "quotInteger#" GenPrimOp
386 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
387 with out_of_line = True
389 primop IntegerRemOp "remInteger#" GenPrimOp
390 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
391 with out_of_line = True
393 primop IntegerCmpOp "cmpInteger#" GenPrimOp
394 Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
395 with needs_wrapper = True
397 primop IntegerCmpIntOp "cmpIntegerInt#" GenPrimOp
398 Int# -> ByteArr# -> Int# -> Int#
399 with needs_wrapper = True
401 primop IntegerQuotRemOp "quotRemInteger#" GenPrimOp
402 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
406 primop IntegerDivModOp "divModInteger#" GenPrimOp
407 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
411 primop Integer2IntOp "integer2Int#" GenPrimOp
412 Int# -> ByteArr# -> Int#
413 with needs_wrapper = True
415 primop Integer2WordOp "integer2Word#" GenPrimOp
416 Int# -> ByteArr# -> Word#
417 with needs_wrapper = True
419 primop IntegerToInt64Op "integerToInt64#" GenPrimOp
420 Int# -> ByteArr# -> Int64#
422 primop IntegerToWord64Op "integerToWord64#" GenPrimOp
423 Int# -> ByteArr# -> Word64#
425 primop IntegerAndOp "andInteger#" GenPrimOp
426 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
427 with out_of_line = True
429 primop IntegerOrOp "orInteger#" GenPrimOp
430 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
431 with out_of_line = True
433 primop IntegerXorOp "xorInteger#" GenPrimOp
434 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
435 with out_of_line = True
437 primop IntegerComplementOp "complementInteger#" GenPrimOp
438 Int# -> ByteArr# -> (# Int#, ByteArr# #)
439 with out_of_line = True
441 ------------------------------------------------------------------------
443 ------------------------------------------------------------------------
445 primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word#
446 primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word#
448 primop AndOp "and#" Dyadic
449 Word# -> Word# -> Word#
450 with commutable = True
452 primop OrOp "or#" Dyadic
453 Word# -> Word# -> Word#
454 with commutable = True
456 primop XorOp "xor#" Dyadic
457 Word# -> Word# -> Word#
458 with commutable = True
460 primop NotOp "not#" Monadic Word# -> Word#
462 primop SllOp "shiftL#" GenPrimOp Word# -> Int# -> Word#
463 primop SrlOp "shiftRL#" GenPrimOp Word# -> Int# -> Word#
466 primop Word2IntOp "word2Int#" GenPrimOp Word# -> Int#
468 primop Word2IntegerOp "word2Integer#" GenPrimOp
469 Word# -> (# Int#, ByteArr# #)
470 with out_of_line = True
472 primop WordGtOp "gtWord#" Compare Word# -> Word# -> Bool
473 primop WordGeOp "geWord#" Compare Word# -> Word# -> Bool
474 primop WordEqOp "eqWord#" Compare Word# -> Word# -> Bool
475 primop WordNeOp "neWord#" Compare Word# -> Word# -> Bool
476 primop WordLtOp "ltWord#" Compare Word# -> Word# -> Bool
477 primop WordLeOp "leWord#" Compare Word# -> Word# -> Bool
479 ------------------------------------------------------------------------
481 ------------------------------------------------------------------------
483 primop Word64ToIntegerOp "word64ToInteger#" GenPrimOp
484 Word64# -> (# Int#, ByteArr# #)
485 with out_of_line = True
488 ------------------------------------------------------------------------
490 ------------------------------------------------------------------------
492 primop NewByteArrayOp_Char "newCharArray#" GenPrimOp
493 Int# -> State# s -> (# State# s, MutByteArr# s #)
494 with out_of_line = True
496 primop NewByteArrayOp_Int "newIntArray#" GenPrimOp
497 Int# -> State# s -> (# State# s, MutByteArr# s #)
498 with out_of_line = True
500 primop NewByteArrayOp_Word "newWordArray#" GenPrimOp
501 Int# -> State# s -> (# State# s, MutByteArr# s #)
502 with out_of_line = True
504 primop NewByteArrayOp_Addr "newAddrArray#" GenPrimOp
505 Int# -> State# s -> (# State# s, MutByteArr# s #)
506 with out_of_line = True
508 primop NewByteArrayOp_Float "newFloatArray#" GenPrimOp
509 Int# -> State# s -> (# State# s, MutByteArr# s #)
510 with out_of_line = True
512 primop NewByteArrayOp_Double "newDoubleArray#" GenPrimOp
513 Int# -> State# s -> (# State# s, MutByteArr# s #)
514 with out_of_line = True
516 primop NewByteArrayOp_StablePtr "newStablePtrArray#" GenPrimOp
517 Int# -> State# s -> (# State# s, MutByteArr# s #)
518 with out_of_line = True
522 primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
523 MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
525 primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp
526 MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
528 primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp
529 MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
531 primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
532 MutByteArr# s -> Int# -> State# s -> (# State# s, Addr# #)
534 primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
535 MutByteArr# s -> Int# -> State# s -> (# State# s, Float# #)
537 primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
538 MutByteArr# s -> Int# -> State# s -> (# State# s, Double# #)
540 primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
541 MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
543 primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
544 MutByteArr# s -> Int# -> State# s -> (# State# s, Int64# #)
546 primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
547 MutByteArr# s -> Int# -> State# s -> (# State# s, Word64# #)
551 primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
552 MutByteArr# s -> Int# -> Char# -> State# s -> State# s
553 with has_side_effects = True
555 primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
556 MutByteArr# s -> Int# -> Int# -> State# s -> State# s
557 with has_side_effects = True
559 primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
560 MutByteArr# s -> Int# -> Word# -> State# s -> State# s
561 with has_side_effects = True
563 primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
564 MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
565 with has_side_effects = True
567 primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
568 MutByteArr# s -> Int# -> Float# -> State# s -> State# s
569 with has_side_effects = True
571 primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
572 MutByteArr# s -> Int# -> Double# -> State# s -> State# s
573 with has_side_effects = True
575 primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
576 MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
577 with has_side_effects = True
579 primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
580 MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
581 with has_side_effects = True
583 primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
584 MutByteArr# s -> Int# -> Word64# -> State# s -> State# s
585 with has_side_effects = True
588 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
589 ByteArr# -> Int# -> Char#
591 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
592 ByteArr# -> Int# -> Int#
594 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
595 ByteArr# -> Int# -> Word#
597 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
598 ByteArr# -> Int# -> Addr#
600 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
601 ByteArr# -> Int# -> Float#
603 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
604 ByteArr# -> Int# -> Double#
606 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
607 ByteArr# -> Int# -> StablePtr# a
609 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
610 ByteArr# -> Int# -> Int64#
612 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
613 ByteArr# -> Int# -> Word64#
616 primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
617 Addr# -> Int# -> Char#
619 primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
620 Addr# -> Int# -> Int#
622 primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
623 Addr# -> Int# -> Word#
625 primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
626 Addr# -> Int# -> Addr#
628 primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
629 Addr# -> Int# -> Float#
631 primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
632 Addr# -> Int# -> Double#
634 primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
635 Addr# -> Int# -> StablePtr# a
637 primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
638 Addr# -> Int# -> Int64#
640 primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
641 Addr# -> Int# -> Word64#
644 primop IndexOffForeignObjOp_Char "indexCharOffForeignObj#" GenPrimOp
645 ForeignObj# -> Int# -> Char#
647 primop IndexOffForeignObjOp_Int "indexIntOffForeignObj#" GenPrimOp
648 ForeignObj# -> Int# -> Int#
650 primop IndexOffForeignObjOp_Word "indexWordOffForeignObj#" GenPrimOp
651 ForeignObj# -> Int# -> Word#
653 primop IndexOffForeignObjOp_Addr "indexAddrOffForeignObj#" GenPrimOp
654 ForeignObj# -> Int# -> Addr#
656 primop IndexOffForeignObjOp_Float "indexFloatOffForeignObj#" GenPrimOp
657 ForeignObj# -> Int# -> Float#
659 primop IndexOffForeignObjOp_Double "indexDoubleOffForeignObj#" GenPrimOp
660 ForeignObj# -> Int# -> Double#
662 primop IndexOffForeignObjOp_StablePtr "indexStablePtrOffForeignObj#" GenPrimOp
663 ForeignObj# -> Int# -> StablePtr# a
665 primop IndexOffForeignObjOp_Int64 "indexInt64OffForeignObj#" GenPrimOp
666 ForeignObj# -> Int# -> Int64#
668 primop IndexOffForeignObjOp_Word64 "indexWord64OffForeignObj#" GenPrimOp
669 ForeignObj# -> Int# -> Word64#
673 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
674 Addr# -> Int# -> State# s -> (# State# s, Char# #)
676 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
677 Addr# -> Int# -> State# s -> (# State# s, Int# #)
679 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
680 Addr# -> Int# -> State# s -> (# State# s, Word# #)
682 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
683 Addr# -> Int# -> State# s -> (# State# s, Addr# #)
685 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
686 Addr# -> Int# -> State# s -> (# State# s, Float# #)
688 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
689 Addr# -> Int# -> State# s -> (# State# s, Double# #)
691 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
692 Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
694 primop ReadOffAddrOp_ForeignObj "readForeignObjOffAddr#" GenPrimOp
695 Addr# -> Int# -> State# s -> (# State# s, ForeignObj# #)
697 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
698 Addr# -> Int# -> State# s -> (# State# s, Int64# #)
700 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
701 Addr# -> Int# -> State# s -> (# State# s, Word64# #)
704 primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
705 Addr# -> Int# -> Char# -> State# s -> State# s
706 with has_side_effects = True
708 primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
709 Addr# -> Int# -> Int# -> State# s -> State# s
710 with has_side_effects = True
712 primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
713 Addr# -> Int# -> Word# -> State# s -> State# s
714 with has_side_effects = True
716 primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
717 Addr# -> Int# -> Addr# -> State# s -> State# s
718 with has_side_effects = True
720 primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
721 Addr# -> Int# -> Float# -> State# s -> State# s
722 with has_side_effects = True
724 primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
725 Addr# -> Int# -> Double# -> State# s -> State# s
726 with has_side_effects = True
728 primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
729 Addr# -> Int# -> StablePtr# a -> State# s -> State# s
730 with has_side_effects = True
732 primop WriteOffAddrOp_ForeignObj "writeForeignObjOffAddr#" GenPrimOp
733 Addr# -> Int# -> ForeignObj# -> State# s -> State# s
734 with has_side_effects = True
736 primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
737 Addr# -> Int# -> Int64# -> State# s -> State# s
738 with has_side_effects = True
740 primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
741 Addr# -> Int# -> Word64# -> State# s -> State# s
742 with has_side_effects = True
746 primop NewArrayOp "newArray#" GenPrimOp
747 Int# -> a -> State# s -> (# State# s, MutArr# s a #)
749 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
750 usage = { mangle NewArrayOp [mkP, mkM, mkP] mkM }
753 primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
754 MutArr# s a -> MutArr# s a -> Bool
756 usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
758 primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
759 MutByteArr# s -> MutByteArr# s -> Bool
761 primop ReadArrayOp "readArray#" GenPrimOp
762 MutArr# s a -> Int# -> State# s -> (# State# s, a #)
764 usage = { mangle ReadArrayOp [mkM, mkP, mkP] mkM }
766 primop WriteArrayOp "writeArray#" GenPrimOp
767 MutArr# s a -> Int# -> a -> State# s -> State# s
769 usage = { mangle WriteArrayOp [mkM, mkP, mkM, mkP] mkR }
770 strictness = { \ arity -> StrictnessInfo [wwPrim, wwPrim, wwLazy, wwPrim] False }
771 has_side_effects = True
773 primop IndexArrayOp "indexArray#" GenPrimOp
774 Array# a -> Int# -> (# a #)
776 usage = { mangle IndexArrayOp [mkM, mkP] mkM }
778 primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
779 MutArr# s a -> State# s -> (# State# s, Array# a #)
781 usage = { mangle UnsafeFreezeArrayOp [mkM, mkP] mkM }
782 has_side_effects = True
784 primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
785 MutByteArr# s -> State# s -> (# State# s, ByteArr# #)
787 has_side_effects = True
789 primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
790 Array# a -> State# s -> (# State# s, MutArr# s a #)
792 usage = { mangle UnsafeThawArrayOp [mkM, mkP] mkM }
795 primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
798 primop SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
799 MutByteArr# s -> Int#
801 ------------------------------------------------------------------------
802 --- Mutable variables ---
803 ------------------------------------------------------------------------
805 primop NewMutVarOp "newMutVar#" GenPrimOp
806 a -> State# s -> (# State# s, MutVar# s a #)
808 usage = { mangle NewMutVarOp [mkM, mkP] mkM }
809 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
812 primop ReadMutVarOp "readMutVar#" GenPrimOp
813 MutVar# s a -> State# s -> (# State# s, a #)
815 usage = { mangle ReadMutVarOp [mkM, mkP] mkM }
817 primop WriteMutVarOp "writeMutVar#" GenPrimOp
818 MutVar# s a -> a -> State# s -> State# s
820 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
821 usage = { mangle WriteMutVarOp [mkM, mkM, mkP] mkR }
822 has_side_effects = True
824 primop SameMutVarOp "sameMutVar#" GenPrimOp
825 MutVar# s a -> MutVar# s a -> Bool
827 usage = { mangle SameMutVarOp [mkP, mkP] mkM }
829 ------------------------------------------------------------------------
831 ------------------------------------------------------------------------
833 primop CatchOp "catch#" GenPrimOp
834 (State# RealWorld -> (# State# RealWorld, a #) )
835 -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
837 -> (# State# RealWorld, a #)
839 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwPrim] False }
840 -- Catch is actually strict in its first argument
841 -- but we don't want to tell the strictness
842 -- analyser about that!
843 usage = { mangle CatchOp [mkM, mkM . (inFun CatchOp mkM mkM), mkP] mkM }
844 -- [mkO, mkO . (inFun mkM mkO)] mkO
845 -- might use caught action multiply
848 primop RaiseOp "raise#" GenPrimOp
851 strictness = { \ arity -> StrictnessInfo [wwLazy] True }
852 -- NB: True => result is bottom
853 usage = { mangle RaiseOp [mkM] mkM }
856 primop BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
857 (State# RealWorld -> (# State# RealWorld, a #))
858 -> (State# RealWorld -> (# State# RealWorld, a #))
860 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
863 primop UnblockAsyncExceptionsOp "unblockAsyncExceptions#" GenPrimOp
864 (State# RealWorld -> (# State# RealWorld, a #))
865 -> (State# RealWorld -> (# State# RealWorld, a #))
867 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
870 ------------------------------------------------------------------------
871 --- MVars (not the same as mutable variables!) ---
872 ------------------------------------------------------------------------
874 primop NewMVarOp "newMVar#" GenPrimOp
875 State# s -> (# State# s, MVar# s a #)
877 usage = { mangle NewMVarOp [mkP] mkR }
880 primop TakeMVarOp "takeMVar#" GenPrimOp
881 MVar# s a -> State# s -> (# State# s, a #)
883 usage = { mangle TakeMVarOp [mkM, mkP] mkM }
884 has_side_effects = True
887 primop PutMVarOp "putMVar#" GenPrimOp
888 MVar# s a -> a -> State# s -> State# s
890 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
891 usage = { mangle PutMVarOp [mkM, mkM, mkP] mkR }
892 has_side_effects = True
895 primop SameMVarOp "sameMVar#" GenPrimOp
896 MVar# s a -> MVar# s a -> Bool
898 usage = { mangle SameMVarOp [mkP, mkP] mkM }
900 primop TryTakeMVarOp "tryTakeMVar#" GenPrimOp
901 MVar# s a -> State# s -> (# State# s, Int#, a #)
903 usage = { mangle TryTakeMVarOp [mkM, mkP] mkM }
904 has_side_effects = True
907 primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
908 MVar# s a -> State# s -> (# State# s, Int# #)
910 usage = { mangle IsEmptyMVarOp [mkP, mkP] mkM }
913 ------------------------------------------------------------------------
914 --- delay/wait operations ---
915 ------------------------------------------------------------------------
917 primop DelayOp "delay#" GenPrimOp
918 Int# -> State# s -> State# s
921 has_side_effects = True
924 primop WaitReadOp "waitRead#" GenPrimOp
925 Int# -> State# s -> State# s
928 has_side_effects = True
931 primop WaitWriteOp "waitWrite#" GenPrimOp
932 Int# -> State# s -> State# s
935 has_side_effects = True
938 ------------------------------------------------------------------------
939 --- concurrency primitives ---
940 ------------------------------------------------------------------------
942 primop ForkOp "fork#" GenPrimOp
943 a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
945 usage = { mangle ForkOp [mkO, mkP] mkR }
946 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
947 has_side_effects = True
950 primop KillThreadOp "killThread#" GenPrimOp
951 ThreadId# -> a -> State# RealWorld -> State# RealWorld
953 usage = { mangle KillThreadOp [mkP, mkM, mkP] mkR }
954 has_side_effects = True
957 primop YieldOp "yield#" GenPrimOp
958 State# RealWorld -> State# RealWorld
960 has_side_effects = True
963 primop MyThreadIdOp "myThreadId#" GenPrimOp
964 State# RealWorld -> (# State# RealWorld, ThreadId# #)
966 ------------------------------------------------------------------------
967 --- foreign objects ---
968 ------------------------------------------------------------------------
970 primop MkForeignObjOp "mkForeignObj#" GenPrimOp
971 Addr# -> State# RealWorld -> (# State# RealWorld, ForeignObj# #)
973 has_side_effects = True
976 primop WriteForeignObjOp "writeForeignObj#" GenPrimOp
977 ForeignObj# -> Addr# -> State# s -> State# s
979 has_side_effects = True
981 primop ForeignObjToAddrOp "foreignObjToAddr#" GenPrimOp
984 primop TouchOp "touch#" GenPrimOp
985 o -> State# RealWorld -> State# RealWorld
987 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
989 ------------------------------------------------------------------------
990 --- Bytecode objects ---
991 ------------------------------------------------------------------------
993 primop NewBCOOp "newBCO#" GenPrimOp
994 Int# -> Int# -> Int# -> a -> State# RealWorld -> (# State# RealWorld, BCO# #)
996 has_side_effects = True
998 strictness = { \ arity -> StrictnessInfo
999 [wwPrim, wwPrim, wwPrim, wwLazy, wwPrim] False }
1000 usage = { mangle NewBCOOp [mkP, mkP, mkP, mkM, mkP] mkR }
1002 primop WriteBCOPtrOp "writeBCOPtr#" GenPrimOp
1003 BCO# -> Int# -> o -> State# RealWorld -> State# RealWorld
1005 usage = { mangle WriteBCOPtrOp [mkP, mkP, mkM, mkP] mkR }
1006 strictness = { \ arity -> StrictnessInfo
1007 [wwPrim, wwPrim, wwLazy, wwPrim] False }
1008 has_side_effects = True
1010 primop WriteBCONonPtrOp "writeBCONonPtr#" GenPrimOp
1011 BCO# -> Int# -> Word# -> State# RealWorld -> State# RealWorld
1013 has_side_effects = True
1015 primop WriteBCOInstrOp "writeBCOInstr#" GenPrimOp
1016 BCO# -> Int# -> Word# -> State# RealWorld -> State# RealWorld
1018 has_side_effects = True
1020 primop ReadBCOPtrOp "readBCOPtr#" GenPrimOp
1021 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
1023 usage = { mangle ReadBCOPtrOp [mkP, mkP] mkM }
1025 primop ReadBCONonPtrOp "readBCONonPtr#" GenPrimOp
1026 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
1028 primop ReadBCOInstrOp "readBCOInstr#" GenPrimOp
1029 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
1031 primop SameBCOOp "sameBCO#" GenPrimOp
1032 BCO# -> BCO# -> Bool
1034 -- is this usage right?
1035 usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
1038 ------------------------------------------------------------------------
1039 --- Weak pointers ---
1040 ------------------------------------------------------------------------
1042 -- note that tyvar "o" denoted openAlphaTyVar
1044 primop MkWeakOp "mkWeak#" GenPrimOp
1045 o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
1047 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwLazy, wwPrim] False }
1048 usage = { mangle MkWeakOp [mkZ, mkM, mkM, mkP] mkM }
1049 has_side_effects = True
1052 primop DeRefWeakOp "deRefWeak#" GenPrimOp
1053 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
1055 usage = { mangle DeRefWeakOp [mkM, mkP] mkM }
1056 has_side_effects = True
1058 primop FinalizeWeakOp "finalizeWeak#" GenPrimOp
1059 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#,
1060 (State# RealWorld -> (# State# RealWorld, Unit #)) #)
1062 usage = { mangle FinalizeWeakOp [mkM, mkP]
1063 (mkR . (inUB FinalizeWeakOp
1064 [id,id,inFun FinalizeWeakOp mkR mkM])) }
1065 has_side_effects = True
1069 ------------------------------------------------------------------------
1070 --- Stable pointers and names ---
1071 ------------------------------------------------------------------------
1073 primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
1074 a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
1076 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1077 usage = { mangle MakeStablePtrOp [mkM, mkP] mkM }
1078 has_side_effects = True
1080 primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
1081 StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
1083 usage = { mangle DeRefStablePtrOp [mkM, mkP] mkM }
1084 needs_wrapper = True
1085 has_side_effects = True
1087 primop EqStablePtrOp "eqStablePtr#" GenPrimOp
1088 StablePtr# a -> StablePtr# a -> Int#
1090 usage = { mangle EqStablePtrOp [mkP, mkP] mkR }
1091 has_side_effects = True
1093 primop MakeStableNameOp "makeStableName#" GenPrimOp
1094 a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
1096 usage = { mangle MakeStableNameOp [mkZ, mkP] mkR }
1097 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1098 needs_wrapper = True
1099 has_side_effects = True
1102 primop EqStableNameOp "eqStableName#" GenPrimOp
1103 StableName# a -> StableName# a -> Int#
1105 usage = { mangle EqStableNameOp [mkP, mkP] mkR }
1107 primop StableNameToIntOp "stableNameToInt#" GenPrimOp
1108 StableName# a -> Int#
1110 usage = { mangle StableNameToIntOp [mkP] mkR }
1112 ------------------------------------------------------------------------
1113 --- Unsafe pointer equality (#1 Bad Guy: Alistair Reid :) ---
1114 ------------------------------------------------------------------------
1116 primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
1119 usage = { mangle ReallyUnsafePtrEqualityOp [mkZ, mkZ] mkR }
1121 ------------------------------------------------------------------------
1123 ------------------------------------------------------------------------
1125 primop SeqOp "seq#" GenPrimOp
1128 usage = { mangle SeqOp [mkO] mkR }
1129 strictness = { \ arity -> StrictnessInfo [wwStrict] False }
1130 -- Seq is strict in its argument; see notes in ConFold.lhs
1131 has_side_effects = True
1133 primop ParOp "par#" GenPrimOp
1136 usage = { mangle ParOp [mkO] mkR }
1137 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1138 -- Note that Par is lazy to avoid that the sparked thing
1139 -- gets evaluted strictly, which it should *not* be
1140 has_side_effects = True
1142 -- HWL: The first 4 Int# in all par... annotations denote:
1143 -- name, granularity info, size of result, degree of parallelism
1144 -- Same structure as _seq_ i.e. returns Int#
1145 -- KSW: v, the second arg in parAt# and parAtForNow#, is used only to determine
1146 -- `the processor containing the expression v'; it is not evaluated
1148 primop ParGlobalOp "parGlobal#" GenPrimOp
1149 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1151 usage = { mangle ParGlobalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1152 has_side_effects = True
1154 primop ParLocalOp "parLocal#" GenPrimOp
1155 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1157 usage = { mangle ParLocalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1158 has_side_effects = True
1160 primop ParAtOp "parAt#" GenPrimOp
1161 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1163 usage = { mangle ParAtOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1164 has_side_effects = True
1166 primop ParAtAbsOp "parAtAbs#" GenPrimOp
1167 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1169 usage = { mangle ParAtAbsOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1170 has_side_effects = True
1172 primop ParAtRelOp "parAtRel#" GenPrimOp
1173 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1175 usage = { mangle ParAtRelOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1176 has_side_effects = True
1178 primop ParAtForNowOp "parAtForNow#" GenPrimOp
1179 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1181 usage = { mangle ParAtForNowOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1182 has_side_effects = True
1184 primop CopyableOp "copyable#" GenPrimOp
1187 usage = { mangle CopyableOp [mkZ] mkR }
1188 has_side_effects = True
1190 primop NoFollowOp "noFollow#" GenPrimOp
1193 usage = { mangle NoFollowOp [mkZ] mkR }
1194 has_side_effects = True
1197 ------------------------------------------------------------------------
1198 --- tag to enum stuff ---
1199 ------------------------------------------------------------------------
1201 primop DataToTagOp "dataToTag#" GenPrimOp
1204 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1206 primop TagToEnumOp "tagToEnum#" GenPrimOp
1212 ------------------------------------------------------------------------
1214 ------------------------------------------------------------------------