[project @ 2001-12-05 17:35:12 by sewardj]
[ghc-hetmet.git] / ghc / compiler / prelude / primops.txt.pp
1 -----------------------------------------------------------------------
2 -- $Id: primops.txt.pp,v 1.10 2001/12/05 17:35:14 sewardj Exp $
3 --
4 -- Primitive Operations
5 --
6 -----------------------------------------------------------------------
7
8 -- This file is processed by the utility program genprimopcode to produce
9 -- a number of include files within the compiler and optionally to produce
10 -- human-readable documentation.
11 --
12 -- It should first be preprocessed.
13 --
14 -- To add a new primop, you currently need to update the following files:
15 --
16 --      - this file (ghc/compiler/prelude/primops.txt.pp), which includes
17 --        the type of the primop, and various other properties (its
18 --        strictness attributes, whether it is defined as a macro
19 --        or as out-of-line code, etc.)
20 --
21 --      - ghc/lib/std/PrelGHC.hi-boot, to declare the primop
22 --
23 --      - if the primop is inline (i.e. a macro), then:
24 --              ghc/includes/PrimOps.h
25 --              ghc/compiler/nativeGen/StixPrim.lhs 
26 --              ghc/compiler/nativeGen/MachCode.lhs (if implementation is machine-dependent)
27 --              
28 --      - or, for an out-of-line primop:
29 --              ghc/includes/PrimOps.h (just add the declaration)
30 --              ghc/rts/PrimOps.hc     (define it here)
31 --
32 --      - the User's Guide 
33 --
34
35 -- This file is divided into named sections, each containing or more
36 -- primop entries. Section headers have the format:
37 --
38 --      section "section-name" {description}
39 --
40 -- This information is used solely when producing documentation; it is
41 -- otherwise ignored.  The description is optional.
42 --
43 -- The format of each primop entry is as follows:
44 --
45 --      primop internal-name "name-in-program-text" type category {description} attributes
46
47 -- The default attribute values which apply if you don't specify
48 -- other ones.  Attribute values can be True, False, or arbitrary
49 -- text between curly brackets.  This is a kludge to enable 
50 -- processors of this file to easily get hold of simple info
51 -- (eg, out_of_line), whilst avoiding parsing complex expressions
52 -- needed for strictness and usage info.
53
54 defaults
55    has_side_effects = False
56    out_of_line      = False
57    commutable       = False
58    needs_wrapper    = False
59    can_fail         = False
60    strictness       = { \ arity -> StrictnessInfo (replicate arity wwPrim) False }
61    usage            = { nomangle other }
62
63 -- Currently, documentation is produced using latex, so contents of
64 -- description fields should be legal latex. Descriptions can contain
65 -- matched pairs of embedded curly brackets.
66
67 #include "MachDeps.h"
68
69 section "The word size story."
70         {Haskell98 specifies that signed integers (type {\tt Int})
71          must contain at least 30 bits. GHC always implements {\tt
72          Int} using the primitive type {\tt Int\#}, whose size equals
73          the {\tt MachDeps.h} constant {\tt WORD\_SIZE\_IN\_BITS}.
74          This is normally set based on the {\tt config.h} parameter
75          {\tt SIZEOF\_HSWORD}, i.e., 32 bits on 32-bit machines, 64
76          bits on 64-bit machines.  However, it can also be explicitly
77          set to a smaller number, e.g., 31 bits, to allow the
78          possibility of using tag bits. Currently GHC itself has only
79          32-bit and 64-bit variants, but 30 or 31-bit code can be
80          exported as an external core file for use in other back ends.
81
82          GHC also implements a primitive unsigned integer type {\tt
83          Word\#} which always has the same number of bits as {\tt
84          Int\#}.
85         
86          In addition, GHC supports families of explicit-sized integers
87          and words at 8, 16, 32, and 64 bits, with the usual
88          arithmetic operations, comparisons, and a range of
89          conversions.  The 8-bit and 16-bit sizes are always
90          represented as {\tt Int\#} and {\tt Word\#}, and the
91          operations implemented in terms of the the primops on these
92          types, with suitable range restrictions on the results (using
93          the {\tt narrow$n$Int\#} and {\tt narrow$n$Word\#} families
94          of primops.  The 32-bit sizes are represented using {\tt
95          Int\#} and {\tt Word\#} when {\tt WORD\_SIZE\_IN\_BITS}
96          $\geq$ 32; otherwise, these are represented using distinct
97          primitive types {\tt Int32\#} and {\tt Word32\#}. These (when
98          needed) have a complete set of corresponding operations;
99          however, nearly all of these are implemented as external C
100          functions rather than as primops.  Exactly the same story
101          applies to the 64-bit sizes.  All of these details are hidden
102          under the {\tt PrelInt} and {\tt PrelWord} modules, which use
103          {\tt \#if}-defs to invoke the appropriate types and
104          operators.
105
106          Word size also matters for the families of primops for
107          indexing/reading/writing fixed-size quantities at offsets
108          from an array base, address, or foreign pointer.  Here, a
109          slightly different approach is taken.  The names of these
110          primops are fixed, but their {\it types} vary according to
111          the value of {\tt WORD\_SIZE\_IN\_BITS}. For example, if word
112          size is at least 32 bits then an operator like
113          \texttt{indexInt32Array\#} has type {\tt ByteArr\# -> Int\#
114          -> Int\#}; otherwise it has type {\tt ByteArr\# -> Int\# ->
115          Int32\#}.  This approach confines the necessary {\tt
116          \#if}-defs to this file; no conditional compilation is needed
117          in the files that expose these primops, namely
118          \texttt{lib/std/PrelStorable.lhs},
119          \texttt{hslibs/lang/ArrayBase.hs}, and (in deprecated
120          fashion) in \texttt{hslibs/lang/ForeignObj.lhs} and
121          \texttt{hslibs/lang/Addr.lhs}.
122
123          Finally, there are strongly deprecated primops for coercing
124          between {\tt Addr\#}, the primitive type of machine
125          addresses, and {\tt Int\#}.  These are pretty bogus anyway,
126          but will work on existing 32-bit and 64-bit GHC targets; they
127          are completely bogus when tag bits are used in {\tt Int\#},
128          so are not available in this case.  }
129         
130 -- Define synonyms for indexing ops. 
131
132 #if WORD_SIZE_IN_BITS < 32 
133 #define INT32 Int32#
134 #define WORD32 Word32#
135 #else
136 #define INT32 Int#
137 #define WORD32 Word#
138 #endif
139
140 #if WORD_SIZE_IN_BITS < 64
141 #define INT64 Int64#
142 #define WORD64 Word64#
143 #else
144 #define INT64 Int#
145 #define WORD64 Word#
146 #endif
147
148 ------------------------------------------------------------------------
149 section "Char#" 
150         {Operations on 31-bit characters.}
151 ------------------------------------------------------------------------
152
153
154 primop   CharGtOp  "gtChar#"   Compare   Char# -> Char# -> Bool
155 primop   CharGeOp  "geChar#"   Compare   Char# -> Char# -> Bool
156
157 primop   CharEqOp  "eqChar#"   Compare
158    Char# -> Char# -> Bool
159    with commutable = True
160
161 primop   CharNeOp  "neChar#"   Compare
162    Char# -> Char# -> Bool
163    with commutable = True
164
165 primop   CharLtOp  "ltChar#"   Compare   Char# -> Char# -> Bool
166 primop   CharLeOp  "leChar#"   Compare   Char# -> Char# -> Bool
167
168 primop   OrdOp   "ord#"  GenPrimOp   Char# -> Int#
169
170 ------------------------------------------------------------------------
171 section "Int#"
172         {Operations on native-size integers (30+ bits).}
173 ------------------------------------------------------------------------
174
175 primop   IntAddOp    "+#"    Dyadic
176    Int# -> Int# -> Int#
177    with commutable = True
178
179 primop   IntSubOp    "-#"    Dyadic   Int# -> Int# -> Int#
180
181 primop   IntMulOp    "*#" 
182    Dyadic   Int# -> Int# -> Int#
183    with commutable = True
184
185 primop   IntQuotOp    "quotInt#"    Dyadic
186    Int# -> Int# -> Int#
187    {Rounds towards zero.}
188    with can_fail = True
189
190 primop   IntRemOp    "remInt#"    Dyadic
191    Int# -> Int# -> Int#
192    {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}.}
193    with can_fail = True
194
195 primop   IntGcdOp    "gcdInt#"    Dyadic   Int# -> Int# -> Int#
196    with out_of_line = True
197
198 primop   IntNegOp    "negateInt#"    Monadic   Int# -> Int#
199 primop   IntAddCOp   "addIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
200          {Add with carry.  First member of result is (wrapped) sum; second member is 0 iff no overflow occured.}
201 primop   IntSubCOp   "subIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
202          {Subtract with carry.  First member of result is (wrapped) difference; second member is 0 iff no overflow occured.}
203 primop   IntMulCOp   "mulIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
204          {Multiply with carry.  First member of result is (wrapped) product; second member is 0 iff no overflow occured.}
205 primop   IntGtOp  ">#"   Compare   Int# -> Int# -> Bool
206 primop   IntGeOp  ">=#"   Compare   Int# -> Int# -> Bool
207
208 primop   IntEqOp  "==#"   Compare
209    Int# -> Int# -> Bool
210    with commutable = True
211
212 primop   IntNeOp  "/=#"   Compare
213    Int# -> Int# -> Bool
214    with commutable = True
215
216 primop   IntLtOp  "<#"   Compare   Int# -> Int# -> Bool
217 primop   IntLeOp  "<=#"   Compare   Int# -> Int# -> Bool
218
219 primop   ChrOp   "chr#"   GenPrimOp   Int# -> Char#
220
221 primop   Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
222 primop   Int2FloatOp   "int2Float#"      GenPrimOp  Int# -> Float#
223 primop   Int2DoubleOp   "int2Double#"          GenPrimOp  Int# -> Double#
224
225 primop   Int2IntegerOp    "int2Integer#"
226    GenPrimOp Int# -> (# Int#, ByteArr# #)
227    with out_of_line = True
228
229 primop   ISllOp   "iShiftL#" GenPrimOp  Int# -> Int# -> Int#
230          {Shift left. Return 0 if shifted by more than size of an Int\#.} 
231 primop   ISraOp   "iShiftRA#" GenPrimOp Int# -> Int# -> Int#
232          {Shift right arithemetic. Return 0 if shifted by more than size of an Int\#.}
233 primop   ISrlOp   "iShiftRL#" GenPrimOp Int# -> Int# -> Int#
234          {Shift right logical. Return 0 if shifted by more than size of an Int\#.}
235
236 ------------------------------------------------------------------------
237 section "Word#"
238         {Operations on native-sized unsigned words (30+ bits).}
239 ------------------------------------------------------------------------
240
241 primop   WordAddOp   "plusWord#"   Dyadic   Word# -> Word# -> Word#
242    with commutable = True
243
244 primop   WordSubOp   "minusWord#"   Dyadic   Word# -> Word# -> Word#
245
246 primop   WordMulOp   "timesWord#"   Dyadic   Word# -> Word# -> Word#
247    with commutable = True
248
249 primop   WordQuotOp   "quotWord#"   Dyadic   Word# -> Word# -> Word#
250    with can_fail = True
251
252 primop   WordRemOp   "remWord#"   Dyadic   Word# -> Word# -> Word#
253    with can_fail = True
254
255 primop   AndOp   "and#"   Dyadic   Word# -> Word# -> Word#
256    with commutable = True
257
258 primop   OrOp   "or#"   Dyadic   Word# -> Word# -> Word#
259    with commutable = True
260
261 primop   XorOp   "xor#"   Dyadic   Word# -> Word# -> Word#
262    with commutable = True
263
264 primop   NotOp   "not#"   Monadic   Word# -> Word#
265
266 primop   SllOp   "shiftL#"   GenPrimOp   Word# -> Int# -> Word#
267          {Shift left logical. Return 0 if shifted by more than number of bits in a Word\#.}
268 primop   SrlOp   "shiftRL#"   GenPrimOp   Word# -> Int# -> Word#
269          {Shift right logical. Return 0 if shifted by more than number of bits in a Word\#.}
270
271 primop   Word2IntOp   "word2Int#"   GenPrimOp   Word# -> Int#
272
273 primop   Word2IntegerOp   "word2Integer#"   GenPrimOp 
274    Word# -> (# Int#, ByteArr# #)
275    with out_of_line = True
276
277 primop   WordGtOp   "gtWord#"   Compare   Word# -> Word# -> Bool
278 primop   WordGeOp   "geWord#"   Compare   Word# -> Word# -> Bool
279 primop   WordEqOp   "eqWord#"   Compare   Word# -> Word# -> Bool
280 primop   WordNeOp   "neWord#"   Compare   Word# -> Word# -> Bool
281 primop   WordLtOp   "ltWord#"   Compare   Word# -> Word# -> Bool
282 primop   WordLeOp   "leWord#"   Compare   Word# -> Word# -> Bool
283
284 ------------------------------------------------------------------------
285 section "Narrowings" 
286         {Explicit narrowing of native-sized ints or words.}
287 ------------------------------------------------------------------------
288
289 primop   Narrow8IntOp      "narrow8Int#"      Monadic   Int# -> Int#
290 primop   Narrow16IntOp     "narrow16Int#"     Monadic   Int# -> Int#
291 primop   Narrow32IntOp     "narrow32Int#"     Monadic   Int# -> Int#
292 primop   Narrow8WordOp     "narrow8Word#"     Monadic   Word# -> Word#
293 primop   Narrow16WordOp    "narrow16Word#"    Monadic   Word# -> Word#
294 primop   Narrow32WordOp    "narrow32Word#"    Monadic   Word# -> Word#
295
296
297 #if WORD_SIZE_IN_BITS < 32
298 ------------------------------------------------------------------------
299 section "Int32#"
300         {Operations on 32-bit integers (Int32\#).  This type is only used
301          if plain Int\# has less than 32 bits.  In any case, the operations
302          are not primops; they are implemented (if needed) as ccalls instead.}
303 ------------------------------------------------------------------------
304
305 primop   Int32ToIntegerOp   "int32ToInteger#" GenPrimOp 
306    Int32# -> (# Int#, ByteArr# #)
307    with out_of_line = True
308
309
310 ------------------------------------------------------------------------
311 section "Word32#"
312         {Operations on 32-bit unsigned words. This type is only used 
313          if plain Word\# has less than 32 bits. In any case, the operations
314          are not primops; they are implemented (if needed) as ccalls instead.}
315 ------------------------------------------------------------------------
316
317 primop   Word32ToIntegerOp   "word32ToInteger#" GenPrimOp
318    Word32# -> (# Int#, ByteArr# #)
319    with out_of_line = True
320
321
322 #endif 
323
324
325 #if WORD_SIZE_IN_BITS < 64
326 ------------------------------------------------------------------------
327 section "Int64#"
328         {Operations on 64-bit unsigned words. This type is only used 
329          if plain Int\# has less than 64 bits. In any case, the operations
330          are not primops; they are implemented (if needed) as ccalls instead.}
331 ------------------------------------------------------------------------
332
333 primop   Int64ToIntegerOp   "int64ToInteger#" GenPrimOp 
334    Int64# -> (# Int#, ByteArr# #)
335    with out_of_line = True
336
337 ------------------------------------------------------------------------
338 section "Word64#"
339         {Operations on 64-bit unsigned words. This type is only used 
340          if plain Word\# has less than 64 bits. In any case, the operations
341          are not primops; they are implemented (if needed) as ccalls instead.}
342 ------------------------------------------------------------------------
343
344 primop   Word64ToIntegerOp   "word64ToInteger#" GenPrimOp
345    Word64# -> (# Int#, ByteArr# #)
346    with out_of_line = True
347
348 #endif
349
350 ------------------------------------------------------------------------
351 section "Integer#"
352         {Operations on arbitrary-precision integers. These operations are 
353 implemented via the GMP package. An integer is represented as a pair
354 consisting of an Int\# representing the number of 'limbs' in use and
355 the sign, and a ByteArr\# containing the 'limbs' themselves.  Such pairs
356 are returned as unboxed pairs, but must be passed as separate
357 components.
358
359 For .NET these operations are implemented by foreign imports, so the
360 primops are omitted.}
361 ------------------------------------------------------------------------
362
363 #ifndef ILX
364
365 primop   IntegerAddOp   "plusInteger#" GenPrimOp   
366    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
367    with commutable = True
368         out_of_line = True
369
370 primop   IntegerSubOp   "minusInteger#" GenPrimOp  
371    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
372    with out_of_line = True
373
374 primop   IntegerMulOp   "timesInteger#" GenPrimOp   
375    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
376    with commutable = True
377         out_of_line = True
378
379 primop   IntegerGcdOp   "gcdInteger#" GenPrimOp    
380    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
381    {Greatest common divisor.}
382    with commutable = True
383         out_of_line = True
384
385 primop   IntegerIntGcdOp   "gcdIntegerInt#" GenPrimOp
386    Int# -> ByteArr# -> Int# -> Int#
387    {Greatest common divisor, where second argument is an ordinary Int\#.}
388    with out_of_line = True
389
390 primop   IntegerDivExactOp   "divExactInteger#" GenPrimOp
391    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
392    {Divisor is guaranteed to be a factor of dividend.}
393    with out_of_line = True
394
395 primop   IntegerQuotOp   "quotInteger#" GenPrimOp
396    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
397    {Rounds towards zero.}
398    with out_of_line = True
399
400 primop   IntegerRemOp   "remInteger#" GenPrimOp
401    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
402    {Satisfies \texttt{plusInteger\# (timesInteger\# (quotInteger\# x y) y) (remInteger\# x y) == x}.}
403    with out_of_line = True
404
405 primop   IntegerCmpOp   "cmpInteger#"   GenPrimOp  
406    Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
407    {Returns -1,0,1 according as first argument is less than, equal to, or greater than second argument.}
408    with needs_wrapper = True
409         out_of_line = True
410
411 primop   IntegerCmpIntOp   "cmpIntegerInt#" GenPrimOp
412    Int# -> ByteArr# -> Int# -> Int#
413    {Returns -1,0,1 according as first argument is less than, equal to, or greater than second argument, which
414    is an ordinary Int\#.}
415    with needs_wrapper = True
416         out_of_line = True
417
418 primop   IntegerQuotRemOp   "quotRemInteger#" GenPrimOp
419    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
420    {Compute quot and rem simulaneously.}
421    with can_fail = True
422         out_of_line = True
423
424 primop   IntegerDivModOp    "divModInteger#"  GenPrimOp
425    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
426    {Compute div and mod simultaneously, where div rounds towards negative infinity
427     and\texttt{(q,r) = divModInteger\#(x,y)} implies \texttt{plusInteger\# (timesInteger\# q y) r = x}.}
428    with can_fail = True
429         out_of_line = True
430
431 primop   Integer2IntOp   "integer2Int#"    GenPrimOp
432    Int# -> ByteArr# -> Int#
433    with needs_wrapper = True
434         out_of_line = True
435
436 primop   Integer2WordOp   "integer2Word#"   GenPrimOp
437    Int# -> ByteArr# -> Word#
438    with needs_wrapper = True
439         out_of_line = True
440
441 #if WORD_SIZE_IN_BITS < 32
442 primop   IntegerToInt32Op   "integerToInt32#" GenPrimOp
443    Int# -> ByteArr# -> Int32#
444
445 primop   IntegerToWord32Op   "integerToWord32#" GenPrimOp
446    Int# -> ByteArr# -> Word32#
447 #endif
448
449 primop   IntegerAndOp  "andInteger#" GenPrimOp
450    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
451    with out_of_line = True
452
453 primop   IntegerOrOp  "orInteger#" GenPrimOp
454    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
455    with out_of_line = True
456
457 primop   IntegerXorOp  "xorInteger#" GenPrimOp
458    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
459    with out_of_line = True
460
461 primop   IntegerComplementOp  "complementInteger#" GenPrimOp
462    Int# -> ByteArr# -> (# Int#, ByteArr# #)
463    with out_of_line = True
464
465 #endif /* ndef ILX */
466
467 ------------------------------------------------------------------------
468 section "Double#"
469         {Operations on double-precision (64 bit) floating-point numbers.}
470 ------------------------------------------------------------------------
471
472 primop   DoubleGtOp ">##"   Compare   Double# -> Double# -> Bool
473 primop   DoubleGeOp ">=##"   Compare   Double# -> Double# -> Bool
474
475 primop DoubleEqOp "==##"   Compare
476    Double# -> Double# -> Bool
477    with commutable = True
478
479 primop DoubleNeOp "/=##"   Compare
480    Double# -> Double# -> Bool
481    with commutable = True
482
483 primop   DoubleLtOp "<##"   Compare   Double# -> Double# -> Bool
484 primop   DoubleLeOp "<=##"   Compare   Double# -> Double# -> Bool
485
486 primop   DoubleAddOp   "+##"   Dyadic
487    Double# -> Double# -> Double#
488    with commutable = True
489
490 primop   DoubleSubOp   "-##"   Dyadic   Double# -> Double# -> Double#
491
492 primop   DoubleMulOp   "*##"   Dyadic
493    Double# -> Double# -> Double#
494    with commutable = True
495
496 primop   DoubleDivOp   "/##"   Dyadic
497    Double# -> Double# -> Double#
498    with can_fail = True
499
500 primop   DoubleNegOp   "negateDouble#"  Monadic   Double# -> Double#
501
502 primop   Double2IntOp   "double2Int#"          GenPrimOp  Double# -> Int#
503 primop   Double2FloatOp   "double2Float#" GenPrimOp Double# -> Float#
504
505 primop   DoubleExpOp   "expDouble#"      Monadic
506    Double# -> Double#
507    with needs_wrapper = True
508
509 primop   DoubleLogOp   "logDouble#"      Monadic         
510    Double# -> Double#
511    with
512    needs_wrapper = True
513    can_fail = True
514
515 primop   DoubleSqrtOp   "sqrtDouble#"      Monadic  
516    Double# -> Double#
517    with needs_wrapper = True
518
519 primop   DoubleSinOp   "sinDouble#"      Monadic          
520    Double# -> Double#
521    with needs_wrapper = True
522
523 primop   DoubleCosOp   "cosDouble#"      Monadic          
524    Double# -> Double#
525    with needs_wrapper = True
526
527 primop   DoubleTanOp   "tanDouble#"      Monadic          
528    Double# -> Double#
529    with needs_wrapper = True
530
531 primop   DoubleAsinOp   "asinDouble#"      Monadic 
532    Double# -> Double#
533    with
534    needs_wrapper = True
535    can_fail = True
536
537 primop   DoubleAcosOp   "acosDouble#"      Monadic  
538    Double# -> Double#
539    with
540    needs_wrapper = True
541    can_fail = True
542
543 primop   DoubleAtanOp   "atanDouble#"      Monadic  
544    Double# -> Double#
545    with
546    needs_wrapper = True
547
548 primop   DoubleSinhOp   "sinhDouble#"      Monadic  
549    Double# -> Double#
550    with needs_wrapper = True
551
552 primop   DoubleCoshOp   "coshDouble#"      Monadic  
553    Double# -> Double#
554    with needs_wrapper = True
555
556 primop   DoubleTanhOp   "tanhDouble#"      Monadic  
557    Double# -> Double#
558    with needs_wrapper = True
559
560 primop   DoublePowerOp   "**##" Dyadic  
561    Double# -> Double# -> Double#
562    {Exponentiation.}
563    with needs_wrapper = True
564
565 primop   DoubleDecodeOp   "decodeDouble#" GenPrimOp    
566    Double# -> (# Int#, Int#, ByteArr# #)
567    {Convert to arbitrary-precision integer.
568     First Int\# in result is the exponent; second Int\# and ByteArr\# represent an Integer\# 
569     holding the mantissa.}
570    with out_of_line = True
571
572 ------------------------------------------------------------------------
573 section "Float#" 
574         {Operations on single-precision (32-bit) floating-point numbers.}
575 ------------------------------------------------------------------------
576
577 primop   FloatGtOp  "gtFloat#"   Compare   Float# -> Float# -> Bool
578 primop   FloatGeOp  "geFloat#"   Compare   Float# -> Float# -> Bool
579
580 primop   FloatEqOp  "eqFloat#"   Compare
581    Float# -> Float# -> Bool
582    with commutable = True
583
584 primop   FloatNeOp  "neFloat#"   Compare
585    Float# -> Float# -> Bool
586    with commutable = True
587
588 primop   FloatLtOp  "ltFloat#"   Compare   Float# -> Float# -> Bool
589 primop   FloatLeOp  "leFloat#"   Compare   Float# -> Float# -> Bool
590
591 primop   FloatAddOp   "plusFloat#"      Dyadic            
592    Float# -> Float# -> Float#
593    with commutable = True
594
595 primop   FloatSubOp   "minusFloat#"      Dyadic      Float# -> Float# -> Float#
596
597 primop   FloatMulOp   "timesFloat#"      Dyadic    
598    Float# -> Float# -> Float#
599    with commutable = True
600
601 primop   FloatDivOp   "divideFloat#"      Dyadic  
602    Float# -> Float# -> Float#
603    with can_fail = True
604
605 primop   FloatNegOp   "negateFloat#"      Monadic    Float# -> Float#
606
607 primop   Float2IntOp   "float2Int#"      GenPrimOp  Float# -> Int#
608
609 primop   FloatExpOp   "expFloat#"      Monadic          
610    Float# -> Float#
611    with needs_wrapper = True
612
613 primop   FloatLogOp   "logFloat#"      Monadic          
614    Float# -> Float#
615    with needs_wrapper = True
616         can_fail = True
617
618 primop   FloatSqrtOp   "sqrtFloat#"      Monadic          
619    Float# -> Float#
620    with needs_wrapper = True
621
622 primop   FloatSinOp   "sinFloat#"      Monadic          
623    Float# -> Float#
624    with needs_wrapper = True
625
626 primop   FloatCosOp   "cosFloat#"      Monadic          
627    Float# -> Float#
628    with needs_wrapper = True
629
630 primop   FloatTanOp   "tanFloat#"      Monadic          
631    Float# -> Float#
632    with needs_wrapper = True
633
634 primop   FloatAsinOp   "asinFloat#"      Monadic          
635    Float# -> Float#
636    with needs_wrapper = True
637         can_fail = True
638
639 primop   FloatAcosOp   "acosFloat#"      Monadic          
640    Float# -> Float#
641    with needs_wrapper = True
642         can_fail = True
643
644 primop   FloatAtanOp   "atanFloat#"      Monadic          
645    Float# -> Float#
646    with needs_wrapper = True
647
648 primop   FloatSinhOp   "sinhFloat#"      Monadic          
649    Float# -> Float#
650    with needs_wrapper = True
651
652 primop   FloatCoshOp   "coshFloat#"      Monadic          
653    Float# -> Float#
654    with needs_wrapper = True
655
656 primop   FloatTanhOp   "tanhFloat#"      Monadic          
657    Float# -> Float#
658    with needs_wrapper = True
659
660 primop   FloatPowerOp   "powerFloat#"      Dyadic   
661    Float# -> Float# -> Float#
662    with needs_wrapper = True
663
664 primop   Float2DoubleOp   "float2Double#" GenPrimOp  Float# -> Double#
665
666 primop   FloatDecodeOp   "decodeFloat#" GenPrimOp
667    Float# -> (# Int#, Int#, ByteArr# #)
668    {Convert to arbitrary-precision integer.
669     First Int\# in result is the exponent; second Int\# and ByteArr\# represent an Integer\# 
670     holding the mantissa.}
671    with out_of_line = True
672
673 ------------------------------------------------------------------------
674 section "Arrays"
675         {Operations on Array\#.}
676 ------------------------------------------------------------------------
677
678 primop  NewArrayOp "newArray#" GenPrimOp
679    Int# -> a -> State# s -> (# State# s, MutArr# s a #)
680    {Create a new mutable array of specified size (in bytes),
681     in the specified state thread,
682     with each element containing the specified initial value.}
683    with
684    strictness  = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
685    usage       = { mangle NewArrayOp [mkP, mkM, mkP] mkM }
686    out_of_line = True
687
688 primop  SameMutableArrayOp "sameMutableArray#" GenPrimOp
689    MutArr# s a -> MutArr# s a -> Bool
690    with
691    usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
692
693 primop  ReadArrayOp "readArray#" GenPrimOp
694    MutArr# s a -> Int# -> State# s -> (# State# s, a #)
695    {Read from specified index of mutable array. Result is not yet evaluated.}
696    with
697    usage = { mangle ReadArrayOp [mkM, mkP, mkP] mkM }
698
699 primop  WriteArrayOp "writeArray#" GenPrimOp
700    MutArr# s a -> Int# -> a -> State# s -> State# s
701    {Write to specified index of mutable array.}
702    with
703    usage            = { mangle WriteArrayOp [mkM, mkP, mkM, mkP] mkR }
704    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwPrim, wwLazy, wwPrim] False }
705    has_side_effects = True
706
707 primop  IndexArrayOp "indexArray#" GenPrimOp
708    Array# a -> Int# -> (# a #)
709    {Read from specified index of immutable array. Result is packaged into
710     an unboxed singleton; the result itself is not yet evaluated.}
711    with
712    usage = { mangle  IndexArrayOp [mkM, mkP] mkM }
713
714 primop  UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
715    MutArr# s a -> State# s -> (# State# s, Array# a #)
716    {Make a mutable array immutable, without copying.}
717    with
718    usage            = { mangle UnsafeFreezeArrayOp [mkM, mkP] mkM }
719    has_side_effects = True
720
721 primop  UnsafeThawArrayOp  "unsafeThawArray#" GenPrimOp
722    Array# a -> State# s -> (# State# s, MutArr# s a #)
723    {Make an immutable array mutable, without copying.}
724    with
725    usage       = { mangle UnsafeThawArrayOp [mkM, mkP] mkM }
726    out_of_line = True
727
728 ------------------------------------------------------------------------
729 section "Byte Arrays"
730         {Operations on ByteArray\#. A ByteArray\# is a just a region of
731          raw memory in the garbage-collected heap, which is not scanned
732          for pointers. It carries its own size (in bytes). There are
733          three sets of operations for accessing byte array contents:
734          index for reading from immutable byte arrays, and read/write
735          for mutable byte arrays.  Each set contains operations for 
736          a range of useful primitive data types.  Each operation takes  
737          an offset measured in terms of the size fo the primitive type
738          being read or written.}
739
740 ------------------------------------------------------------------------
741
742 primop  NewByteArrayOp_Char "newByteArray#" GenPrimOp
743    Int# -> State# s -> (# State# s, MutByteArr# s #)
744    {Create a new mutable byte array of specified size (in bytes), in
745     the specified state thread.}
746    with out_of_line = True
747
748 primop  NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp
749    Int# -> State# s -> (# State# s, MutByteArr# s #)
750    {Create a mutable byte array that the GC guarantees not to move.}
751    with out_of_line = True
752
753 primop  ByteArrayContents_Char "byteArrayContents#" GenPrimOp
754    ByteArr# -> Addr#
755    {Intended for use with pinned arrays; otherwise very unsafe!}
756
757 primop  SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
758    MutByteArr# s -> MutByteArr# s -> Bool
759
760 primop  UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
761    MutByteArr# s -> State# s -> (# State# s, ByteArr# #)
762    {Make a mutable byte array immutable, without copying.}
763    with
764    has_side_effects = True
765
766 primop  SizeofByteArrayOp "sizeofByteArray#" GenPrimOp  
767    ByteArr# -> Int#
768
769 primop  SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
770    MutByteArr# s -> Int#
771
772
773 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
774    ByteArr# -> Int# -> Char#
775    {Read 8-bit character; offset in bytes.}
776
777 primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp
778    ByteArr# -> Int# -> Char#
779    {Read 31-bit character; offset in 4-byte words.}
780
781 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
782    ByteArr# -> Int# -> Int#
783
784 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
785    ByteArr# -> Int# -> Word#
786
787 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
788    ByteArr# -> Int# -> Addr#
789
790 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
791    ByteArr# -> Int# -> Float#
792
793 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
794    ByteArr# -> Int# -> Double#
795
796 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
797    ByteArr# -> Int# -> StablePtr# a
798
799 primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
800    ByteArr# -> Int# -> Int#
801
802 primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
803    ByteArr# -> Int# -> Int#
804
805 primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
806    ByteArr# -> Int# -> INT32
807
808 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
809    ByteArr# -> Int# -> INT64
810
811 primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
812    ByteArr# -> Int# -> Word#
813
814 primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
815    ByteArr# -> Int# -> Word#
816
817 primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
818    ByteArr# -> Int# -> WORD32
819
820 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
821    ByteArr# -> Int# -> WORD64
822
823 primop  ReadByteArrayOp_Char "readCharArray#" GenPrimOp
824    MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
825    {Read 8-bit character; offset in bytes.}
826
827 primop  ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp
828    MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
829    {Read 31-bit character; offset in 4-byte words.}
830
831 primop  ReadByteArrayOp_Int "readIntArray#" GenPrimOp
832    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
833
834 primop  ReadByteArrayOp_Word "readWordArray#" GenPrimOp
835    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
836
837 primop  ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
838    MutByteArr# s -> Int# -> State# s -> (# State# s, Addr# #)
839
840 primop  ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
841    MutByteArr# s -> Int# -> State# s -> (# State# s, Float# #)
842
843 primop  ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
844    MutByteArr# s -> Int# -> State# s -> (# State# s, Double# #)
845
846 primop  ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
847    MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
848
849 primop  ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
850    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
851
852 primop  ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
853    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
854
855 primop  ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
856    MutByteArr# s -> Int# -> State# s -> (# State# s, INT32 #)
857
858 primop  ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
859    MutByteArr# s -> Int# -> State# s -> (# State# s, INT64 #)
860
861 primop  ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
862    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
863
864 primop  ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
865    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
866
867 primop  ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
868    MutByteArr# s -> Int# -> State# s -> (# State# s, WORD32 #)
869
870 primop  ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
871    MutByteArr# s -> Int# -> State# s -> (# State# s, WORD64 #)
872
873 primop  WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
874    MutByteArr# s -> Int# -> Char# -> State# s -> State# s
875    {Write 8-bit character; offset in bytes.}
876    with has_side_effects = True
877
878 primop  WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp
879    MutByteArr# s -> Int# -> Char# -> State# s -> State# s
880    {Write 31-bit character; offset in 4-byte words.}
881    with has_side_effects = True
882
883 primop  WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
884    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
885    with has_side_effects = True
886
887 primop  WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
888    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
889    with has_side_effects = True
890
891 primop  WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
892    MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
893    with has_side_effects = True
894
895 primop  WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
896    MutByteArr# s -> Int# -> Float# -> State# s -> State# s
897    with has_side_effects = True
898
899 primop  WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
900    MutByteArr# s -> Int# -> Double# -> State# s -> State# s
901    with has_side_effects = True
902
903 primop  WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
904    MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
905    with has_side_effects = True
906
907 primop  WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
908    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
909    with has_side_effects = True
910
911 primop  WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
912    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
913    with has_side_effects = True
914
915 primop  WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
916    MutByteArr# s -> Int# -> INT32 -> State# s -> State# s
917    with has_side_effects = True
918
919 primop  WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
920    MutByteArr# s -> Int# -> INT64 -> State# s -> State# s
921    with has_side_effects = True
922
923 primop  WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
924    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
925    with has_side_effects = True
926
927 primop  WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
928    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
929    with has_side_effects = True
930
931 primop  WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
932    MutByteArr# s -> Int# -> WORD32 -> State# s -> State# s
933    with has_side_effects = True
934
935 primop  WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
936    MutByteArr# s -> Int# -> WORD64 -> State# s -> State# s
937    with has_side_effects = True
938
939 ------------------------------------------------------------------------
940 section "Addr#"
941         {Addr\# is an arbitrary machine address assumed to point outside
942          the garbage-collected heap.  
943
944          NB: {\tt nullAddr\#::Addr\#} is not a primop, but is defined in MkId.lhs.
945          It is the null address.}
946 ------------------------------------------------------------------------
947
948 primop   AddrAddOp "plusAddr#" GenPrimOp Addr# -> Int# -> Addr#
949 primop   AddrSubOp "minusAddr#" GenPrimOp Addr# -> Addr# -> Int#
950          {Result is meaningless if two Addr\#s are so far apart that their
951          difference doesn't fit in an Int\#.}
952 primop   AddrRemOp "remAddr#" GenPrimOp Addr# -> Int# -> Int#
953          {Return the remainder when the Addr\# arg, treated like an Int\#,
954           is divided by the Int\# arg.}
955 #if (WORD_SIZE_IN_BITS == 32 || WORD_SIZE_IN_BITS == 64)
956 primop   Addr2IntOp  "addr2Int#"     GenPrimOp   Addr# -> Int#
957         {Coerce directly from address to int. Strongly deprecated.}
958 primop   Int2AddrOp   "int2Addr#"    GenPrimOp  Int# -> Addr#
959         {Coerce directly from int to address. Strongly deprecated.}
960 #endif
961
962 primop   AddrGtOp  "gtAddr#"   Compare   Addr# -> Addr# -> Bool
963 primop   AddrGeOp  "geAddr#"   Compare   Addr# -> Addr# -> Bool
964 primop   AddrEqOp  "eqAddr#"   Compare   Addr# -> Addr# -> Bool
965 primop   AddrNeOp  "neAddr#"   Compare   Addr# -> Addr# -> Bool
966 primop   AddrLtOp  "ltAddr#"   Compare   Addr# -> Addr# -> Bool
967 primop   AddrLeOp  "leAddr#"   Compare   Addr# -> Addr# -> Bool
968
969 primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
970    Addr# -> Int# -> Char#
971    {Reads 8-bit character; offset in bytes.}
972
973 primop IndexOffAddrOp_WideChar "indexWideCharOffAddr#" GenPrimOp
974    Addr# -> Int# -> Char#
975    {Reads 31-bit character; offset in 4-byte words.}
976
977 primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
978    Addr# -> Int# -> Int#
979
980 primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
981    Addr# -> Int# -> Word#
982
983 primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
984    Addr# -> Int# -> Addr#
985
986 primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
987    Addr# -> Int# -> Float#
988
989 primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
990    Addr# -> Int# -> Double#
991
992 primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
993    Addr# -> Int# -> StablePtr# a
994
995 primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
996    Addr# -> Int# -> Int#
997
998 primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
999    Addr# -> Int# -> Int#
1000
1001 primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
1002    Addr# -> Int# -> INT32
1003
1004 primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
1005    Addr# -> Int# -> INT64
1006
1007 primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
1008    Addr# -> Int# -> Word#
1009
1010 primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
1011    Addr# -> Int# -> Word#
1012
1013 primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
1014    Addr# -> Int# -> WORD32
1015
1016 primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
1017    Addr# -> Int# -> WORD64
1018
1019 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
1020    Addr# -> Int# -> State# s -> (# State# s, Char# #)
1021    {Reads 8-bit character; offset in bytes.}
1022
1023 primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp
1024    Addr# -> Int# -> State# s -> (# State# s, Char# #)
1025    {Reads 31-bit character; offset in 4-byte words.}
1026
1027 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
1028    Addr# -> Int# -> State# s -> (# State# s, Int# #)
1029
1030 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
1031    Addr# -> Int# -> State# s -> (# State# s, Word# #)
1032
1033 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
1034    Addr# -> Int# -> State# s -> (# State# s, Addr# #)
1035
1036 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
1037    Addr# -> Int# -> State# s -> (# State# s, Float# #)
1038
1039 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
1040    Addr# -> Int# -> State# s -> (# State# s, Double# #)
1041
1042 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
1043    Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
1044
1045 primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
1046    Addr# -> Int# -> State# s -> (# State# s, Int# #)
1047
1048 primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
1049    Addr# -> Int# -> State# s -> (# State# s, Int# #)
1050
1051 primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
1052    Addr# -> Int# -> State# s -> (# State# s, INT32 #)
1053
1054 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
1055    Addr# -> Int# -> State# s -> (# State# s, INT64 #)
1056
1057 primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
1058    Addr# -> Int# -> State# s -> (# State# s, Word# #)
1059
1060 primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
1061    Addr# -> Int# -> State# s -> (# State# s, Word# #)
1062
1063 primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
1064    Addr# -> Int# -> State# s -> (# State# s, WORD32 #)
1065
1066 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
1067    Addr# -> Int# -> State# s -> (# State# s, WORD64 #)
1068
1069
1070 primop  WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
1071    Addr# -> Int# -> Char# -> State# s -> State# s
1072    with has_side_effects = True
1073
1074 primop  WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp
1075    Addr# -> Int# -> Char# -> State# s -> State# s
1076    with has_side_effects = True
1077
1078 primop  WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
1079    Addr# -> Int# -> Int# -> State# s -> State# s
1080    with has_side_effects = True
1081
1082 primop  WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
1083    Addr# -> Int# -> Word# -> State# s -> State# s
1084    with has_side_effects = True
1085
1086 primop  WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
1087    Addr# -> Int# -> Addr# -> State# s -> State# s
1088    with has_side_effects = True
1089
1090 primop  WriteOffAddrOp_ForeignObj "writeForeignObjOffAddr#" GenPrimOp
1091    Addr# -> Int# -> ForeignObj# -> State# s -> State# s
1092    with has_side_effects = True
1093
1094 primop  WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
1095    Addr# -> Int# -> Float# -> State# s -> State# s
1096    with has_side_effects = True
1097
1098 primop  WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
1099    Addr# -> Int# -> Double# -> State# s -> State# s
1100    with has_side_effects = True
1101
1102 primop  WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
1103    Addr# -> Int# -> StablePtr# a -> State# s -> State# s
1104    with has_side_effects = True
1105
1106 primop  WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
1107    Addr# -> Int# -> Int# -> State# s -> State# s
1108    with has_side_effects = True
1109
1110 primop  WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
1111    Addr# -> Int# -> Int# -> State# s -> State# s
1112    with has_side_effects = True
1113
1114 primop  WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
1115    Addr# -> Int# -> INT32 -> State# s -> State# s
1116    with has_side_effects = True
1117
1118 primop  WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
1119    Addr# -> Int# -> INT64 -> State# s -> State# s
1120    with has_side_effects = True
1121
1122 primop  WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
1123    Addr# -> Int# -> Word# -> State# s -> State# s
1124    with has_side_effects = True
1125
1126 primop  WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
1127    Addr# -> Int# -> Word# -> State# s -> State# s
1128    with has_side_effects = True
1129
1130 primop  WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
1131    Addr# -> Int# -> WORD32 -> State# s -> State# s
1132    with has_side_effects = True
1133
1134 primop  WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
1135    Addr# -> Int# -> WORD64 -> State# s -> State# s
1136    with has_side_effects = True
1137
1138 ------------------------------------------------------------------------
1139 section "ForeignObj#"
1140         {Operations on ForeignObj\#.  The indexing operations are
1141         all deprecated.}
1142 ------------------------------------------------------------------------
1143
1144 primop  MkForeignObjOp "mkForeignObj#" GenPrimOp
1145    Addr# -> State# RealWorld -> (# State# RealWorld, ForeignObj# #)
1146    with
1147    has_side_effects = True
1148    out_of_line      = True
1149
1150 primop  WriteForeignObjOp "writeForeignObj#" GenPrimOp
1151    ForeignObj# -> Addr# -> State# s -> State# s
1152    with
1153    has_side_effects = True
1154
1155 primop ForeignObjToAddrOp "foreignObjToAddr#" GenPrimOp
1156    ForeignObj# -> Addr#
1157
1158 primop TouchOp "touch#" GenPrimOp
1159    o -> State# RealWorld -> State# RealWorld
1160    with
1161    has_side_effects = True
1162    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1163
1164 primop EqForeignObj "eqForeignObj#" GenPrimOp
1165    ForeignObj# -> ForeignObj# -> Bool
1166    with commutable = True
1167
1168 primop IndexOffForeignObjOp_Char "indexCharOffForeignObj#" GenPrimOp
1169    ForeignObj# -> Int# -> Char#
1170    {Read 8-bit character; offset in bytes.}
1171
1172 primop IndexOffForeignObjOp_WideChar "indexWideCharOffForeignObj#" GenPrimOp
1173    ForeignObj# -> Int# -> Char#
1174    {Read 31-bit character; offset in 4-byte words.}
1175
1176 primop IndexOffForeignObjOp_Int "indexIntOffForeignObj#" GenPrimOp
1177    ForeignObj# -> Int# -> Int#
1178
1179 primop IndexOffForeignObjOp_Word "indexWordOffForeignObj#" GenPrimOp
1180    ForeignObj# -> Int# -> Word#
1181
1182 primop IndexOffForeignObjOp_Addr "indexAddrOffForeignObj#" GenPrimOp
1183    ForeignObj# -> Int# -> Addr#
1184
1185 primop IndexOffForeignObjOp_Float "indexFloatOffForeignObj#" GenPrimOp
1186    ForeignObj# -> Int# -> Float#
1187
1188 primop IndexOffForeignObjOp_Double "indexDoubleOffForeignObj#" GenPrimOp
1189    ForeignObj# -> Int# -> Double#
1190
1191 primop IndexOffForeignObjOp_StablePtr "indexStablePtrOffForeignObj#" GenPrimOp
1192    ForeignObj# -> Int# -> StablePtr# a
1193
1194 primop IndexOffForeignObjOp_Int8 "indexInt8OffForeignObj#" GenPrimOp
1195    ForeignObj# -> Int# -> Int#
1196
1197 primop IndexOffForeignObjOp_Int16 "indexInt16OffForeignObj#" GenPrimOp
1198    ForeignObj# -> Int# -> Int#
1199
1200 primop IndexOffForeignObjOp_Int32 "indexInt32OffForeignObj#" GenPrimOp
1201    ForeignObj# -> Int# -> INT32
1202
1203 primop IndexOffForeignObjOp_Int64 "indexInt64OffForeignObj#" GenPrimOp
1204    ForeignObj# -> Int# -> INT64
1205
1206 primop IndexOffForeignObjOp_Word8 "indexWord8OffForeignObj#" GenPrimOp
1207    ForeignObj# -> Int# -> Word#
1208
1209 primop IndexOffForeignObjOp_Word16 "indexWord16OffForeignObj#" GenPrimOp
1210    ForeignObj# -> Int# -> Word#
1211
1212 primop IndexOffForeignObjOp_Word32 "indexWord32OffForeignObj#" GenPrimOp
1213    ForeignObj# -> Int# -> WORD32
1214
1215 primop IndexOffForeignObjOp_Word64 "indexWord64OffForeignObj#" GenPrimOp
1216    ForeignObj# -> Int# -> WORD64
1217
1218
1219
1220 ------------------------------------------------------------------------
1221 section "Mutable variables"
1222         {Operations on MutVar\#s, which behave like single-element mutable arrays.}
1223 ------------------------------------------------------------------------
1224
1225 primop  NewMutVarOp "newMutVar#" GenPrimOp
1226    a -> State# s -> (# State# s, MutVar# s a #)
1227    {Create MutVar\# with specified initial value in specified state thread.}
1228    with
1229    usage       = { mangle NewMutVarOp [mkM, mkP] mkM }
1230    strictness  = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1231    out_of_line = True
1232
1233 primop  ReadMutVarOp "readMutVar#" GenPrimOp
1234    MutVar# s a -> State# s -> (# State# s, a #)
1235    {Read contents of MutVar\#. Result is not yet evaluated.}
1236    with
1237    usage = { mangle ReadMutVarOp [mkM, mkP] mkM }
1238
1239 primop  WriteMutVarOp "writeMutVar#"  GenPrimOp
1240    MutVar# s a -> a -> State# s -> State# s
1241    {Write contents of MutVar\#.}
1242    with
1243    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
1244    usage            = { mangle WriteMutVarOp [mkM, mkM, mkP] mkR }
1245    has_side_effects = True
1246
1247 primop  SameMutVarOp "sameMutVar#" GenPrimOp
1248    MutVar# s a -> MutVar# s a -> Bool
1249    with
1250    usage = { mangle SameMutVarOp [mkP, mkP] mkM }
1251
1252 ------------------------------------------------------------------------
1253 section "Exceptions"
1254 ------------------------------------------------------------------------
1255
1256 primop  CatchOp "catch#" GenPrimOp
1257           (State# RealWorld -> (# State# RealWorld, a #) )
1258        -> (b -> State# RealWorld -> (# State# RealWorld, a #) ) 
1259        -> State# RealWorld
1260        -> (# State# RealWorld, a #)
1261    with
1262    strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwPrim] False }
1263         -- Catch is actually strict in its first argument
1264         -- but we don't want to tell the strictness
1265         -- analyser about that!
1266    usage = { mangle CatchOp [mkM, mkM . (inFun CatchOp mkM mkM), mkP] mkM }
1267         --     [mkO, mkO . (inFun mkM mkO)] mkO
1268         -- might use caught action multiply
1269    out_of_line = True
1270
1271 primop  RaiseOp "raise#" GenPrimOp
1272    a -> b
1273    with
1274    strictness  = { \ arity -> StrictnessInfo [wwLazy] True }
1275       -- NB: True => result is bottom
1276    usage       = { mangle RaiseOp [mkM] mkM }
1277    out_of_line = True
1278
1279 primop  BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
1280         (State# RealWorld -> (# State# RealWorld, a #))
1281      -> (State# RealWorld -> (# State# RealWorld, a #))
1282    with
1283    strictness  = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1284    out_of_line = True
1285
1286 primop  UnblockAsyncExceptionsOp "unblockAsyncExceptions#" GenPrimOp
1287         (State# RealWorld -> (# State# RealWorld, a #))
1288      -> (State# RealWorld -> (# State# RealWorld, a #))
1289    with
1290    strictness  = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1291    out_of_line = True
1292
1293 ------------------------------------------------------------------------
1294 section "Synchronized Mutable Variables"
1295         {Operations on MVar\#s, which are shared mutable variables
1296         ({\it not} the same as MutVar\#s!). (Note: in a non-concurrent implementation,
1297         (MVar\# a) can be represented by (MutVar\# (Maybe a)).)}
1298 ------------------------------------------------------------------------
1299
1300
1301 primop  NewMVarOp "newMVar#"  GenPrimOp
1302    State# s -> (# State# s, MVar# s a #)
1303    {Create new mvar; initially empty.}
1304    with
1305    usage       = { mangle NewMVarOp [mkP] mkR }
1306    out_of_line = True
1307
1308 primop  TakeMVarOp "takeMVar#" GenPrimOp
1309    MVar# s a -> State# s -> (# State# s, a #)
1310    {If mvar is empty, block until it becomes full.
1311    Then remove and return its contents, and set it empty.}
1312    with
1313    usage            = { mangle TakeMVarOp [mkM, mkP] mkM }
1314    has_side_effects = True
1315    out_of_line      = True
1316
1317 primop  TryTakeMVarOp "tryTakeMVar#" GenPrimOp
1318    MVar# s a -> State# s -> (# State# s, Int#, a #)
1319    {If mvar is empty, immediately return with integer 0 and value undefined.
1320    Otherwise, return with integer 1 and contents of mvar, and set mvar empty.}
1321    with
1322    usage            = { mangle TryTakeMVarOp [mkM, mkP] mkM }
1323    has_side_effects = True
1324    out_of_line      = True
1325
1326 primop  PutMVarOp "putMVar#" GenPrimOp
1327    MVar# s a -> a -> State# s -> State# s
1328    {If mvar is full, block until it becomes empty.
1329    Then store value arg as its new contents.}
1330    with
1331    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
1332    usage            = { mangle PutMVarOp [mkM, mkM, mkP] mkR }
1333    has_side_effects = True
1334    out_of_line      = True
1335
1336 primop  TryPutMVarOp "tryPutMVar#" GenPrimOp
1337    MVar# s a -> a -> State# s -> (# State# s, Int# #)
1338    {If mvar is full, immediately return with integer 0.
1339     Otherwise, store value arg as mvar's new contents, and return with integer 1.}
1340    with
1341    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
1342    usage            = { mangle TryPutMVarOp [mkM, mkM, mkP] mkR }
1343    has_side_effects = True
1344    out_of_line      = True
1345
1346 primop  SameMVarOp "sameMVar#" GenPrimOp
1347    MVar# s a -> MVar# s a -> Bool
1348    with
1349    usage = { mangle SameMVarOp [mkP, mkP] mkM }
1350
1351 primop  IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
1352    MVar# s a -> State# s -> (# State# s, Int# #)
1353    {Return 1 if mvar is empty; 0 otherwise.}
1354    with
1355    usage = { mangle IsEmptyMVarOp [mkP, mkP] mkM }
1356    out_of_line = True
1357
1358 ------------------------------------------------------------------------
1359 section "Delay/wait operations"
1360 ------------------------------------------------------------------------
1361
1362 primop  DelayOp "delay#" GenPrimOp
1363    Int# -> State# s -> State# s
1364    {Sleep specified number of microseconds.}
1365    with
1366    needs_wrapper    = True
1367    has_side_effects = True
1368    out_of_line      = True
1369
1370 primop  WaitReadOp "waitRead#" GenPrimOp
1371    Int# -> State# s -> State# s
1372    {Block until input is available on specified file descriptor.}
1373    with
1374    needs_wrapper    = True
1375    has_side_effects = True
1376    out_of_line      = True
1377
1378 primop  WaitWriteOp "waitWrite#" GenPrimOp
1379    Int# -> State# s -> State# s
1380    {Block until output is possible on specified file descriptor.}
1381    with
1382    needs_wrapper    = True
1383    has_side_effects = True
1384    out_of_line      = True
1385
1386 ------------------------------------------------------------------------
1387 section "Concurrency primitives"
1388         {(In a non-concurrent implementation, ThreadId\# can be as singleton
1389         type, whose (unique) value is returned by myThreadId\#.  The 
1390         other operations can be omitted.)}
1391 ------------------------------------------------------------------------
1392
1393 primop  ForkOp "fork#" GenPrimOp
1394    a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
1395    with
1396    usage            = { mangle ForkOp [mkO, mkP] mkR }
1397    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1398    has_side_effects = True
1399    out_of_line      = True
1400
1401 primop  KillThreadOp "killThread#"  GenPrimOp
1402    ThreadId# -> a -> State# RealWorld -> State# RealWorld
1403    with
1404    usage            = { mangle KillThreadOp [mkP, mkM, mkP] mkR }
1405    has_side_effects = True
1406    out_of_line      = True
1407
1408 primop  YieldOp "yield#" GenPrimOp
1409    State# RealWorld -> State# RealWorld
1410    with
1411    has_side_effects = True
1412    out_of_line      = True
1413
1414 primop  MyThreadIdOp "myThreadId#" GenPrimOp
1415    State# RealWorld -> (# State# RealWorld, ThreadId# #)
1416    with
1417    out_of_line = True
1418
1419 ------------------------------------------------------------------------
1420 section "Weak pointers"
1421 ------------------------------------------------------------------------
1422
1423 -- note that tyvar "o" denotes openAlphaTyVar
1424
1425 primop  MkWeakOp "mkWeak#" GenPrimOp
1426    o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
1427    with
1428    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwLazy, wwPrim] False }
1429    usage            = { mangle MkWeakOp [mkZ, mkM, mkM, mkP] mkM }
1430    has_side_effects = True
1431    out_of_line      = True
1432
1433 primop  DeRefWeakOp "deRefWeak#" GenPrimOp
1434    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
1435    with
1436    usage            = { mangle DeRefWeakOp [mkM, mkP] mkM }
1437    has_side_effects = True
1438    out_of_line      = True
1439
1440 primop  FinalizeWeakOp "finalizeWeak#" GenPrimOp
1441    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, 
1442               (State# RealWorld -> (# State# RealWorld, Unit #)) #)
1443    with
1444    usage            = { mangle FinalizeWeakOp [mkM, mkP] 
1445                                (mkR . (inUB FinalizeWeakOp 
1446                                             [id,id,inFun FinalizeWeakOp mkR mkM])) }
1447    has_side_effects = True
1448    out_of_line      = True
1449
1450 ------------------------------------------------------------------------
1451 section "Stable pointers and names"
1452 ------------------------------------------------------------------------
1453
1454 primop  MakeStablePtrOp "makeStablePtr#" GenPrimOp
1455    a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
1456    with
1457    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1458    usage            = { mangle MakeStablePtrOp [mkM, mkP] mkM }
1459    has_side_effects = True
1460    out_of_line      = True
1461
1462 primop  DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
1463    StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
1464    with
1465    usage            = { mangle DeRefStablePtrOp [mkM, mkP] mkM }
1466    needs_wrapper    = True
1467    has_side_effects = True
1468    out_of_line      = True
1469
1470 primop  EqStablePtrOp "eqStablePtr#" GenPrimOp
1471    StablePtr# a -> StablePtr# a -> Int#
1472    with
1473    usage            = { mangle EqStablePtrOp [mkP, mkP] mkR }
1474    has_side_effects = True
1475
1476 primop  MakeStableNameOp "makeStableName#" GenPrimOp
1477    a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
1478    with
1479    usage            = { mangle MakeStableNameOp [mkZ, mkP] mkR }
1480    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
1481    needs_wrapper    = True
1482    has_side_effects = True
1483    out_of_line      = True
1484
1485 primop  EqStableNameOp "eqStableName#" GenPrimOp
1486    StableName# a -> StableName# a -> Int#
1487    with
1488    usage = { mangle EqStableNameOp [mkP, mkP] mkR }
1489
1490 primop  StableNameToIntOp "stableNameToInt#" GenPrimOp
1491    StableName# a -> Int#
1492    with
1493    usage = { mangle StableNameToIntOp [mkP] mkR }
1494
1495 ------------------------------------------------------------------------
1496 section "Parallelism"
1497 ------------------------------------------------------------------------
1498
1499 primop  SeqOp "seq#" GenPrimOp
1500    a -> Int#
1501    with
1502    usage            = { mangle  SeqOp [mkO] mkR }
1503    strictness       = { \ arity -> StrictnessInfo [wwStrict] False }
1504       -- Seq is strict in its argument; see notes in ConFold.lhs
1505    has_side_effects = True
1506
1507 primop  ParOp "par#" GenPrimOp
1508    a -> Int#
1509    with
1510    usage            = { mangle ParOp [mkO] mkR }
1511    strictness       = { \ arity -> StrictnessInfo [wwLazy] False }
1512       -- Note that Par is lazy to avoid that the sparked thing
1513       -- gets evaluted strictly, which it should *not* be
1514    has_side_effects = True
1515
1516 -- HWL: The first 4 Int# in all par... annotations denote:
1517 --   name, granularity info, size of result, degree of parallelism
1518 --      Same  structure as _seq_ i.e. returns Int#
1519 -- KSW: v, the second arg in parAt# and parAtForNow#, is used only to determine
1520 --   `the processor containing the expression v'; it is not evaluated
1521
1522 primop  ParGlobalOp  "parGlobal#"  GenPrimOp
1523    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1524    with
1525    usage            = { mangle ParGlobalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1526    has_side_effects = True
1527
1528 primop  ParLocalOp  "parLocal#"  GenPrimOp
1529    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1530    with
1531    usage            = { mangle ParLocalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1532    has_side_effects = True
1533
1534 primop  ParAtOp  "parAt#"  GenPrimOp
1535    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1536    with
1537    usage            = { mangle ParAtOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1538    has_side_effects = True
1539
1540 primop  ParAtAbsOp  "parAtAbs#"  GenPrimOp
1541    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1542    with
1543    usage            = { mangle ParAtAbsOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1544    has_side_effects = True
1545
1546 primop  ParAtRelOp  "parAtRel#" GenPrimOp
1547    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
1548    with
1549    usage            = { mangle ParAtRelOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
1550    has_side_effects = True
1551
1552 primop  ParAtForNowOp  "parAtForNow#" GenPrimOp
1553    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
1554    with
1555    usage            = { mangle ParAtForNowOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
1556    has_side_effects = True
1557
1558 -- copyable# and noFollow# are yet to be implemented (for GpH)
1559 --
1560 --primop  CopyableOp  "copyable#" GenPrimOp
1561 --   a -> Int#
1562 --   with
1563 --   usage            = { mangle CopyableOp [mkZ] mkR }
1564 --   has_side_effects = True
1565 --
1566 --primop  NoFollowOp "noFollow#" GenPrimOp
1567 --   a -> Int#
1568 --   with
1569 --   usage            = { mangle NoFollowOp [mkZ] mkR }
1570 --   has_side_effects = True
1571
1572
1573 ------------------------------------------------------------------------
1574 section "Tag to enum stuff"
1575         {Convert back and forth between values of enumerated types
1576         and small integers.}
1577 ------------------------------------------------------------------------
1578
1579 primop  DataToTagOp "dataToTag#" GenPrimOp
1580    a -> Int#
1581    with
1582    strictness = { \ arity -> StrictnessInfo [wwLazy] False }
1583
1584 primop  TagToEnumOp "tagToEnum#" GenPrimOp     
1585    Int# -> a
1586
1587 ------------------------------------------------------------------------
1588 section "Bytecode operations" 
1589         {Support for the bytecode interpreter and linker.}
1590 ------------------------------------------------------------------------
1591
1592
1593 primop   AddrToHValueOp "addrToHValue#" GenPrimOp
1594    Addr# -> (# a #)
1595    {Convert an Addr\# to a followable type.}
1596
1597 primop   MkApUpd0_Op "mkApUpd0#" GenPrimOp
1598    a -> (# a #)
1599    with
1600    out_of_line = True
1601
1602 primop  NewBCOOp "newBCO#" GenPrimOp
1603    ByteArr# -> ByteArr# -> Array# a -> ByteArr# -> State# s -> (# State# s, BCO# #)
1604    with
1605    has_side_effects = True
1606    out_of_line      = True
1607
1608 ------------------------------------------------------------------------
1609 section "Coercion" 
1610         {{\tt unsafeCoerce# :: a -> b} is not a primop, but is defined in MkId.lhs.}
1611
1612 ------------------------------------------------------------------------
1613
1614
1615 ------------------------------------------------------------------------
1616 ---                                                                  ---
1617 ------------------------------------------------------------------------
1618
1619 thats_all_folks
1620
1621
1622