4268859f16f9c35f8dde82cf6e79772ff295fe32
[ghc-hetmet.git] / ghc / compiler / prelude / primops.txt
1 -----------------------------------------------------------------------
2 -- $Id: primops.txt,v 1.26 2001/09/14 15:51:42 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
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 \f
628
629
630
631
632
633 \f
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
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143 section "The word size story."
1144         {Haskell98 specifies that signed integers (type {\tt Int}) must contain at least 30 
1145          bits. GHC always implements {\tt Int} using the primitive type {\tt Int\#}, whose
1146          size equals the {\tt MachDeps.h} constant {\tt WORD\_SIZE\_IN\_BITS}.  This
1147          is normally set based on the {\tt config.h} parameter {\tt SIZEOF\_LONG},
1148          i.e., 32 bits on 32-bit machines, 64 bits on 64-bit machines.  However, it can
1149          also be explicitly set to a smaller number, e.g., 31 bits, to allow the possibility
1150          of using  tag bits. Currently GHC itself has only 32-bit and 64-bit variants,
1151          but 30 or 31-bit code can be exported as an external core file for use in 
1152          other back ends.
1153
1154          GHC also implements a primitive unsigned integer type {\tt Word\#} which always
1155          has the same number of bits as {\tt Int\#}.
1156         
1157          In addition, GHC supports families of explicit-sized integers and words at
1158          8, 16, 32, and 64 bits, with the usual arithmetic operations, comparisons,
1159          and a range of conversions.  The 8-bit and 16-bit sizes are always represented as
1160          {\tt Int\#} and {\tt Word\#}, and the operations implemented in terms of the
1161          the primops on these types, with suitable range restrictions on the results
1162          (using the {\tt narrow$n$Int\#} and {\tt narrow$n$Word\#} families of primops.
1163          The 32-bit sizes are represented using {\tt Int\#} and {\tt Word\#} when 
1164          {\tt WORD\_SIZE\_IN\_BITS} $\geq$ 32;
1165          otherwise, these are represented using distinct primitive types {\tt Int32\#}
1166          and {\tt Word32\#}. These (when needed) have a complete set of corresponding
1167          operations; however, nearly all of these are implemented as external C functions
1168          rather than as primops.  Exactly the same story applies to the 64-bit sizes.    
1169          All of these details are hidden under the {\tt PrelInt} and {\tt PrelWord} modules,
1170          which use {\tt \#if}-defs to invoke the appropriate types and operators.
1171
1172          Word size also matters for the families of primops 
1173          for indexing/reading/writing fixed-size quantities at offsets from
1174          an array base, address, or foreign pointer.  Here, a slightly different approach is taken.
1175          The names of these primops are fixed, but their 
1176          {\it types} vary according to the value of {\tt WORD\_SIZE\_IN\_BITS}. For example, if
1177          word size is at least 32 bits then an operator like \texttt{indexInt32Array\#}  
1178          has type {\tt ByteArr\# -> Int\# -> Int\#}; otherwise it has type 
1179          {\tt ByteArr\# -> Int\# -> Int32\#}.  This approach confines the necessary {\tt \#if}-defs to this file;
1180          no conditional compilation is needed in the files that expose these primops, namely \texttt{lib/std/PrelStorable.lhs},
1181          \texttt{hslibs/lang/ArrayBase.hs}, and (in deprecated fashion) in \texttt{hslibs/lang/ForeignObj.lhs}
1182          and \texttt{hslibs/lang/Addr.lhs}.
1183
1184          Finally, there are strongly deprecated primops for coercing between {\tt Addr\#}, the primitive
1185          type of machine addresses, and {\tt Int\#}.  These are pretty bogus anyway, but will work on
1186          existing 32-bit and 64-bit GHC targets;  they are completely bogus when tag bits are used in
1187          {\tt Int\#}, so are not available in this case.
1188 }
1189         
1190 -- Define synonyms for indexing ops. 
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208 ------------------------------------------------------------------------
1209 section "Char#" 
1210         {Operations on 31-bit characters.}
1211 ------------------------------------------------------------------------
1212
1213
1214 primop   CharGtOp  "gtChar#"   Compare   Char# -> Char# -> Bool
1215 primop   CharGeOp  "geChar#"   Compare   Char# -> Char# -> Bool
1216
1217 primop   CharEqOp  "eqChar#"   Compare
1218    Char# -> Char# -> Bool
1219    with commutable = True
1220
1221 primop   CharNeOp  "neChar#"   Compare
1222    Char# -> Char# -> Bool
1223    with commutable = True
1224
1225 primop   CharLtOp  "ltChar#"   Compare   Char# -> Char# -> Bool
1226 primop   CharLeOp  "leChar#"   Compare   Char# -> Char# -> Bool
1227
1228 primop   OrdOp   "ord#"  GenPrimOp   Char# -> Int#
1229
1230 ------------------------------------------------------------------------
1231 section "Int#"
1232         {Operations on native-size integers (30+ bits).}
1233 ------------------------------------------------------------------------
1234
1235 primop   IntAddOp    "+#"    Dyadic
1236    Int# -> Int# -> Int#
1237    with commutable = True
1238
1239 primop   IntSubOp    "-#"    Dyadic   Int# -> Int# -> Int#
1240
1241 primop   IntMulOp    "*#" 
1242    Dyadic   Int# -> Int# -> Int#
1243    with commutable = True
1244
1245 primop   IntQuotOp    "quotInt#"    Dyadic
1246    Int# -> Int# -> Int#
1247    {Rounds towards zero.}
1248    with can_fail = True
1249
1250 primop   IntRemOp    "remInt#"    Dyadic
1251    Int# -> Int# -> Int#
1252    {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}.}
1253    with can_fail = True
1254
1255 primop   IntGcdOp    "gcdInt#"    Dyadic   Int# -> Int# -> Int#
1256 primop   IntNegOp    "negateInt#"    Monadic   Int# -> Int#
1257 primop   IntAddCOp   "addIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
1258          {Add with carry.  First member of result is (wrapped) sum; second member is 0 iff no overflow occured.}
1259 primop   IntSubCOp   "subIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
1260          {Subtract with carry.  First member of result is (wrapped) difference; second member is 0 iff no overflow occured.}
1261 primop   IntMulCOp   "mulIntC#"    GenPrimOp   Int# -> Int# -> (# Int#, Int# #)
1262          {Multiply with carry.  First member of result is (wrapped) product; second member is 0 iff no overflow occured.}
1263 primop   IntGtOp  ">#"   Compare   Int# -> Int# -> Bool
1264 primop   IntGeOp  ">=#"   Compare   Int# -> Int# -> Bool
1265
1266 primop   IntEqOp  "==#"   Compare
1267    Int# -> Int# -> Bool
1268    with commutable = True
1269
1270 primop   IntNeOp  "/=#"   Compare
1271    Int# -> Int# -> Bool
1272    with commutable = True
1273
1274 primop   IntLtOp  "<#"   Compare   Int# -> Int# -> Bool
1275 primop   IntLeOp  "<=#"   Compare   Int# -> Int# -> Bool
1276
1277 primop   ChrOp   "chr#"   GenPrimOp   Int# -> Char#
1278
1279 primop   Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
1280 primop   Int2FloatOp   "int2Float#"      GenPrimOp  Int# -> Float#
1281 primop   Int2DoubleOp   "int2Double#"          GenPrimOp  Int# -> Double#
1282
1283 primop   Int2IntegerOp    "int2Integer#"
1284    GenPrimOp Int# -> (# Int#, ByteArr# #)
1285    with out_of_line = True
1286
1287 primop   ISllOp   "iShiftL#" GenPrimOp  Int# -> Int# -> Int#
1288          {Shift left. Return 0 if shifted by more than size of an Int\#.} 
1289 primop   ISraOp   "iShiftRA#" GenPrimOp Int# -> Int# -> Int#
1290          {Shift right arithemetic. Return 0 if shifted by more than size of an Int\#.}
1291 primop   ISrlOp   "iShiftRL#" GenPrimOp Int# -> Int# -> Int#
1292          {Shift right logical. Return 0 if shifted by more than size of an Int\#.}
1293
1294 ------------------------------------------------------------------------
1295 section "Word#"
1296         {Operations on native-sized unsigned words (30+ bits).}
1297 ------------------------------------------------------------------------
1298
1299 primop   WordAddOp   "plusWord#"   Dyadic   Word# -> Word# -> Word#
1300    with commutable = True
1301
1302 primop   WordSubOp   "minusWord#"   Dyadic   Word# -> Word# -> Word#
1303
1304 primop   WordMulOp   "timesWord#"   Dyadic   Word# -> Word# -> Word#
1305    with commutable = True
1306
1307 primop   WordQuotOp   "quotWord#"   Dyadic   Word# -> Word# -> Word#
1308    with can_fail = True
1309
1310 primop   WordRemOp   "remWord#"   Dyadic   Word# -> Word# -> Word#
1311    with can_fail = True
1312
1313 primop   AndOp   "and#"   Dyadic   Word# -> Word# -> Word#
1314    with commutable = True
1315
1316 primop   OrOp   "or#"   Dyadic   Word# -> Word# -> Word#
1317    with commutable = True
1318
1319 primop   XorOp   "xor#"   Dyadic   Word# -> Word# -> Word#
1320    with commutable = True
1321
1322 primop   NotOp   "not#"   Monadic   Word# -> Word#
1323
1324 primop   SllOp   "shiftL#"   GenPrimOp   Word# -> Int# -> Word#
1325          {Shift left logical. Return 0 if shifted by more than number of bits in a Word\#.}
1326 primop   SrlOp   "shiftRL#"   GenPrimOp   Word# -> Int# -> Word#
1327          {Shift right logical. Return 0 if shifted by more than number of bits in a Word\#.}
1328
1329 primop   Word2IntOp   "word2Int#"   GenPrimOp   Word# -> Int#
1330
1331 primop   Word2IntegerOp   "word2Integer#"   GenPrimOp 
1332    Word# -> (# Int#, ByteArr# #)
1333    with out_of_line = True
1334
1335 primop   WordGtOp   "gtWord#"   Compare   Word# -> Word# -> Bool
1336 primop   WordGeOp   "geWord#"   Compare   Word# -> Word# -> Bool
1337 primop   WordEqOp   "eqWord#"   Compare   Word# -> Word# -> Bool
1338 primop   WordNeOp   "neWord#"   Compare   Word# -> Word# -> Bool
1339 primop   WordLtOp   "ltWord#"   Compare   Word# -> Word# -> Bool
1340 primop   WordLeOp   "leWord#"   Compare   Word# -> Word# -> Bool
1341
1342 ------------------------------------------------------------------------
1343 section "Narrowings" 
1344         {Explicit narrowing of native-sized ints or words.}
1345 ------------------------------------------------------------------------
1346
1347 primop   Narrow8IntOp      "narrow8Int#"      Monadic   Int# -> Int#
1348 primop   Narrow16IntOp     "narrow16Int#"     Monadic   Int# -> Int#
1349 primop   Narrow32IntOp     "narrow32Int#"     Monadic   Int# -> Int#
1350 primop   Narrow8WordOp     "narrow8Word#"     Monadic   Word# -> Word#
1351 primop   Narrow16WordOp    "narrow16Word#"    Monadic   Word# -> Word#
1352 primop   Narrow32WordOp    "narrow32Word#"    Monadic   Word# -> Word#
1353
1354
1355
1356
1357
1358
1359 ------------------------------------------------------------------------
1360 section "Int64#"
1361         {Operations on 64-bit unsigned words. This type is only used 
1362          if plain Int\# has less than 64 bits. In any case, the operations
1363          are not primops; they are implemented (if needed) as ccalls instead.}
1364 ------------------------------------------------------------------------
1365
1366 primop   Int64ToIntegerOp   "int64ToInteger#" GenPrimOp 
1367    Int64# -> (# Int#, ByteArr# #)
1368    with out_of_line = True
1369
1370 ------------------------------------------------------------------------
1371 section "Word64#"
1372         {Operations on 64-bit unsigned words. This type is only used 
1373          if plain Word\# has less than 64 bits. In any case, the operations
1374          are not primops; they are implemented (if needed) as ccalls instead.}
1375 ------------------------------------------------------------------------
1376
1377 primop   Word64ToIntegerOp   "word64ToInteger#" GenPrimOp
1378    Word64# -> (# Int#, ByteArr# #)
1379    with out_of_line = True
1380
1381
1382
1383 ------------------------------------------------------------------------
1384 section "Integer#"
1385         {Operations on arbitrary-precision integers. These operations are 
1386 implemented via the GMP package. An integer is represented as a pair
1387 consisting of an Int\# representing the number of 'limbs' in use and
1388 the sign, and a ByteArr\# containing the 'limbs' themselves.  Such pairs
1389 are returned as unboxed pairs, but must be passed as separate components.}
1390 ------------------------------------------------------------------------
1391
1392 primop   IntegerAddOp   "plusInteger#" GenPrimOp   
1393    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1394    with commutable = True
1395         out_of_line = True
1396
1397 primop   IntegerSubOp   "minusInteger#" GenPrimOp  
1398    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1399    with out_of_line = True
1400
1401 primop   IntegerMulOp   "timesInteger#" GenPrimOp   
1402    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1403    with commutable = True
1404         out_of_line = True
1405
1406 primop   IntegerGcdOp   "gcdInteger#" GenPrimOp    
1407    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1408    {Greatest common divisor.}
1409    with commutable = True
1410         out_of_line = True
1411
1412 primop   IntegerIntGcdOp   "gcdIntegerInt#" GenPrimOp
1413    Int# -> ByteArr# -> Int# -> Int#
1414    {Greatest common divisor, where second argument is an ordinary Int\#.}
1415    -- with commutable = True  (surely not? APT 8/01)
1416
1417 primop   IntegerDivExactOp   "divExactInteger#" GenPrimOp
1418    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1419    {Divisor is guaranteed to be a factor of dividend.}
1420    with out_of_line = True
1421
1422 primop   IntegerQuotOp   "quotInteger#" GenPrimOp
1423    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1424    {Rounds towards zero.}
1425    with out_of_line = True
1426
1427 primop   IntegerRemOp   "remInteger#" GenPrimOp
1428    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1429    {Satisfies \texttt{plusInteger\# (timesInteger\# (quotInteger\# x y) y) (remInteger\# x y) == x}.}
1430    with out_of_line = True
1431
1432 primop   IntegerCmpOp   "cmpInteger#"   GenPrimOp  
1433    Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
1434    {Returns -1,0,1 according as first argument is less than, equal to, or greater than second argument.}
1435    with needs_wrapper = True
1436
1437 primop   IntegerCmpIntOp   "cmpIntegerInt#" GenPrimOp
1438    Int# -> ByteArr# -> Int# -> Int#
1439    {Returns -1,0,1 according as first argument is less than, equal to, or greater than second argument, which
1440    is an ordinary Int\#.}
1441    with needs_wrapper = True
1442
1443 primop   IntegerQuotRemOp   "quotRemInteger#" GenPrimOp
1444    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
1445    {Compute quot and rem simulaneously.}
1446    with can_fail = True
1447         out_of_line = True
1448
1449 primop   IntegerDivModOp    "divModInteger#"  GenPrimOp
1450    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr#, Int#, ByteArr# #)
1451    {Compute div and mod simultaneously, where div rounds towards negative infinity
1452     and\texttt{(q,r) = divModInteger\#(x,y)} implies \texttt{plusInteger\# (timesInteger\# q y) r = x}.}
1453    with can_fail = True
1454         out_of_line = True
1455
1456 primop   Integer2IntOp   "integer2Int#"    GenPrimOp
1457    Int# -> ByteArr# -> Int#
1458    with needs_wrapper = True
1459
1460 primop   Integer2WordOp   "integer2Word#"   GenPrimOp
1461    Int# -> ByteArr# -> Word#
1462    with needs_wrapper = True
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473 primop   IntegerToInt64Op   "integerToInt64#" GenPrimOp
1474    Int# -> ByteArr# -> Int64#
1475
1476 primop   IntegerToWord64Op   "integerToWord64#" GenPrimOp
1477    Int# -> ByteArr# -> Word64#
1478
1479
1480 primop   IntegerAndOp  "andInteger#" GenPrimOp
1481    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1482    with out_of_line = True
1483
1484 primop   IntegerOrOp  "orInteger#" GenPrimOp
1485    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1486    with out_of_line = True
1487
1488 primop   IntegerXorOp  "xorInteger#" GenPrimOp
1489    Int# -> ByteArr# -> Int# -> ByteArr# -> (# Int#, ByteArr# #)
1490    with out_of_line = True
1491
1492 primop   IntegerComplementOp  "complementInteger#" GenPrimOp
1493    Int# -> ByteArr# -> (# Int#, ByteArr# #)
1494    with out_of_line = True
1495
1496
1497 ------------------------------------------------------------------------
1498 section "Double#"
1499         {Operations on double-precision (64 bit) floating-point numbers.}
1500 ------------------------------------------------------------------------
1501
1502 primop   DoubleGtOp ">##"   Compare   Double# -> Double# -> Bool
1503 primop   DoubleGeOp ">=##"   Compare   Double# -> Double# -> Bool
1504
1505 primop DoubleEqOp "==##"   Compare
1506    Double# -> Double# -> Bool
1507    with commutable = True
1508
1509 primop DoubleNeOp "/=##"   Compare
1510    Double# -> Double# -> Bool
1511    with commutable = True
1512
1513 primop   DoubleLtOp "<##"   Compare   Double# -> Double# -> Bool
1514 primop   DoubleLeOp "<=##"   Compare   Double# -> Double# -> Bool
1515
1516 primop   DoubleAddOp   "+##"   Dyadic
1517    Double# -> Double# -> Double#
1518    with commutable = True
1519
1520 primop   DoubleSubOp   "-##"   Dyadic   Double# -> Double# -> Double#
1521
1522 primop   DoubleMulOp   "*##"   Dyadic
1523    Double# -> Double# -> Double#
1524    with commutable = True
1525
1526 primop   DoubleDivOp   "/##"   Dyadic
1527    Double# -> Double# -> Double#
1528    with can_fail = True
1529
1530 primop   DoubleNegOp   "negateDouble#"  Monadic   Double# -> Double#
1531
1532 primop   Double2IntOp   "double2Int#"          GenPrimOp  Double# -> Int#
1533 primop   Double2FloatOp   "double2Float#" GenPrimOp Double# -> Float#
1534
1535 primop   DoubleExpOp   "expDouble#"      Monadic
1536    Double# -> Double#
1537    with needs_wrapper = True
1538
1539 primop   DoubleLogOp   "logDouble#"      Monadic         
1540    Double# -> Double#
1541    with
1542    needs_wrapper = True
1543    can_fail = True
1544
1545 primop   DoubleSqrtOp   "sqrtDouble#"      Monadic  
1546    Double# -> Double#
1547    with needs_wrapper = True
1548
1549 primop   DoubleSinOp   "sinDouble#"      Monadic          
1550    Double# -> Double#
1551    with needs_wrapper = True
1552
1553 primop   DoubleCosOp   "cosDouble#"      Monadic          
1554    Double# -> Double#
1555    with needs_wrapper = True
1556
1557 primop   DoubleTanOp   "tanDouble#"      Monadic          
1558    Double# -> Double#
1559    with needs_wrapper = True
1560
1561 primop   DoubleAsinOp   "asinDouble#"      Monadic 
1562    Double# -> Double#
1563    with
1564    needs_wrapper = True
1565    can_fail = True
1566
1567 primop   DoubleAcosOp   "acosDouble#"      Monadic  
1568    Double# -> Double#
1569    with
1570    needs_wrapper = True
1571    can_fail = True
1572
1573 primop   DoubleAtanOp   "atanDouble#"      Monadic  
1574    Double# -> Double#
1575    with
1576    needs_wrapper = True
1577
1578 primop   DoubleSinhOp   "sinhDouble#"      Monadic  
1579    Double# -> Double#
1580    with needs_wrapper = True
1581
1582 primop   DoubleCoshOp   "coshDouble#"      Monadic  
1583    Double# -> Double#
1584    with needs_wrapper = True
1585
1586 primop   DoubleTanhOp   "tanhDouble#"      Monadic  
1587    Double# -> Double#
1588    with needs_wrapper = True
1589
1590 primop   DoublePowerOp   "**##" Dyadic  
1591    Double# -> Double# -> Double#
1592    {Exponentiation.}
1593    with needs_wrapper = True
1594
1595 primop   DoubleDecodeOp   "decodeDouble#" GenPrimOp    
1596    Double# -> (# Int#, Int#, ByteArr# #)
1597    {Convert to arbitrary-precision integer.
1598     First Int\# in result is the exponent; second Int\# and ByteArr\# represent an Integer\# 
1599     holding the mantissa.}
1600    with out_of_line = True
1601
1602 ------------------------------------------------------------------------
1603 section "Float#" 
1604         {Operations on single-precision (32-bit) floating-point numbers.}
1605 ------------------------------------------------------------------------
1606
1607 primop   FloatGtOp  "gtFloat#"   Compare   Float# -> Float# -> Bool
1608 primop   FloatGeOp  "geFloat#"   Compare   Float# -> Float# -> Bool
1609
1610 primop   FloatEqOp  "eqFloat#"   Compare
1611    Float# -> Float# -> Bool
1612    with commutable = True
1613
1614 primop   FloatNeOp  "neFloat#"   Compare
1615    Float# -> Float# -> Bool
1616    with commutable = True
1617
1618 primop   FloatLtOp  "ltFloat#"   Compare   Float# -> Float# -> Bool
1619 primop   FloatLeOp  "leFloat#"   Compare   Float# -> Float# -> Bool
1620
1621 primop   FloatAddOp   "plusFloat#"      Dyadic            
1622    Float# -> Float# -> Float#
1623    with commutable = True
1624
1625 primop   FloatSubOp   "minusFloat#"      Dyadic      Float# -> Float# -> Float#
1626
1627 primop   FloatMulOp   "timesFloat#"      Dyadic    
1628    Float# -> Float# -> Float#
1629    with commutable = True
1630
1631 primop   FloatDivOp   "divideFloat#"      Dyadic  
1632    Float# -> Float# -> Float#
1633    with can_fail = True
1634
1635 primop   FloatNegOp   "negateFloat#"      Monadic    Float# -> Float#
1636
1637 primop   Float2IntOp   "float2Int#"      GenPrimOp  Float# -> Int#
1638
1639 primop   FloatExpOp   "expFloat#"      Monadic          
1640    Float# -> Float#
1641    with needs_wrapper = True
1642
1643 primop   FloatLogOp   "logFloat#"      Monadic          
1644    Float# -> Float#
1645    with needs_wrapper = True
1646         can_fail = True
1647
1648 primop   FloatSqrtOp   "sqrtFloat#"      Monadic          
1649    Float# -> Float#
1650    with needs_wrapper = True
1651
1652 primop   FloatSinOp   "sinFloat#"      Monadic          
1653    Float# -> Float#
1654    with needs_wrapper = True
1655
1656 primop   FloatCosOp   "cosFloat#"      Monadic          
1657    Float# -> Float#
1658    with needs_wrapper = True
1659
1660 primop   FloatTanOp   "tanFloat#"      Monadic          
1661    Float# -> Float#
1662    with needs_wrapper = True
1663
1664 primop   FloatAsinOp   "asinFloat#"      Monadic          
1665    Float# -> Float#
1666    with needs_wrapper = True
1667         can_fail = True
1668
1669 primop   FloatAcosOp   "acosFloat#"      Monadic          
1670    Float# -> Float#
1671    with needs_wrapper = True
1672         can_fail = True
1673
1674 primop   FloatAtanOp   "atanFloat#"      Monadic          
1675    Float# -> Float#
1676    with needs_wrapper = True
1677
1678 primop   FloatSinhOp   "sinhFloat#"      Monadic          
1679    Float# -> Float#
1680    with needs_wrapper = True
1681
1682 primop   FloatCoshOp   "coshFloat#"      Monadic          
1683    Float# -> Float#
1684    with needs_wrapper = True
1685
1686 primop   FloatTanhOp   "tanhFloat#"      Monadic          
1687    Float# -> Float#
1688    with needs_wrapper = True
1689
1690 primop   FloatPowerOp   "powerFloat#"      Dyadic   
1691    Float# -> Float# -> Float#
1692    with needs_wrapper = True
1693
1694 primop   Float2DoubleOp   "float2Double#" GenPrimOp  Float# -> Double#
1695
1696 primop   FloatDecodeOp   "decodeFloat#" GenPrimOp
1697    Float# -> (# Int#, Int#, ByteArr# #)
1698    {Convert to arbitrary-precision integer.
1699     First Int\# in result is the exponent; second Int\# and ByteArr\# represent an Integer\# 
1700     holding the mantissa.}
1701    with out_of_line = True
1702
1703 ------------------------------------------------------------------------
1704 section "Arrays"
1705         {Operations on Array\#.}
1706 ------------------------------------------------------------------------
1707
1708 primop  NewArrayOp "newArray#" GenPrimOp
1709    Int# -> a -> State# s -> (# State# s, MutArr# s a #)
1710    {Create a new mutable array of specified size (in bytes),
1711     in the specified state thread,
1712     with each element containing the specified initial value.}
1713    with
1714    strictness  = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
1715    usage       = { mangle NewArrayOp [mkP, mkM, mkP] mkM }
1716    out_of_line = True
1717
1718 primop  SameMutableArrayOp "sameMutableArray#" GenPrimOp
1719    MutArr# s a -> MutArr# s a -> Bool
1720    with
1721    usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
1722
1723 primop  ReadArrayOp "readArray#" GenPrimOp
1724    MutArr# s a -> Int# -> State# s -> (# State# s, a #)
1725    {Read from specified index of mutable array. Result is not yet evaluated.}
1726    with
1727    usage = { mangle ReadArrayOp [mkM, mkP, mkP] mkM }
1728
1729 primop  WriteArrayOp "writeArray#" GenPrimOp
1730    MutArr# s a -> Int# -> a -> State# s -> State# s
1731    {Write to specified index of mutable array.}
1732    with
1733    usage            = { mangle WriteArrayOp [mkM, mkP, mkM, mkP] mkR }
1734    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwPrim, wwLazy, wwPrim] False }
1735    has_side_effects = True
1736
1737 primop  IndexArrayOp "indexArray#" GenPrimOp
1738    Array# a -> Int# -> (# a #)
1739    {Read from specified index of immutable array. Result is packaged into
1740     an unboxed singleton; the result itself is not yet evaluated.}
1741    with
1742    usage = { mangle  IndexArrayOp [mkM, mkP] mkM }
1743
1744 primop  UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
1745    MutArr# s a -> State# s -> (# State# s, Array# a #)
1746    {Make a mutable array immutable, without copying.}
1747    with
1748    usage            = { mangle UnsafeFreezeArrayOp [mkM, mkP] mkM }
1749    has_side_effects = True
1750
1751 primop  UnsafeThawArrayOp  "unsafeThawArray#" GenPrimOp
1752    Array# a -> State# s -> (# State# s, MutArr# s a #)
1753    {Make an immutable array mutable, without copying.}
1754    with
1755    usage       = { mangle UnsafeThawArrayOp [mkM, mkP] mkM }
1756    out_of_line = True
1757
1758 ------------------------------------------------------------------------
1759 section "Byte Arrays"
1760         {Operations on ByteArray\#. A ByteArray\# is a just a region of
1761          raw memory in the garbage-collected heap, which is not scanned
1762          for pointers. It carries its own size (in bytes). There are
1763          three sets of operations for accessing byte array contents:
1764          index for reading from immutable byte arrays, and read/write
1765          for mutable byte arrays.  Each set contains operations for 
1766          a range of useful primitive data types.  Each operation takes  
1767          an offset measured in terms of the size fo the primitive type
1768          being read or written.}
1769
1770 ------------------------------------------------------------------------
1771
1772 primop  NewByteArrayOp_Char "newByteArray#" GenPrimOp
1773    Int# -> State# s -> (# State# s, MutByteArr# s #)
1774    {Create a new mutable byte array of specified size (in bytes), in
1775     the specified state thread.}
1776    with out_of_line = True
1777
1778 primop  NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp
1779    Int# -> State# s -> (# State# s, MutByteArr# s #)
1780    {Create a mutable byte array that the GC guarantees not to move.}
1781    with out_of_line = True
1782
1783 primop  ByteArrayContents_Char "byteArrayContents#" GenPrimOp
1784    ByteArr# -> Addr#
1785    {Intended for use with pinned arrays; otherwise very unsafe!}
1786
1787 primop  SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
1788    MutByteArr# s -> MutByteArr# s -> Bool
1789
1790 primop  UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
1791    MutByteArr# s -> State# s -> (# State# s, ByteArr# #)
1792    {Make a mutable byte array immutable, without copying.}
1793    with
1794    has_side_effects = True
1795
1796 primop  SizeofByteArrayOp "sizeofByteArray#" GenPrimOp  
1797    ByteArr# -> Int#
1798
1799 primop  SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
1800    MutByteArr# s -> Int#
1801
1802
1803 primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
1804    ByteArr# -> Int# -> Char#
1805    {Read 8-bit character; offset in bytes.}
1806
1807 primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp
1808    ByteArr# -> Int# -> Char#
1809    {Read 31-bit character; offset in 4-byte words.}
1810
1811 primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
1812    ByteArr# -> Int# -> Int#
1813
1814 primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
1815    ByteArr# -> Int# -> Word#
1816
1817 primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
1818    ByteArr# -> Int# -> Addr#
1819
1820 primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
1821    ByteArr# -> Int# -> Float#
1822
1823 primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
1824    ByteArr# -> Int# -> Double#
1825
1826 primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
1827    ByteArr# -> Int# -> StablePtr# a
1828
1829 primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
1830    ByteArr# -> Int# -> Int#
1831
1832 primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
1833    ByteArr# -> Int# -> Int#
1834
1835 primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
1836    ByteArr# -> Int# -> Int#
1837
1838 primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
1839    ByteArr# -> Int# -> Int64#
1840
1841 primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
1842    ByteArr# -> Int# -> Word#
1843
1844 primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
1845    ByteArr# -> Int# -> Word#
1846
1847 primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
1848    ByteArr# -> Int# -> Word#
1849
1850 primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
1851    ByteArr# -> Int# -> Word64#
1852
1853 primop  ReadByteArrayOp_Char "readCharArray#" GenPrimOp
1854    MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
1855    {Read 8-bit character; offset in bytes.}
1856
1857 primop  ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp
1858    MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
1859    {Read 31-bit character; offset in 4-byte words.}
1860
1861 primop  ReadByteArrayOp_Int "readIntArray#" GenPrimOp
1862    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
1863
1864 primop  ReadByteArrayOp_Word "readWordArray#" GenPrimOp
1865    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
1866
1867 primop  ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
1868    MutByteArr# s -> Int# -> State# s -> (# State# s, Addr# #)
1869
1870 primop  ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
1871    MutByteArr# s -> Int# -> State# s -> (# State# s, Float# #)
1872
1873 primop  ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
1874    MutByteArr# s -> Int# -> State# s -> (# State# s, Double# #)
1875
1876 primop  ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
1877    MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
1878
1879 primop  ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
1880    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
1881
1882 primop  ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
1883    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
1884
1885 primop  ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
1886    MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
1887
1888 primop  ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
1889    MutByteArr# s -> Int# -> State# s -> (# State# s, Int64# #)
1890
1891 primop  ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
1892    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
1893
1894 primop  ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
1895    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
1896
1897 primop  ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
1898    MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
1899
1900 primop  ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
1901    MutByteArr# s -> Int# -> State# s -> (# State# s, Word64# #)
1902
1903 primop  WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
1904    MutByteArr# s -> Int# -> Char# -> State# s -> State# s
1905    {Write 8-bit character; offset in bytes.}
1906    with has_side_effects = True
1907
1908 primop  WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp
1909    MutByteArr# s -> Int# -> Char# -> State# s -> State# s
1910    {Write 31-bit character; offset in 4-byte words.}
1911    with has_side_effects = True
1912
1913 primop  WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
1914    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
1915    with has_side_effects = True
1916
1917 primop  WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
1918    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
1919    with has_side_effects = True
1920
1921 primop  WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
1922    MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
1923    with has_side_effects = True
1924
1925 primop  WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
1926    MutByteArr# s -> Int# -> Float# -> State# s -> State# s
1927    with has_side_effects = True
1928
1929 primop  WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
1930    MutByteArr# s -> Int# -> Double# -> State# s -> State# s
1931    with has_side_effects = True
1932
1933 primop  WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
1934    MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
1935    with has_side_effects = True
1936
1937 primop  WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
1938    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
1939    with has_side_effects = True
1940
1941 primop  WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
1942    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
1943    with has_side_effects = True
1944
1945 primop  WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
1946    MutByteArr# s -> Int# -> Int# -> State# s -> State# s
1947    with has_side_effects = True
1948
1949 primop  WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
1950    MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
1951    with has_side_effects = True
1952
1953 primop  WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
1954    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
1955    with has_side_effects = True
1956
1957 primop  WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
1958    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
1959    with has_side_effects = True
1960
1961 primop  WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
1962    MutByteArr# s -> Int# -> Word# -> State# s -> State# s
1963    with has_side_effects = True
1964
1965 primop  WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
1966    MutByteArr# s -> Int# -> Word64# -> State# s -> State# s
1967    with has_side_effects = True
1968
1969 ------------------------------------------------------------------------
1970 section "Addr#"
1971         {Addr\# is an arbitrary machine address assumed to point outside
1972          the garbage-collected heap.}
1973 ------------------------------------------------------------------------
1974
1975 primop   AddrNullOp "nullAddr#" GenPrimOp  Int# -> Addr#
1976          {Returns null address. Argument is ignored (nullary primops 
1977           don't quite work!)}
1978 primop   AddrAddOp "plusAddr#" GenPrimOp Addr# -> Int# -> Addr#
1979 primop   AddrSubOp "minusAddr#" GenPrimOp Addr# -> Addr# -> Int#
1980          {Result is meaningless if two Addr\#s are so far apart that their
1981          difference doesn't fit in an Int\#.}
1982 primop   AddrRemOp "remAddr#" GenPrimOp Addr# -> Int# -> Int#
1983          {Return the remainder when the Addr\# arg, treated like an Int\#,
1984           is divided by the Int\# arg.}
1985
1986 primop   Addr2IntOp  "addr2Int#"     GenPrimOp   Addr# -> Int#
1987         {Coerce directly from address to int. Strongly deprecated.}
1988 primop   Int2AddrOp   "int2Addr#"    GenPrimOp  Int# -> Addr#
1989         {Coerce directly from int to address. Strongly deprecated.}
1990
1991
1992 primop   AddrGtOp  "gtAddr#"   Compare   Addr# -> Addr# -> Bool
1993 primop   AddrGeOp  "geAddr#"   Compare   Addr# -> Addr# -> Bool
1994 primop   AddrEqOp  "eqAddr#"   Compare   Addr# -> Addr# -> Bool
1995 primop   AddrNeOp  "neAddr#"   Compare   Addr# -> Addr# -> Bool
1996 primop   AddrLtOp  "ltAddr#"   Compare   Addr# -> Addr# -> Bool
1997 primop   AddrLeOp  "leAddr#"   Compare   Addr# -> Addr# -> Bool
1998
1999 primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
2000    Addr# -> Int# -> Char#
2001    {Reads 8-bit character; offset in bytes.}
2002
2003 primop IndexOffAddrOp_WideChar "indexWideCharOffAddr#" GenPrimOp
2004    Addr# -> Int# -> Char#
2005    {Reads 31-bit character; offset in 4-byte words.}
2006
2007 primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
2008    Addr# -> Int# -> Int#
2009
2010 primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
2011    Addr# -> Int# -> Word#
2012
2013 primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
2014    Addr# -> Int# -> Addr#
2015
2016 primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
2017    Addr# -> Int# -> Float#
2018
2019 primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
2020    Addr# -> Int# -> Double#
2021
2022 primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
2023    Addr# -> Int# -> StablePtr# a
2024
2025 primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
2026    Addr# -> Int# -> Int#
2027
2028 primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
2029    Addr# -> Int# -> Int#
2030
2031 primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
2032    Addr# -> Int# -> Int#
2033
2034 primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
2035    Addr# -> Int# -> Int64#
2036
2037 primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
2038    Addr# -> Int# -> Word#
2039
2040 primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
2041    Addr# -> Int# -> Word#
2042
2043 primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
2044    Addr# -> Int# -> Word#
2045
2046 primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
2047    Addr# -> Int# -> Word64#
2048
2049 primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
2050    Addr# -> Int# -> State# s -> (# State# s, Char# #)
2051    {Reads 8-bit character; offset in bytes.}
2052
2053 primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp
2054    Addr# -> Int# -> State# s -> (# State# s, Char# #)
2055    {Reads 31-bit character; offset in 4-byte words.}
2056
2057 primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
2058    Addr# -> Int# -> State# s -> (# State# s, Int# #)
2059
2060 primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
2061    Addr# -> Int# -> State# s -> (# State# s, Word# #)
2062
2063 primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
2064    Addr# -> Int# -> State# s -> (# State# s, Addr# #)
2065
2066 primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
2067    Addr# -> Int# -> State# s -> (# State# s, Float# #)
2068
2069 primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
2070    Addr# -> Int# -> State# s -> (# State# s, Double# #)
2071
2072 primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
2073    Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
2074
2075 primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
2076    Addr# -> Int# -> State# s -> (# State# s, Int# #)
2077
2078 primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
2079    Addr# -> Int# -> State# s -> (# State# s, Int# #)
2080
2081 primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
2082    Addr# -> Int# -> State# s -> (# State# s, Int# #)
2083
2084 primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
2085    Addr# -> Int# -> State# s -> (# State# s, Int64# #)
2086
2087 primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
2088    Addr# -> Int# -> State# s -> (# State# s, Word# #)
2089
2090 primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
2091    Addr# -> Int# -> State# s -> (# State# s, Word# #)
2092
2093 primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
2094    Addr# -> Int# -> State# s -> (# State# s, Word# #)
2095
2096 primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
2097    Addr# -> Int# -> State# s -> (# State# s, Word64# #)
2098
2099
2100 primop  WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
2101    Addr# -> Int# -> Char# -> State# s -> State# s
2102    with has_side_effects = True
2103
2104 primop  WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp
2105    Addr# -> Int# -> Char# -> State# s -> State# s
2106    with has_side_effects = True
2107
2108 primop  WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
2109    Addr# -> Int# -> Int# -> State# s -> State# s
2110    with has_side_effects = True
2111
2112 primop  WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
2113    Addr# -> Int# -> Word# -> State# s -> State# s
2114    with has_side_effects = True
2115
2116 primop  WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
2117    Addr# -> Int# -> Addr# -> State# s -> State# s
2118    with has_side_effects = True
2119
2120 primop  WriteOffAddrOp_ForeignObj "writeForeignObjOffAddr#" GenPrimOp
2121    Addr# -> Int# -> ForeignObj# -> State# s -> State# s
2122    with has_side_effects = True
2123
2124 primop  WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
2125    Addr# -> Int# -> Float# -> State# s -> State# s
2126    with has_side_effects = True
2127
2128 primop  WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
2129    Addr# -> Int# -> Double# -> State# s -> State# s
2130    with has_side_effects = True
2131
2132 primop  WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
2133    Addr# -> Int# -> StablePtr# a -> State# s -> State# s
2134    with has_side_effects = True
2135
2136 primop  WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
2137    Addr# -> Int# -> Int# -> State# s -> State# s
2138    with has_side_effects = True
2139
2140 primop  WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
2141    Addr# -> Int# -> Int# -> State# s -> State# s
2142    with has_side_effects = True
2143
2144 primop  WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
2145    Addr# -> Int# -> Int# -> State# s -> State# s
2146    with has_side_effects = True
2147
2148 primop  WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
2149    Addr# -> Int# -> Int64# -> State# s -> State# s
2150    with has_side_effects = True
2151
2152 primop  WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
2153    Addr# -> Int# -> Word# -> State# s -> State# s
2154    with has_side_effects = True
2155
2156 primop  WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
2157    Addr# -> Int# -> Word# -> State# s -> State# s
2158    with has_side_effects = True
2159
2160 primop  WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
2161    Addr# -> Int# -> Word# -> State# s -> State# s
2162    with has_side_effects = True
2163
2164 primop  WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
2165    Addr# -> Int# -> Word64# -> State# s -> State# s
2166    with has_side_effects = True
2167
2168 ------------------------------------------------------------------------
2169 section "ForeignObj#"
2170         {Operations on ForeignObj\#.  The indexing operations are
2171         all deprecated.}
2172 ------------------------------------------------------------------------
2173
2174 primop  MkForeignObjOp "mkForeignObj#" GenPrimOp
2175    Addr# -> State# RealWorld -> (# State# RealWorld, ForeignObj# #)
2176    with
2177    has_side_effects = True
2178    out_of_line      = True
2179
2180 primop  WriteForeignObjOp "writeForeignObj#" GenPrimOp
2181    ForeignObj# -> Addr# -> State# s -> State# s
2182    with
2183    has_side_effects = True
2184
2185 primop ForeignObjToAddrOp "foreignObjToAddr#" GenPrimOp
2186    ForeignObj# -> Addr#
2187
2188 primop TouchOp "touch#" GenPrimOp
2189    o -> State# RealWorld -> State# RealWorld
2190    with
2191    has_side_effects = True
2192    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2193
2194 primop EqForeignObj "eqForeignObj#" GenPrimOp
2195    ForeignObj# -> ForeignObj# -> Bool
2196    with commutable = True
2197
2198 primop IndexOffForeignObjOp_Char "indexCharOffForeignObj#" GenPrimOp
2199    ForeignObj# -> Int# -> Char#
2200    {Read 8-bit character; offset in bytes.}
2201
2202 primop IndexOffForeignObjOp_WideChar "indexWideCharOffForeignObj#" GenPrimOp
2203    ForeignObj# -> Int# -> Char#
2204    {Read 31-bit character; offset in 4-byte words.}
2205
2206 primop IndexOffForeignObjOp_Int "indexIntOffForeignObj#" GenPrimOp
2207    ForeignObj# -> Int# -> Int#
2208
2209 primop IndexOffForeignObjOp_Word "indexWordOffForeignObj#" GenPrimOp
2210    ForeignObj# -> Int# -> Word#
2211
2212 primop IndexOffForeignObjOp_Addr "indexAddrOffForeignObj#" GenPrimOp
2213    ForeignObj# -> Int# -> Addr#
2214
2215 primop IndexOffForeignObjOp_Float "indexFloatOffForeignObj#" GenPrimOp
2216    ForeignObj# -> Int# -> Float#
2217
2218 primop IndexOffForeignObjOp_Double "indexDoubleOffForeignObj#" GenPrimOp
2219    ForeignObj# -> Int# -> Double#
2220
2221 primop IndexOffForeignObjOp_StablePtr "indexStablePtrOffForeignObj#" GenPrimOp
2222    ForeignObj# -> Int# -> StablePtr# a
2223
2224 primop IndexOffForeignObjOp_Int8 "indexInt8OffForeignObj#" GenPrimOp
2225    ForeignObj# -> Int# -> Int#
2226
2227 primop IndexOffForeignObjOp_Int16 "indexInt16OffForeignObj#" GenPrimOp
2228    ForeignObj# -> Int# -> Int#
2229
2230 primop IndexOffForeignObjOp_Int32 "indexInt32OffForeignObj#" GenPrimOp
2231    ForeignObj# -> Int# -> Int#
2232
2233 primop IndexOffForeignObjOp_Int64 "indexInt64OffForeignObj#" GenPrimOp
2234    ForeignObj# -> Int# -> Int64#
2235
2236 primop IndexOffForeignObjOp_Word8 "indexWord8OffForeignObj#" GenPrimOp
2237    ForeignObj# -> Int# -> Word#
2238
2239 primop IndexOffForeignObjOp_Word16 "indexWord16OffForeignObj#" GenPrimOp
2240    ForeignObj# -> Int# -> Word#
2241
2242 primop IndexOffForeignObjOp_Word32 "indexWord32OffForeignObj#" GenPrimOp
2243    ForeignObj# -> Int# -> Word#
2244
2245 primop IndexOffForeignObjOp_Word64 "indexWord64OffForeignObj#" GenPrimOp
2246    ForeignObj# -> Int# -> Word64#
2247
2248
2249
2250 ------------------------------------------------------------------------
2251 section "Mutable variables"
2252         {Operations on MutVar\#s, which behave like single-element mutable arrays.}
2253 ------------------------------------------------------------------------
2254
2255 primop  NewMutVarOp "newMutVar#" GenPrimOp
2256    a -> State# s -> (# State# s, MutVar# s a #)
2257    {Create MutVar\# with specified initial value in specified state thread.}
2258    with
2259    usage       = { mangle NewMutVarOp [mkM, mkP] mkM }
2260    strictness  = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2261    out_of_line = True
2262
2263 primop  ReadMutVarOp "readMutVar#" GenPrimOp
2264    MutVar# s a -> State# s -> (# State# s, a #)
2265    {Read contents of MutVar\#. Result is not yet evaluated.}
2266    with
2267    usage = { mangle ReadMutVarOp [mkM, mkP] mkM }
2268
2269 primop  WriteMutVarOp "writeMutVar#"  GenPrimOp
2270    MutVar# s a -> a -> State# s -> State# s
2271    {Write contents of MutVar\#.}
2272    with
2273    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
2274    usage            = { mangle WriteMutVarOp [mkM, mkM, mkP] mkR }
2275    has_side_effects = True
2276
2277 primop  SameMutVarOp "sameMutVar#" GenPrimOp
2278    MutVar# s a -> MutVar# s a -> Bool
2279    with
2280    usage = { mangle SameMutVarOp [mkP, mkP] mkM }
2281
2282 ------------------------------------------------------------------------
2283 section "Exceptions"
2284 ------------------------------------------------------------------------
2285
2286 primop  CatchOp "catch#" GenPrimOp
2287           (State# RealWorld -> (# State# RealWorld, a #) )
2288        -> (b -> State# RealWorld -> (# State# RealWorld, a #) ) 
2289        -> State# RealWorld
2290        -> (# State# RealWorld, a #)
2291    with
2292    strictness = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwPrim] False }
2293         -- Catch is actually strict in its first argument
2294         -- but we don't want to tell the strictness
2295         -- analyser about that!
2296    usage = { mangle CatchOp [mkM, mkM . (inFun CatchOp mkM mkM), mkP] mkM }
2297         --     [mkO, mkO . (inFun mkM mkO)] mkO
2298         -- might use caught action multiply
2299    out_of_line = True
2300
2301 primop  RaiseOp "raise#" GenPrimOp
2302    a -> b
2303    with
2304    strictness  = { \ arity -> StrictnessInfo [wwLazy] True }
2305       -- NB: True => result is bottom
2306    usage       = { mangle RaiseOp [mkM] mkM }
2307    out_of_line = True
2308
2309 primop  BlockAsyncExceptionsOp "blockAsyncExceptions#" GenPrimOp
2310         (State# RealWorld -> (# State# RealWorld, a #))
2311      -> (State# RealWorld -> (# State# RealWorld, a #))
2312    with
2313    strictness  = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2314    out_of_line = True
2315
2316 primop  UnblockAsyncExceptionsOp "unblockAsyncExceptions#" GenPrimOp
2317         (State# RealWorld -> (# State# RealWorld, a #))
2318      -> (State# RealWorld -> (# State# RealWorld, a #))
2319    with
2320    strictness  = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2321    out_of_line = True
2322
2323 ------------------------------------------------------------------------
2324 section "Synchronized Mutable Variables"
2325         {Operations on MVar\#s, which are shared mutable variables
2326         ({\it not} the same as MutVar\#s!). (Note: in a non-concurrent implementation,
2327         (MVar\# a) can be represented by (MutVar\# (Maybe a)).)}
2328 ------------------------------------------------------------------------
2329
2330
2331 primop  NewMVarOp "newMVar#"  GenPrimOp
2332    State# s -> (# State# s, MVar# s a #)
2333    {Create new mvar; initially empty.}
2334    with
2335    usage       = { mangle NewMVarOp [mkP] mkR }
2336    out_of_line = True
2337
2338 primop  TakeMVarOp "takeMVar#" GenPrimOp
2339    MVar# s a -> State# s -> (# State# s, a #)
2340    {If mvar is empty, block until it becomes full.
2341    Then remove and return its contents, and set it empty.}
2342    with
2343    usage            = { mangle TakeMVarOp [mkM, mkP] mkM }
2344    has_side_effects = True
2345    out_of_line      = True
2346
2347 primop  TryTakeMVarOp "tryTakeMVar#" GenPrimOp
2348    MVar# s a -> State# s -> (# State# s, Int#, a #)
2349    {If mvar is empty, immediately return with integer 0 and value undefined.
2350    Otherwise, return with integer 1 and contents of mvar, and set mvar empty.}
2351    with
2352    usage            = { mangle TryTakeMVarOp [mkM, mkP] mkM }
2353    has_side_effects = True
2354    out_of_line      = True
2355
2356 primop  PutMVarOp "putMVar#" GenPrimOp
2357    MVar# s a -> a -> State# s -> State# s
2358    {If mvar is full, block until it becomes empty.
2359    Then store value arg as its new contents.}
2360    with
2361    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
2362    usage            = { mangle PutMVarOp [mkM, mkM, mkP] mkR }
2363    has_side_effects = True
2364    out_of_line      = True
2365
2366 primop  TryPutMVarOp "tryPutMVar#" GenPrimOp
2367    MVar# s a -> a -> State# s -> (# State# s, Int# #)
2368    {If mvar is full, immediately return with integer 0.
2369     Otherwise, store value arg as mvar's new contents, and return with integer 1.}
2370    with
2371    strictness       = { \ arity -> StrictnessInfo [wwPrim, wwLazy, wwPrim] False }
2372    usage            = { mangle TryPutMVarOp [mkM, mkM, mkP] mkR }
2373    has_side_effects = True
2374    out_of_line      = True
2375
2376 primop  SameMVarOp "sameMVar#" GenPrimOp
2377    MVar# s a -> MVar# s a -> Bool
2378    with
2379    usage = { mangle SameMVarOp [mkP, mkP] mkM }
2380
2381 primop  IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
2382    MVar# s a -> State# s -> (# State# s, Int# #)
2383    {Return 1 if mvar is empty; 0 otherwise.}
2384    with
2385    usage = { mangle IsEmptyMVarOp [mkP, mkP] mkM }
2386
2387
2388 ------------------------------------------------------------------------
2389 section "Delay/wait operations"
2390 ------------------------------------------------------------------------
2391
2392 primop  DelayOp "delay#" GenPrimOp
2393    Int# -> State# s -> State# s
2394    {Sleep specified number of microseconds.}
2395    with
2396    needs_wrapper    = True
2397    has_side_effects = True
2398    out_of_line      = True
2399
2400 primop  WaitReadOp "waitRead#" GenPrimOp
2401    Int# -> State# s -> State# s
2402    {Block until input is available on specified file descriptor.}
2403    with
2404    needs_wrapper    = True
2405    has_side_effects = True
2406    out_of_line      = True
2407
2408 primop  WaitWriteOp "waitWrite#" GenPrimOp
2409    Int# -> State# s -> State# s
2410    {Block until output is possible on specified file descriptor.}
2411    with
2412    needs_wrapper    = True
2413    has_side_effects = True
2414    out_of_line      = True
2415
2416 ------------------------------------------------------------------------
2417 section "Concurrency primitives"
2418         {(In a non-concurrent implementation, ThreadId\# can be as singleton
2419         type, whose (unique) value is returned by myThreadId\#.  The 
2420         other operations can be omitted.)}
2421 ------------------------------------------------------------------------
2422
2423 primop  ForkOp "fork#" GenPrimOp
2424    a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
2425    with
2426    usage            = { mangle ForkOp [mkO, mkP] mkR }
2427    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2428    has_side_effects = True
2429    out_of_line      = True
2430
2431 primop  KillThreadOp "killThread#"  GenPrimOp
2432    ThreadId# -> a -> State# RealWorld -> State# RealWorld
2433    with
2434    usage            = { mangle KillThreadOp [mkP, mkM, mkP] mkR }
2435    has_side_effects = True
2436    out_of_line      = True
2437
2438 primop  YieldOp "yield#" GenPrimOp
2439    State# RealWorld -> State# RealWorld
2440    with
2441    has_side_effects = True
2442    out_of_line      = True
2443
2444 primop  MyThreadIdOp "myThreadId#" GenPrimOp
2445     State# RealWorld -> (# State# RealWorld, ThreadId# #)
2446
2447 ------------------------------------------------------------------------
2448 section "Weak pointers"
2449 ------------------------------------------------------------------------
2450
2451 -- note that tyvar "o" denotes openAlphaTyVar
2452
2453 primop  MkWeakOp "mkWeak#" GenPrimOp
2454    o -> b -> c -> State# RealWorld -> (# State# RealWorld, Weak# b #)
2455    with
2456    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwLazy, wwLazy, wwPrim] False }
2457    usage            = { mangle MkWeakOp [mkZ, mkM, mkM, mkP] mkM }
2458    has_side_effects = True
2459    out_of_line      = True
2460
2461 primop  DeRefWeakOp "deRefWeak#" GenPrimOp
2462    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
2463    with
2464    usage            = { mangle DeRefWeakOp [mkM, mkP] mkM }
2465    has_side_effects = True
2466
2467 primop  FinalizeWeakOp "finalizeWeak#" GenPrimOp
2468    Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, 
2469               (State# RealWorld -> (# State# RealWorld, Unit #)) #)
2470    with
2471    usage            = { mangle FinalizeWeakOp [mkM, mkP] 
2472                                (mkR . (inUB FinalizeWeakOp 
2473                                             [id,id,inFun FinalizeWeakOp mkR mkM])) }
2474    has_side_effects = True
2475    out_of_line      = True
2476
2477 ------------------------------------------------------------------------
2478 section "Stable pointers and names"
2479 ------------------------------------------------------------------------
2480
2481 primop  MakeStablePtrOp "makeStablePtr#" GenPrimOp
2482    a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
2483    with
2484    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2485    usage            = { mangle MakeStablePtrOp [mkM, mkP] mkM }
2486    has_side_effects = True
2487
2488 primop  DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
2489    StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
2490    with
2491    usage            = { mangle DeRefStablePtrOp [mkM, mkP] mkM }
2492    needs_wrapper    = True
2493    has_side_effects = True
2494
2495 primop  EqStablePtrOp "eqStablePtr#" GenPrimOp
2496    StablePtr# a -> StablePtr# a -> Int#
2497    with
2498    usage            = { mangle EqStablePtrOp [mkP, mkP] mkR }
2499    has_side_effects = True
2500
2501 primop  MakeStableNameOp "makeStableName#" GenPrimOp
2502    a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
2503    with
2504    usage            = { mangle MakeStableNameOp [mkZ, mkP] mkR }
2505    strictness       = { \ arity -> StrictnessInfo [wwLazy, wwPrim] False }
2506    needs_wrapper    = True
2507    has_side_effects = True
2508    out_of_line      = True
2509
2510 primop  EqStableNameOp "eqStableName#" GenPrimOp
2511    StableName# a -> StableName# a -> Int#
2512    with
2513    usage = { mangle EqStableNameOp [mkP, mkP] mkR }
2514
2515 primop  StableNameToIntOp "stableNameToInt#" GenPrimOp
2516    StableName# a -> Int#
2517    with
2518    usage = { mangle StableNameToIntOp [mkP] mkR }
2519
2520 ------------------------------------------------------------------------
2521 section "Unsafe pointer equality"
2522 --  (#1 Bad Guy: Alistair Reid :)   
2523 ------------------------------------------------------------------------
2524
2525 primop  ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
2526    a -> a -> Int#
2527    with
2528    usage = { mangle ReallyUnsafePtrEqualityOp [mkZ, mkZ] mkR }
2529
2530 ------------------------------------------------------------------------
2531 section "Parallelism"
2532 ------------------------------------------------------------------------
2533
2534 primop  SeqOp "seq#" GenPrimOp
2535    a -> Int#
2536    with
2537    usage            = { mangle  SeqOp [mkO] mkR }
2538    strictness       = { \ arity -> StrictnessInfo [wwStrict] False }
2539       -- Seq is strict in its argument; see notes in ConFold.lhs
2540    has_side_effects = True
2541
2542 primop  ParOp "par#" GenPrimOp
2543    a -> Int#
2544    with
2545    usage            = { mangle ParOp [mkO] mkR }
2546    strictness       = { \ arity -> StrictnessInfo [wwLazy] False }
2547       -- Note that Par is lazy to avoid that the sparked thing
2548       -- gets evaluted strictly, which it should *not* be
2549    has_side_effects = True
2550
2551 -- HWL: The first 4 Int# in all par... annotations denote:
2552 --   name, granularity info, size of result, degree of parallelism
2553 --      Same  structure as _seq_ i.e. returns Int#
2554 -- KSW: v, the second arg in parAt# and parAtForNow#, is used only to determine
2555 --   `the processor containing the expression v'; it is not evaluated
2556
2557 primop  ParGlobalOp  "parGlobal#"  GenPrimOp
2558    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
2559    with
2560    usage            = { mangle ParGlobalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
2561    has_side_effects = True
2562
2563 primop  ParLocalOp  "parLocal#"  GenPrimOp
2564    a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
2565    with
2566    usage            = { mangle ParLocalOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
2567    has_side_effects = True
2568
2569 primop  ParAtOp  "parAt#"  GenPrimOp
2570    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
2571    with
2572    usage            = { mangle ParAtOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
2573    has_side_effects = True
2574
2575 primop  ParAtAbsOp  "parAtAbs#"  GenPrimOp
2576    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
2577    with
2578    usage            = { mangle ParAtAbsOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
2579    has_side_effects = True
2580
2581 primop  ParAtRelOp  "parAtRel#" GenPrimOp
2582    a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
2583    with
2584    usage            = { mangle ParAtRelOp [mkO, mkP, mkP, mkP, mkP, mkM] mkM }
2585    has_side_effects = True
2586
2587 primop  ParAtForNowOp  "parAtForNow#" GenPrimOp
2588    b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
2589    with
2590    usage            = { mangle ParAtForNowOp [mkO, mkZ, mkP, mkP, mkP, mkP, mkM] mkM }
2591    has_side_effects = True
2592
2593 -- copyable# and noFollow# are yet to be implemented (for GpH)
2594 --
2595 --primop  CopyableOp  "copyable#" GenPrimOp
2596 --   a -> Int#
2597 --   with
2598 --   usage            = { mangle CopyableOp [mkZ] mkR }
2599 --   has_side_effects = True
2600 --
2601 --primop  NoFollowOp "noFollow#" GenPrimOp
2602 --   a -> Int#
2603 --   with
2604 --   usage            = { mangle NoFollowOp [mkZ] mkR }
2605 --   has_side_effects = True
2606
2607
2608 ------------------------------------------------------------------------
2609 section "Tag to enum stuff"
2610         {Convert back and forth between values of enumerated types
2611         and small integers.}
2612 ------------------------------------------------------------------------
2613
2614 primop  DataToTagOp "dataToTag#" GenPrimOp
2615    a -> Int#
2616    with
2617    strictness = { \ arity -> StrictnessInfo [wwLazy] False }
2618
2619 primop  TagToEnumOp "tagToEnum#" GenPrimOp     
2620    Int# -> a
2621
2622 ------------------------------------------------------------------------
2623 section "Bytecode operations" 
2624         {Support for the bytecode interpreter and linker.}
2625 ------------------------------------------------------------------------
2626
2627
2628 primop   AddrToHValueOp "addrToHValue#" GenPrimOp
2629    Addr# -> (# a #)
2630    {Convert an Addr\# to a followable type.}
2631
2632 primop   MkApUpd0_Op "mkApUpd0#" GenPrimOp
2633    a -> (# a #)
2634    with
2635    out_of_line = True
2636
2637 primop  NewBCOOp "newBCO#" GenPrimOp
2638    ByteArr# -> ByteArr# -> Array# a -> ByteArr# -> State# s -> (# State# s, BCO# #)
2639    with
2640    has_side_effects = True
2641    out_of_line      = True
2642
2643 ------------------------------------------------------------------------
2644 ---                                                                  ---
2645 ------------------------------------------------------------------------
2646
2647 thats_all_folks
2648
2649
2650