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