4 -----------------------------------------------------------------------
5 -- $Id: primops.txt,v 1.1 2001/02/26 15:44:59 rrt Exp $
7 -- Primitive Operations
9 -----------------------------------------------------------------------
11 -- To add a new primop, you currently need to update the following files:
13 -- - this file (ghc/compiler/prelude/primops.txt), which includes
14 -- the type of the primop, and various other properties (its
15 -- strictness attributes, whether it is defined as a macro
16 -- or as out-of-line code, etc.)
18 -- - ghc/lib/std/PrelGHC.hi-boot, to declare the primop
20 -- - if the primop is inline (i.e. a macro), then:
21 -- ghc/includes/PrimOps.h
22 -- ghc/compiler/nativeGen/StixPrim.lhs
24 -- - or, for an out-of-line primop:
25 -- ghc/includes/PrimOps.h (just add the declaration)
26 -- ghc/rts/PrimOps.hc (define it here)
31 -- The default attribute values which apply if you don't specify
32 -- other ones. Attribute values can be True, False, or arbitrary
33 -- text between curly brackets. This is a kludge to enable
34 -- processors of this file to easily get hold of simple info
35 -- (eg, out_of_line), whilst avoiding parsing complex expressions
36 -- needed for strictness and usage info.
39 has_side_effects = False
44 strictness = { \ arity -> StrictnessInfo (replicate arity wwPrim) False }
45 usage = { nomangle other }
48 ------------------------------------------------------------------------
49 --- Support for the metacircular interpreter ---
50 ------------------------------------------------------------------------
52 primop IndexOffClosureOp_Ptr "indexPtrOffClosure#" GenPrimOp
54 primop IndexOffClosureOp_Word "indexWordOffClosure#" GenPrimOp
58 primop Addr2IntOp "addr2Int#" GenPrimOp Addr# -> Int#
60 primop DoubleDecodeOp "decodeDouble#" GenPrimOp
61 Double# -> (# Int#, Int#, ByteArr# #)
62 with out_of_line = True
64 primop FloatDecodeOp "decodeFloat#" GenPrimOp
65 Float# -> (# Int#, Int#, ByteArr# #)
66 with out_of_line = True
68 primop IntegerSubOp "minusInteger#" GenPrimOp
69 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
70 with out_of_line = True
72 primop IntegerMulOp "timesInteger#" GenPrimOp
73 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
74 with commutable = True
77 primop IntegerGcdOp "gcdInteger#" GenPrimOp
78 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
79 with commutable = True
82 primop IntegerIntGcdOp "gcdIntegerInt#" GenPrimOp
83 Int# -> ByteArr# -> Int# -> Int#
84 with commutable = True
86 primop IntegerDivExactOp "divExactInteger#" GenPrimOp
87 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
88 with out_of_line = True
90 primop IntegerQuotOp "quotInteger#" GenPrimOp
91 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
92 with out_of_line = True
94 primop IntegerRemOp "remInteger#" GenPrimOp
95 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
96 with out_of_line = True
98 primop IntegerCmpOp "cmpInteger#" GenPrimOp
99 Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
100 with needs_wrapper = True
102 primop IntegerCmpIntOp "cmpIntegerInt#" GenPrimOp
103 Int# -> ByteArr# -> Int# -> Int#
104 with needs_wrapper = True
106 primop IntegerQuotRemOp "quotRemInteger#" GenPrimOp
107 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
111 primop IntegerDivModOp "divModInteger#" GenPrimOp
112 Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
116 primop Integer2IntOp "integer2Int#" GenPrimOp
117 Int# -> ByteArr# -> Int#
118 with needs_wrapper = True
120 primop Integer2WordOp "integer2Word#" GenPrimOp
121 Int# -> ByteArr# -> Word#
122 with needs_wrapper = True
124 primop IntegerToInt64Op "integerToInt64#" GenPrimOp
125 Int# -> ByteArr# -> Int64#
127 primop IntegerToWord64Op "integerToWord64#" GenPrimOp
128 Int# -> ByteArr# -> Word64#
130 ------------------------------------------------------------------------
132 ------------------------------------------------------------------------
134 primop NewByteArrayOp_Char "newCharArray#" GenPrimOp
135 Int# -> State# s -> (# State# s, MutByteArr# s #)
136 with out_of_line = True
138 primop NewByteArrayOp_Int "newIntArray#" GenPrimOp
139 Int# -> State# s -> (# State# s, MutByteArr# s #)
140 with out_of_line = True
142 primop NewByteArrayOp_Word "newWordArray#" GenPrimOp
143 Int# -> State# s -> (# State# s, MutByteArr# s #)
144 with out_of_line = True
146 primop NewByteArrayOp_Addr "newAddrArray#" GenPrimOp
147 Int# -> State# s -> (# State# s, MutByteArr# s #)
148 with out_of_line = True
150 primop NewByteArrayOp_Float "newFloatArray#" GenPrimOp
151 Int# -> State# s -> (# State# s, MutByteArr# s #)
152 with out_of_line = True
154 primop NewByteArrayOp_Double "newDoubleArray#" GenPrimOp
155 Int# -> State# s -> (# State# s, MutByteArr# s #)
156 with out_of_line = True
158 primop NewByteArrayOp_StablePtr "newStablePtrArray#" GenPrimOp
159 Int# -> State# s -> (# State# s, MutByteArr# s #)
160 with out_of_line = True
164 primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
165 MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
167 primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp
168 MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
170 primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp
171 MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
173 primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
174 MutByteArr# s -> Int# -> State# s -> (# State# s, Addr# #)
176 primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
177 MutByteArr# s -> Int# -> State# s -> (# State# s, Float# #)
179 primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
180 MutByteArr# s -> Int# -> State# s -> (# State# s, Double# #)
182 primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
183 MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
185 primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
186 MutByteArr# s -> Int# -> State# s -> (# State# s, Int64# #)
188 primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
189 MutByteArr# s -> Int# -> State# s -> (# State# s, Word64# #)
193 primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
194 MutByteArr# s -> Int# -> Char# -> State# s -> State# s
195 with has_side_effects = True
197 primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
198 MutByteArr# s -> Int# -> Int# -> State# s -> State# s
199 with has_side_effects = True
201 primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
202 MutByteArr# s -> Int# -> Word# -> State# s -> State# s
203 with has_side_effects = True
205 primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
206 MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
207 with has_side_effects = True
209 primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
210 MutByteArr# s -> Int# -> Float# -> State# s -> State# s
211 with has_side_effects = True
213 primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
214 MutByteArr# s -> Int# -> Double# -> State# s -> State# s
215 with has_side_effects = True
217 primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
218 MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
219 with has_side_effects = True
221 primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
222 MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
223 with has_side_effects = True
225 primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
226 MutByteArr# s -> Int# -> Word64# -> State# s -> State# s
227 with has_side_effects = True
230 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
231 ByteArr# -> Int# -> Char#
233 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
234 ByteArr# -> Int# -> Int#
236 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
237 ByteArr# -> Int# -> Word#
239 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
240 ByteArr# -> Int# -> Addr#
242 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
243 ByteArr# -> Int# -> Float#
245 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
246 ByteArr# -> Int# -> Double#
248 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
249 ByteArr# -> Int# -> StablePtr# a
251 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
252 ByteArr# -> Int# -> Int64#
254 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
255 ByteArr# -> Int# -> Word64#
260 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
261 Addr# -> Int# -> State# s -> (# State# s, Char# #)
263 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
264 Addr# -> Int# -> State# s -> (# State# s, Int# #)
266 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
267 Addr# -> Int# -> State# s -> (# State# s, Word# #)
269 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
270 Addr# -> Int# -> State# s -> (# State# s, Addr# #)
272 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
273 Addr# -> Int# -> State# s -> (# State# s, Float# #)
275 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
276 Addr# -> Int# -> State# s -> (# State# s, Double# #)
278 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
279 Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
281 primop ReadOffAddrOp_ForeignObj "readForeignObjOffAddr#" GenPrimOp
282 Addr# -> Int# -> State# s -> (# State# s, ForeignObj# #)
284 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
285 Addr# -> Int# -> State# s -> (# State# s, Int64# #)
287 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
288 Addr# -> Int# -> State# s -> (# State# s, Word64# #)
291 primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
292 Addr# -> Int# -> Char# -> State# s -> State# s
293 with has_side_effects = True
295 primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
296 Addr# -> Int# -> Int# -> State# s -> State# s
297 with has_side_effects = True
299 primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
300 Addr# -> Int# -> Word# -> State# s -> State# s
301 with has_side_effects = True
303 primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
304 Addr# -> Int# -> Addr# -> State# s -> State# s
305 with has_side_effects = True
307 primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
308 Addr# -> Int# -> Float# -> State# s -> State# s
309 with has_side_effects = True
311 primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
312 Addr# -> Int# -> Double# -> State# s -> State# s
313 with has_side_effects = True
315 primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
316 Addr# -> Int# -> StablePtr# a -> State# s -> State# s
317 with has_side_effects = True
319 primop WriteOffAddrOp_ForeignObj "writeForeignObjOffAddr#" GenPrimOp
320 Addr# -> Int# -> ForeignObj# -> State# s -> State# s
321 with has_side_effects = True
323 primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
324 Addr# -> Int# -> Int64# -> State# s -> State# s
325 with has_side_effects = True
327 primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
328 Addr# -> Int# -> Word64# -> State# s -> State# s
329 with has_side_effects = True
333 primop NewArrayOp "newArray#" GenPrimOp
334 Int# -> a -> State# s -> (# State# s, MutArr# s a #)
336 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
337 usage = { mangle NewArrayOp [mkP, mkM, mkP] mkM }
340 primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
341 MutArr# s a -> MutArr# s a -> Bool
343 usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
345 primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
346 MutByteArr# s -> MutByteArr# s -> Bool
348 primop ReadArrayOp "readArray#" GenPrimOp
349 MutArr# s a -> Int# -> State# s -> (# State# s, a #)
351 usage = { mangle ReadArrayOp [mkM, mkP, mkP] mkM }
353 primop WriteArrayOp "writeArray#" GenPrimOp
354 MutArr# s a -> Int# -> a -> State# s -> State# s
356 usage = { mangle WriteArrayOp [mkM, mkP, mkM, mkP] mkR }
357 strictness = { \ arity -> StrictnessInfo [wwPrim, wwPrim, wwLazy, wwPrim] False }
358 has_side_effects = True
360 primop IndexArrayOp "indexArray#" GenPrimOp
361 Array# a -> Int# -> (# a #)
363 usage = { mangle IndexArrayOp [mkM, mkP] mkM }
365 primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
366 MutArr# s a -> State# s -> (# State# s, Array# a #)
368 usage = { mangle UnsafeFreezeArrayOp [mkM, mkP] mkM }
369 has_side_effects = True
371 primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
372 MutByteArr# s -> State# s -> (# State# s, ByteArr# #)
374 has_side_effects = True
376 primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
377 Array# a -> State# s -> (# State# s, MutArr# s a #)
379 usage = { mangle UnsafeThawArrayOp [mkM, mkP] mkM }
382 primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
385 primop SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
386 MutByteArr# s -> Int#
388 ------------------------------------------------------------------------
389 --- Mutable variables ---
390 ------------------------------------------------------------------------
392 primop NewMutVarOp "newMutVar#" GenPrimOp
393 a -> State# s -> (# State# s, MutVar# s a #)
395 usage = { mangle NewMutVarOp [mkM, mkP] mkM }
396 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
399 primop ReadMutVarOp "readMutVar#" GenPrimOp
400 MutVar# s a -> State# s -> (# State# s, a #)
402 usage = { mangle ReadMutVarOp [mkM, mkP] mkM }
404 primop WriteMutVarOp "writeMutVar#" GenPrimOp
405 MutVar# s a -> a -> State# s -> State# s
407 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
408 usage = { mangle WriteMutVarOp [mkM, mkM, mkP] mkR }
409 has_side_effects = True
411 primop SameMutVarOp "sameMutVar#" GenPrimOp
412 MutVar# s a -> MutVar# s a -> Bool
414 usage = { mangle SameMutVarOp [mkP, mkP] mkM }
416 ------------------------------------------------------------------------
418 ------------------------------------------------------------------------
420 primop CatchOp "catch#" GenPrimOp
421 (State# RealWorld -> (# State# RealWorld, a #) )
422 -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
424 -> (# State# RealWorld, a #)
426 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwPrim] False }
427 -- Catch is actually strict in its first argument
428 -- but we don't want to tell the strictness
429 -- analyser about that!
430 usage = { mangle CatchOp [mkM, mkM . (inFun CatchOp mkM mkM), mkP] mkM }
431 -- [mkO, mkO . (inFun mkM mkO)] mkO
432 -- might use caught action multiply
435 primop RaiseOp "raise#" GenPrimOp
438 strictness = { \ arity -> StrictnessInfo [wwLazy] True }
439 -- NB: True => result is bottom
440 usage = { mangle RaiseOp [mkM] mkM }
443 primop BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
444 (State# RealWorld -> (# State# RealWorld, a #))
445 -> (State# RealWorld -> (# State# RealWorld, a #))
447 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
450 primop UnblockAsyncExceptionsOp "unblockAsyncExceptions#" GenPrimOp
451 (State# RealWorld -> (# State# RealWorld, a #))
452 -> (State# RealWorld -> (# State# RealWorld, a #))
454 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
457 ------------------------------------------------------------------------
458 --- MVars (not the same as mutable variables!) ---
459 ------------------------------------------------------------------------
461 primop NewMVarOp "newMVar#" GenPrimOp
462 State# s -> (# State# s, MVar# s a #)
464 usage = { mangle NewMVarOp [mkP] mkR }
467 primop TakeMVarOp "takeMVar#" GenPrimOp
468 MVar# s a -> State# s -> (# State# s, a #)
470 usage = { mangle TakeMVarOp [mkM, mkP] mkM }
471 has_side_effects = True
474 primop PutMVarOp "putMVar#" GenPrimOp
475 MVar# s a -> a -> State# s -> State# s
477 strictness = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
478 usage = { mangle PutMVarOp [mkM, mkM, mkP] mkR }
479 has_side_effects = True
482 primop SameMVarOp "sameMVar#" GenPrimOp
483 MVar# s a -> MVar# s a -> Bool
485 usage = { mangle SameMVarOp [mkP, mkP] mkM }
487 primop TakeMaybeMVarOp "tryTakeMVar#" GenPrimOp
488 MVar# s a -> State# s -> (# State# s, Int#, a #)
490 usage = { mangle TakeMaybeMVarOp [mkM, mkP] mkM }
491 has_side_effects = True
494 primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
495 MVar# s a -> State# s -> (# State# s, Int# #)
497 usage = { mangle IsEmptyMVarOp [mkP, mkP] mkM }
500 ------------------------------------------------------------------------
501 --- delay/wait operations ---
502 ------------------------------------------------------------------------
504 primop DelayOp "delay#" GenPrimOp
505 Int# -> State# s -> State# s
508 has_side_effects = True
511 primop WaitReadOp "waitRead#" GenPrimOp
512 Int# -> State# s -> State# s
515 has_side_effects = True
518 primop WaitWriteOp "waitWrite#" GenPrimOp
519 Int# -> State# s -> State# s
522 has_side_effects = True
525 ------------------------------------------------------------------------
526 --- concurrency primitives ---
527 ------------------------------------------------------------------------
529 primop ForkOp "fork#" GenPrimOp
530 a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
532 usage = { mangle ForkOp [mkO, mkP] mkR }
533 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
534 has_side_effects = True
537 primop KillThreadOp "killThread#" GenPrimOp
538 ThreadId# -> a -> State# RealWorld -> State# RealWorld
540 usage = { mangle KillThreadOp [mkP, mkM, mkP] mkR }
541 has_side_effects = True
544 primop YieldOp "yield#" GenPrimOp
545 State# RealWorld -> State# RealWorld
547 has_side_effects = True
550 primop MyThreadIdOp "myThreadId#" GenPrimOp
551 State# RealWorld -> (# State# RealWorld, ThreadId# #)
553 ------------------------------------------------------------------------
554 --- foreign objects ---
555 ------------------------------------------------------------------------
557 primop MkForeignObjOp "mkForeignObj#" GenPrimOp
558 Addr# -> State# RealWorld -> (# State# RealWorld, ForeignObj# #)
560 has_side_effects = True
563 primop WriteForeignObjOp "writeForeignObj#" GenPrimOp
564 ForeignObj# -> Addr# -> State# s -> State# s
566 has_side_effects = True
568 primop ForeignObjToAddrOp "foreignObjToAddr#" GenPrimOp
571 primop TouchOp "touch#" GenPrimOp
572 o -> State# RealWorld -> State# RealWorld
574 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
576 ------------------------------------------------------------------------
577 --- Bytecode objects ---
578 ------------------------------------------------------------------------
580 primop NewBCOOp "newBCO#" GenPrimOp
581 Int# -> Int# -> Int# -> a -> State# RealWorld -> (# State# RealWorld, BCO# #)
583 has_side_effects = True
585 strictness = { \ arity -> StrictnessInfo
586 [wwPrim, wwPrim, wwPrim, wwLazy, wwPrim] False }
587 usage = { mangle NewBCOOp [mkP, mkP, mkP, mkM, mkP] mkR }
589 primop WriteBCOPtrOp "writeBCOPtr#" GenPrimOp
590 BCO# -> Int# -> o -> State# RealWorld -> State# RealWorld
592 usage = { mangle WriteBCOPtrOp [mkP, mkP, mkM, mkP] mkR }
593 strictness = { \ arity -> StrictnessInfo
594 [wwPrim, wwPrim, wwLazy, wwPrim] False }
595 has_side_effects = True
597 primop WriteBCONonPtrOp "writeBCONonPtr#" GenPrimOp
598 BCO# -> Int# -> Word# -> State# RealWorld -> State# RealWorld
600 has_side_effects = True
602 primop WriteBCOInstrOp "writeBCOInstr#" GenPrimOp
603 BCO# -> Int# -> Word# -> State# RealWorld -> State# RealWorld
605 has_side_effects = True
607 primop ReadBCOPtrOp "readBCOPtr#" GenPrimOp
608 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
610 usage = { mangle ReadBCOPtrOp [mkP, mkP] mkM }
612 primop ReadBCONonPtrOp "readBCONonPtr#" GenPrimOp
613 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
615 primop ReadBCOInstrOp "readBCOInstr#" GenPrimOp
616 BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
618 primop SameBCOOp "sameBCO#" GenPrimOp
621 -- is this usage right?
622 usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
625 ------------------------------------------------------------------------
626 --- Weak pointers ---
627 ------------------------------------------------------------------------
629 -- note that tyvar "o" denoted openAlphaTyVar
631 primop MkWeakOp "mkWeak#" GenPrimOp
632 o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
634 strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwLazy, wwPrim] False }
635 usage = { mangle MkWeakOp [mkZ, mkM, mkM, mkP] mkM }
636 has_side_effects = True
639 primop DeRefWeakOp "deRefWeak#" GenPrimOp
640 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
642 usage = { mangle DeRefWeakOp [mkM, mkP] mkM }
643 has_side_effects = True
645 primop FinalizeWeakOp "finalizeWeak#" GenPrimOp
646 Weak# a -> State# RealWorld -> (# State# RealWorld, Int#,
647 (State# RealWorld -> (# State# RealWorld, Unit #)) #)
649 usage = { mangle FinalizeWeakOp [mkM, mkP]
650 (mkR . (inUB FinalizeWeakOp
651 [id,id,inFun FinalizeWeakOp mkR mkM])) }
652 has_side_effects = True
656 ------------------------------------------------------------------------
657 --- Stable pointers and names ---
658 ------------------------------------------------------------------------
660 primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
661 a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
663 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
664 usage = { mangle MakeStablePtrOp [mkM, mkP] mkM }
665 has_side_effects = True
667 primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
668 StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
670 usage = { mangle DeRefStablePtrOp [mkM, mkP] mkM }
672 has_side_effects = True
674 primop EqStablePtrOp "eqStablePtr#" GenPrimOp
675 StablePtr# a -> StablePtr# a -> Int#
677 usage = { mangle EqStablePtrOp [mkP, mkP] mkR }
678 has_side_effects = True
680 primop MakeStableNameOp "makeStableName#" GenPrimOp
681 a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
683 usage = { mangle MakeStableNameOp [mkZ, mkP] mkR }
684 strictness = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
686 has_side_effects = True
689 primop EqStableNameOp "eqStableName#" GenPrimOp
690 StableName# a -> StableName# a -> Int#
692 usage = { mangle EqStableNameOp [mkP, mkP] mkR }
694 primop StableNameToIntOp "stableNameToInt#" GenPrimOp
695 StableName# a -> Int#
697 usage = { mangle StableNameToIntOp [mkP] mkR }
699 ------------------------------------------------------------------------
700 --- Unsafe pointer equality (#1 Bad Guy: Alistair Reid :) ---
701 ------------------------------------------------------------------------
703 primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
706 usage = { mangle ReallyUnsafePtrEqualityOp [mkZ, mkZ] mkR }
708 ------------------------------------------------------------------------
710 ------------------------------------------------------------------------
712 primop SeqOp "seq#" GenPrimOp
715 usage = { mangle SeqOp [mkO] mkR }
716 strictness = { \ arity -> StrictnessInfo [wwStrict] False }
717 -- Seq is strict in its argument; see notes in ConFold.lhs
718 has_side_effects = True
720 primop ParOp "par#" GenPrimOp
723 usage = { mangle ParOp [mkO] mkR }
724 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
725 -- Note that Par is lazy to avoid that the sparked thing
726 -- gets evaluted strictly, which it should *not* be
727 has_side_effects = True
729 -- HWL: The first 4 Int# in all par... annotations denote:
730 -- name, granularity info, size of result, degree of parallelism
731 -- Same structure as _seq_ i.e. returns Int#
732 -- KSW: v, the second arg in parAt# and parAtForNow#, is used only to determine
733 -- `the processor containing the expression v'; it is not evaluated
735 primop ParGlobalOp "parGlobal#" GenPrimOp
736 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
738 usage = { mangle ParGlobalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
739 has_side_effects = True
741 primop ParLocalOp "parLocal#" GenPrimOp
742 a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
744 usage = { mangle ParLocalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
745 has_side_effects = True
747 primop ParAtOp "parAt#" GenPrimOp
748 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
750 usage = { mangle ParAtOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
751 has_side_effects = True
753 primop ParAtAbsOp "parAtAbs#" GenPrimOp
754 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
756 usage = { mangle ParAtAbsOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
757 has_side_effects = True
759 primop ParAtRelOp "parAtRel#" GenPrimOp
760 a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
762 usage = { mangle ParAtRelOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
763 has_side_effects = True
765 primop ParAtForNowOp "parAtForNow#" GenPrimOp
766 b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
768 usage = { mangle ParAtForNowOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
769 has_side_effects = True
771 primop CopyableOp "copyable#" GenPrimOp
774 usage = { mangle CopyableOp [mkZ] mkR }
775 has_side_effects = True
777 primop NoFollowOp "noFollow#" GenPrimOp
780 usage = { mangle NoFollowOp [mkZ] mkR }
781 has_side_effects = True
784 ------------------------------------------------------------------------
785 --- tag to enum stuff ---
786 ------------------------------------------------------------------------
788 primop DataToTagOp "dataToTag#" GenPrimOp
791 strictness = { \ arity -> StrictnessInfo [wwLazy] False }
793 primop TagToEnumOp "tagToEnum#" GenPrimOp
799 ------------------------------------------------------------------------
801 ------------------------------------------------------------------------
804 -- Char#-related ops:
808 -- Float#-related ops:
810 -- primitive ops for primitive arrays
813 | ReadOffAddrOp PrimRep
814 | WriteOffAddrOp PrimRep
815 | IndexOffAddrOp PrimRep
816 -- PrimRep can be one of :
817 -- {Char,Int,Word,Addr,Float,Double,StablePtr,Int64,Word64}Rep.
818 -- This is just a cheesy encoding of a bunch of ops.
819 -- Note that ForeignObjRep is not included -- the only way of
820 -- creating a ForeignObj is with a ccall or casm.
821 | IndexOffForeignObjOp PrimRep
823 | UnsafeFreezeArrayOp | UnsafeFreezeByteArrayOp
824 | SizeofByteArrayOp | SizeofMutableByteArrayOp
851 -- Operation to test two closure addresses for equality (yes really!)
852 -- BLAME ALASTAIR REID FOR THIS! THE REST OF US ARE INNOCENT!
853 | ReallyUnsafePtrEqualityOp
868 -- more parallel stuff
869 | ParGlobalOp -- named global par
870 | ParLocalOp -- named local par
871 | ParAtOp -- specifies destination of local par
872 | ParAtAbsOp -- specifies destination of local par (abs processor)
873 | ParAtRelOp -- specifies destination of local par (rel processor)
874 | ParAtForNowOp -- specifies initial destination of global par
875 | CopyableOp -- marks copyable code
876 | NoFollowOp -- marks non-followup expression