1 -----------------------------------------------------------------------
2 -- $Id: primops.txt,v 1.2 2000/08/21 13:34:06 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 }
44 ------------------------------------------------------------------------
46 ------------------------------------------------------------------------
48 primop AddrGtOp "gtAddr#" Compare Addr# -> Addr# -> Bool
49 primop AddrGeOp "geAddr#" Compare Addr# -> Addr# -> Bool
50 primop AddrEqOp "eqAddr#" Compare Addr# -> Addr# -> Bool
51 primop AddrNeOp "neAddr#" Compare Addr# -> Addr# -> Bool
52 primop AddrLtOp "ltAddr#" Compare Addr# -> Addr# -> Bool
53 primop AddrLeOp "leAddr#" Compare Addr# -> Addr# -> Bool
55 primop Addr2IntOp "addr2Int#" GenPrimOp Addr# -> Int#
57 primop Addr2IntegerOp "addr2Integer#" GenPrimOp
58 Addr# -> (# Int#, ByteArr# #)
59 with out_of_line = True
62 ------------------------------------------------------------------------
64 ------------------------------------------------------------------------
66 primop CharGtOp "gtChar#" Compare Char# -> Char# -> Bool
67 primop CharGeOp "geChar#" Compare Char# -> Char# -> Bool
69 primop CharEqOp "eqChar#" Compare
70 Char# -> Char# -> Bool
71 with commutable = True
73 primop CharNeOp "neChar#" Compare
74 Char# -> Char# -> Bool
75 with commutable = True
77 primop CharLtOp "ltChar#" Compare Char# -> Char# -> Bool
78 primop CharLeOp "leChar#" Compare Char# -> Char# -> Bool
80 primop OrdOp "ord#" GenPrimOp Char# -> Int#
82 ------------------------------------------------------------------------
84 ------------------------------------------------------------------------
86 primop DoubleGtOp ">##" Compare Double# -> Double# -> Bool
87 primop DoubleGeOp ">=##" Compare Double# -> Double# -> Bool
89 primop DoubleEqOp "==##" Compare
90 Double# -> Double# -> Bool
91 with commutable = True
93 primop DoubleNeOp "/=##" Compare
94 Double# -> Double# -> Bool
95 with commutable = True
97 primop DoubleLtOp "<##" Compare Double# -> Double# -> Bool
98 primop DoubleLeOp "<=##" Compare Double# -> Double# -> Bool
100 primop DoubleAddOp "+##" Dyadic
101 Double# -> Double# -> Double#
102 with commutable = True
104 primop DoubleSubOp "-##" Dyadic Double# -> Double# -> Double#
106 primop DoubleMulOp "*##" Dyadic
107 Double# -> Double# -> Double#
108 with commutable = True
110 primop DoubleDivOp "/##" Dyadic
111 Double# -> Double# -> Double#
114 primop DoubleNegOp "negateDouble#" Monadic Double# -> Double#
116 primop Double2IntOp "double2Int#" GenPrimOp Double# -> Int#
117 primop Double2FloatOp "double2Float#" GenPrimOp Double# -> Float#
119 primop DoubleExpOp "expDouble#" Monadic
121 with needs_wrapper = True
123 primop DoubleLogOp "logDouble#" Monadic
129 primop DoubleSqrtOp "sqrtDouble#" Monadic
131 with needs_wrapper = True
133 primop DoubleSinOp "sinDouble#" Monadic
135 with needs_wrapper = True
137 primop DoubleCosOp "cosDouble#" Monadic
139 with needs_wrapper = True
141 primop DoubleTanOp "tanDouble#" Monadic
143 with needs_wrapper = True
145 primop DoubleAsinOp "asinDouble#" Monadic
151 primop DoubleAcosOp "acosDouble#" Monadic
157 primop DoubleAtanOp "atanDouble#" Monadic
162 primop DoubleSinhOp "sinhDouble#" Monadic
164 with needs_wrapper = True
166 primop DoubleCoshOp "coshDouble#" Monadic
168 with needs_wrapper = True
170 primop DoubleTanhOp "tanhDouble#" Monadic
172 with needs_wrapper = True
174 primop DoublePowerOp "**##" Dyadic
175 Double# -> Double# -> Double#
176 with needs_wrapper = True
178 primop DoubleDecodeOp "decodeDouble#" GenPrimOp
179 Double# -> (# Int#, Int#, ByteArr# #)
180 with out_of_line = True
182 ------------------------------------------------------------------------
184 ------------------------------------------------------------------------
186 primop FloatGtOp "gtFloat#" Compare Float# -> Float# -> Bool
187 primop FloatGeOp "geFloat#" Compare Float# -> Float# -> Bool
189 primop FloatEqOp "eqFloat#" Compare
190 Float# -> Float# -> Bool
191 with commutable = True
193 primop FloatNeOp "neFloat#" Compare
194 Float# -> Float# -> Bool
195 with commutable = True
197 primop FloatLtOp "ltFloat#" Compare Float# -> Float# -> Bool
198 primop FloatLeOp "leFloat#" Compare Float# -> Float# -> Bool
200 primop FloatAddOp "plusFloat#" Dyadic
201 Float# -> Float# -> Float#
202 with commutable = True
204 primop FloatSubOp "minusFloat#" Dyadic Float# -> Float# -> Float#
206 primop FloatMulOp "timesFloat#" Dyadic
207 Float# -> Float# -> Float#
208 with commutable = True
210 primop FloatDivOp "divideFloat#" Dyadic
211 Float# -> Float# -> Float#
214 primop FloatNegOp "negateFloat#" Monadic Float# -> Float#
216 primop Float2IntOp "float2Int#" GenPrimOp Float# -> Int#
218 primop FloatExpOp "expFloat#" Monadic
220 with needs_wrapper = True
222 primop FloatLogOp "logFloat#" Monadic
224 with needs_wrapper = True
227 primop FloatSqrtOp "sqrtFloat#" Monadic
229 with needs_wrapper = True
231 primop FloatSinOp "sinFloat#" Monadic
233 with needs_wrapper = True
235 primop FloatCosOp "cosFloat#" Monadic
237 with needs_wrapper = True
239 primop FloatTanOp "tanFloat#" Monadic
241 with needs_wrapper = True
243 primop FloatAsinOp "asinFloat#" Monadic
245 with needs_wrapper = True
248 primop FloatAcosOp "acosFloat#" Monadic
250 with needs_wrapper = True
253 primop FloatAtanOp "atanFloat#" Monadic
255 with needs_wrapper = True
257 primop FloatSinhOp "sinhFloat#" Monadic
259 with needs_wrapper = True
261 primop FloatCoshOp "coshFloat#" Monadic
263 with needs_wrapper = True
265 primop FloatTanhOp "tanhFloat#" Monadic
267 with needs_wrapper = True
269 primop FloatPowerOp "powerFloat#" Dyadic
270 Float# -> Float# -> Float#
271 with needs_wrapper = True
273 primop Float2DoubleOp "float2Double#" GenPrimOp Float# -> Double#
275 primop FloatDecodeOp "decodeFloat#" GenPrimOp
276 Float# -> (# Int#, Int#, ByteArr# #)
277 with out_of_line = True
279 ------------------------------------------------------------------------
281 ------------------------------------------------------------------------
283 primop IntAddOp "+#" Dyadic
285 with commutable = True
287 primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
290 Dyadic Int# -> Int# -> Int#
291 with commutable = True
293 primop IntQuotOp "quotInt#" Dyadic
297 primop IntRemOp "remInt#" Dyadic
301 primop IntGcdOp "gcdInt#" Dyadic Int# -> Int# -> Int#
302 primop IntNegOp "negateInt#" Monadic Int# -> Int#
303 primop IntAddCOp "addIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
304 primop IntSubCOp "subIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
305 primop IntMulCOp "mulIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
306 primop IntGtOp ">#" Compare Int# -> Int# -> Bool
307 primop IntGeOp ">=#" Compare Int# -> Int# -> Bool
309 primop IntEqOp "==#" Compare
311 with commutable = True
313 primop IntNeOp "/=#" Compare
315 with commutable = True
317 primop IntLtOp "<#" Compare Int# -> Int# -> Bool
318 primop IntLeOp "<=#" Compare Int# -> Int# -> Bool
320 primop ChrOp "chr#" GenPrimOp Int# -> Char#
322 primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
323 primop Int2AddrOp "int2Addr#"GenPrimOp Int# -> Addr#
324 primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
325 primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
327 primop Int2IntegerOp "int2Integer#"
328 GenPrimOp Int# -> (# Int#, ByteArr# #)
329 with out_of_line = True
331 primop ISllOp "iShiftL#" GenPrimOp Int# -> Int# -> Int#
332 primop ISraOp "iShiftRA#" GenPrimOp Int# -> Int# -> Int#
333 primop ISrlOp "iShiftRL#" GenPrimOp Int# -> Int# -> Int#
335 ------------------------------------------------------------------------
337 ------------------------------------------------------------------------
339 primop Int64ToIntegerOp "int64ToInteger#" GenPrimOp
340 Int64# -> (# Int#, ByteArr# #)
341 with out_of_line = True
344 ------------------------------------------------------------------------
346 ------------------------------------------------------------------------
348 primop IntegerNegOp "negateInteger#" GenPrimOp
349 Int# -> ByteArr# -> (# Int#, ByteArr# #)
351 primop IntegerAddOp "plusInteger#" GenPrimOp
352 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
353 with commutable = True
356 primop IntegerSubOp "minusInteger#" GenPrimOp
357 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
358 with out_of_line = True
360 primop IntegerMulOp "timesInteger#" GenPrimOp
361 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
362 with commutable = True
365 primop IntegerGcdOp "gcdInteger#" GenPrimOp
366 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
367 with commutable = True
370 primop IntegerIntGcdOp "gcdIntegerInt#" GenPrimOp
371 Int# -> ByteArr# -> Int# -> Int#
372 with commutable = True
374 primop IntegerDivExactOp "divExactInteger#" GenPrimOp
375 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
376 with out_of_line = True
378 primop IntegerQuotOp "quotInteger#" GenPrimOp
379 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
380 with out_of_line = True
382 primop IntegerRemOp "remInteger#" GenPrimOp
383 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
384 with out_of_line = True
386 primop IntegerCmpOp "cmpInteger#" GenPrimOp
387 Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
388 with needs_wrapper = True
390 primop IntegerCmpIntOp "cmpIntegerInt#" GenPrimOp
391 Int# -> ByteArr# -> Int# -> Int#
392 with needs_wrapper = True
394 primop IntegerQuotRemOp "quotRemInteger#" GenPrimOp
395 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
399 primop IntegerDivModOp "divModInteger#" GenPrimOp
400 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
404 primop Integer2IntOp "integer2Int#" GenPrimOp
405 Int# -> ByteArr# -> Int#
406 with needs_wrapper = True
408 primop Integer2WordOp "integer2Word#" GenPrimOp
409 Int# -> ByteArr# -> Word#
410 with needs_wrapper = True
412 primop IntegerToInt64Op "integerToInt64#" GenPrimOp
413 Int# -> ByteArr# -> Int64#
415 primop IntegerToWord64Op "integerToWord64#" GenPrimOp
416 Int# -> ByteArr# -> Word64#
418 ------------------------------------------------------------------------
420 ------------------------------------------------------------------------
422 primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word#
423 primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word#
425 primop AndOp "and#" Dyadic
426 Word# -> Word# -> Word#
427 with commutable = True
429 primop OrOp "or#" Dyadic
430 Word# -> Word# -> Word#
431 with commutable = True
433 primop XorOp "xor#" Dyadic
434 Word# -> Word# -> Word#
435 with commutable = True
437 primop NotOp "not#" Monadic Word# -> Word#
439 primop SllOp "shiftL#" GenPrimOp Word# -> Int# -> Word#
440 primop SrlOp "shiftRL#" GenPrimOp Word# -> Int# -> Word#
443 primop Word2IntOp "word2Int#" GenPrimOp Word# -> Int#
445 primop Word2IntegerOp "word2Integer#" GenPrimOp
446 Word# -> (# Int#, ByteArr# #)
447 with out_of_line = True
449 primop WordGtOp "gtWord#" Compare Word# -> Word# -> Bool
450 primop WordGeOp "geWord#" Compare Word# -> Word# -> Bool
451 primop WordEqOp "eqWord#" Compare Word# -> Word# -> Bool
452 primop WordNeOp "neWord#" Compare Word# -> Word# -> Bool
453 primop WordLtOp "ltWord#" Compare Word# -> Word# -> Bool
454 primop WordLeOp "leWord#" Compare Word# -> Word# -> Bool
456 ------------------------------------------------------------------------
458 ------------------------------------------------------------------------
460 primop Word64ToIntegerOp "word64ToInteger#" GenPrimOp
461 Word64# -> (# Int#, ByteArr# #)
462 with out_of_line = True
465 ------------------------------------------------------------------------
467 ------------------------------------------------------------------------
469 primop NewByteArrayOp_Char "newCharArray#" GenPrimOp
470 Int# -> State# s -> (# State# s, MutByteArr# s #)
471 with out_of_line = True
473 primop NewByteArrayOp_Int "newIntArray#" GenPrimOp
474 Int# -> State# s -> (# State# s, MutByteArr# s #)
475 with out_of_line = True
477 primop NewByteArrayOp_Word "newWordArray#" GenPrimOp
478 Int# -> State# s -> (# State# s, MutByteArr# s #)
479 with out_of_line = True
481 primop NewByteArrayOp_Addr "newAddrArray#" GenPrimOp
482 Int# -> State# s -> (# State# s, MutByteArr# s #)
483 with out_of_line = True
485 primop NewByteArrayOp_Float "newFloatArray#" GenPrimOp
486 Int# -> State# s -> (# State# s, MutByteArr# s #)
487 with out_of_line = True
489 primop NewByteArrayOp_Double "newDoubleArray#" GenPrimOp
490 Int# -> State# s -> (# State# s, MutByteArr# s #)
491 with out_of_line = True
493 primop NewByteArrayOp_StablePtr "newStablePtrArray#" GenPrimOp
494 Int# -> State# s -> (# State# s, MutByteArr# s #)
495 with out_of_line = True
499 primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
500 MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
502 primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp
503 MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
505 primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp
506 MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
508 primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
509 MutByteArr# s -> Int# -> State# s -> (# State# s, Addr# #)
511 primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
512 MutByteArr# s -> Int# -> State# s -> (# State# s, Float# #)
514 primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
515 MutByteArr# s -> Int# -> State# s -> (# State# s, Double# #)
517 primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
518 MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
520 primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
521 MutByteArr# s -> Int# -> State# s -> (# State# s, Int64# #)
523 primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
524 MutByteArr# s -> Int# -> State# s -> (# State# s, Word64# #)
528 primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
529 MutByteArr# s -> Int# -> Char# -> State# s -> State# s
530 with has_side_effects = True
532 primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
533 MutByteArr# s -> Int# -> Int# -> State# s -> State# s
534 with has_side_effects = True
536 primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
537 MutByteArr# s -> Int# -> Word# -> State# s -> State# s
538 with has_side_effects = True
540 primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
541 MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
542 with has_side_effects = True
544 primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
545 MutByteArr# s -> Int# -> Float# -> State# s -> State# s
546 with has_side_effects = True
548 primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
549 MutByteArr# s -> Int# -> Double# -> State# s -> State# s
550 with has_side_effects = True
552 primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
553 MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
554 with has_side_effects = True
556 primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
557 MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
558 with has_side_effects = True
560 primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
561 MutByteArr# s -> Int# -> Word64# -> State# s -> State# s
562 with has_side_effects = True
565 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
566 ByteArr# -> Int# -> Char#
568 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
569 ByteArr# -> Int# -> Int#
571 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
572 ByteArr# -> Int# -> Word#
574 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
575 ByteArr# -> Int# -> Addr#
577 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
578 ByteArr# -> Int# -> Float#
580 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
581 ByteArr# -> Int# -> Double#
583 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
584 ByteArr# -> Int# -> StablePtr# a
586 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
587 ByteArr# -> Int# -> Int64#
589 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
590 ByteArr# -> Int# -> Word64#
593 primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
594 Addr# -> Int# -> Char#
596 primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
597 Addr# -> Int# -> Int#
599 primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
600 Addr# -> Int# -> Word#
602 primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
603 Addr# -> Int# -> Addr#
605 primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
606 Addr# -> Int# -> Float#
608 primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
609 Addr# -> Int# -> Double#
611 primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
612 Addr# -> Int# -> StablePtr# a
614 primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
615 Addr# -> Int# -> Int64#
617 primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
618 Addr# -> Int# -> Word64#
621 primop IndexOffForeignObjOp_Char "indexCharOffForeignObj#" GenPrimOp
622 ForeignObj# -> Int# -> Char#
624 primop IndexOffForeignObjOp_Int "indexIntOffForeignObj#" GenPrimOp
625 ForeignObj# -> Int# -> Int#
627 primop IndexOffForeignObjOp_Word "indexWordOffForeignObj#" GenPrimOp
628 ForeignObj# -> Int# -> Word#
630 primop IndexOffForeignObjOp_Addr "indexAddrOffForeignObj#" GenPrimOp
631 ForeignObj# -> Int# -> Addr#
633 primop IndexOffForeignObjOp_Float "indexFloatOffForeignObj#" GenPrimOp
634 ForeignObj# -> Int# -> Float#
636 primop IndexOffForeignObjOp_Double "indexDoubleOffForeignObj#" GenPrimOp
637 ForeignObj# -> Int# -> Double#
639 primop IndexOffForeignObjOp_StablePtr "indexStablePtrOffForeignObj#" GenPrimOp
640 ForeignObj# -> Int# -> StablePtr# a
642 primop IndexOffForeignObjOp_Int64 "indexInt64OffForeignObj#" GenPrimOp
643 ForeignObj# -> Int# -> Int64#
645 primop IndexOffForeignObjOp_Word64 "indexWord64OffForeignObj#" GenPrimOp
646 ForeignObj# -> Int# -> Word64#
650 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
651 Addr# -> Int# -> State# s -> (# State# s, Char# #)
653 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
654 Addr# -> Int# -> State# s -> (# State# s, Int# #)
656 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
657 Addr# -> Int# -> State# s -> (# State# s, Word# #)
659 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
660 Addr# -> Int# -> State# s -> (# State# s, Addr# #)
662 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
663 Addr# -> Int# -> State# s -> (# State# s, Float# #)
665 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
666 Addr# -> Int# -> State# s -> (# State# s, Double# #)
668 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
669 Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
671 primop ReadOffAddrOp_ForeignObj "readForeignObjOffAddr#" GenPrimOp
672 Addr# -> Int# -> State# s -> (# State# s, ForeignObj# #)
674 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
675 Addr# -> Int# -> State# s -> (# State# s, Int64# #)
677 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
678 Addr# -> Int# -> State# s -> (# State# s, Word64# #)
681 primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
682 Addr# -> Int# -> Char# -> State# s -> State# s
683 with has_side_effects = True
685 primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
686 Addr# -> Int# -> Int# -> State# s -> State# s
687 with has_side_effects = True
689 primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
690 Addr# -> Int# -> Word# -> State# s -> State# s
691 with has_side_effects = True
693 primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
694 Addr# -> Int# -> Addr# -> State# s -> State# s
695 with has_side_effects = True
697 primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
698 Addr# -> Int# -> Float# -> State# s -> State# s
699 with has_side_effects = True
701 primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
702 Addr# -> Int# -> Double# -> State# s -> State# s
703 with has_side_effects = True
705 primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
706 Addr# -> Int# -> StablePtr# a -> State# s -> State# s
707 with has_side_effects = True
709 primop WriteOffAddrOp_ForeignObj "writeForeignObjOffAddr#" GenPrimOp
710 Addr# -> Int# -> ForeignObj# -> State# s -> State# s
711 with has_side_effects = True
713 primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
714 Addr# -> Int# -> Int64# -> State# s -> State# s
715 with has_side_effects = True
717 primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
718 Addr# -> Int# -> Word64# -> State# s -> State# s
719 with has_side_effects = True
723 primop NewArrayOp "newArray#" GenPrimOp
724 Int# -> a -> State# s -> (# State# s, MutArr# s a #)
726 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
727 usage = { mangle NewArrayOp [mkP, mkM, mkP] mkM }
730 primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
731 MutArr# s a -> MutArr# s a -> Bool
733 usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
735 primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
736 MutByteArr# s -> MutByteArr# s -> Bool
738 primop ReadArrayOp "readArray#" GenPrimOp
739 MutArr# s a -> Int# -> State# s -> (# State# s, a #)
741 usage = { mangle ReadArrayOp [mkM, mkP, mkP] mkM }
743 primop WriteArrayOp "writeArray#" GenPrimOp
744 MutArr# s a -> Int# -> a -> State# s -> State# s
746 usage = { mangle WriteArrayOp [mkM, mkP, mkM, mkP] mkR }
747 strictness = { \ arity -> StrictnessInfo [wwPrim, wwPrim, wwLazy, wwPrim] False }
748 has_side_effects = True
750 primop IndexArrayOp "indexArray#" GenPrimOp
751 Array# a -> Int# -> (# a #)
753 usage = { mangle IndexArrayOp [mkM, mkP] mkM }
755 primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
756 MutArr# s a -> State# s -> (# State# s, Array# a #)
758 usage = { mangle UnsafeFreezeArrayOp [mkM, mkP] mkM }
759 has_side_effects = True
761 primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
762 MutByteArr# s -> State# s -> (# State# s, ByteArr# #)
764 has_side_effects = True
766 primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
767 Array# a -> State# s -> (# State# s, MutArr# s a #)
769 usage = { mangle UnsafeThawArrayOp [mkM, mkP] mkM }
772 primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
775 primop SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
776 MutByteArr# s -> Int#
778 ------------------------------------------------------------------------
779 --- Mutable variables ---
780 ------------------------------------------------------------------------
782 primop NewMutVarOp "newMutVar#" GenPrimOp
783 a -> State# s -> (# State# s, MutVar# s a #)
785 usage = { mangle NewMutVarOp [mkM, mkP] mkM }
786 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
789 primop ReadMutVarOp "readMutVar#" GenPrimOp
790 MutVar# s a -> State# s -> (# State# s, a #)
792 usage = { mangle ReadMutVarOp [mkM, mkP] mkM }
794 primop WriteMutVarOp "writeMutVar#" GenPrimOp
795 MutVar# s a -> a -> State# s -> State# s
797 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
798 usage = { mangle WriteMutVarOp [mkM, mkM, mkP] mkR }
799 has_side_effects = True
801 primop SameMutVarOp "sameMutVar#" GenPrimOp
802 MutVar# s a -> MutVar# s a -> Bool
804 usage = { mangle SameMutVarOp [mkP, mkP] mkM }
806 ------------------------------------------------------------------------
808 ------------------------------------------------------------------------
810 primop CatchOp "catch#" GenPrimOp
811 (State# RealWorld -> (# State# RealWorld, a #) )
812 -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
814 -> (# State# RealWorld, a #)
816 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwPrim] False }
817 -- Catch is actually strict in its first argument
818 -- but we don't want to tell the strictness
819 -- analyser about that!
820 usage = { mangle CatchOp [mkM, mkM . (inFun CatchOp mkM mkM), mkP] mkM }
821 -- [mkO, mkO . (inFun mkM mkO)] mkO
822 -- might use caught action multiply
825 primop RaiseOp "raise#" GenPrimOp
828 strictness = { \ arity -> StrictnessInfo [wwLazy] True }
829 -- NB: True => result is bottom
830 usage = { mangle RaiseOp [mkM] mkM }
833 primop BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
834 (State# RealWorld -> (# State# RealWorld, a #))
835 -> (State# RealWorld -> (# State# RealWorld, a #))
837 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
840 primop UnblockAsyncExceptionsOp "unblockAsyncExceptions#" GenPrimOp
841 (State# RealWorld -> (# State# RealWorld, a #))
842 -> (State# RealWorld -> (# State# RealWorld, a #))
844 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
847 ------------------------------------------------------------------------
848 --- MVars (not the same as mutable variables!) ---
849 ------------------------------------------------------------------------
851 primop NewMVarOp "newMVar#" GenPrimOp
852 State# s -> (# State# s, MVar# s a #)
854 usage = { mangle NewMVarOp [mkP] mkR }
857 primop TakeMVarOp "takeMVar#" GenPrimOp
858 MVar# s a -> State# s -> (# State# s, a #)
860 usage = { mangle TakeMVarOp [mkM, mkP] mkM }
861 has_side_effects = True
864 primop PutMVarOp "putMVar#" GenPrimOp
865 MVar# s a -> a -> State# s -> State# s
867 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
868 usage = { mangle PutMVarOp [mkM, mkM, mkP] mkR }
869 has_side_effects = True
872 primop SameMVarOp "sameMVar#" GenPrimOp
873 MVar# s a -> MVar# s a -> Bool
875 usage = { mangle SameMVarOp [mkP, mkP] mkM }
877 primop TryTakeMVarOp "tryTakeMVar#" GenPrimOp
878 MVar# s a -> State# s -> (# State# s, Int#, a #)
880 usage = { mangle TryTakeMVarOp [mkM, mkP] mkM }
881 has_side_effects = True
884 primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
885 MVar# s a -> State# s -> (# State# s, Int# #)
887 usage = { mangle IsEmptyMVarOp [mkP, mkP] mkM }
890 ------------------------------------------------------------------------
891 --- delay/wait operations ---
892 ------------------------------------------------------------------------
894 primop DelayOp "delay#" GenPrimOp
895 Int# -> State# s -> State# s
898 has_side_effects = True
901 primop WaitReadOp "waitRead#" GenPrimOp
902 Int# -> State# s -> State# s
905 has_side_effects = True
908 primop WaitWriteOp "waitWrite#" GenPrimOp
909 Int# -> State# s -> State# s
912 has_side_effects = True
915 ------------------------------------------------------------------------
916 --- concurrency primitives ---
917 ------------------------------------------------------------------------
919 primop ForkOp "fork#" GenPrimOp
920 a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
922 usage = { mangle ForkOp [mkO, mkP] mkR }
923 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
924 has_side_effects = True
927 primop KillThreadOp "killThread#" GenPrimOp
928 ThreadId# -> a -> State# RealWorld -> State# RealWorld
930 usage = { mangle KillThreadOp [mkP, mkM, mkP] mkR }
931 has_side_effects = True
934 primop YieldOp "yield#" GenPrimOp
935 State# RealWorld -> State# RealWorld
937 has_side_effects = True
940 primop MyThreadIdOp "myThreadId#" GenPrimOp
941 State# RealWorld -> (# State# RealWorld, ThreadId# #)
943 ------------------------------------------------------------------------
944 --- foreign objects ---
945 ------------------------------------------------------------------------
947 primop MkForeignObjOp "mkForeignObj#" GenPrimOp
948 Addr# -> State# RealWorld -> (# State# RealWorld, ForeignObj# #)
950 has_side_effects = True
953 primop WriteForeignObjOp "writeForeignObj#" GenPrimOp
954 ForeignObj# -> Addr# -> State# s -> State# s
956 has_side_effects = True
958 primop ForeignObjToAddrOp "foreignObjToAddr#" GenPrimOp
961 primop TouchOp "touch#" GenPrimOp
962 o -> State# RealWorld -> State# RealWorld
964 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
966 ------------------------------------------------------------------------
967 --- Bytecode objects ---
968 ------------------------------------------------------------------------
970 primop NewBCOOp "newBCO#" GenPrimOp
971 Int# -> Int# -> Int# -> a -> State# RealWorld -> (# State# RealWorld, BCO# #)
973 has_side_effects = True
976 primop WriteBCOPtrOp "writeBCOPtr#" GenPrimOp
977 BCO# -> Int# -> o -> State# RealWorld -> State# RealWorld
979 usage = { mangle WriteBCOPtrOp [mkP, mkP, mkM] mkR }
980 has_side_effects = True
982 primop WriteBCONonPtrOp "writeBCONonPtr#" GenPrimOp
983 BCO# -> Int# -> Word# -> State# RealWorld -> State# RealWorld
985 has_side_effects = True
987 primop WriteBCOInstrOp "writeBCOInstr#" GenPrimOp
988 BCO# -> Int# -> Word# -> State# RealWorld -> State# RealWorld
990 has_side_effects = True
992 primop ReadBCOPtrOp "readBCOPtr#" GenPrimOp
993 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
995 usage = { mangle ReadBCOPtrOp [mkP, mkP] mkM }
997 primop ReadBCONonPtrOp "readBCONonPtr#" GenPrimOp
998 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
1000 primop ReadBCOInstrOp "readBCOInstr#" GenPrimOp
1001 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
1003 ------------------------------------------------------------------------
1004 --- Weak pointers ---
1005 ------------------------------------------------------------------------
1007 -- note that tyvar "o" denoted openAlphaTyVar
1009 primop MkWeakOp "mkWeak#" GenPrimOp
1010 o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
1012 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwLazy, wwPrim] False }
1013 usage = { mangle MkWeakOp [mkZ, mkM, mkM, mkP] mkM }
1014 has_side_effects = True
1017 primop DeRefWeakOp "deRefWeak#" GenPrimOp
1018 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
1020 usage = { mangle DeRefWeakOp [mkM, mkP] mkM }
1021 has_side_effects = True
1023 primop FinalizeWeakOp "finalizeWeak#" GenPrimOp
1024 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#,
1025 (State# RealWorld -> (# State# RealWorld, Unit #)) #)
1027 usage = { mangle FinalizeWeakOp [mkM, mkP]
1028 (mkR . (inUB FinalizeWeakOp
1029 [id,id,inFun FinalizeWeakOp mkR mkM])) }
1030 has_side_effects = True
1034 ------------------------------------------------------------------------
1035 --- Stable pointers and names ---
1036 ------------------------------------------------------------------------
1038 primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
1039 a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
1041 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1042 usage = { mangle MakeStablePtrOp [mkM, mkP] mkM }
1043 has_side_effects = True
1045 primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
1046 StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
1048 usage = { mangle DeRefStablePtrOp [mkM, mkP] mkM }
1049 needs_wrapper = True
1050 has_side_effects = True
1052 primop EqStablePtrOp "eqStablePtr#" GenPrimOp
1053 StablePtr# a -> StablePtr# a -> Int#
1055 usage = { mangle EqStablePtrOp [mkP, mkP] mkR }
1056 has_side_effects = True
1058 primop MakeStableNameOp "makeStableName#" GenPrimOp
1059 a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
1061 usage = { mangle MakeStableNameOp [mkZ, mkP] mkR }
1062 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1063 needs_wrapper = True
1064 has_side_effects = True
1067 primop EqStableNameOp "eqStableName#" GenPrimOp
1068 StableName# a -> StableName# a -> Int#
1070 usage = { mangle EqStableNameOp [mkP, mkP] mkR }
1072 primop StableNameToIntOp "stableNameToInt#" GenPrimOp
1073 StableName# a -> Int#
1075 usage = { mangle StableNameToIntOp [mkP] mkR }
1077 ------------------------------------------------------------------------
1078 --- Unsafe pointer equality (#1 Bad Guy: Alistair Reid :) ---
1079 ------------------------------------------------------------------------
1081 primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
1084 usage = { mangle ReallyUnsafePtrEqualityOp [mkZ, mkZ] mkR }
1086 ------------------------------------------------------------------------
1088 ------------------------------------------------------------------------
1090 primop SeqOp "seq#" GenPrimOp
1093 usage = { mangle SeqOp [mkO] mkR }
1094 strictness = { \ arity -> StrictnessInfo [wwStrict] False }
1095 -- Seq is strict in its argument; see notes in ConFold.lhs
1096 has_side_effects = True
1098 primop ParOp "par#" GenPrimOp
1101 usage = { mangle ParOp [mkO] mkR }
1102 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1103 -- Note that Par is lazy to avoid that the sparked thing
1104 -- gets evaluted strictly, which it should *not* be
1105 has_side_effects = True
1107 -- HWL: The first 4 Int# in all par... annotations denote:
1108 -- name, granularity info, size of result, degree of parallelism
1109 -- Same structure as _seq_ i.e. returns Int#
1110 -- KSW: v, the second arg in parAt# and parAtForNow#, is used only to determine
1111 -- `the processor containing the expression v'; it is not evaluated
1113 primop ParGlobalOp "parGlobal#" GenPrimOp
1114 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1116 usage = { mangle ParGlobalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1117 has_side_effects = True
1119 primop ParLocalOp "parLocal#" GenPrimOp
1120 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1122 usage = { mangle ParLocalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1123 has_side_effects = True
1125 primop ParAtOp "parAt#" GenPrimOp
1126 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1128 usage = { mangle ParAtOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1129 has_side_effects = True
1131 primop ParAtAbsOp "parAtAbs#" GenPrimOp
1132 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1134 usage = { mangle ParAtAbsOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1135 has_side_effects = True
1137 primop ParAtRelOp "parAtRel#" GenPrimOp
1138 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1140 usage = { mangle ParAtRelOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1141 has_side_effects = True
1143 primop ParAtForNowOp "parAtForNow#" GenPrimOp
1144 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1146 usage = { mangle ParAtForNowOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1147 has_side_effects = True
1149 primop CopyableOp "copyable#" GenPrimOp
1152 usage = { mangle CopyableOp [mkZ] mkR }
1153 has_side_effects = True
1155 primop NoFollowOp "noFollow#" GenPrimOp
1158 usage = { mangle NoFollowOp [mkZ] mkR }
1159 has_side_effects = True
1162 ------------------------------------------------------------------------
1163 --- tag to enum stuff ---
1164 ------------------------------------------------------------------------
1166 primop DataToTagOp "dataToTag#" GenPrimOp
1169 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1171 primop TagToEnumOp "tagToEnum#" GenPrimOp
1177 ------------------------------------------------------------------------
1179 ------------------------------------------------------------------------