[project @ 2001-08-21 10:00:22 by simonpj]
[ghc-hetmet.git] / ghc / compiler / prelude / primops.txt
1 -----------------------------------------------------------------------
2 -- $Id: primops.txt,v 1.25 2001/08/17 17:18:53 apt 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120 \f
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287  
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111 section "The word size story."
1112         {Haskell98 specifies that signed integers (type {\tt Int}) must contain at least 30 
1113          bits. GHC always implements {\tt Int} using the primitive type {\tt Int\#}, whose
1114          size equals the {\tt MachDeps.h} constant {\tt WORD\_SIZE\_IN\_BITS}.  This
1115          is normally set based on the {\tt config.h} parameter {\tt 4},
1116          i.e., 32 bits on 32-bit machines, 64 bits on 64-bit machines.  However, it can
1117          also be explicitly set to a smaller number, e.g., 31 bits, to allow the possibility
1118          of using  tag bits. Currently GHC itself has only 32-bit and 64-bit variants,
1119          but 30 or 31-bit code can be exported as an external core file for use in 
1120          other back ends.
1121
1122          GHC also implements a primitive unsigned integer type {\tt Word\#} which always
1123          has the same number of bits as {\tt Int\#}.
1124         
1125          In addition, GHC supports families of explicit-sized integers and words at
1126          8, 16, 32, and 64 bits, with the usual arithmetic operations, comparisons,
1127          and a range of conversions.  The 8-bit and 16-bit sizes are always represented as
1128          {\tt Int\#} and {\tt Word\#}, and the operations implemented in terms of the
1129          the primops on these types, with suitable range restrictions on the results
1130          (using the {\tt Narrow$n$Int\#} and {\tt Narrow$n$Word\#} families of primops.
1131          The 32-bit sizes are represented using {\tt Int\#} and {\tt Word\#} when 
1132          {\tt WORD\_SIZE\_IN\_BITS} $\geq$ 32;
1133          otherwise, these are represented using distinct primitive types {\tt Int32\#}
1134          and {\tt Word32\#}. These (when needed) have a complete set of corresponding
1135          operations; however, nearly all of these are implemented as external C functions
1136          rather than as primops.  Exactly the same story applies to the 64-bit sizes.    
1137          All of these details are hidden under the {\tt PrelInt} and {\tt PrelWord} modules,
1138          which use {\tt \#if}-defs to invoke the appropriate types and operators.
1139
1140          Word size also matters for the families of primops 
1141          for indexing/reading/writing fixed-size quantities at offsets from
1142          an array base, address, or foreign pointer.  Here, a slightly different approach is taken.
1143          The names of these primops are fixed, but their 
1144          {\it types} vary according to the value of {\tt WORD\_SIZE\_IN\_BITS}. For example, if
1145          word size is at least 32 bits then an operator like \texttt{indexInt32Array\#}  
1146          has type {\tt ByteArr\# -> Int\# -> Int\#}; otherwise it has type 
1147          {\tt ByteArr\# -> Int\# -> Int32\#}.  This approach confines the necessary {\tt \#if}-defs to this file;
1148          no conditional compilation is needed in the files that expose these primops, namely \texttt{lib/std/PrelStorable.lhs},
1149          \texttt{hslibs/lang/ArrayBase.hs}, and (in deprecated fashion) in \texttt{hslibs/lang/ForeignObj.lhs}
1150          and \texttt{hslibs/lang/Addr.lhs}.
1151
1152          Finally, there are strongly deprecated primops for coercing between {\tt Addr\#}, the primitive
1153          type of machine addresses, and {\tt Int\#}.  These are pretty bogus anyway, but will work on
1154          existing 32-bit and 64-bit GHC targets;  they are completely bogus when tag bits are used in
1155          {\tt Int\#}, so are not available in this case.
1156 }
1157         
1158 -- Define synonyms for indexing ops. 
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176 ------------------------------------------------------------------------
1177 section "Char#" 
1178         {Operations on 31-bit characters.}
1179 ------------------------------------------------------------------------
1180
1181
1182 primop   CharGtOp  "gtChar#"   Compare   Char# -> Char# -> Bool
1183 primop   CharGeOp  "geChar#"   Compare   Char# -> Char# -> Bool
1184
1185 primop   CharEqOp  "eqChar#"   Compare
1186    Char# -> Char# -> Bool
1187    with commutable = True
1188
1189 primop   CharNeOp  "neChar#"   Compare
1190    Char# -> Char# -> Bool
1191    with commutable = True
1192
1193 primop   CharLtOp  "ltChar#"   Compare   Char# -> Char# -> Bool
1194 primop   CharLeOp  "leChar#"   Compare   Char# -> Char# -> Bool
1195
1196 primop   OrdOp   "ord#"  GenPrimOp   Char# -> Int#
1197
1198 ------------------------------------------------------------------------
1199 section "Int#"
1200         {Operations on native-size integers (30+ bits).}
1201 ------------------------------------------------------------------------
1202
1203 primop   IntAddOp    "+#"    Dyadic
1204    Int# -> Int# -> Int#
1205    with commutable = True
1206
1207 primop   IntSubOp    "-#"    Dyadic   Int# -> Int# -> Int#
1208
1209 primop   IntMulOp    "*#" 
1210    Dyadic   Int# -> Int# -> Int#
1211    with commutable = True
1212
1213 primop   IntQuotOp    "quotInt#"    Dyadic
1214    Int# -> Int# -> Int#
1215    {Rounds towards zero.}
1216    with can_fail = True
1217
1218 primop   IntRemOp    "remInt#"    Dyadic
1219    Int# -> Int# -> Int#
1220    {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}.}
1221    with can_fail = True
1222
1223 primop   IntGcdOp    "gcdInt#"    Dyadic   Int# -> Int# -> Int#
1224 primop   IntNegOp    "negateInt#"    Monadic   Int# -> Int#
1225 primop   IntAddCOp   "addIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
1226          {Add with carry.  First member of result is (wrapped) sum; second member is 0 iff no overflow occured.}
1227 primop   IntSubCOp   "subIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
1228          {Subtract with carry.  First member of result is (wrapped) difference; second member is 0 iff no overflow occured.}
1229 primop   IntMulCOp   "mulIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
1230          {Multiply with carry.  First member of result is (wrapped) product; second member is 0 iff no overflow occured.}
1231 primop   IntGtOp  ">#"   Compare   Int# -> Int# -> Bool
1232 primop   IntGeOp  ">=#"   Compare   Int# -> Int# -> Bool
1233
1234 primop   IntEqOp  "==#"   Compare
1235    Int# -> Int# -> Bool
1236    with commutable = True
1237
1238 primop   IntNeOp  "/=#"   Compare
1239    Int# -> Int# -> Bool
1240    with commutable = True
1241
1242 primop   IntLtOp  "<#"   Compare   Int# -> Int# -> Bool
1243 primop   IntLeOp  "<=#"   Compare   Int# -> Int# -> Bool
1244
1245 primop   ChrOp   "chr#"   GenPrimOp   Int# -> Char#
1246
1247 primop   Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
1248 primop   Int2FloatOp   "int2Float#"      GenPrimOp  Int# -> Float#
1249 primop   Int2DoubleOp   "int2Double#"          GenPrimOp  Int# -> Double#
1250
1251 primop   Int2IntegerOp    "int2Integer#"
1252    GenPrimOp Int# -> (# Int#, ByteArr# #)
1253    with out_of_line = True
1254
1255 primop   ISllOp   "iShiftL#" GenPrimOp  Int# -> Int# -> Int#
1256          {Shift left. Return 0 if shifted by more than size of an Int\#.} 
1257 primop   ISraOp   "iShiftRA#" GenPrimOp Int# -> Int# -> Int#
1258          {Shift right arithemetic. Return 0 if shifted by more than size of an Int\#.}
1259 primop   ISrlOp   "iShiftRL#" GenPrimOp Int# -> Int# -> Int#
1260          {Shift right logical. Return 0 if shifted by more than size of an Int\#.}
1261
1262 ------------------------------------------------------------------------
1263 section "Word#"
1264         {Operations on native-sized unsigned words (30+ bits).}
1265 ------------------------------------------------------------------------
1266
1267 primop   WordAddOp   "plusWord#"   Dyadic   Word# -> Word# -> Word#
1268    with commutable = True
1269
1270 primop   WordSubOp   "minusWord#"   Dyadic   Word# -> Word# -> Word#
1271
1272 primop   WordMulOp   "timesWord#"   Dyadic   Word# -> Word# -> Word#
1273    with commutable = True
1274
1275 primop   WordQuotOp   "quotWord#"   Dyadic   Word# -> Word# -> Word#
1276    with can_fail = True
1277
1278 primop   WordRemOp   "remWord#"   Dyadic   Word# -> Word# -> Word#
1279    with can_fail = True
1280
1281 primop   AndOp   "and#"   Dyadic   Word# -> Word# -> Word#
1282    with commutable = True
1283
1284 primop   OrOp   "or#"   Dyadic   Word# -> Word# -> Word#
1285    with commutable = True
1286
1287 primop   XorOp   "xor#"   Dyadic   Word# -> Word# -> Word#
1288    with commutable = True
1289
1290 primop   NotOp   "not#"   Monadic   Word# -> Word#
1291
1292 primop   SllOp   "shiftL#"   GenPrimOp   Word# -> Int# -> Word#
1293          {Shift left logical. Return 0 if shifted by more than number of bits in a Word\#.}
1294 primop   SrlOp   "shiftRL#"   GenPrimOp   Word# -> Int# -> Word#
1295          {Shift right logical. Return 0 if shifted by more than number of bits in a Word\#.}
1296
1297 primop   Word2IntOp   "word2Int#"   GenPrimOp   Word# -> Int#
1298
1299 primop   Word2IntegerOp   "word2Integer#"   GenPrimOp 
1300    Word# -> (# Int#, ByteArr# #)
1301    with out_of_line = True
1302
1303 primop   WordGtOp   "gtWord#"   Compare   Word# -> Word# -> Bool
1304 primop   WordGeOp   "geWord#"   Compare   Word# -> Word# -> Bool
1305 primop   WordEqOp   "eqWord#"   Compare   Word# -> Word# -> Bool
1306 primop   WordNeOp   "neWord#"   Compare   Word# -> Word# -> Bool
1307 primop   WordLtOp   "ltWord#"   Compare   Word# -> Word# -> Bool
1308 primop   WordLeOp   "leWord#"   Compare   Word# -> Word# -> Bool
1309
1310 ------------------------------------------------------------------------
1311 section "Narrowings" 
1312         {Explicit narrowing of native-sized ints or words.}
1313 ------------------------------------------------------------------------
1314
1315 primop   Narrow8IntOp      "narrow8Int#"      Monadic   Int# -> Int#
1316 primop   Narrow16IntOp     "narrow16Int#"     Monadic   Int# -> Int#
1317 primop   Narrow32IntOp     "narrow32Int#"     Monadic   Int# -> Int#
1318 primop   Narrow8WordOp     "narrow8Word#"     Monadic   Word# -> Word#
1319 primop   Narrow16WordOp    "narrow16Word#"    Monadic   Word# -> Word#
1320 primop   Narrow32WordOp    "narrow32Word#"    Monadic   Word# -> Word#
1321
1322
1323
1324
1325
1326
1327 ------------------------------------------------------------------------
1328 section "Int64#"
1329         {Operations on 64-bit unsigned words. This type is only used 
1330          if plain Int\# has less than 64 bits. In any case, the operations
1331          are not primops; they are implemented (if needed) as ccalls instead.}
1332 ------------------------------------------------------------------------
1333
1334 primop   Int64ToIntegerOp   "int64ToInteger#" GenPrimOp 
1335    Int64# -> (# Int#, ByteArr# #)
1336    with out_of_line = True
1337
1338 ------------------------------------------------------------------------
1339 section "Word64#"
1340         {Operations on 64-bit unsigned words. This type is only used 
1341          if plain Word\# has less than 64 bits. In any case, the operations
1342          are not primops; they are implemented (if needed) as ccalls instead.}
1343 ------------------------------------------------------------------------
1344
1345 primop   Word64ToIntegerOp   "word64ToInteger#" GenPrimOp
1346    Word64# -> (# Int#, ByteArr# #)
1347    with out_of_line = True
1348
1349
1350
1351 ------------------------------------------------------------------------
1352 section "Integer#"
1353         {Operations on arbitrary-precision integers. These operations are 
1354 implemented via the GMP package. An integer is represented as a pair
1355 consisting of an Int\# representing the number of 'limbs' in use and
1356 the sign, and a ByteArr\# containing the 'limbs' themselves.  Such pairs
1357 are returned as unboxed pairs, but must be passed as separate components.}
1358 ------------------------------------------------------------------------
1359
1360 primop   IntegerAddOp   "plusInteger#" GenPrimOp   
1361    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1362    with commutable = True
1363         out_of_line = True
1364
1365 primop   IntegerSubOp   "minusInteger#" GenPrimOp  
1366    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1367    with out_of_line = True
1368
1369 primop   IntegerMulOp   "timesInteger#" GenPrimOp   
1370    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1371    with commutable = True
1372         out_of_line = True
1373
1374 primop   IntegerGcdOp   "gcdInteger#" GenPrimOp    
1375    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1376    {Greatest common divisor.}
1377    with commutable = True
1378         out_of_line = True
1379
1380 primop   IntegerIntGcdOp   "gcdIntegerInt#" GenPrimOp
1381    Int# -> ByteArr# -> Int# -> Int#
1382    {Greatest common divisor, where second argument is an ordinary Int\#.}
1383    -- with commutable = True  (surely not? APT 8/01)
1384
1385 primop   IntegerDivExactOp   "divExactInteger#" GenPrimOp
1386    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1387    {Divisor is guaranteed to be a factor of dividend.}
1388    with out_of_line = True
1389
1390 primop   IntegerQuotOp   "quotInteger#" GenPrimOp
1391    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1392    {Rounds towards zero.}
1393    with out_of_line = True
1394
1395 primop   IntegerRemOp   "remInteger#" GenPrimOp
1396    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1397    {Satisfies \texttt{plusInteger\# (timesInteger\# (quotInteger\# x y) y) (remInteger\# x y) == x}.}
1398    with out_of_line = True
1399
1400 primop   IntegerCmpOp   "cmpInteger#"   GenPrimOp  
1401    Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
1402    {Returns -1,0,1 according as first argument is less than, equal to, or greater than second argument.}
1403    with needs_wrapper = True
1404
1405 primop   IntegerCmpIntOp   "cmpIntegerInt#" GenPrimOp
1406    Int# -> ByteArr# -> Int# -> Int#
1407    {Returns -1,0,1 according as first argument is less than, equal to, or greater than second argument, which
1408    is an ordinary Int\#.}
1409    with needs_wrapper = True
1410
1411 primop   IntegerQuotRemOp   "quotRemInteger#" GenPrimOp
1412    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
1413    {Compute quot and rem simulaneously.}
1414    with can_fail = True
1415         out_of_line = True
1416
1417 primop   IntegerDivModOp    "divModInteger#"  GenPrimOp
1418    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
1419    {Compute div and mod simultaneously, where div rounds towards negative infinity
1420     and\texttt{(q,r) = divModInteger\#(x,y)} implies \texttt{plusInteger\# (timesInteger\# q y) r = x}.}
1421    with can_fail = True
1422         out_of_line = True
1423
1424 primop   Integer2IntOp   "integer2Int#"    GenPrimOp
1425    Int# -> ByteArr# -> Int#
1426    with needs_wrapper = True
1427
1428 primop   Integer2WordOp   "integer2Word#"   GenPrimOp
1429    Int# -> ByteArr# -> Word#
1430    with needs_wrapper = True
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441 primop   IntegerToInt64Op   "integerToInt64#" GenPrimOp
1442    Int# -> ByteArr# -> Int64#
1443
1444 primop   IntegerToWord64Op   "integerToWord64#" GenPrimOp
1445    Int# -> ByteArr# -> Word64#
1446
1447
1448 primop   IntegerAndOp  "andInteger#" GenPrimOp
1449    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1450    with out_of_line = True
1451
1452 primop   IntegerOrOp  "orInteger#" GenPrimOp
1453    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1454    with out_of_line = True
1455
1456 primop   IntegerXorOp  "xorInteger#" GenPrimOp
1457    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1458    with out_of_line = True
1459
1460 primop   IntegerComplementOp  "complementInteger#" GenPrimOp
1461    Int# -> ByteArr# -> (# Int#, ByteArr# #)
1462    with out_of_line = True
1463
1464
1465 ------------------------------------------------------------------------
1466 section "Double#"
1467         {Operations on double-precision (64 bit) floating-point numbers.}
1468 ------------------------------------------------------------------------
1469
1470 primop   DoubleGtOp ">##"   Compare   Double# -> Double# -> Bool
1471 primop   DoubleGeOp ">=##"   Compare   Double# -> Double# -> Bool
1472
1473 primop DoubleEqOp "==##"   Compare
1474    Double# -> Double# -> Bool
1475    with commutable = True
1476
1477 primop DoubleNeOp "/=##"   Compare
1478    Double# -> Double# -> Bool
1479    with commutable = True
1480
1481 primop   DoubleLtOp "<##"   Compare   Double# -> Double# -> Bool
1482 primop   DoubleLeOp "<=##"   Compare   Double# -> Double# -> Bool
1483
1484 primop   DoubleAddOp   "+##"   Dyadic
1485    Double# -> Double# -> Double#
1486    with commutable = True
1487
1488 primop   DoubleSubOp   "-##"   Dyadic   Double# -> Double# -> Double#
1489
1490 primop   DoubleMulOp   "*##"   Dyadic
1491    Double# -> Double# -> Double#
1492    with commutable = True
1493
1494 primop   DoubleDivOp   "/##"   Dyadic
1495    Double# -> Double# -> Double#
1496    with can_fail = True
1497
1498 primop   DoubleNegOp   "negateDouble#"  Monadic   Double# -> Double#
1499
1500 primop   Double2IntOp   "double2Int#"          GenPrimOp  Double# -> Int#
1501 primop   Double2FloatOp   "double2Float#" GenPrimOp Double# -> Float#
1502
1503 primop   DoubleExpOp   "expDouble#"      Monadic
1504    Double# -> Double#
1505    with needs_wrapper = True
1506
1507 primop   DoubleLogOp   "logDouble#"      Monadic         
1508    Double# -> Double#
1509    with
1510    needs_wrapper = True
1511    can_fail = True
1512
1513 primop   DoubleSqrtOp   "sqrtDouble#"      Monadic  
1514    Double# -> Double#
1515    with needs_wrapper = True
1516
1517 primop   DoubleSinOp   "sinDouble#"      Monadic          
1518    Double# -> Double#
1519    with needs_wrapper = True
1520
1521 primop   DoubleCosOp   "cosDouble#"      Monadic          
1522    Double# -> Double#
1523    with needs_wrapper = True
1524
1525 primop   DoubleTanOp   "tanDouble#"      Monadic          
1526    Double# -> Double#
1527    with needs_wrapper = True
1528
1529 primop   DoubleAsinOp   "asinDouble#"      Monadic 
1530    Double# -> Double#
1531    with
1532    needs_wrapper = True
1533    can_fail = True
1534
1535 primop   DoubleAcosOp   "acosDouble#"      Monadic  
1536    Double# -> Double#
1537    with
1538    needs_wrapper = True
1539    can_fail = True
1540
1541 primop   DoubleAtanOp   "atanDouble#"      Monadic  
1542    Double# -> Double#
1543    with
1544    needs_wrapper = True
1545
1546 primop   DoubleSinhOp   "sinhDouble#"      Monadic  
1547    Double# -> Double#
1548    with needs_wrapper = True
1549
1550 primop   DoubleCoshOp   "coshDouble#"      Monadic  
1551    Double# -> Double#
1552    with needs_wrapper = True
1553
1554 primop   DoubleTanhOp   "tanhDouble#"      Monadic  
1555    Double# -> Double#
1556    with needs_wrapper = True
1557
1558 primop   DoublePowerOp   "**##" Dyadic  
1559    Double# -> Double# -> Double#
1560    {Exponentiation.}
1561    with needs_wrapper = True
1562
1563 primop   DoubleDecodeOp   "decodeDouble#" GenPrimOp    
1564    Double# -> (# Int#, Int#, ByteArr# #)
1565    {Convert to arbitrary-precision integer.
1566     First Int\# in result is the exponent; second Int\# and ByteArr\# represent an Integer\# 
1567     holding the mantissa.}
1568    with out_of_line = True
1569
1570 ------------------------------------------------------------------------
1571 section "Float#" 
1572         {Operations on single-precision (32-bit) floating-point numbers.}
1573 ------------------------------------------------------------------------
1574
1575 primop   FloatGtOp  "gtFloat#"   Compare   Float# -> Float# -> Bool
1576 primop   FloatGeOp  "geFloat#"   Compare   Float# -> Float# -> Bool
1577
1578 primop   FloatEqOp  "eqFloat#"   Compare
1579    Float# -> Float# -> Bool
1580    with commutable = True
1581
1582 primop   FloatNeOp  "neFloat#"   Compare
1583    Float# -> Float# -> Bool
1584    with commutable = True
1585
1586 primop   FloatLtOp  "ltFloat#"   Compare   Float# -> Float# -> Bool
1587 primop   FloatLeOp  "leFloat#"   Compare   Float# -> Float# -> Bool
1588
1589 primop   FloatAddOp   "plusFloat#"      Dyadic            
1590    Float# -> Float# -> Float#
1591    with commutable = True
1592
1593 primop   FloatSubOp   "minusFloat#"      Dyadic      Float# -> Float# -> Float#
1594
1595 primop   FloatMulOp   "timesFloat#"      Dyadic    
1596    Float# -> Float# -> Float#
1597    with commutable = True
1598
1599 primop   FloatDivOp   "divideFloat#"      Dyadic  
1600    Float# -> Float# -> Float#
1601    with can_fail = True
1602
1603 primop   FloatNegOp   "negateFloat#"      Monadic    Float# -> Float#
1604
1605 primop   Float2IntOp   "float2Int#"      GenPrimOp  Float# -> Int#
1606
1607 primop   FloatExpOp   "expFloat#"      Monadic          
1608    Float# -> Float#
1609    with needs_wrapper = True
1610
1611 primop   FloatLogOp   "logFloat#"      Monadic          
1612    Float# -> Float#
1613    with needs_wrapper = True
1614         can_fail = True
1615
1616 primop   FloatSqrtOp   "sqrtFloat#"      Monadic          
1617    Float# -> Float#
1618    with needs_wrapper = True
1619
1620 primop   FloatSinOp   "sinFloat#"      Monadic          
1621    Float# -> Float#
1622    with needs_wrapper = True
1623
1624 primop   FloatCosOp   "cosFloat#"      Monadic          
1625    Float# -> Float#
1626    with needs_wrapper = True
1627
1628 primop   FloatTanOp   "tanFloat#"      Monadic          
1629    Float# -> Float#
1630    with needs_wrapper = True
1631
1632 primop   FloatAsinOp   "asinFloat#"      Monadic          
1633    Float# -> Float#
1634    with needs_wrapper = True
1635         can_fail = True
1636
1637 primop   FloatAcosOp   "acosFloat#"      Monadic          
1638    Float# -> Float#
1639    with needs_wrapper = True
1640         can_fail = True
1641
1642 primop   FloatAtanOp   "atanFloat#"      Monadic          
1643    Float# -> Float#
1644    with needs_wrapper = True
1645
1646 primop   FloatSinhOp   "sinhFloat#"      Monadic          
1647    Float# -> Float#
1648    with needs_wrapper = True
1649
1650 primop   FloatCoshOp   "coshFloat#"      Monadic          
1651    Float# -> Float#
1652    with needs_wrapper = True
1653
1654 primop   FloatTanhOp   "tanhFloat#"      Monadic          
1655    Float# -> Float#
1656    with needs_wrapper = True
1657
1658 primop   FloatPowerOp   "powerFloat#"      Dyadic   
1659    Float# -> Float# -> Float#
1660    with needs_wrapper = True
1661
1662 primop   Float2DoubleOp   "float2Double#" GenPrimOp  Float# -> Double#
1663
1664 primop   FloatDecodeOp   "decodeFloat#" GenPrimOp
1665    Float# -> (# Int#, Int#, ByteArr# #)
1666    {Convert to arbitrary-precision integer.
1667     First Int\# in result is the exponent; second Int\# and ByteArr\# represent an Integer\# 
1668     holding the mantissa.}
1669    with out_of_line = True
1670
1671 ------------------------------------------------------------------------
1672 section "Arrays"
1673         {Operations on Array\#.}
1674 ------------------------------------------------------------------------
1675
1676 primop  NewArrayOp "newArray#" GenPrimOp
1677    Int# -> a -> State# s -> (# State# s, MutArr# s a #)
1678    {Create a new mutable array of specified size (in bytes),
1679     in the specified state thread,
1680     with each element containing the specified initial value.}
1681    with
1682    strictness  = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
1683    usage       = { mangle NewArrayOp [mkP, mkM, mkP] mkM }
1684    out_of_line = True
1685
1686 primop  SameMutableArrayOp "sameMutableArray#" GenPrimOp
1687    MutArr# s a -> MutArr# s a -> Bool
1688    with
1689    usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
1690
1691 primop  ReadArrayOp "readArray#" GenPrimOp
1692    MutArr# s a -> Int# -> State# s -> (# State# s, a #)
1693    {Read from specified index of mutable array. Result is not yet evaluated.}
1694    with
1695    usage = { mangle ReadArrayOp [mkM, mkP, mkP] mkM }
1696
1697 primop  WriteArrayOp "writeArray#" GenPrimOp
1698    MutArr# s a -> Int# -> a -> State# s -> State# s
1699    {Write to specified index of mutable array.}
1700    with
1701    usage            = { mangle WriteArrayOp [mkM, mkP, mkM, mkP] mkR }
1702    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwPrim, wwLazy, wwPrim] False }
1703    has_side_effects = True
1704
1705 primop  IndexArrayOp "indexArray#" GenPrimOp
1706    Array# a -> Int# -> (# a #)
1707    {Read from specified index of immutable array. Result is packaged into
1708     an unboxed singleton; the result itself is not yet evaluated.}
1709    with
1710    usage = { mangle  IndexArrayOp [mkM, mkP] mkM }
1711
1712 primop  UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
1713    MutArr# s a -> State# s -> (# State# s, Array# a #)
1714    {Make a mutable array immutable, without copying.}
1715    with
1716    usage            = { mangle UnsafeFreezeArrayOp [mkM, mkP] mkM }
1717    has_side_effects = True
1718
1719 primop  UnsafeThawArrayOp  "unsafeThawArray#" GenPrimOp
1720    Array# a -> State# s -> (# State# s, MutArr# s a #)
1721    {Make an immutable array mutable, without copying.}
1722    with
1723    usage       = { mangle UnsafeThawArrayOp [mkM, mkP] mkM }
1724    out_of_line = True
1725
1726 ------------------------------------------------------------------------
1727 section "Byte Arrays"
1728         {Operations on ByteArray\#. A ByteArray\# is a just a region of
1729          raw memory in the garbage-collected heap, which is not scanned
1730          for pointers. It carries its own size (in bytes). There are
1731          three sets of operations for accessing byte array contents:
1732          index for reading from immutable byte arrays, and read/write
1733          for mutable byte arrays.  Each set contains operations for 
1734          a range of useful primitive data types.  Each operation takes  
1735          an offset measured in terms of the size fo the primitive type
1736          being read or written.}
1737
1738 ------------------------------------------------------------------------
1739
1740 primop  NewByteArrayOp_Char "newByteArray#" GenPrimOp
1741    Int# -> State# s -> (# State# s, MutByteArr# s #)
1742    {Create a new mutable byte array of specified size (in bytes), in
1743     the specified state thread.}
1744    with out_of_line = True
1745
1746 primop  NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp
1747    Int# -> State# s -> (# State# s, MutByteArr# s #)
1748    {Create a mutable byte array that the GC guarantees not to move.}
1749    with out_of_line = True
1750
1751 primop  ByteArrayContents_Char "byteArrayContents#" GenPrimOp
1752    ByteArr# -> Addr#
1753    {Intended for use with pinned arrays; otherwise very unsafe!}
1754
1755 primop  SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
1756    MutByteArr# s -> MutByteArr# s -> Bool
1757
1758 primop  UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
1759    MutByteArr# s -> State# s -> (# State# s, ByteArr# #)
1760    {Make a mutable byte array immutable, without copying.}
1761    with
1762    has_side_effects = True
1763
1764 primop  SizeofByteArrayOp "sizeofByteArray#" GenPrimOp  
1765    ByteArr# -> Int#
1766
1767 primop  SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
1768    MutByteArr# s -> Int#
1769
1770
1771 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
1772    ByteArr# -> Int# -> Char#
1773    {Read 8-bit character; offset in bytes.}
1774
1775 primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp
1776    ByteArr# -> Int# -> Char#
1777    {Read 31-bit character; offset in 4-byte words.}
1778
1779 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
1780    ByteArr# -> Int# -> Int#
1781
1782 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
1783    ByteArr# -> Int# -> Word#
1784
1785 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
1786    ByteArr# -> Int# -> Addr#
1787
1788 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
1789    ByteArr# -> Int# -> Float#
1790
1791 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
1792    ByteArr# -> Int# -> Double#
1793
1794 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
1795    ByteArr# -> Int# -> StablePtr# a
1796
1797 primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
1798    ByteArr# -> Int# -> Int#
1799
1800 primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
1801    ByteArr# -> Int# -> Int#
1802
1803 primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
1804    ByteArr# -> Int# -> Int#
1805
1806 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
1807    ByteArr# -> Int# -> Int64#
1808
1809 primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
1810    ByteArr# -> Int# -> Word#
1811
1812 primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
1813    ByteArr# -> Int# -> Word#
1814
1815 primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
1816    ByteArr# -> Int# -> Word#
1817
1818 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
1819    ByteArr# -> Int# -> Word64#
1820
1821 primop  ReadByteArrayOp_Char "readCharArray#" GenPrimOp
1822    MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
1823    {Read 8-bit character; offset in bytes.}
1824
1825 primop  ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp
1826    MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
1827    {Read 31-bit character; offset in 4-byte words.}
1828
1829 primop  ReadByteArrayOp_Int "readIntArray#" GenPrimOp
1830    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
1831
1832 primop  ReadByteArrayOp_Word "readWordArray#" GenPrimOp
1833    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
1834
1835 primop  ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
1836    MutByteArr# s -> Int# -> State# s -> (# State# s, Addr# #)
1837
1838 primop  ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
1839    MutByteArr# s -> Int# -> State# s -> (# State# s, Float# #)
1840
1841 primop  ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
1842    MutByteArr# s -> Int# -> State# s -> (# State# s, Double# #)
1843
1844 primop  ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
1845    MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
1846
1847 primop  ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
1848    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
1849
1850 primop  ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
1851    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
1852
1853 primop  ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
1854    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
1855
1856 primop  ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
1857    MutByteArr# s -> Int# -> State# s -> (# State# s, Int64# #)
1858
1859 primop  ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
1860    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
1861
1862 primop  ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
1863    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
1864
1865 primop  ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
1866    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
1867
1868 primop  ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
1869    MutByteArr# s -> Int# -> State# s -> (# State# s, Word64# #)
1870
1871 primop  WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
1872    MutByteArr# s -> Int# -> Char# -> State# s -> State# s
1873    {Write 8-bit character; offset in bytes.}
1874    with has_side_effects = True
1875
1876 primop  WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp
1877    MutByteArr# s -> Int# -> Char# -> State# s -> State# s
1878    {Write 31-bit character; offset in 4-byte words.}
1879    with has_side_effects = True
1880
1881 primop  WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
1882    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
1883    with has_side_effects = True
1884
1885 primop  WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
1886    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
1887    with has_side_effects = True
1888
1889 primop  WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
1890    MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
1891    with has_side_effects = True
1892
1893 primop  WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
1894    MutByteArr# s -> Int# -> Float# -> State# s -> State# s
1895    with has_side_effects = True
1896
1897 primop  WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
1898    MutByteArr# s -> Int# -> Double# -> State# s -> State# s
1899    with has_side_effects = True
1900
1901 primop  WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
1902    MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
1903    with has_side_effects = True
1904
1905 primop  WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
1906    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
1907    with has_side_effects = True
1908
1909 primop  WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
1910    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
1911    with has_side_effects = True
1912
1913 primop  WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
1914    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
1915    with has_side_effects = True
1916
1917 primop  WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
1918    MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
1919    with has_side_effects = True
1920
1921 primop  WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
1922    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
1923    with has_side_effects = True
1924
1925 primop  WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
1926    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
1927    with has_side_effects = True
1928
1929 primop  WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
1930    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
1931    with has_side_effects = True
1932
1933 primop  WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
1934    MutByteArr# s -> Int# -> Word64# -> State# s -> State# s
1935    with has_side_effects = True
1936
1937 ------------------------------------------------------------------------
1938 section "Addr#"
1939         {Addr\# is an arbitrary machine address assumed to point outside
1940          the garbage-collected heap.}
1941 ------------------------------------------------------------------------
1942
1943 primop   AddrNullOp "nullAddr#" GenPrimOp  Int# -> Addr#
1944          {Returns null address. Argument is ignored (nullary primops 
1945           don't quite work!)}
1946 primop   AddrAddOp "plusAddr#" GenPrimOp Addr# -> Int# -> Addr#
1947 primop   AddrSubOp "minusAddr#" GenPrimOp Addr# -> Addr# -> Int#
1948          {Result is meaningless if two Addr\#s are so far apart that their
1949          difference doesn't fit in an Int\#.}
1950 primop   AddrRemOp "remAddr#" GenPrimOp Addr# -> Int# -> Int#
1951          {Return the remainder when the Addr\# arg, treated like an Int\#,
1952           is divided by the Int\# arg.}
1953
1954 primop   Addr2IntOp  "addr2Int#"     GenPrimOp   Addr# -> Int#
1955         {Coerce directly from address to int. Strongly deprecated.}
1956 primop   Int2AddrOp   "int2Addr#"    GenPrimOp  Int# -> Addr#
1957         {Coerce directly from int to address. Strongly deprecated.}
1958
1959
1960 primop   AddrGtOp  "gtAddr#"   Compare   Addr# -> Addr# -> Bool
1961 primop   AddrGeOp  "geAddr#"   Compare   Addr# -> Addr# -> Bool
1962 primop   AddrEqOp  "eqAddr#"   Compare   Addr# -> Addr# -> Bool
1963 primop   AddrNeOp  "neAddr#"   Compare   Addr# -> Addr# -> Bool
1964 primop   AddrLtOp  "ltAddr#"   Compare   Addr# -> Addr# -> Bool
1965 primop   AddrLeOp  "leAddr#"   Compare   Addr# -> Addr# -> Bool
1966
1967 primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
1968    Addr# -> Int# -> Char#
1969    {Reads 8-bit character; offset in bytes.}
1970
1971 primop IndexOffAddrOp_WideChar "indexWideCharOffAddr#" GenPrimOp
1972    Addr# -> Int# -> Char#
1973    {Reads 31-bit character; offset in 4-byte words.}
1974
1975 primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
1976    Addr# -> Int# -> Int#
1977
1978 primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
1979    Addr# -> Int# -> Word#
1980
1981 primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
1982    Addr# -> Int# -> Addr#
1983
1984 primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
1985    Addr# -> Int# -> Float#
1986
1987 primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
1988    Addr# -> Int# -> Double#
1989
1990 primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
1991    Addr# -> Int# -> StablePtr# a
1992
1993 primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
1994    Addr# -> Int# -> Int#
1995
1996 primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
1997    Addr# -> Int# -> Int#
1998
1999 primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
2000    Addr# -> Int# -> Int#
2001
2002 primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
2003    Addr# -> Int# -> Int64#
2004
2005 primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
2006    Addr# -> Int# -> Word#
2007
2008 primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
2009    Addr# -> Int# -> Word#
2010
2011 primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
2012    Addr# -> Int# -> Word#
2013
2014 primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
2015    Addr# -> Int# -> Word64#
2016
2017 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
2018    Addr# -> Int# -> State# s -> (# State# s, Char# #)
2019    {Reads 8-bit character; offset in bytes.}
2020
2021 primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp
2022    Addr# -> Int# -> State# s -> (# State# s, Char# #)
2023    {Reads 31-bit character; offset in 4-byte words.}
2024
2025 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
2026    Addr# -> Int# -> State# s -> (# State# s, Int# #)
2027
2028 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
2029    Addr# -> Int# -> State# s -> (# State# s, Word# #)
2030
2031 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
2032    Addr# -> Int# -> State# s -> (# State# s, Addr# #)
2033
2034 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
2035    Addr# -> Int# -> State# s -> (# State# s, Float# #)
2036
2037 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
2038    Addr# -> Int# -> State# s -> (# State# s, Double# #)
2039
2040 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
2041    Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
2042
2043 primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
2044    Addr# -> Int# -> State# s -> (# State# s, Int# #)
2045
2046 primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
2047    Addr# -> Int# -> State# s -> (# State# s, Int# #)
2048
2049 primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
2050    Addr# -> Int# -> State# s -> (# State# s, Int# #)
2051
2052 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
2053    Addr# -> Int# -> State# s -> (# State# s, Int64# #)
2054
2055 primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
2056    Addr# -> Int# -> State# s -> (# State# s, Word# #)
2057
2058 primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
2059    Addr# -> Int# -> State# s -> (# State# s, Word# #)
2060
2061 primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
2062    Addr# -> Int# -> State# s -> (# State# s, Word# #)
2063
2064 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
2065    Addr# -> Int# -> State# s -> (# State# s, Word64# #)
2066
2067
2068 primop  WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
2069    Addr# -> Int# -> Char# -> State# s -> State# s
2070    with has_side_effects = True
2071
2072 primop  WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp
2073    Addr# -> Int# -> Char# -> State# s -> State# s
2074    with has_side_effects = True
2075
2076 primop  WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
2077    Addr# -> Int# -> Int# -> State# s -> State# s
2078    with has_side_effects = True
2079
2080 primop  WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
2081    Addr# -> Int# -> Word# -> State# s -> State# s
2082    with has_side_effects = True
2083
2084 primop  WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
2085    Addr# -> Int# -> Addr# -> State# s -> State# s
2086    with has_side_effects = True
2087
2088 primop  WriteOffAddrOp_ForeignObj "writeForeignObjOffAddr#" GenPrimOp
2089    Addr# -> Int# -> ForeignObj# -> State# s -> State# s
2090    with has_side_effects = True
2091
2092 primop  WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
2093    Addr# -> Int# -> Float# -> State# s -> State# s
2094    with has_side_effects = True
2095
2096 primop  WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
2097    Addr# -> Int# -> Double# -> State# s -> State# s
2098    with has_side_effects = True
2099
2100 primop  WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
2101    Addr# -> Int# -> StablePtr# a -> State# s -> State# s
2102    with has_side_effects = True
2103
2104 primop  WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
2105    Addr# -> Int# -> Int# -> State# s -> State# s
2106    with has_side_effects = True
2107
2108 primop  WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
2109    Addr# -> Int# -> Int# -> State# s -> State# s
2110    with has_side_effects = True
2111
2112 primop  WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
2113    Addr# -> Int# -> Int# -> State# s -> State# s
2114    with has_side_effects = True
2115
2116 primop  WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
2117    Addr# -> Int# -> Int64# -> State# s -> State# s
2118    with has_side_effects = True
2119
2120 primop  WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
2121    Addr# -> Int# -> Word# -> State# s -> State# s
2122    with has_side_effects = True
2123
2124 primop  WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
2125    Addr# -> Int# -> Word# -> State# s -> State# s
2126    with has_side_effects = True
2127
2128 primop  WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
2129    Addr# -> Int# -> Word# -> State# s -> State# s
2130    with has_side_effects = True
2131
2132 primop  WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
2133    Addr# -> Int# -> Word64# -> State# s -> State# s
2134    with has_side_effects = True
2135
2136 ------------------------------------------------------------------------
2137 section "ForeignObj#"
2138         {Operations on ForeignObj\#.  The indexing operations are
2139         all deprecated.}
2140 ------------------------------------------------------------------------
2141
2142 primop  MkForeignObjOp "mkForeignObj#" GenPrimOp
2143    Addr# -> State# RealWorld -> (# State# RealWorld, ForeignObj# #)
2144    with
2145    has_side_effects = True
2146    out_of_line      = True
2147
2148 primop  WriteForeignObjOp "writeForeignObj#" GenPrimOp
2149    ForeignObj# -> Addr# -> State# s -> State# s
2150    with
2151    has_side_effects = True
2152
2153 primop ForeignObjToAddrOp "foreignObjToAddr#" GenPrimOp
2154    ForeignObj# -> Addr#
2155
2156 primop TouchOp "touch#" GenPrimOp
2157    o -> State# RealWorld -> State# RealWorld
2158    with
2159    has_side_effects = True
2160    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2161
2162 primop EqForeignObj "eqForeignObj#" GenPrimOp
2163    ForeignObj# -> ForeignObj# -> Bool
2164    with commutable = True
2165
2166 primop IndexOffForeignObjOp_Char "indexCharOffForeignObj#" GenPrimOp
2167    ForeignObj# -> Int# -> Char#
2168    {Read 8-bit character; offset in bytes.}
2169
2170 primop IndexOffForeignObjOp_WideChar "indexWideCharOffForeignObj#" GenPrimOp
2171    ForeignObj# -> Int# -> Char#
2172    {Read 31-bit character; offset in 4-byte words.}
2173
2174 primop IndexOffForeignObjOp_Int "indexIntOffForeignObj#" GenPrimOp
2175    ForeignObj# -> Int# -> Int#
2176
2177 primop IndexOffForeignObjOp_Word "indexWordOffForeignObj#" GenPrimOp
2178    ForeignObj# -> Int# -> Word#
2179
2180 primop IndexOffForeignObjOp_Addr "indexAddrOffForeignObj#" GenPrimOp
2181    ForeignObj# -> Int# -> Addr#
2182
2183 primop IndexOffForeignObjOp_Float "indexFloatOffForeignObj#" GenPrimOp
2184    ForeignObj# -> Int# -> Float#
2185
2186 primop IndexOffForeignObjOp_Double "indexDoubleOffForeignObj#" GenPrimOp
2187    ForeignObj# -> Int# -> Double#
2188
2189 primop IndexOffForeignObjOp_StablePtr "indexStablePtrOffForeignObj#" GenPrimOp
2190    ForeignObj# -> Int# -> StablePtr# a
2191
2192 primop IndexOffForeignObjOp_Int8 "indexInt8OffForeignObj#" GenPrimOp
2193    ForeignObj# -> Int# -> Int#
2194
2195 primop IndexOffForeignObjOp_Int16 "indexInt16OffForeignObj#" GenPrimOp
2196    ForeignObj# -> Int# -> Int#
2197
2198 primop IndexOffForeignObjOp_Int32 "indexInt32OffForeignObj#" GenPrimOp
2199    ForeignObj# -> Int# -> Int#
2200
2201 primop IndexOffForeignObjOp_Int64 "indexInt64OffForeignObj#" GenPrimOp
2202    ForeignObj# -> Int# -> Int64#
2203
2204 primop IndexOffForeignObjOp_Word8 "indexWord8OffForeignObj#" GenPrimOp
2205    ForeignObj# -> Int# -> Word#
2206
2207 primop IndexOffForeignObjOp_Word16 "indexWord16OffForeignObj#" GenPrimOp
2208    ForeignObj# -> Int# -> Word#
2209
2210 primop IndexOffForeignObjOp_Word32 "indexWord32OffForeignObj#" GenPrimOp
2211    ForeignObj# -> Int# -> Word#
2212
2213 primop IndexOffForeignObjOp_Word64 "indexWord64OffForeignObj#" GenPrimOp
2214    ForeignObj# -> Int# -> Word64#
2215
2216
2217
2218 ------------------------------------------------------------------------
2219 section "Mutable variables"
2220         {Operations on MutVar\#s, which behave like single-element mutable arrays.}
2221 ------------------------------------------------------------------------
2222
2223 primop  NewMutVarOp "newMutVar#" GenPrimOp
2224    a -> State# s -> (# State# s, MutVar# s a #)
2225    {Create MutVar\# with specified initial value in specified state thread.}
2226    with
2227    usage       = { mangle NewMutVarOp [mkM, mkP] mkM }
2228    strictness  = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2229    out_of_line = True
2230
2231 primop  ReadMutVarOp "readMutVar#" GenPrimOp
2232    MutVar# s a -> State# s -> (# State# s, a #)
2233    {Read contents of MutVar\#. Result is not yet evaluated.}
2234    with
2235    usage = { mangle ReadMutVarOp [mkM, mkP] mkM }
2236
2237 primop  WriteMutVarOp "writeMutVar#"  GenPrimOp
2238    MutVar# s a -> a -> State# s -> State# s
2239    {Write contents of MutVar\#.}
2240    with
2241    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
2242    usage            = { mangle WriteMutVarOp [mkM, mkM, mkP] mkR }
2243    has_side_effects = True
2244
2245 primop  SameMutVarOp "sameMutVar#" GenPrimOp
2246    MutVar# s a -> MutVar# s a -> Bool
2247    with
2248    usage = { mangle SameMutVarOp [mkP, mkP] mkM }
2249
2250 ------------------------------------------------------------------------
2251 section "Exceptions"
2252 ------------------------------------------------------------------------
2253
2254 primop  CatchOp "catch#" GenPrimOp
2255           (State# RealWorld -> (# State# RealWorld, a #) )
2256        -> (b -> State# RealWorld -> (# State# RealWorld, a #) ) 
2257        -> State# RealWorld
2258        -> (# State# RealWorld, a #)
2259    with
2260    strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwPrim] False }
2261         -- Catch is actually strict in its first argument
2262         -- but we don't want to tell the strictness
2263         -- analyser about that!
2264    usage = { mangle CatchOp [mkM, mkM . (inFun CatchOp mkM mkM), mkP] mkM }
2265         --     [mkO, mkO . (inFun mkM mkO)] mkO
2266         -- might use caught action multiply
2267    out_of_line = True
2268
2269 primop  RaiseOp "raise#" GenPrimOp
2270    a -> b
2271    with
2272    strictness  = { \ arity -> StrictnessInfo [wwLazy] True }
2273       -- NB: True => result is bottom
2274    usage       = { mangle RaiseOp [mkM] mkM }
2275    out_of_line = True
2276
2277 primop  BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
2278         (State# RealWorld -> (# State# RealWorld, a #))
2279      -> (State# RealWorld -> (# State# RealWorld, a #))
2280    with
2281    strictness  = { \ arity -> StrictnessInfo [wwLazy] False }
2282    out_of_line = True
2283
2284 primop  UnblockAsyncExceptionsOp "unblockAsyncExceptions#" GenPrimOp
2285         (State# RealWorld -> (# State# RealWorld, a #))
2286      -> (State# RealWorld -> (# State# RealWorld, a #))
2287    with
2288    strictness  = { \ arity -> StrictnessInfo [wwLazy] False }
2289    out_of_line = True
2290
2291 ------------------------------------------------------------------------
2292 section "Synchronized Mutable Variables"
2293         {Operations on MVar\#s, which are shared mutable variables
2294         ({\it not} the same as MutVar\#s!). (Note: in a non-concurrent implementation,
2295         (MVar\# a) can be represented by (MutVar\# (Maybe a)).)}
2296 ------------------------------------------------------------------------
2297
2298
2299 primop  NewMVarOp "newMVar#"  GenPrimOp
2300    State# s -> (# State# s, MVar# s a #)
2301    {Create new mvar; initially empty.}
2302    with
2303    usage       = { mangle NewMVarOp [mkP] mkR }
2304    out_of_line = True
2305
2306 primop  TakeMVarOp "takeMVar#" GenPrimOp
2307    MVar# s a -> State# s -> (# State# s, a #)
2308    {If mvar is empty, block until it becomes full.
2309    Then remove and return its contents, and set it empty.}
2310    with
2311    usage            = { mangle TakeMVarOp [mkM, mkP] mkM }
2312    has_side_effects = True
2313    out_of_line      = True
2314
2315 primop  TryTakeMVarOp "tryTakeMVar#" GenPrimOp
2316    MVar# s a -> State# s -> (# State# s, Int#, a #)
2317    {If mvar is empty, immediately return with integer 0 and value undefined.
2318    Otherwise, return with integer 1 and contents of mvar, and set mvar empty.}
2319    with
2320    usage            = { mangle TryTakeMVarOp [mkM, mkP] mkM }
2321    has_side_effects = True
2322    out_of_line      = True
2323
2324 primop  PutMVarOp "putMVar#" GenPrimOp
2325    MVar# s a -> a -> State# s -> State# s
2326    {If mvar is full, block until it becomes empty.
2327    Then store value arg as its new contents.}
2328    with
2329    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
2330    usage            = { mangle PutMVarOp [mkM, mkM, mkP] mkR }
2331    has_side_effects = True
2332    out_of_line      = True
2333
2334 primop  TryPutMVarOp "tryPutMVar#" GenPrimOp
2335    MVar# s a -> a -> State# s -> (# State# s, Int# #)
2336    {If mvar is full, immediately return with integer 0.
2337     Otherwise, store value arg as mvar's new contents, and return with integer 1.}
2338    with
2339    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
2340    usage            = { mangle TryPutMVarOp [mkM, mkM, mkP] mkR }
2341    has_side_effects = True
2342    out_of_line      = True
2343
2344 primop  SameMVarOp "sameMVar#" GenPrimOp
2345    MVar# s a -> MVar# s a -> Bool
2346    with
2347    usage = { mangle SameMVarOp [mkP, mkP] mkM }
2348
2349 primop  IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
2350    MVar# s a -> State# s -> (# State# s, Int# #)
2351    {Return 1 if mvar is empty; 0 otherwise.}
2352    with
2353    usage = { mangle IsEmptyMVarOp [mkP, mkP] mkM }
2354
2355
2356 ------------------------------------------------------------------------
2357 section "Delay/wait operations"
2358 ------------------------------------------------------------------------
2359
2360 primop  DelayOp "delay#" GenPrimOp
2361    Int# -> State# s -> State# s
2362    {Sleep specified number of microseconds.}
2363    with
2364    needs_wrapper    = True
2365    has_side_effects = True
2366    out_of_line      = True
2367
2368 primop  WaitReadOp "waitRead#" GenPrimOp
2369    Int# -> State# s -> State# s
2370    {Block until input is available on specified file descriptor.}
2371    with
2372    needs_wrapper    = True
2373    has_side_effects = True
2374    out_of_line      = True
2375
2376 primop  WaitWriteOp "waitWrite#" GenPrimOp
2377    Int# -> State# s -> State# s
2378    {Block until output is possible on specified file descriptor.}
2379    with
2380    needs_wrapper    = True
2381    has_side_effects = True
2382    out_of_line      = True
2383
2384 ------------------------------------------------------------------------
2385 section "Concurrency primitives"
2386         {(In a non-concurrent implementation, ThreadId\# can be as singleton
2387         type, whose (unique) value is returned by myThreadId\#.  The 
2388         other operations can be omitted.)}
2389 ------------------------------------------------------------------------
2390
2391 primop  ForkOp "fork#" GenPrimOp
2392    a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
2393    with
2394    usage            = { mangle ForkOp [mkO, mkP] mkR }
2395    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2396    has_side_effects = True
2397    out_of_line      = True
2398
2399 primop  KillThreadOp "killThread#"  GenPrimOp
2400    ThreadId# -> a -> State# RealWorld -> State# RealWorld
2401    with
2402    usage            = { mangle KillThreadOp [mkP, mkM, mkP] mkR }
2403    has_side_effects = True
2404    out_of_line      = True
2405
2406 primop  YieldOp "yield#" GenPrimOp
2407    State# RealWorld -> State# RealWorld
2408    with
2409    has_side_effects = True
2410    out_of_line      = True
2411
2412 primop  MyThreadIdOp "myThreadId#" GenPrimOp
2413     State# RealWorld -> (# State# RealWorld, ThreadId# #)
2414
2415 ------------------------------------------------------------------------
2416 section "Weak pointers"
2417 ------------------------------------------------------------------------
2418
2419 -- note that tyvar "o" denotes openAlphaTyVar
2420
2421 primop  MkWeakOp "mkWeak#" GenPrimOp
2422    o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
2423    with
2424    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwLazy, wwPrim] False }
2425    usage            = { mangle MkWeakOp [mkZ, mkM, mkM, mkP] mkM }
2426    has_side_effects = True
2427    out_of_line      = True
2428
2429 primop  DeRefWeakOp "deRefWeak#" GenPrimOp
2430    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
2431    with
2432    usage            = { mangle DeRefWeakOp [mkM, mkP] mkM }
2433    has_side_effects = True
2434
2435 primop  FinalizeWeakOp "finalizeWeak#" GenPrimOp
2436    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, 
2437               (State# RealWorld -> (# State# RealWorld, Unit #)) #)
2438    with
2439    usage            = { mangle FinalizeWeakOp [mkM, mkP] 
2440                                (mkR . (inUB FinalizeWeakOp 
2441                                             [id,id,inFun FinalizeWeakOp mkR mkM])) }
2442    has_side_effects = True
2443    out_of_line      = True
2444
2445 ------------------------------------------------------------------------
2446 section "Stable pointers and names"
2447 ------------------------------------------------------------------------
2448
2449 primop  MakeStablePtrOp "makeStablePtr#" GenPrimOp
2450    a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
2451    with
2452    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2453    usage            = { mangle MakeStablePtrOp [mkM, mkP] mkM }
2454    has_side_effects = True
2455
2456 primop  DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
2457    StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
2458    with
2459    usage            = { mangle DeRefStablePtrOp [mkM, mkP] mkM }
2460    needs_wrapper    = True
2461    has_side_effects = True
2462
2463 primop  EqStablePtrOp "eqStablePtr#" GenPrimOp
2464    StablePtr# a -> StablePtr# a -> Int#
2465    with
2466    usage            = { mangle EqStablePtrOp [mkP, mkP] mkR }
2467    has_side_effects = True
2468
2469 primop  MakeStableNameOp "makeStableName#" GenPrimOp
2470    a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
2471    with
2472    usage            = { mangle MakeStableNameOp [mkZ, mkP] mkR }
2473    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2474    needs_wrapper    = True
2475    has_side_effects = True
2476    out_of_line      = True
2477
2478 primop  EqStableNameOp "eqStableName#" GenPrimOp
2479    StableName# a -> StableName# a -> Int#
2480    with
2481    usage = { mangle EqStableNameOp [mkP, mkP] mkR }
2482
2483 primop  StableNameToIntOp "stableNameToInt#" GenPrimOp
2484    StableName# a -> Int#
2485    with
2486    usage = { mangle StableNameToIntOp [mkP] mkR }
2487
2488 ------------------------------------------------------------------------
2489 section "Unsafe pointer equality"
2490 --  (#1 Bad Guy: Alistair Reid :)   
2491 ------------------------------------------------------------------------
2492
2493 primop  ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
2494    a -> a -> Int#
2495    with
2496    usage = { mangle ReallyUnsafePtrEqualityOp [mkZ, mkZ] mkR }
2497
2498 ------------------------------------------------------------------------
2499 section "Parallelism"
2500 ------------------------------------------------------------------------
2501
2502 primop  SeqOp "seq#" GenPrimOp
2503    a -> Int#
2504    with
2505    usage            = { mangle  SeqOp [mkO] mkR }
2506    strictness       = { \ arity -> StrictnessInfo [wwStrict] False }
2507       -- Seq is strict in its argument; see notes in ConFold.lhs
2508    has_side_effects = True
2509
2510 primop  ParOp "par#" GenPrimOp
2511    a -> Int#
2512    with
2513    usage            = { mangle ParOp [mkO] mkR }
2514    strictness       = { \ arity -> StrictnessInfo [wwLazy] False }
2515       -- Note that Par is lazy to avoid that the sparked thing
2516       -- gets evaluted strictly, which it should *not* be
2517    has_side_effects = True
2518
2519 -- HWL: The first 4 Int# in all par... annotations denote:
2520 --   name, granularity info, size of result, degree of parallelism
2521 --      Same  structure as _seq_ i.e. returns Int#
2522 -- KSW: v, the second arg in parAt# and parAtForNow#, is used only to determine
2523 --   `the processor containing the expression v'; it is not evaluated
2524
2525 primop  ParGlobalOp  "parGlobal#"  GenPrimOp
2526    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
2527    with
2528    usage            = { mangle ParGlobalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
2529    has_side_effects = True
2530
2531 primop  ParLocalOp  "parLocal#"  GenPrimOp
2532    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
2533    with
2534    usage            = { mangle ParLocalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
2535    has_side_effects = True
2536
2537 primop  ParAtOp  "parAt#"  GenPrimOp
2538    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
2539    with
2540    usage            = { mangle ParAtOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
2541    has_side_effects = True
2542
2543 primop  ParAtAbsOp  "parAtAbs#"  GenPrimOp
2544    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
2545    with
2546    usage            = { mangle ParAtAbsOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
2547    has_side_effects = True
2548
2549 primop  ParAtRelOp  "parAtRel#" GenPrimOp
2550    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
2551    with
2552    usage            = { mangle ParAtRelOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
2553    has_side_effects = True
2554
2555 primop  ParAtForNowOp  "parAtForNow#" GenPrimOp
2556    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
2557    with
2558    usage            = { mangle ParAtForNowOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
2559    has_side_effects = True
2560
2561 -- copyable# and noFollow# are yet to be implemented (for GpH)
2562 --
2563 --primop  CopyableOp  "copyable#" GenPrimOp
2564 --   a -> Int#
2565 --   with
2566 --   usage            = { mangle CopyableOp [mkZ] mkR }
2567 --   has_side_effects = True
2568 --
2569 --primop  NoFollowOp "noFollow#" GenPrimOp
2570 --   a -> Int#
2571 --   with
2572 --   usage            = { mangle NoFollowOp [mkZ] mkR }
2573 --   has_side_effects = True
2574
2575
2576 ------------------------------------------------------------------------
2577 section "Tag to enum stuff"
2578         {Convert back and forth between values of enumerated types
2579         and small integers.}
2580 ------------------------------------------------------------------------
2581
2582 primop  DataToTagOp "dataToTag#" GenPrimOp
2583    a -> Int#
2584    with
2585    strictness = { \ arity -> StrictnessInfo [wwLazy] False }
2586
2587 primop  TagToEnumOp "tagToEnum#" GenPrimOp     
2588    Int# -> a
2589
2590 ------------------------------------------------------------------------
2591 section "Bytecode operations" 
2592         {Support for the bytecode interpreter and linker.}
2593 ------------------------------------------------------------------------
2594
2595
2596 primop   AddrToHValueOp "addrToHValue#" GenPrimOp
2597    Addr# -> (# a #)
2598    {Convert an Addr\# to a followable type.}
2599
2600 primop   MkApUpd0_Op "mkApUpd0#" GenPrimOp
2601    a -> (# a #)
2602    with
2603    out_of_line = True
2604
2605 primop  NewBCOOp "newBCO#" GenPrimOp
2606    ByteArr# -> ByteArr# -> Array# a -> ByteArr# -> State# s -> (# State# s, BCO# #)
2607    with
2608    has_side_effects = True
2609    out_of_line      = True
2610
2611 ------------------------------------------------------------------------
2612 ---                                                                  ---
2613 ------------------------------------------------------------------------
2614
2615 thats_all_folks
2616
2617
2618