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