1 -----------------------------------------------------------------------
2 -- $Id: primops.txt,v 1.5 2000/09/26 16:45:34 simonpj 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 ------------------------------------------------------------------------
427 ------------------------------------------------------------------------
429 primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word#
430 primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word#
432 primop AndOp "and#" Dyadic
433 Word# -> Word# -> Word#
434 with commutable = True
436 primop OrOp "or#" Dyadic
437 Word# -> Word# -> Word#
438 with commutable = True
440 primop XorOp "xor#" Dyadic
441 Word# -> Word# -> Word#
442 with commutable = True
444 primop NotOp "not#" Monadic Word# -> Word#
446 primop SllOp "shiftL#" GenPrimOp Word# -> Int# -> Word#
447 primop SrlOp "shiftRL#" GenPrimOp Word# -> Int# -> Word#
450 primop Word2IntOp "word2Int#" GenPrimOp Word# -> Int#
452 primop Word2IntegerOp "word2Integer#" GenPrimOp
453 Word# -> (# Int#, ByteArr# #)
454 with out_of_line = True
456 primop WordGtOp "gtWord#" Compare Word# -> Word# -> Bool
457 primop WordGeOp "geWord#" Compare Word# -> Word# -> Bool
458 primop WordEqOp "eqWord#" Compare Word# -> Word# -> Bool
459 primop WordNeOp "neWord#" Compare Word# -> Word# -> Bool
460 primop WordLtOp "ltWord#" Compare Word# -> Word# -> Bool
461 primop WordLeOp "leWord#" Compare Word# -> Word# -> Bool
463 ------------------------------------------------------------------------
465 ------------------------------------------------------------------------
467 primop Word64ToIntegerOp "word64ToInteger#" GenPrimOp
468 Word64# -> (# Int#, ByteArr# #)
469 with out_of_line = True
472 ------------------------------------------------------------------------
474 ------------------------------------------------------------------------
476 primop NewByteArrayOp_Char "newCharArray#" GenPrimOp
477 Int# -> State# s -> (# State# s, MutByteArr# s #)
478 with out_of_line = True
480 primop NewByteArrayOp_Int "newIntArray#" GenPrimOp
481 Int# -> State# s -> (# State# s, MutByteArr# s #)
482 with out_of_line = True
484 primop NewByteArrayOp_Word "newWordArray#" GenPrimOp
485 Int# -> State# s -> (# State# s, MutByteArr# s #)
486 with out_of_line = True
488 primop NewByteArrayOp_Addr "newAddrArray#" GenPrimOp
489 Int# -> State# s -> (# State# s, MutByteArr# s #)
490 with out_of_line = True
492 primop NewByteArrayOp_Float "newFloatArray#" GenPrimOp
493 Int# -> State# s -> (# State# s, MutByteArr# s #)
494 with out_of_line = True
496 primop NewByteArrayOp_Double "newDoubleArray#" GenPrimOp
497 Int# -> State# s -> (# State# s, MutByteArr# s #)
498 with out_of_line = True
500 primop NewByteArrayOp_StablePtr "newStablePtrArray#" GenPrimOp
501 Int# -> State# s -> (# State# s, MutByteArr# s #)
502 with out_of_line = True
506 primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
507 MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
509 primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp
510 MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
512 primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp
513 MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
515 primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
516 MutByteArr# s -> Int# -> State# s -> (# State# s, Addr# #)
518 primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
519 MutByteArr# s -> Int# -> State# s -> (# State# s, Float# #)
521 primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
522 MutByteArr# s -> Int# -> State# s -> (# State# s, Double# #)
524 primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
525 MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
527 primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
528 MutByteArr# s -> Int# -> State# s -> (# State# s, Int64# #)
530 primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
531 MutByteArr# s -> Int# -> State# s -> (# State# s, Word64# #)
535 primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
536 MutByteArr# s -> Int# -> Char# -> State# s -> State# s
537 with has_side_effects = True
539 primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
540 MutByteArr# s -> Int# -> Int# -> State# s -> State# s
541 with has_side_effects = True
543 primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
544 MutByteArr# s -> Int# -> Word# -> State# s -> State# s
545 with has_side_effects = True
547 primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
548 MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
549 with has_side_effects = True
551 primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
552 MutByteArr# s -> Int# -> Float# -> State# s -> State# s
553 with has_side_effects = True
555 primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
556 MutByteArr# s -> Int# -> Double# -> State# s -> State# s
557 with has_side_effects = True
559 primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
560 MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
561 with has_side_effects = True
563 primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
564 MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
565 with has_side_effects = True
567 primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
568 MutByteArr# s -> Int# -> Word64# -> State# s -> State# s
569 with has_side_effects = True
572 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
573 ByteArr# -> Int# -> Char#
575 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
576 ByteArr# -> Int# -> Int#
578 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
579 ByteArr# -> Int# -> Word#
581 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
582 ByteArr# -> Int# -> Addr#
584 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
585 ByteArr# -> Int# -> Float#
587 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
588 ByteArr# -> Int# -> Double#
590 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
591 ByteArr# -> Int# -> StablePtr# a
593 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
594 ByteArr# -> Int# -> Int64#
596 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
597 ByteArr# -> Int# -> Word64#
600 primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
601 Addr# -> Int# -> Char#
603 primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
604 Addr# -> Int# -> Int#
606 primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
607 Addr# -> Int# -> Word#
609 primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
610 Addr# -> Int# -> Addr#
612 primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
613 Addr# -> Int# -> Float#
615 primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
616 Addr# -> Int# -> Double#
618 primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
619 Addr# -> Int# -> StablePtr# a
621 primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
622 Addr# -> Int# -> Int64#
624 primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
625 Addr# -> Int# -> Word64#
628 primop IndexOffForeignObjOp_Char "indexCharOffForeignObj#" GenPrimOp
629 ForeignObj# -> Int# -> Char#
631 primop IndexOffForeignObjOp_Int "indexIntOffForeignObj#" GenPrimOp
632 ForeignObj# -> Int# -> Int#
634 primop IndexOffForeignObjOp_Word "indexWordOffForeignObj#" GenPrimOp
635 ForeignObj# -> Int# -> Word#
637 primop IndexOffForeignObjOp_Addr "indexAddrOffForeignObj#" GenPrimOp
638 ForeignObj# -> Int# -> Addr#
640 primop IndexOffForeignObjOp_Float "indexFloatOffForeignObj#" GenPrimOp
641 ForeignObj# -> Int# -> Float#
643 primop IndexOffForeignObjOp_Double "indexDoubleOffForeignObj#" GenPrimOp
644 ForeignObj# -> Int# -> Double#
646 primop IndexOffForeignObjOp_StablePtr "indexStablePtrOffForeignObj#" GenPrimOp
647 ForeignObj# -> Int# -> StablePtr# a
649 primop IndexOffForeignObjOp_Int64 "indexInt64OffForeignObj#" GenPrimOp
650 ForeignObj# -> Int# -> Int64#
652 primop IndexOffForeignObjOp_Word64 "indexWord64OffForeignObj#" GenPrimOp
653 ForeignObj# -> Int# -> Word64#
657 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
658 Addr# -> Int# -> State# s -> (# State# s, Char# #)
660 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
661 Addr# -> Int# -> State# s -> (# State# s, Int# #)
663 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
664 Addr# -> Int# -> State# s -> (# State# s, Word# #)
666 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
667 Addr# -> Int# -> State# s -> (# State# s, Addr# #)
669 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
670 Addr# -> Int# -> State# s -> (# State# s, Float# #)
672 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
673 Addr# -> Int# -> State# s -> (# State# s, Double# #)
675 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
676 Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
678 primop ReadOffAddrOp_ForeignObj "readForeignObjOffAddr#" GenPrimOp
679 Addr# -> Int# -> State# s -> (# State# s, ForeignObj# #)
681 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
682 Addr# -> Int# -> State# s -> (# State# s, Int64# #)
684 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
685 Addr# -> Int# -> State# s -> (# State# s, Word64# #)
688 primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
689 Addr# -> Int# -> Char# -> State# s -> State# s
690 with has_side_effects = True
692 primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
693 Addr# -> Int# -> Int# -> State# s -> State# s
694 with has_side_effects = True
696 primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
697 Addr# -> Int# -> Word# -> State# s -> State# s
698 with has_side_effects = True
700 primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
701 Addr# -> Int# -> Addr# -> State# s -> State# s
702 with has_side_effects = True
704 primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
705 Addr# -> Int# -> Float# -> State# s -> State# s
706 with has_side_effects = True
708 primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
709 Addr# -> Int# -> Double# -> State# s -> State# s
710 with has_side_effects = True
712 primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
713 Addr# -> Int# -> StablePtr# a -> State# s -> State# s
714 with has_side_effects = True
716 primop WriteOffAddrOp_ForeignObj "writeForeignObjOffAddr#" GenPrimOp
717 Addr# -> Int# -> ForeignObj# -> State# s -> State# s
718 with has_side_effects = True
720 primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
721 Addr# -> Int# -> Int64# -> State# s -> State# s
722 with has_side_effects = True
724 primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
725 Addr# -> Int# -> Word64# -> State# s -> State# s
726 with has_side_effects = True
730 primop NewArrayOp "newArray#" GenPrimOp
731 Int# -> a -> State# s -> (# State# s, MutArr# s a #)
733 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
734 usage = { mangle NewArrayOp [mkP, mkM, mkP] mkM }
737 primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
738 MutArr# s a -> MutArr# s a -> Bool
740 usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
742 primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
743 MutByteArr# s -> MutByteArr# s -> Bool
745 primop ReadArrayOp "readArray#" GenPrimOp
746 MutArr# s a -> Int# -> State# s -> (# State# s, a #)
748 usage = { mangle ReadArrayOp [mkM, mkP, mkP] mkM }
750 primop WriteArrayOp "writeArray#" GenPrimOp
751 MutArr# s a -> Int# -> a -> State# s -> State# s
753 usage = { mangle WriteArrayOp [mkM, mkP, mkM, mkP] mkR }
754 strictness = { \ arity -> StrictnessInfo [wwPrim, wwPrim, wwLazy, wwPrim] False }
755 has_side_effects = True
757 primop IndexArrayOp "indexArray#" GenPrimOp
758 Array# a -> Int# -> (# a #)
760 usage = { mangle IndexArrayOp [mkM, mkP] mkM }
762 primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
763 MutArr# s a -> State# s -> (# State# s, Array# a #)
765 usage = { mangle UnsafeFreezeArrayOp [mkM, mkP] mkM }
766 has_side_effects = True
768 primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
769 MutByteArr# s -> State# s -> (# State# s, ByteArr# #)
771 has_side_effects = True
773 primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
774 Array# a -> State# s -> (# State# s, MutArr# s a #)
776 usage = { mangle UnsafeThawArrayOp [mkM, mkP] mkM }
779 primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
782 primop SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
783 MutByteArr# s -> Int#
785 ------------------------------------------------------------------------
786 --- Mutable variables ---
787 ------------------------------------------------------------------------
789 primop NewMutVarOp "newMutVar#" GenPrimOp
790 a -> State# s -> (# State# s, MutVar# s a #)
792 usage = { mangle NewMutVarOp [mkM, mkP] mkM }
793 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
796 primop ReadMutVarOp "readMutVar#" GenPrimOp
797 MutVar# s a -> State# s -> (# State# s, a #)
799 usage = { mangle ReadMutVarOp [mkM, mkP] mkM }
801 primop WriteMutVarOp "writeMutVar#" GenPrimOp
802 MutVar# s a -> a -> State# s -> State# s
804 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
805 usage = { mangle WriteMutVarOp [mkM, mkM, mkP] mkR }
806 has_side_effects = True
808 primop SameMutVarOp "sameMutVar#" GenPrimOp
809 MutVar# s a -> MutVar# s a -> Bool
811 usage = { mangle SameMutVarOp [mkP, mkP] mkM }
813 ------------------------------------------------------------------------
815 ------------------------------------------------------------------------
817 primop CatchOp "catch#" GenPrimOp
818 (State# RealWorld -> (# State# RealWorld, a #) )
819 -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
821 -> (# State# RealWorld, a #)
823 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwPrim] False }
824 -- Catch is actually strict in its first argument
825 -- but we don't want to tell the strictness
826 -- analyser about that!
827 usage = { mangle CatchOp [mkM, mkM . (inFun CatchOp mkM mkM), mkP] mkM }
828 -- [mkO, mkO . (inFun mkM mkO)] mkO
829 -- might use caught action multiply
832 primop RaiseOp "raise#" GenPrimOp
835 strictness = { \ arity -> StrictnessInfo [wwLazy] True }
836 -- NB: True => result is bottom
837 usage = { mangle RaiseOp [mkM] mkM }
840 primop BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
841 (State# RealWorld -> (# State# RealWorld, a #))
842 -> (State# RealWorld -> (# State# RealWorld, a #))
844 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
847 primop UnblockAsyncExceptionsOp "unblockAsyncExceptions#" GenPrimOp
848 (State# RealWorld -> (# State# RealWorld, a #))
849 -> (State# RealWorld -> (# State# RealWorld, a #))
851 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
854 ------------------------------------------------------------------------
855 --- MVars (not the same as mutable variables!) ---
856 ------------------------------------------------------------------------
858 primop NewMVarOp "newMVar#" GenPrimOp
859 State# s -> (# State# s, MVar# s a #)
861 usage = { mangle NewMVarOp [mkP] mkR }
864 primop TakeMVarOp "takeMVar#" GenPrimOp
865 MVar# s a -> State# s -> (# State# s, a #)
867 usage = { mangle TakeMVarOp [mkM, mkP] mkM }
868 has_side_effects = True
871 primop PutMVarOp "putMVar#" GenPrimOp
872 MVar# s a -> a -> State# s -> State# s
874 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
875 usage = { mangle PutMVarOp [mkM, mkM, mkP] mkR }
876 has_side_effects = True
879 primop SameMVarOp "sameMVar#" GenPrimOp
880 MVar# s a -> MVar# s a -> Bool
882 usage = { mangle SameMVarOp [mkP, mkP] mkM }
884 primop TryTakeMVarOp "tryTakeMVar#" GenPrimOp
885 MVar# s a -> State# s -> (# State# s, Int#, a #)
887 usage = { mangle TryTakeMVarOp [mkM, mkP] mkM }
888 has_side_effects = True
891 primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
892 MVar# s a -> State# s -> (# State# s, Int# #)
894 usage = { mangle IsEmptyMVarOp [mkP, mkP] mkM }
897 ------------------------------------------------------------------------
898 --- delay/wait operations ---
899 ------------------------------------------------------------------------
901 primop DelayOp "delay#" GenPrimOp
902 Int# -> State# s -> State# s
905 has_side_effects = True
908 primop WaitReadOp "waitRead#" GenPrimOp
909 Int# -> State# s -> State# s
912 has_side_effects = True
915 primop WaitWriteOp "waitWrite#" GenPrimOp
916 Int# -> State# s -> State# s
919 has_side_effects = True
922 ------------------------------------------------------------------------
923 --- concurrency primitives ---
924 ------------------------------------------------------------------------
926 primop ForkOp "fork#" GenPrimOp
927 a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
929 usage = { mangle ForkOp [mkO, mkP] mkR }
930 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
931 has_side_effects = True
934 primop KillThreadOp "killThread#" GenPrimOp
935 ThreadId# -> a -> State# RealWorld -> State# RealWorld
937 usage = { mangle KillThreadOp [mkP, mkM, mkP] mkR }
938 has_side_effects = True
941 primop YieldOp "yield#" GenPrimOp
942 State# RealWorld -> State# RealWorld
944 has_side_effects = True
947 primop MyThreadIdOp "myThreadId#" GenPrimOp
948 State# RealWorld -> (# State# RealWorld, ThreadId# #)
950 ------------------------------------------------------------------------
951 --- foreign objects ---
952 ------------------------------------------------------------------------
954 primop MkForeignObjOp "mkForeignObj#" GenPrimOp
955 Addr# -> State# RealWorld -> (# State# RealWorld, ForeignObj# #)
957 has_side_effects = True
960 primop WriteForeignObjOp "writeForeignObj#" GenPrimOp
961 ForeignObj# -> Addr# -> State# s -> State# s
963 has_side_effects = True
965 primop ForeignObjToAddrOp "foreignObjToAddr#" GenPrimOp
968 primop TouchOp "touch#" GenPrimOp
969 o -> State# RealWorld -> State# RealWorld
971 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
973 ------------------------------------------------------------------------
974 --- Bytecode objects ---
975 ------------------------------------------------------------------------
977 primop NewBCOOp "newBCO#" GenPrimOp
978 Int# -> Int# -> Int# -> a -> State# RealWorld -> (# State# RealWorld, BCO# #)
980 has_side_effects = True
982 strictness = { \ arity -> StrictnessInfo
983 [wwPrim, wwPrim, wwPrim, wwLazy, wwPrim] False }
984 usage = { mangle NewBCOOp [mkP, mkP, mkP, mkM, mkP] mkR }
986 primop WriteBCOPtrOp "writeBCOPtr#" GenPrimOp
987 BCO# -> Int# -> o -> State# RealWorld -> State# RealWorld
989 usage = { mangle WriteBCOPtrOp [mkP, mkP, mkM, mkP] mkR }
990 strictness = { \ arity -> StrictnessInfo
991 [wwPrim, wwPrim, wwLazy, wwPrim] False }
992 has_side_effects = True
994 primop WriteBCONonPtrOp "writeBCONonPtr#" GenPrimOp
995 BCO# -> Int# -> Word# -> State# RealWorld -> State# RealWorld
997 has_side_effects = True
999 primop WriteBCOInstrOp "writeBCOInstr#" GenPrimOp
1000 BCO# -> Int# -> Word# -> State# RealWorld -> State# RealWorld
1002 has_side_effects = True
1004 primop ReadBCOPtrOp "readBCOPtr#" GenPrimOp
1005 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
1007 usage = { mangle ReadBCOPtrOp [mkP, mkP] mkM }
1009 primop ReadBCONonPtrOp "readBCONonPtr#" GenPrimOp
1010 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
1012 primop ReadBCOInstrOp "readBCOInstr#" GenPrimOp
1013 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
1015 primop SameBCOOp "sameBCO#" GenPrimOp
1016 BCO# -> BCO# -> Bool
1018 -- is this usage right?
1019 usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
1022 ------------------------------------------------------------------------
1023 --- Weak pointers ---
1024 ------------------------------------------------------------------------
1026 -- note that tyvar "o" denoted openAlphaTyVar
1028 primop MkWeakOp "mkWeak#" GenPrimOp
1029 o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
1031 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwLazy, wwPrim] False }
1032 usage = { mangle MkWeakOp [mkZ, mkM, mkM, mkP] mkM }
1033 has_side_effects = True
1036 primop DeRefWeakOp "deRefWeak#" GenPrimOp
1037 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
1039 usage = { mangle DeRefWeakOp [mkM, mkP] mkM }
1040 has_side_effects = True
1042 primop FinalizeWeakOp "finalizeWeak#" GenPrimOp
1043 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#,
1044 (State# RealWorld -> (# State# RealWorld, Unit #)) #)
1046 usage = { mangle FinalizeWeakOp [mkM, mkP]
1047 (mkR . (inUB FinalizeWeakOp
1048 [id,id,inFun FinalizeWeakOp mkR mkM])) }
1049 has_side_effects = True
1053 ------------------------------------------------------------------------
1054 --- Stable pointers and names ---
1055 ------------------------------------------------------------------------
1057 primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
1058 a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
1060 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1061 usage = { mangle MakeStablePtrOp [mkM, mkP] mkM }
1062 has_side_effects = True
1064 primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
1065 StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
1067 usage = { mangle DeRefStablePtrOp [mkM, mkP] mkM }
1068 needs_wrapper = True
1069 has_side_effects = True
1071 primop EqStablePtrOp "eqStablePtr#" GenPrimOp
1072 StablePtr# a -> StablePtr# a -> Int#
1074 usage = { mangle EqStablePtrOp [mkP, mkP] mkR }
1075 has_side_effects = True
1077 primop MakeStableNameOp "makeStableName#" GenPrimOp
1078 a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
1080 usage = { mangle MakeStableNameOp [mkZ, mkP] mkR }
1081 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1082 needs_wrapper = True
1083 has_side_effects = True
1086 primop EqStableNameOp "eqStableName#" GenPrimOp
1087 StableName# a -> StableName# a -> Int#
1089 usage = { mangle EqStableNameOp [mkP, mkP] mkR }
1091 primop StableNameToIntOp "stableNameToInt#" GenPrimOp
1092 StableName# a -> Int#
1094 usage = { mangle StableNameToIntOp [mkP] mkR }
1096 ------------------------------------------------------------------------
1097 --- Unsafe pointer equality (#1 Bad Guy: Alistair Reid :) ---
1098 ------------------------------------------------------------------------
1100 primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
1103 usage = { mangle ReallyUnsafePtrEqualityOp [mkZ, mkZ] mkR }
1105 ------------------------------------------------------------------------
1107 ------------------------------------------------------------------------
1109 primop SeqOp "seq#" GenPrimOp
1112 usage = { mangle SeqOp [mkO] mkR }
1113 strictness = { \ arity -> StrictnessInfo [wwStrict] False }
1114 -- Seq is strict in its argument; see notes in ConFold.lhs
1115 has_side_effects = True
1117 primop ParOp "par#" GenPrimOp
1120 usage = { mangle ParOp [mkO] mkR }
1121 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1122 -- Note that Par is lazy to avoid that the sparked thing
1123 -- gets evaluted strictly, which it should *not* be
1124 has_side_effects = True
1126 -- HWL: The first 4 Int# in all par... annotations denote:
1127 -- name, granularity info, size of result, degree of parallelism
1128 -- Same structure as _seq_ i.e. returns Int#
1129 -- KSW: v, the second arg in parAt# and parAtForNow#, is used only to determine
1130 -- `the processor containing the expression v'; it is not evaluated
1132 primop ParGlobalOp "parGlobal#" GenPrimOp
1133 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1135 usage = { mangle ParGlobalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1136 has_side_effects = True
1138 primop ParLocalOp "parLocal#" GenPrimOp
1139 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1141 usage = { mangle ParLocalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1142 has_side_effects = True
1144 primop ParAtOp "parAt#" GenPrimOp
1145 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1147 usage = { mangle ParAtOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1148 has_side_effects = True
1150 primop ParAtAbsOp "parAtAbs#" GenPrimOp
1151 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1153 usage = { mangle ParAtAbsOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1154 has_side_effects = True
1156 primop ParAtRelOp "parAtRel#" GenPrimOp
1157 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1159 usage = { mangle ParAtRelOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1160 has_side_effects = True
1162 primop ParAtForNowOp "parAtForNow#" GenPrimOp
1163 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1165 usage = { mangle ParAtForNowOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1166 has_side_effects = True
1168 primop CopyableOp "copyable#" GenPrimOp
1171 usage = { mangle CopyableOp [mkZ] mkR }
1172 has_side_effects = True
1174 primop NoFollowOp "noFollow#" GenPrimOp
1177 usage = { mangle NoFollowOp [mkZ] mkR }
1178 has_side_effects = True
1181 ------------------------------------------------------------------------
1182 --- tag to enum stuff ---
1183 ------------------------------------------------------------------------
1185 primop DataToTagOp "dataToTag#" GenPrimOp
1188 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1190 primop TagToEnumOp "tagToEnum#" GenPrimOp
1196 ------------------------------------------------------------------------
1198 ------------------------------------------------------------------------