1 -----------------------------------------------------------------------
2 -- $Id: primops.txt,v 1.8 2000/12/11 12:56:14 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
54 primop SetOffClosureOp_Ptr "setPtrOffClosure#" GenPrimOp
55 a -> Int# -> b -> (# a #)
56 with strictness = { \ arity -> StrictnessInfo [wwStrict, wwPrim, wwLazy] False }
58 primop SetOffClosureOp_Word "setWordOffClosure#" GenPrimOp
59 a -> Int# -> Word# -> (# a #)
60 with strictness = { \ arity -> StrictnessInfo [wwStrict, wwPrim, wwPrim] False }
62 ------------------------------------------------------------------------
64 ------------------------------------------------------------------------
66 primop AddrGtOp "gtAddr#" Compare Addr# -> Addr# -> Bool
67 primop AddrGeOp "geAddr#" Compare Addr# -> Addr# -> Bool
68 primop AddrEqOp "eqAddr#" Compare Addr# -> Addr# -> Bool
69 primop AddrNeOp "neAddr#" Compare Addr# -> Addr# -> Bool
70 primop AddrLtOp "ltAddr#" Compare Addr# -> Addr# -> Bool
71 primop AddrLeOp "leAddr#" Compare Addr# -> Addr# -> Bool
73 primop Addr2IntOp "addr2Int#" GenPrimOp Addr# -> Int#
76 ------------------------------------------------------------------------
78 ------------------------------------------------------------------------
80 primop CharGtOp "gtChar#" Compare Char# -> Char# -> Bool
81 primop CharGeOp "geChar#" Compare Char# -> Char# -> Bool
83 primop CharEqOp "eqChar#" Compare
84 Char# -> Char# -> Bool
85 with commutable = True
87 primop CharNeOp "neChar#" Compare
88 Char# -> Char# -> Bool
89 with commutable = True
91 primop CharLtOp "ltChar#" Compare Char# -> Char# -> Bool
92 primop CharLeOp "leChar#" Compare Char# -> Char# -> Bool
94 primop OrdOp "ord#" GenPrimOp Char# -> Int#
96 ------------------------------------------------------------------------
98 ------------------------------------------------------------------------
100 primop DoubleGtOp ">##" Compare Double# -> Double# -> Bool
101 primop DoubleGeOp ">=##" Compare Double# -> Double# -> Bool
103 primop DoubleEqOp "==##" Compare
104 Double# -> Double# -> Bool
105 with commutable = True
107 primop DoubleNeOp "/=##" Compare
108 Double# -> Double# -> Bool
109 with commutable = True
111 primop DoubleLtOp "<##" Compare Double# -> Double# -> Bool
112 primop DoubleLeOp "<=##" Compare Double# -> Double# -> Bool
114 primop DoubleAddOp "+##" Dyadic
115 Double# -> Double# -> Double#
116 with commutable = True
118 primop DoubleSubOp "-##" Dyadic Double# -> Double# -> Double#
120 primop DoubleMulOp "*##" Dyadic
121 Double# -> Double# -> Double#
122 with commutable = True
124 primop DoubleDivOp "/##" Dyadic
125 Double# -> Double# -> Double#
128 primop DoubleNegOp "negateDouble#" Monadic Double# -> Double#
130 primop Double2IntOp "double2Int#" GenPrimOp Double# -> Int#
131 primop Double2FloatOp "double2Float#" GenPrimOp Double# -> Float#
133 primop DoubleExpOp "expDouble#" Monadic
135 with needs_wrapper = True
137 primop DoubleLogOp "logDouble#" Monadic
143 primop DoubleSqrtOp "sqrtDouble#" Monadic
145 with needs_wrapper = True
147 primop DoubleSinOp "sinDouble#" Monadic
149 with needs_wrapper = True
151 primop DoubleCosOp "cosDouble#" Monadic
153 with needs_wrapper = True
155 primop DoubleTanOp "tanDouble#" Monadic
157 with needs_wrapper = True
159 primop DoubleAsinOp "asinDouble#" Monadic
165 primop DoubleAcosOp "acosDouble#" Monadic
171 primop DoubleAtanOp "atanDouble#" Monadic
176 primop DoubleSinhOp "sinhDouble#" Monadic
178 with needs_wrapper = True
180 primop DoubleCoshOp "coshDouble#" Monadic
182 with needs_wrapper = True
184 primop DoubleTanhOp "tanhDouble#" Monadic
186 with needs_wrapper = True
188 primop DoublePowerOp "**##" Dyadic
189 Double# -> Double# -> Double#
190 with needs_wrapper = True
192 primop DoubleDecodeOp "decodeDouble#" GenPrimOp
193 Double# -> (# Int#, Int#, ByteArr# #)
194 with out_of_line = True
196 ------------------------------------------------------------------------
198 ------------------------------------------------------------------------
200 primop FloatGtOp "gtFloat#" Compare Float# -> Float# -> Bool
201 primop FloatGeOp "geFloat#" Compare Float# -> Float# -> Bool
203 primop FloatEqOp "eqFloat#" Compare
204 Float# -> Float# -> Bool
205 with commutable = True
207 primop FloatNeOp "neFloat#" Compare
208 Float# -> Float# -> Bool
209 with commutable = True
211 primop FloatLtOp "ltFloat#" Compare Float# -> Float# -> Bool
212 primop FloatLeOp "leFloat#" Compare Float# -> Float# -> Bool
214 primop FloatAddOp "plusFloat#" Dyadic
215 Float# -> Float# -> Float#
216 with commutable = True
218 primop FloatSubOp "minusFloat#" Dyadic Float# -> Float# -> Float#
220 primop FloatMulOp "timesFloat#" Dyadic
221 Float# -> Float# -> Float#
222 with commutable = True
224 primop FloatDivOp "divideFloat#" Dyadic
225 Float# -> Float# -> Float#
228 primop FloatNegOp "negateFloat#" Monadic Float# -> Float#
230 primop Float2IntOp "float2Int#" GenPrimOp Float# -> Int#
232 primop FloatExpOp "expFloat#" Monadic
234 with needs_wrapper = True
236 primop FloatLogOp "logFloat#" Monadic
238 with needs_wrapper = True
241 primop FloatSqrtOp "sqrtFloat#" Monadic
243 with needs_wrapper = True
245 primop FloatSinOp "sinFloat#" Monadic
247 with needs_wrapper = True
249 primop FloatCosOp "cosFloat#" Monadic
251 with needs_wrapper = True
253 primop FloatTanOp "tanFloat#" Monadic
255 with needs_wrapper = True
257 primop FloatAsinOp "asinFloat#" Monadic
259 with needs_wrapper = True
262 primop FloatAcosOp "acosFloat#" Monadic
264 with needs_wrapper = True
267 primop FloatAtanOp "atanFloat#" Monadic
269 with needs_wrapper = True
271 primop FloatSinhOp "sinhFloat#" Monadic
273 with needs_wrapper = True
275 primop FloatCoshOp "coshFloat#" Monadic
277 with needs_wrapper = True
279 primop FloatTanhOp "tanhFloat#" Monadic
281 with needs_wrapper = True
283 primop FloatPowerOp "powerFloat#" Dyadic
284 Float# -> Float# -> Float#
285 with needs_wrapper = True
287 primop Float2DoubleOp "float2Double#" GenPrimOp Float# -> Double#
289 primop FloatDecodeOp "decodeFloat#" GenPrimOp
290 Float# -> (# Int#, Int#, ByteArr# #)
291 with out_of_line = True
293 ------------------------------------------------------------------------
295 ------------------------------------------------------------------------
297 primop IntAddOp "+#" Dyadic
299 with commutable = True
301 primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
304 Dyadic Int# -> Int# -> Int#
305 with commutable = True
307 primop IntQuotOp "quotInt#" Dyadic
311 primop IntRemOp "remInt#" Dyadic
315 primop IntGcdOp "gcdInt#" Dyadic Int# -> Int# -> Int#
316 primop IntNegOp "negateInt#" Monadic Int# -> Int#
317 primop IntAddCOp "addIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
318 primop IntSubCOp "subIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
319 primop IntMulCOp "mulIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
320 primop IntGtOp ">#" Compare Int# -> Int# -> Bool
321 primop IntGeOp ">=#" Compare Int# -> Int# -> Bool
323 primop IntEqOp "==#" Compare
325 with commutable = True
327 primop IntNeOp "/=#" Compare
329 with commutable = True
331 primop IntLtOp "<#" Compare Int# -> Int# -> Bool
332 primop IntLeOp "<=#" Compare Int# -> Int# -> Bool
334 primop ChrOp "chr#" GenPrimOp Int# -> Char#
336 primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
337 primop Int2AddrOp "int2Addr#"GenPrimOp Int# -> Addr#
338 primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
339 primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
341 primop Int2IntegerOp "int2Integer#"
342 GenPrimOp Int# -> (# Int#, ByteArr# #)
343 with out_of_line = True
345 primop ISllOp "iShiftL#" GenPrimOp Int# -> Int# -> Int#
346 primop ISraOp "iShiftRA#" GenPrimOp Int# -> Int# -> Int#
347 primop ISrlOp "iShiftRL#" GenPrimOp Int# -> Int# -> Int#
349 ------------------------------------------------------------------------
351 ------------------------------------------------------------------------
353 primop Int64ToIntegerOp "int64ToInteger#" GenPrimOp
354 Int64# -> (# Int#, ByteArr# #)
355 with out_of_line = True
358 ------------------------------------------------------------------------
360 ------------------------------------------------------------------------
362 primop IntegerNegOp "negateInteger#" GenPrimOp
363 Int# -> ByteArr# -> (# Int#, ByteArr# #)
365 primop IntegerAddOp "plusInteger#" GenPrimOp
366 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
367 with commutable = True
370 primop IntegerSubOp "minusInteger#" GenPrimOp
371 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
372 with out_of_line = True
374 primop IntegerMulOp "timesInteger#" GenPrimOp
375 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
376 with commutable = True
379 primop IntegerGcdOp "gcdInteger#" GenPrimOp
380 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
381 with commutable = True
384 primop IntegerIntGcdOp "gcdIntegerInt#" GenPrimOp
385 Int# -> ByteArr# -> Int# -> Int#
386 with commutable = True
388 primop IntegerDivExactOp "divExactInteger#" GenPrimOp
389 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
390 with out_of_line = True
392 primop IntegerQuotOp "quotInteger#" GenPrimOp
393 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
394 with out_of_line = True
396 primop IntegerRemOp "remInteger#" GenPrimOp
397 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
398 with out_of_line = True
400 primop IntegerCmpOp "cmpInteger#" GenPrimOp
401 Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
402 with needs_wrapper = True
404 primop IntegerCmpIntOp "cmpIntegerInt#" GenPrimOp
405 Int# -> ByteArr# -> Int# -> Int#
406 with needs_wrapper = True
408 primop IntegerQuotRemOp "quotRemInteger#" GenPrimOp
409 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
413 primop IntegerDivModOp "divModInteger#" GenPrimOp
414 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
418 primop Integer2IntOp "integer2Int#" GenPrimOp
419 Int# -> ByteArr# -> Int#
420 with needs_wrapper = True
422 primop Integer2WordOp "integer2Word#" GenPrimOp
423 Int# -> ByteArr# -> Word#
424 with needs_wrapper = True
426 primop IntegerToInt64Op "integerToInt64#" GenPrimOp
427 Int# -> ByteArr# -> Int64#
429 primop IntegerToWord64Op "integerToWord64#" GenPrimOp
430 Int# -> ByteArr# -> Word64#
432 primop IntegerAndOp "andInteger#" GenPrimOp
433 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
434 with out_of_line = True
436 primop IntegerOrOp "orInteger#" GenPrimOp
437 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
438 with out_of_line = True
440 primop IntegerXorOp "xorInteger#" GenPrimOp
441 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
442 with out_of_line = True
444 primop IntegerComplementOp "complementInteger#" GenPrimOp
445 Int# -> ByteArr# -> (# Int#, ByteArr# #)
446 with out_of_line = True
448 ------------------------------------------------------------------------
450 ------------------------------------------------------------------------
452 primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word#
453 primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word#
455 primop AndOp "and#" Dyadic
456 Word# -> Word# -> Word#
457 with commutable = True
459 primop OrOp "or#" Dyadic
460 Word# -> Word# -> Word#
461 with commutable = True
463 primop XorOp "xor#" Dyadic
464 Word# -> Word# -> Word#
465 with commutable = True
467 primop NotOp "not#" Monadic Word# -> Word#
469 primop SllOp "shiftL#" GenPrimOp Word# -> Int# -> Word#
470 primop SrlOp "shiftRL#" GenPrimOp Word# -> Int# -> Word#
473 primop Word2IntOp "word2Int#" GenPrimOp Word# -> Int#
475 primop Word2IntegerOp "word2Integer#" GenPrimOp
476 Word# -> (# Int#, ByteArr# #)
477 with out_of_line = True
479 primop WordGtOp "gtWord#" Compare Word# -> Word# -> Bool
480 primop WordGeOp "geWord#" Compare Word# -> Word# -> Bool
481 primop WordEqOp "eqWord#" Compare Word# -> Word# -> Bool
482 primop WordNeOp "neWord#" Compare Word# -> Word# -> Bool
483 primop WordLtOp "ltWord#" Compare Word# -> Word# -> Bool
484 primop WordLeOp "leWord#" Compare Word# -> Word# -> Bool
486 ------------------------------------------------------------------------
488 ------------------------------------------------------------------------
490 primop Word64ToIntegerOp "word64ToInteger#" GenPrimOp
491 Word64# -> (# Int#, ByteArr# #)
492 with out_of_line = True
495 ------------------------------------------------------------------------
497 ------------------------------------------------------------------------
499 primop NewByteArrayOp_Char "newCharArray#" GenPrimOp
500 Int# -> State# s -> (# State# s, MutByteArr# s #)
501 with out_of_line = True
503 primop NewByteArrayOp_Int "newIntArray#" GenPrimOp
504 Int# -> State# s -> (# State# s, MutByteArr# s #)
505 with out_of_line = True
507 primop NewByteArrayOp_Word "newWordArray#" GenPrimOp
508 Int# -> State# s -> (# State# s, MutByteArr# s #)
509 with out_of_line = True
511 primop NewByteArrayOp_Addr "newAddrArray#" GenPrimOp
512 Int# -> State# s -> (# State# s, MutByteArr# s #)
513 with out_of_line = True
515 primop NewByteArrayOp_Float "newFloatArray#" GenPrimOp
516 Int# -> State# s -> (# State# s, MutByteArr# s #)
517 with out_of_line = True
519 primop NewByteArrayOp_Double "newDoubleArray#" GenPrimOp
520 Int# -> State# s -> (# State# s, MutByteArr# s #)
521 with out_of_line = True
523 primop NewByteArrayOp_StablePtr "newStablePtrArray#" GenPrimOp
524 Int# -> State# s -> (# State# s, MutByteArr# s #)
525 with out_of_line = True
529 primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
530 MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
532 primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp
533 MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
535 primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp
536 MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
538 primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
539 MutByteArr# s -> Int# -> State# s -> (# State# s, Addr# #)
541 primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
542 MutByteArr# s -> Int# -> State# s -> (# State# s, Float# #)
544 primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
545 MutByteArr# s -> Int# -> State# s -> (# State# s, Double# #)
547 primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
548 MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
550 primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
551 MutByteArr# s -> Int# -> State# s -> (# State# s, Int64# #)
553 primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
554 MutByteArr# s -> Int# -> State# s -> (# State# s, Word64# #)
558 primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
559 MutByteArr# s -> Int# -> Char# -> State# s -> State# s
560 with has_side_effects = True
562 primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
563 MutByteArr# s -> Int# -> Int# -> State# s -> State# s
564 with has_side_effects = True
566 primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
567 MutByteArr# s -> Int# -> Word# -> State# s -> State# s
568 with has_side_effects = True
570 primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
571 MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
572 with has_side_effects = True
574 primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
575 MutByteArr# s -> Int# -> Float# -> State# s -> State# s
576 with has_side_effects = True
578 primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
579 MutByteArr# s -> Int# -> Double# -> State# s -> State# s
580 with has_side_effects = True
582 primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
583 MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
584 with has_side_effects = True
586 primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
587 MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
588 with has_side_effects = True
590 primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
591 MutByteArr# s -> Int# -> Word64# -> State# s -> State# s
592 with has_side_effects = True
595 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
596 ByteArr# -> Int# -> Char#
598 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
599 ByteArr# -> Int# -> Int#
601 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
602 ByteArr# -> Int# -> Word#
604 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
605 ByteArr# -> Int# -> Addr#
607 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
608 ByteArr# -> Int# -> Float#
610 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
611 ByteArr# -> Int# -> Double#
613 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
614 ByteArr# -> Int# -> StablePtr# a
616 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
617 ByteArr# -> Int# -> Int64#
619 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
620 ByteArr# -> Int# -> Word64#
623 primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
624 Addr# -> Int# -> Char#
626 primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
627 Addr# -> Int# -> Int#
629 primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
630 Addr# -> Int# -> Word#
632 primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
633 Addr# -> Int# -> Addr#
635 primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
636 Addr# -> Int# -> Float#
638 primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
639 Addr# -> Int# -> Double#
641 primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
642 Addr# -> Int# -> StablePtr# a
644 primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
645 Addr# -> Int# -> Int64#
647 primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
648 Addr# -> Int# -> Word64#
651 primop IndexOffForeignObjOp_Char "indexCharOffForeignObj#" GenPrimOp
652 ForeignObj# -> Int# -> Char#
654 primop IndexOffForeignObjOp_Int "indexIntOffForeignObj#" GenPrimOp
655 ForeignObj# -> Int# -> Int#
657 primop IndexOffForeignObjOp_Word "indexWordOffForeignObj#" GenPrimOp
658 ForeignObj# -> Int# -> Word#
660 primop IndexOffForeignObjOp_Addr "indexAddrOffForeignObj#" GenPrimOp
661 ForeignObj# -> Int# -> Addr#
663 primop IndexOffForeignObjOp_Float "indexFloatOffForeignObj#" GenPrimOp
664 ForeignObj# -> Int# -> Float#
666 primop IndexOffForeignObjOp_Double "indexDoubleOffForeignObj#" GenPrimOp
667 ForeignObj# -> Int# -> Double#
669 primop IndexOffForeignObjOp_StablePtr "indexStablePtrOffForeignObj#" GenPrimOp
670 ForeignObj# -> Int# -> StablePtr# a
672 primop IndexOffForeignObjOp_Int64 "indexInt64OffForeignObj#" GenPrimOp
673 ForeignObj# -> Int# -> Int64#
675 primop IndexOffForeignObjOp_Word64 "indexWord64OffForeignObj#" GenPrimOp
676 ForeignObj# -> Int# -> Word64#
680 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
681 Addr# -> Int# -> State# s -> (# State# s, Char# #)
683 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
684 Addr# -> Int# -> State# s -> (# State# s, Int# #)
686 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
687 Addr# -> Int# -> State# s -> (# State# s, Word# #)
689 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
690 Addr# -> Int# -> State# s -> (# State# s, Addr# #)
692 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
693 Addr# -> Int# -> State# s -> (# State# s, Float# #)
695 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
696 Addr# -> Int# -> State# s -> (# State# s, Double# #)
698 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
699 Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
701 primop ReadOffAddrOp_ForeignObj "readForeignObjOffAddr#" GenPrimOp
702 Addr# -> Int# -> State# s -> (# State# s, ForeignObj# #)
704 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
705 Addr# -> Int# -> State# s -> (# State# s, Int64# #)
707 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
708 Addr# -> Int# -> State# s -> (# State# s, Word64# #)
711 primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
712 Addr# -> Int# -> Char# -> State# s -> State# s
713 with has_side_effects = True
715 primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
716 Addr# -> Int# -> Int# -> State# s -> State# s
717 with has_side_effects = True
719 primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
720 Addr# -> Int# -> Word# -> State# s -> State# s
721 with has_side_effects = True
723 primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
724 Addr# -> Int# -> Addr# -> State# s -> State# s
725 with has_side_effects = True
727 primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
728 Addr# -> Int# -> Float# -> State# s -> State# s
729 with has_side_effects = True
731 primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
732 Addr# -> Int# -> Double# -> State# s -> State# s
733 with has_side_effects = True
735 primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
736 Addr# -> Int# -> StablePtr# a -> State# s -> State# s
737 with has_side_effects = True
739 primop WriteOffAddrOp_ForeignObj "writeForeignObjOffAddr#" GenPrimOp
740 Addr# -> Int# -> ForeignObj# -> State# s -> State# s
741 with has_side_effects = True
743 primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
744 Addr# -> Int# -> Int64# -> State# s -> State# s
745 with has_side_effects = True
747 primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
748 Addr# -> Int# -> Word64# -> State# s -> State# s
749 with has_side_effects = True
753 primop NewArrayOp "newArray#" GenPrimOp
754 Int# -> a -> State# s -> (# State# s, MutArr# s a #)
756 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
757 usage = { mangle NewArrayOp [mkP, mkM, mkP] mkM }
760 primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
761 MutArr# s a -> MutArr# s a -> Bool
763 usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
765 primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
766 MutByteArr# s -> MutByteArr# s -> Bool
768 primop ReadArrayOp "readArray#" GenPrimOp
769 MutArr# s a -> Int# -> State# s -> (# State# s, a #)
771 usage = { mangle ReadArrayOp [mkM, mkP, mkP] mkM }
773 primop WriteArrayOp "writeArray#" GenPrimOp
774 MutArr# s a -> Int# -> a -> State# s -> State# s
776 usage = { mangle WriteArrayOp [mkM, mkP, mkM, mkP] mkR }
777 strictness = { \ arity -> StrictnessInfo [wwPrim, wwPrim, wwLazy, wwPrim] False }
778 has_side_effects = True
780 primop IndexArrayOp "indexArray#" GenPrimOp
781 Array# a -> Int# -> (# a #)
783 usage = { mangle IndexArrayOp [mkM, mkP] mkM }
785 primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
786 MutArr# s a -> State# s -> (# State# s, Array# a #)
788 usage = { mangle UnsafeFreezeArrayOp [mkM, mkP] mkM }
789 has_side_effects = True
791 primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
792 MutByteArr# s -> State# s -> (# State# s, ByteArr# #)
794 has_side_effects = True
796 primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
797 Array# a -> State# s -> (# State# s, MutArr# s a #)
799 usage = { mangle UnsafeThawArrayOp [mkM, mkP] mkM }
802 primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
805 primop SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
806 MutByteArr# s -> Int#
808 ------------------------------------------------------------------------
809 --- Mutable variables ---
810 ------------------------------------------------------------------------
812 primop NewMutVarOp "newMutVar#" GenPrimOp
813 a -> State# s -> (# State# s, MutVar# s a #)
815 usage = { mangle NewMutVarOp [mkM, mkP] mkM }
816 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
819 primop ReadMutVarOp "readMutVar#" GenPrimOp
820 MutVar# s a -> State# s -> (# State# s, a #)
822 usage = { mangle ReadMutVarOp [mkM, mkP] mkM }
824 primop WriteMutVarOp "writeMutVar#" GenPrimOp
825 MutVar# s a -> a -> State# s -> State# s
827 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
828 usage = { mangle WriteMutVarOp [mkM, mkM, mkP] mkR }
829 has_side_effects = True
831 primop SameMutVarOp "sameMutVar#" GenPrimOp
832 MutVar# s a -> MutVar# s a -> Bool
834 usage = { mangle SameMutVarOp [mkP, mkP] mkM }
836 ------------------------------------------------------------------------
838 ------------------------------------------------------------------------
840 primop CatchOp "catch#" GenPrimOp
841 (State# RealWorld -> (# State# RealWorld, a #) )
842 -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
844 -> (# State# RealWorld, a #)
846 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwPrim] False }
847 -- Catch is actually strict in its first argument
848 -- but we don't want to tell the strictness
849 -- analyser about that!
850 usage = { mangle CatchOp [mkM, mkM . (inFun CatchOp mkM mkM), mkP] mkM }
851 -- [mkO, mkO . (inFun mkM mkO)] mkO
852 -- might use caught action multiply
855 primop RaiseOp "raise#" GenPrimOp
858 strictness = { \ arity -> StrictnessInfo [wwLazy] True }
859 -- NB: True => result is bottom
860 usage = { mangle RaiseOp [mkM] mkM }
863 primop BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
864 (State# RealWorld -> (# State# RealWorld, a #))
865 -> (State# RealWorld -> (# State# RealWorld, a #))
867 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
870 primop UnblockAsyncExceptionsOp "unblockAsyncExceptions#" GenPrimOp
871 (State# RealWorld -> (# State# RealWorld, a #))
872 -> (State# RealWorld -> (# State# RealWorld, a #))
874 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
877 ------------------------------------------------------------------------
878 --- MVars (not the same as mutable variables!) ---
879 ------------------------------------------------------------------------
881 primop NewMVarOp "newMVar#" GenPrimOp
882 State# s -> (# State# s, MVar# s a #)
884 usage = { mangle NewMVarOp [mkP] mkR }
887 primop TakeMVarOp "takeMVar#" GenPrimOp
888 MVar# s a -> State# s -> (# State# s, a #)
890 usage = { mangle TakeMVarOp [mkM, mkP] mkM }
891 has_side_effects = True
894 primop PutMVarOp "putMVar#" GenPrimOp
895 MVar# s a -> a -> State# s -> State# s
897 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
898 usage = { mangle PutMVarOp [mkM, mkM, mkP] mkR }
899 has_side_effects = True
902 primop SameMVarOp "sameMVar#" GenPrimOp
903 MVar# s a -> MVar# s a -> Bool
905 usage = { mangle SameMVarOp [mkP, mkP] mkM }
907 primop TryTakeMVarOp "tryTakeMVar#" GenPrimOp
908 MVar# s a -> State# s -> (# State# s, Int#, a #)
910 usage = { mangle TryTakeMVarOp [mkM, mkP] mkM }
911 has_side_effects = True
914 primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
915 MVar# s a -> State# s -> (# State# s, Int# #)
917 usage = { mangle IsEmptyMVarOp [mkP, mkP] mkM }
920 ------------------------------------------------------------------------
921 --- delay/wait operations ---
922 ------------------------------------------------------------------------
924 primop DelayOp "delay#" GenPrimOp
925 Int# -> State# s -> State# s
928 has_side_effects = True
931 primop WaitReadOp "waitRead#" GenPrimOp
932 Int# -> State# s -> State# s
935 has_side_effects = True
938 primop WaitWriteOp "waitWrite#" GenPrimOp
939 Int# -> State# s -> State# s
942 has_side_effects = True
945 ------------------------------------------------------------------------
946 --- concurrency primitives ---
947 ------------------------------------------------------------------------
949 primop ForkOp "fork#" GenPrimOp
950 a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
952 usage = { mangle ForkOp [mkO, mkP] mkR }
953 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
954 has_side_effects = True
957 primop KillThreadOp "killThread#" GenPrimOp
958 ThreadId# -> a -> State# RealWorld -> State# RealWorld
960 usage = { mangle KillThreadOp [mkP, mkM, mkP] mkR }
961 has_side_effects = True
964 primop YieldOp "yield#" GenPrimOp
965 State# RealWorld -> State# RealWorld
967 has_side_effects = True
970 primop MyThreadIdOp "myThreadId#" GenPrimOp
971 State# RealWorld -> (# State# RealWorld, ThreadId# #)
973 ------------------------------------------------------------------------
974 --- foreign objects ---
975 ------------------------------------------------------------------------
977 primop MkForeignObjOp "mkForeignObj#" GenPrimOp
978 Addr# -> State# RealWorld -> (# State# RealWorld, ForeignObj# #)
980 has_side_effects = True
983 primop WriteForeignObjOp "writeForeignObj#" GenPrimOp
984 ForeignObj# -> Addr# -> State# s -> State# s
986 has_side_effects = True
988 primop ForeignObjToAddrOp "foreignObjToAddr#" GenPrimOp
991 primop TouchOp "touch#" GenPrimOp
992 o -> State# RealWorld -> State# RealWorld
994 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
996 ------------------------------------------------------------------------
997 --- Bytecode objects ---
998 ------------------------------------------------------------------------
1000 primop NewBCOOp "newBCO#" GenPrimOp
1001 ByteArr# -> ByteArr# -> MutArr# s a -> State# s -> (# State# s, BCO# #)
1003 has_side_effects = True
1006 primop GetBCOPtrsOp "getBCOPtrs#" GenPrimOp
1007 BCO# -> State# s -> (# State# s, MutArr# s a #)
1009 ------------------------------------------------------------------------
1010 --- Weak pointers ---
1011 ------------------------------------------------------------------------
1013 -- note that tyvar "o" denoted openAlphaTyVar
1015 primop MkWeakOp "mkWeak#" GenPrimOp
1016 o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
1018 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwLazy, wwPrim] False }
1019 usage = { mangle MkWeakOp [mkZ, mkM, mkM, mkP] mkM }
1020 has_side_effects = True
1023 primop DeRefWeakOp "deRefWeak#" GenPrimOp
1024 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
1026 usage = { mangle DeRefWeakOp [mkM, mkP] mkM }
1027 has_side_effects = True
1029 primop FinalizeWeakOp "finalizeWeak#" GenPrimOp
1030 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#,
1031 (State# RealWorld -> (# State# RealWorld, Unit #)) #)
1033 usage = { mangle FinalizeWeakOp [mkM, mkP]
1034 (mkR . (inUB FinalizeWeakOp
1035 [id,id,inFun FinalizeWeakOp mkR mkM])) }
1036 has_side_effects = True
1040 ------------------------------------------------------------------------
1041 --- Stable pointers and names ---
1042 ------------------------------------------------------------------------
1044 primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
1045 a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
1047 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1048 usage = { mangle MakeStablePtrOp [mkM, mkP] mkM }
1049 has_side_effects = True
1051 primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
1052 StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
1054 usage = { mangle DeRefStablePtrOp [mkM, mkP] mkM }
1055 needs_wrapper = True
1056 has_side_effects = True
1058 primop EqStablePtrOp "eqStablePtr#" GenPrimOp
1059 StablePtr# a -> StablePtr# a -> Int#
1061 usage = { mangle EqStablePtrOp [mkP, mkP] mkR }
1062 has_side_effects = True
1064 primop MakeStableNameOp "makeStableName#" GenPrimOp
1065 a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
1067 usage = { mangle MakeStableNameOp [mkZ, mkP] mkR }
1068 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1069 needs_wrapper = True
1070 has_side_effects = True
1073 primop EqStableNameOp "eqStableName#" GenPrimOp
1074 StableName# a -> StableName# a -> Int#
1076 usage = { mangle EqStableNameOp [mkP, mkP] mkR }
1078 primop StableNameToIntOp "stableNameToInt#" GenPrimOp
1079 StableName# a -> Int#
1081 usage = { mangle StableNameToIntOp [mkP] mkR }
1083 ------------------------------------------------------------------------
1084 --- Unsafe pointer equality (#1 Bad Guy: Alistair Reid :) ---
1085 ------------------------------------------------------------------------
1087 primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
1090 usage = { mangle ReallyUnsafePtrEqualityOp [mkZ, mkZ] mkR }
1092 ------------------------------------------------------------------------
1094 ------------------------------------------------------------------------
1096 primop SeqOp "seq#" GenPrimOp
1099 usage = { mangle SeqOp [mkO] mkR }
1100 strictness = { \ arity -> StrictnessInfo [wwStrict] False }
1101 -- Seq is strict in its argument; see notes in ConFold.lhs
1102 has_side_effects = True
1104 primop ParOp "par#" GenPrimOp
1107 usage = { mangle ParOp [mkO] mkR }
1108 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1109 -- Note that Par is lazy to avoid that the sparked thing
1110 -- gets evaluted strictly, which it should *not* be
1111 has_side_effects = True
1113 -- HWL: The first 4 Int# in all par... annotations denote:
1114 -- name, granularity info, size of result, degree of parallelism
1115 -- Same structure as _seq_ i.e. returns Int#
1116 -- KSW: v, the second arg in parAt# and parAtForNow#, is used only to determine
1117 -- `the processor containing the expression v'; it is not evaluated
1119 primop ParGlobalOp "parGlobal#" GenPrimOp
1120 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1122 usage = { mangle ParGlobalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1123 has_side_effects = True
1125 primop ParLocalOp "parLocal#" GenPrimOp
1126 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1128 usage = { mangle ParLocalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1129 has_side_effects = True
1131 primop ParAtOp "parAt#" GenPrimOp
1132 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1134 usage = { mangle ParAtOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1135 has_side_effects = True
1137 primop ParAtAbsOp "parAtAbs#" GenPrimOp
1138 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1140 usage = { mangle ParAtAbsOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1141 has_side_effects = True
1143 primop ParAtRelOp "parAtRel#" GenPrimOp
1144 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1146 usage = { mangle ParAtRelOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1147 has_side_effects = True
1149 primop ParAtForNowOp "parAtForNow#" GenPrimOp
1150 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1152 usage = { mangle ParAtForNowOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1153 has_side_effects = True
1155 primop CopyableOp "copyable#" GenPrimOp
1158 usage = { mangle CopyableOp [mkZ] mkR }
1159 has_side_effects = True
1161 primop NoFollowOp "noFollow#" GenPrimOp
1164 usage = { mangle NoFollowOp [mkZ] mkR }
1165 has_side_effects = True
1168 ------------------------------------------------------------------------
1169 --- tag to enum stuff ---
1170 ------------------------------------------------------------------------
1172 primop DataToTagOp "dataToTag#" GenPrimOp
1175 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1177 primop TagToEnumOp "tagToEnum#" GenPrimOp
1183 ------------------------------------------------------------------------
1185 ------------------------------------------------------------------------