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