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