@@ -0,0 +1,8711 @@
1+diff --git a/GIT_COMMIT_ID b/GIT_COMMIT_ID
2+index b28416b..d739f3b 100644
3+--- a/GIT_COMMIT_ID
4++++ b/GIT_COMMIT_ID
5+@@ -1 +1 @@
6+-3bed09b2efd3df678c5d0752d2cdfba20d7c4863
7+\ No newline at end of file
8++-n 39e711436400ecde05961224fa37759f2c2ff862
9+diff --git a/boot b/boot
10+index 7dc2983..7bf2196 100755
11+--- a/boot
12++++ b/boot
13+@@ -113,12 +113,13 @@ def boot_pkgs():
14+ elif len(cabals) == 1:
15+ cabal = cabals[0]
16+
17+- if os.path.isfile(cabal):
18++ ghc_mk = os.path.join(package, 'ghc.mk')
19++
20++ if os.path.isfile(cabal) and not os.path.isfile(ghc_mk):
21+ # strip both .cabal and .in
22+ pkg = os.path.splitext(os.path.splitext(os.path.basename(cabal))[0])[0]
23+ top = package
24+
25+- ghc_mk = os.path.join(package, 'ghc.mk')
26+ print('Creating %s' % ghc_mk)
27+ with open(ghc_mk, 'w') as f:
28+ f.write(dedent(
29+diff --git a/compiler/HsVersions.h b/compiler/HsVersions.h
30+deleted file mode 100644
31+index a4ec3e4..0000000
32+--- a/compiler/HsVersions.h
33++++ /dev/null
34+@@ -1,65 +0,0 @@
35+-#pragma once
36+-
37+-#if 0
38+-
39+-IMPORTANT! If you put extra tabs/spaces in these macro definitions,
40+-you will screw up the layout where they are used in case expressions!
41+-
42+-(This is cpp-dependent, of course)
43+-
44+-#endif
45+-
46+-/* Useful in the headers that we share with the RTS */
47+-#define COMPILING_GHC 1
48+-
49+-/* Pull in all the platform defines for this build (foo_TARGET_ARCH etc.) */
50+-#include "ghc_boot_platform.h"
51+-
52+-/* Pull in the autoconf defines (HAVE_FOO), but don't include
53+- * ghcconfig.h, because that will include ghcplatform.h which has the
54+- * wrong platform settings for the compiler (it has the platform
55+- * settings for the target plat instead). */
56+-#include "ghcautoconf.h"
57+-
58+-#define GLOBAL_VAR(name,value,ty) \
59+-{-# NOINLINE name #-}; \
60+-name :: IORef (ty); \
61+-name = Util.global (value);
62+-
63+-#define GLOBAL_VAR_M(name,value,ty) \
64+-{-# NOINLINE name #-}; \
65+-name :: IORef (ty); \
66+-name = Util.globalM (value);
67+-
68+-
69+-#define SHARED_GLOBAL_VAR(name,accessor,saccessor,value,ty) \
70+-{-# NOINLINE name #-}; \
71+-name :: IORef (ty); \
72+-name = Util.sharedGlobal (value) (accessor); \
73+-foreign import ccall unsafe saccessor \
74+- accessor :: Ptr (IORef a) -> IO (Ptr (IORef a));
75+-
76+-#define SHARED_GLOBAL_VAR_M(name,accessor,saccessor,value,ty) \
77+-{-# NOINLINE name #-}; \
78+-name :: IORef (ty); \
79+-name = Util.sharedGlobalM (value) (accessor); \
80+-foreign import ccall unsafe saccessor \
81+- accessor :: Ptr (IORef a) -> IO (Ptr (IORef a));
82+-
83+-
84+-#define ASSERT(e) if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else
85+-#define ASSERT2(e,msg) if debugIsOn && not (e) then (assertPprPanic __FILE__ __LINE__ (msg)) else
86+-#define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg)) $
87+-
88+--- Examples: Assuming flagSet :: String -> m Bool
89+---
90+--- do { c <- getChar; MASSERT( isUpper c ); ... }
91+--- do { c <- getChar; MASSERT2( isUpper c, text "Bad" ); ... }
92+--- do { str <- getStr; ASSERTM( flagSet str ); .. }
93+--- do { str <- getStr; ASSERTM2( flagSet str, text "Bad" ); .. }
94+--- do { str <- getStr; WARNM2( flagSet str, text "Flag is set" ); .. }
95+-#define MASSERT(e) ASSERT(e) return ()
96+-#define MASSERT2(e,msg) ASSERT2(e,msg) return ()
97+-#define ASSERTM(e) do { bool <- e; MASSERT(bool) }
98+-#define ASSERTM2(e,msg) do { bool <- e; MASSERT2(bool,msg) }
99+-#define WARNM2(e,msg) do { bool <- e; WARN(bool, msg) return () }
100+diff --git a/compiler/cmm/Bitmap.hs b/compiler/cmm/Bitmap.hs
101+index 6ff6193..a432c58 100644
102+--- a/compiler/cmm/Bitmap.hs
103++++ b/compiler/cmm/Bitmap.hs
104+@@ -16,7 +16,7 @@ module Bitmap (
105+ ) where
106+
107+ #include "HsVersions.h"
108+-#include "../includes/MachDeps.h"
109++#include "MachDeps.h"
110+
111+ import GhcPrelude
112+
113+diff --git a/compiler/cmm/CmmParse.hs b/compiler/cmm/CmmParse.hs
114+index 64514ff..70f891e 100644
115+--- a/compiler/cmm/CmmParse.hs
116++++ b/compiler/cmm/CmmParse.hs
117+@@ -3157,11 +3157,9 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
118+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
119+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
120+ {-# LINE 1 "<built-in>" #-}
121+-{-# LINE 1 "<command-line>" #-}
122+-{-# LINE 11 "<command-line>" #-}
123+-# 1 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 1 3 4
124++{-# LINE 18 "<built-in>" #-}
125++{-# LINE 1 "/usr/local/Cellar/ghc/8.4.4/lib/ghc-8.4.4/include/ghcversion.h" #-}
126+
127+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
128+
129+
130+
131+@@ -3177,6 +3175,8 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
132+
133+
134+
135++{-# LINE 19 "<built-in>" #-}
136++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
137+
138+
139+
140+@@ -3208,8 +3208,6 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
141+
142+
143+
144+-{-# LINE 11 "<command-line>" #-}
145+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
146+
147+
148+
149+@@ -3225,8 +3223,6 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
150+
151+
152+
153+-{-# LINE 11 "<command-line>" #-}
154+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
155+
156+
157+
158+@@ -3362,52 +3358,7 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
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+-{-# LINE 11 "<command-line>" #-}
208++{-# LINE 20 "<built-in>" #-}
209+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
210+ -- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
211+
212+@@ -3433,6 +3384,7 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
213+ #define GTE(n,m) (n Happy_GHC_Exts.>=# m)
214+ #define EQ(n,m) (n Happy_GHC_Exts.==# m)
215+ #endif
216++
217+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
218+
219+ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
220+@@ -3443,11 +3395,20 @@ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
221+
222+
223+
224++
225+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
226+
227++
228+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
229+
230+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
231++
232++
233++
234++
235++
236++
237++
238++
239+
240+ infixr 9 `HappyStk`
241+ data HappyStk a = HappyStk a (HappyStk a)
242+@@ -3475,7 +3436,7 @@ happyAccept j tk st sts (HappyStk ans _) =
243+
244+ happyDoAction i tk st
245+ = {- nothing -}
246+-
247++
248+
249+ case action of
250+ 0# -> {- nothing -}
251+@@ -3483,11 +3444,11 @@ happyDoAction i tk st
252+ -1# -> {- nothing -}
253+ happyAccept i tk st
254+ n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}
255+-
256++
257+ (happyReduceArr Happy_Data_Array.! rule) i tk st
258+ where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))
259+ n -> {- nothing -}
260+-
261++
262+
263+ happyShift new_state i tk st
264+ where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#))
265+@@ -3533,6 +3494,7 @@ data HappyAddr = HappyA# Happy_GHC_Exts.Addr#
266+ -----------------------------------------------------------------------------
267+ -- HappyState data type (not arrays)
268+
269++
270+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
271+
272+ -----------------------------------------------------------------------------
273+@@ -3698,3 +3660,4 @@ happyDontSeq a b = b
274+ {-# NOINLINE happyFail #-}
275+
276+ -- end of Happy Template.
277++
278+diff --git a/compiler/cmm/PprCmmDecl.hs b/compiler/cmm/PprCmmDecl.hs
279+index 968e872..1ed0d6e 100644
280+--- a/compiler/cmm/PprCmmDecl.hs
281++++ b/compiler/cmm/PprCmmDecl.hs
282+@@ -54,7 +54,7 @@ import System.IO
283+
284+ -- Temp Jan08
285+ import SMRep
286+-#include "../includes/rts/storage/FunTypes.h"
287++#include "rts/storage/FunTypes.h"
288+
289+
290+ pprCmms :: (Outputable info, Outputable g)
291+diff --git a/compiler/cmm/SMRep.hs b/compiler/cmm/SMRep.hs
292+index 1469ae1..c8ae5c0 100644
293+--- a/compiler/cmm/SMRep.hs
294++++ b/compiler/cmm/SMRep.hs
295+@@ -47,8 +47,8 @@ module SMRep (
296+ pprWord8String, stringToWord8s
297+ ) where
298+
299+-#include "../HsVersions.h"
300+-#include "../includes/MachDeps.h"
301++#include "HsVersions.h"
302++#include "MachDeps.h"
303+
304+ import GhcPrelude
305+
306+@@ -424,8 +424,8 @@ cardTableSizeW dflags elems =
307+ -----------------------------------------------------------------------------
308+ -- deriving the RTS closure type from an SMRep
309+
310+-#include "../includes/rts/storage/ClosureTypes.h"
311+-#include "../includes/rts/storage/FunTypes.h"
312++#include "rts/storage/ClosureTypes.h"
313++#include "rts/storage/FunTypes.h"
314+ -- Defines CONSTR, CONSTR_1_0 etc
315+
316+ -- | Derives the RTS closure type from an 'SMRep'
317+diff --git a/compiler/codeGen/CodeGen/Platform/ARM.hs b/compiler/codeGen/CodeGen/Platform/ARM.hs
318+index a2cb476..f1ea503 100644
319+--- a/compiler/codeGen/CodeGen/Platform/ARM.hs
320++++ b/compiler/codeGen/CodeGen/Platform/ARM.hs
321+@@ -6,5 +6,5 @@ import GhcPrelude
322+
323+ #define MACHREGS_NO_REGS 0
324+ #define MACHREGS_arm 1
325+-#include "../../../../includes/CodeGen.Platform.hs"
326++#include "CodeGen.Platform.hs"
327+
328+diff --git a/compiler/codeGen/CodeGen/Platform/ARM64.hs b/compiler/codeGen/CodeGen/Platform/ARM64.hs
329+index 6ace181..7a25fb8 100644
330+--- a/compiler/codeGen/CodeGen/Platform/ARM64.hs
331++++ b/compiler/codeGen/CodeGen/Platform/ARM64.hs
332+@@ -6,5 +6,5 @@ import GhcPrelude
333+
334+ #define MACHREGS_NO_REGS 0
335+ #define MACHREGS_aarch64 1
336+-#include "../../../../includes/CodeGen.Platform.hs"
337++#include "CodeGen.Platform.hs"
338+
339+diff --git a/compiler/codeGen/CodeGen/Platform/NoRegs.hs b/compiler/codeGen/CodeGen/Platform/NoRegs.hs
340+index 4c074ee..4a34c78 100644
341+--- a/compiler/codeGen/CodeGen/Platform/NoRegs.hs
342++++ b/compiler/codeGen/CodeGen/Platform/NoRegs.hs
343+@@ -5,5 +5,5 @@ module CodeGen.Platform.NoRegs where
344+ import GhcPrelude
345+
346+ #define MACHREGS_NO_REGS 1
347+-#include "../../../../includes/CodeGen.Platform.hs"
348++#include "CodeGen.Platform.hs"
349+
350+diff --git a/compiler/codeGen/CodeGen/Platform/PPC.hs b/compiler/codeGen/CodeGen/Platform/PPC.hs
351+index f7eae6b..7dd4587 100644
352+--- a/compiler/codeGen/CodeGen/Platform/PPC.hs
353++++ b/compiler/codeGen/CodeGen/Platform/PPC.hs
354+@@ -6,5 +6,5 @@ import GhcPrelude
355+
356+ #define MACHREGS_NO_REGS 0
357+ #define MACHREGS_powerpc 1
358+-#include "../../../../includes/CodeGen.Platform.hs"
359++#include "CodeGen.Platform.hs"
360+
361+diff --git a/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs b/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs
362+index 91923fd..b0eb097 100644
363+--- a/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs
364++++ b/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs
365+@@ -7,5 +7,5 @@ import GhcPrelude
366+ #define MACHREGS_NO_REGS 0
367+ #define MACHREGS_powerpc 1
368+ #define MACHREGS_darwin 1
369+-#include "../../../../includes/CodeGen.Platform.hs"
370++#include "CodeGen.Platform.hs"
371+
372+diff --git a/compiler/codeGen/CodeGen/Platform/SPARC.hs b/compiler/codeGen/CodeGen/Platform/SPARC.hs
373+index 5d8dbb1..2eeb55c 100644
374+--- a/compiler/codeGen/CodeGen/Platform/SPARC.hs
375++++ b/compiler/codeGen/CodeGen/Platform/SPARC.hs
376+@@ -6,5 +6,5 @@ import GhcPrelude
377+
378+ #define MACHREGS_NO_REGS 0
379+ #define MACHREGS_sparc 1
380+-#include "../../../../includes/CodeGen.Platform.hs"
381++#include "CodeGen.Platform.hs"
382+
383+diff --git a/compiler/codeGen/CodeGen/Platform/X86.hs b/compiler/codeGen/CodeGen/Platform/X86.hs
384+index 84d52c1..fc3e384 100644
385+--- a/compiler/codeGen/CodeGen/Platform/X86.hs
386++++ b/compiler/codeGen/CodeGen/Platform/X86.hs
387+@@ -6,5 +6,5 @@ import GhcPrelude
388+
389+ #define MACHREGS_NO_REGS 0
390+ #define MACHREGS_i386 1
391+-#include "../../../../includes/CodeGen.Platform.hs"
392++#include "CodeGen.Platform.hs"
393+
394+diff --git a/compiler/codeGen/CodeGen/Platform/X86_64.hs b/compiler/codeGen/CodeGen/Platform/X86_64.hs
395+index 1b2b554..0a26a1f 100644
396+--- a/compiler/codeGen/CodeGen/Platform/X86_64.hs
397++++ b/compiler/codeGen/CodeGen/Platform/X86_64.hs
398+@@ -6,5 +6,5 @@ import GhcPrelude
399+
400+ #define MACHREGS_NO_REGS 0
401+ #define MACHREGS_x86_64 1
402+-#include "../../../../includes/CodeGen.Platform.hs"
403++#include "CodeGen.Platform.hs"
404+
405+diff --git a/compiler/codeGen/StgCmmClosure.hs b/compiler/codeGen/StgCmmClosure.hs
406+index 2501ec9..6c80c6e 100644
407+--- a/compiler/codeGen/StgCmmClosure.hs
408++++ b/compiler/codeGen/StgCmmClosure.hs
409+@@ -62,7 +62,7 @@ module StgCmmClosure (
410+ staticClosureNeedsLink,
411+ ) where
412+
413+-#include "../includes/MachDeps.h"
414++#include "MachDeps.h"
415+
416+ #include "HsVersions.h"
417+
418+diff --git a/compiler/codeGen/StgCmmLayout.hs b/compiler/codeGen/StgCmmLayout.hs
419+index a0a64e5..37a1075 100644
420+--- a/compiler/codeGen/StgCmmLayout.hs
421++++ b/compiler/codeGen/StgCmmLayout.hs
422+@@ -527,7 +527,7 @@ mkVirtConstrSizes dflags field_reps
423+ -------------------------------------------------------------------------
424+
425+ -- bring in ARG_P, ARG_N, etc.
426+-#include "../includes/rts/storage/FunTypes.h"
427++#include "rts/storage/FunTypes.h"
428+
429+ mkArgDescr :: DynFlags -> [Id] -> ArgDescr
430+ mkArgDescr dflags args
431+diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in
432+index 9205648..edf1612 100644
433+--- a/compiler/ghc.cabal.in
434++++ b/compiler/ghc.cabal.in
435+@@ -20,31 +20,37 @@ Category: Development
436+ Build-Type: Simple
437+ Cabal-Version: >=1.10
438+
439++extra-source-files:
440++ utils/md5.h
441++ Unique.h
442++ nativeGen/NCG.h
443++ parser/cutils.h
444++
445+ Flag ghci
446+ Description: Build GHCi support.
447+ Default: False
448+ Manual: True
449+
450++Flag terminfo
451++ Description: Build GHC with terminfo support on non-Windows platforms.
452++ Default: True
453++ Manual: True
454++
455+ Flag stage1
456+- Description: Is this stage 1?
457++ Description: Build Stage1 GHC (STAGE=1)
458+ Default: False
459+ Manual: True
460+
461+ Flag stage2
462+- Description: Is this stage 2?
463+- Default: False
464++ Description: Build Stage1 GHC (STAGE=2)
465++ Default: True
466+ Manual: True
467+
468+ Flag stage3
469+- Description: Is this stage 3?
470++ Description: Build Stage1 GHC (STAGE=3)
471+ Default: False
472+ Manual: True
473+
474+-Flag terminfo
475+- Description: Build GHC with terminfo support on non-Windows platforms.
476+- Default: True
477+- Manual: True
478+-
479+ Library
480+ Default-Language: Haskell2010
481+ Exposed: False
482+@@ -66,6 +72,9 @@ Library
483+ ghc-boot-th == @ProjectVersionMunged@,
484+ ghci == @ProjectVersionMunged@
485+
486++ build-tool-depends: alex:alex,
487++ happy:happy
488++
489+ if os(windows)
490+ Build-Depends: Win32 >= 2.3 && < 2.7
491+ else
492+@@ -79,6 +88,15 @@ Library
493+ -Wnoncanonical-monadfail-instances
494+ -Wnoncanonical-monoid-instances
495+
496++ if flag(stage1)
497++ ghc-options: -DSTAGE=1
498++ else
499++ if flag(stage2)
500++ ghc-options: -DSTAGE=2
501++ else
502++ if flag(stage3)
503++ ghc-options: -DSTAGE=3
504++
505+ if flag(ghci)
506+ CPP-Options: -DGHCI
507+ Include-Dirs: ../rts/dist/build @FFIIncludeDir@
508+@@ -118,17 +136,6 @@ Library
509+ -- as it's magic.
510+ GHC-Options: -this-unit-id ghc
511+
512+- if flag(stage1)
513+- Include-Dirs: stage1
514+- else
515+- if flag(stage2)
516+- Include-Dirs: stage2
517+- else
518+- if flag(stage3)
519+- Include-Dirs: stage2
520+-
521+- Install-Includes: HsVersions.h, ghc_boot_platform.h
522+-
523+ c-sources:
524+ parser/cutils.c
525+ ghci/keepCAFsForGHCi.c
526+diff --git a/compiler/ghc.mk b/compiler/ghc.mk
527+index 9bc6b3f..710ac64 100644
528+--- a/compiler/ghc.mk
529++++ b/compiler/ghc.mk
530+@@ -30,9 +30,7 @@ compiler_stage1_C_FILES_NODEPS = compiler/parser/cutils.c
531+ compiler_NO_CHECK = YES
532+
533+ ifneq "$(BINDIST)" "YES"
534+-compiler/stage1/package-data.mk : compiler/stage1/build/Config.hs
535+-compiler/stage2/package-data.mk : compiler/stage2/build/Config.hs
536+-compiler/stage3/package-data.mk : compiler/stage3/build/Config.hs
537++compiler/main/Config.hs : rts/build/config.hs-incl
538+
539+ compiler/stage1/build/PlatformConstants.o: $(includes_GHCCONSTANTS_HASKELL_TYPE)
540+ compiler/stage2/build/PlatformConstants.o: $(includes_GHCCONSTANTS_HASKELL_TYPE)
541+@@ -45,276 +43,6 @@ compiler/stage2/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
542+ compiler/stage3/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
543+ endif
544+
545+-compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
546+- $(call removeFiles,$@)
547+- @echo 'Creating $@ ... '
548+- @echo '{-# LANGUAGE CPP #-}' >> $@
549+- @echo 'module Config where' >> $@
550+- @echo >> $@
551+- @echo 'import GhcPrelude' >> $@
552+- @echo >> $@
553+- @echo '#include "ghc_boot_platform.h"' >> $@
554+- @echo >> $@
555+- @echo 'data IntegerLibrary = IntegerGMP' >> $@
556+- @echo ' | IntegerSimple' >> $@
557+- @echo ' deriving Eq' >> $@
558+- @echo >> $@
559+- @echo 'cBuildPlatformString :: String' >> $@
560+- @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@
561+- @echo 'cHostPlatformString :: String' >> $@
562+- @echo 'cHostPlatformString = HostPlatform_NAME' >> $@
563+- @echo 'cTargetPlatformString :: String' >> $@
564+- @echo 'cTargetPlatformString = TargetPlatform_NAME' >> $@
565+- @echo >> $@
566+- @echo 'cProjectName :: String' >> $@
567+- @echo 'cProjectName = "$(ProjectName)"' >> $@
568+- @echo 'cProjectGitCommitId :: String' >> $@
569+- @echo 'cProjectGitCommitId = "$(ProjectGitCommitId)"' >> $@
570+- @echo 'cProjectVersion :: String' >> $@
571+- @echo 'cProjectVersion = "$(ProjectVersion)"' >> $@
572+- @echo 'cProjectVersionInt :: String' >> $@
573+- @echo 'cProjectVersionInt = "$(ProjectVersionInt)"' >> $@
574+- @echo 'cProjectPatchLevel :: String' >> $@
575+- @echo 'cProjectPatchLevel = "$(ProjectPatchLevel)"' >> $@
576+- @echo 'cProjectPatchLevel1 :: String' >> $@
577+- @echo 'cProjectPatchLevel1 = "$(ProjectPatchLevel1)"' >> $@
578+- @echo 'cProjectPatchLevel2 :: String' >> $@
579+- @echo 'cProjectPatchLevel2 = "$(ProjectPatchLevel2)"' >> $@
580+- @echo 'cBooterVersion :: String' >> $@
581+- @echo 'cBooterVersion = "$(GhcVersion)"' >> $@
582+- @echo 'cStage :: String' >> $@
583+- @echo 'cStage = show (STAGE :: Int)' >> $@
584+- @echo 'cIntegerLibrary :: String' >> $@
585+- @echo 'cIntegerLibrary = "$(INTEGER_LIBRARY)"' >> $@
586+- @echo 'cIntegerLibraryType :: IntegerLibrary' >> $@
587+-ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
588+- @echo 'cIntegerLibraryType = IntegerGMP' >> $@
589+-else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
590+- @echo 'cIntegerLibraryType = IntegerSimple' >> $@
591+-else ifneq "$(CLEANING)" "YES"
592+-$(error Unknown integer library)
593+-endif
594+- @echo 'cSupportsSplitObjs :: String' >> $@
595+- @echo 'cSupportsSplitObjs = "$(SupportsSplitObjs)"' >> $@
596+- @echo 'cGhcWithInterpreter :: String' >> $@
597+- @echo 'cGhcWithInterpreter = "$(GhcWithInterpreter)"' >> $@
598+- @echo 'cGhcWithNativeCodeGen :: String' >> $@
599+- @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"' >> $@
600+- @echo 'cGhcWithSMP :: String' >> $@
601+- @echo 'cGhcWithSMP = "$(GhcWithSMP)"' >> $@
602+- @echo 'cGhcRTSWays :: String' >> $@
603+- @echo 'cGhcRTSWays = "$(GhcRTSWays)"' >> $@
604+- @echo 'cGhcRtsWithLibdw :: Bool' >> $@
605+-ifeq "$(GhcRtsWithLibdw)" "YES"
606+- @echo 'cGhcRtsWithLibdw = True' >> $@
607+-else
608+- @echo 'cGhcRtsWithLibdw = False' >> $@
609+-endif
610+- @echo 'cGhcEnableTablesNextToCode :: String' >> $@
611+- @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
612+- @echo 'cLeadingUnderscore :: String' >> $@
613+- @echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
614+- @echo 'cGHC_UNLIT_PGM :: String' >> $@
615+- @echo 'cGHC_UNLIT_PGM = "$(utils/unlit_dist_PROG)"' >> $@
616+- @echo 'cGHC_SPLIT_PGM :: String' >> $@
617+- @echo 'cGHC_SPLIT_PGM = "$(driver/split_dist_PROG)"' >> $@
618+- @echo 'cLibFFI :: Bool' >> $@
619+-ifeq "$(UseLibFFIForAdjustors)" "YES"
620+- @echo 'cLibFFI = True' >> $@
621+-else
622+- @echo 'cLibFFI = False' >> $@
623+-endif
624+-# Note that GhcThreaded just reflects the Makefile variable setting.
625+-# In particular, the stage1 compiler is never actually compiled with
626+-# -threaded, but it will nevertheless have cGhcThreaded = True.
627+-# The "+RTS --info" output will show what RTS GHC is really using.
628+- @echo 'cGhcThreaded :: Bool' >> $@
629+-ifeq "$(GhcThreaded)" "YES"
630+- @echo 'cGhcThreaded = True' >> $@
631+-else
632+- @echo 'cGhcThreaded = False' >> $@
633+-endif
634+- @echo 'cGhcDebugged :: Bool' >> $@
635+-ifeq "$(GhcDebugged)" "YES"
636+- @echo 'cGhcDebugged = True' >> $@
637+-else
638+- @echo 'cGhcDebugged = False' >> $@
639+-endif
640+- @echo done.
641+-
642+-# -----------------------------------------------------------------------------
643+-# Create platform includes
644+-
645+-# Here we generate a little header file containing CPP symbols that GHC
646+-# uses to determine which platform it is building on/for. The platforms
647+-# can differ between stage1 and stage2 if we're cross-compiling, so we
648+-# need one of these header files per stage.
649+-
650+-PLATFORM_H = ghc_boot_platform.h
651+-
652+-compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
653+- $(call removeFiles,$@)
654+- @echo "Creating $@..."
655+- @echo "#ifndef __PLATFORM_H__" >> $@
656+- @echo "#define __PLATFORM_H__" >> $@
657+- @echo >> $@
658+- @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
659+- @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
660+- @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
661+- @echo >> $@
662+- @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
663+- @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
664+- @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
665+- @echo >> $@
666+- @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
667+- @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
668+- @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
669+- @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
670+- @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
671+- @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
672+- @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@
673+- @echo >> $@
674+- @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
675+- @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
676+- @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
677+- @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
678+- @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
679+- @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
680+- @echo >> $@
681+- @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
682+- @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
683+- @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
684+- @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
685+- @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
686+- @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
687+- @echo >> $@
688+- @echo "#endif /* __PLATFORM_H__ */" >> $@
689+- @echo "Done."
690+-
691+-# For stage2 and above, the BUILD platform is the HOST of stage1, and
692+-# the HOST platform is the TARGET of stage1. The TARGET remains the same
693+-# (stage1 is the cross-compiler, not stage2).
694+-compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
695+- $(call removeFiles,$@)
696+- @echo "Creating $@..."
697+- @echo "#ifndef __PLATFORM_H__" >> $@
698+- @echo "#define __PLATFORM_H__" >> $@
699+- @echo >> $@
700+- @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
701+- @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
702+- @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
703+- @echo >> $@
704+- @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
705+- @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
706+- @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
707+- @echo >> $@
708+- @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
709+- @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
710+- @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
711+- @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
712+- @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
713+- @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
714+- @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@
715+- @echo >> $@
716+- @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
717+- @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
718+- @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
719+- @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
720+- @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
721+- @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
722+- @echo >> $@
723+- @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
724+- @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
725+- @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
726+- @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
727+- @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
728+- @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
729+- @echo >> $@
730+- @echo "#endif /* __PLATFORM_H__ */" >> $@
731+- @echo "Done."
732+-
733+-compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
734+- "$(CP)" $< $@
735+-
736+-# ----------------------------------------------------------------------------
737+-# Generate supporting stuff for prelude/PrimOp.hs
738+-# from prelude/primops.txt
739+-
740+-PRIMOP_BITS_NAMES = primop-data-decl.hs-incl \
741+- primop-tag.hs-incl \
742+- primop-list.hs-incl \
743+- primop-has-side-effects.hs-incl \
744+- primop-out-of-line.hs-incl \
745+- primop-commutable.hs-incl \
746+- primop-code-size.hs-incl \
747+- primop-can-fail.hs-incl \
748+- primop-strictness.hs-incl \
749+- primop-fixity.hs-incl \
750+- primop-primop-info.hs-incl \
751+- primop-vector-uniques.hs-incl \
752+- primop-vector-tys.hs-incl \
753+- primop-vector-tys-exports.hs-incl \
754+- primop-vector-tycons.hs-incl
755+-
756+-PRIMOP_BITS_STAGE1 = $(addprefix compiler/stage1/build/,$(PRIMOP_BITS_NAMES))
757+-PRIMOP_BITS_STAGE2 = $(addprefix compiler/stage2/build/,$(PRIMOP_BITS_NAMES))
758+-PRIMOP_BITS_STAGE3 = $(addprefix compiler/stage3/build/,$(PRIMOP_BITS_NAMES))
759+-
760+-compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
761+-compiler_CPP_OPTS += ${GhcCppOpts}
762+-
763+-# We add these paths to the Haskell compiler's #include search path list since
764+-# we must avoid #including files by paths relative to the source file as Hadrian
765+-# moves the build artifacts out of the source tree. See #8040.
766+-compiler_HC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
767+-
768+-define preprocessCompilerFiles
769+-# $0 = stage
770+-compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
771+- $$(HS_CPP) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
772+-
773+-compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
774+- "$$(genprimopcode_INPLACE)" --data-decl < $$< > $$@
775+-compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
776+- "$$(genprimopcode_INPLACE)" --primop-tag < $$< > $$@
777+-compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
778+- "$$(genprimopcode_INPLACE)" --primop-list < $$< > $$@
779+-compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
780+- "$$(genprimopcode_INPLACE)" --has-side-effects < $$< > $$@
781+-compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
782+- "$$(genprimopcode_INPLACE)" --out-of-line < $$< > $$@
783+-compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
784+- "$$(genprimopcode_INPLACE)" --commutable < $$< > $$@
785+-compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
786+- "$$(genprimopcode_INPLACE)" --code-size < $$< > $$@
787+-compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
788+- "$$(genprimopcode_INPLACE)" --can-fail < $$< > $$@
789+-compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
790+- "$$(genprimopcode_INPLACE)" --strictness < $$< > $$@
791+-compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
792+- "$$(genprimopcode_INPLACE)" --fixity < $$< > $$@
793+-compiler/stage$1/build/primop-primop-info.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
794+- "$$(genprimopcode_INPLACE)" --primop-primop-info < $$< > $$@
795+-compiler/stage$1/build/primop-vector-uniques.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
796+- "$$(genprimopcode_INPLACE)" --primop-vector-uniques < $$< > $$@
797+-compiler/stage$1/build/primop-vector-tys.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
798+- "$$(genprimopcode_INPLACE)" --primop-vector-tys < $$< > $$@
799+-compiler/stage$1/build/primop-vector-tys-exports.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
800+- "$$(genprimopcode_INPLACE)" --primop-vector-tys-exports < $$< > $$@
801+-compiler/stage$1/build/primop-vector-tycons.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
802+- "$$(genprimopcode_INPLACE)" --primop-vector-tycons < $$< > $$@
803+-
804+-# Usages aren't used any more; but the generator
805+-# can still generate them if we want them back
806+-compiler/stage$1/build/primop-usage.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
807+- "$$(genprimopcode_INPLACE)" --usage < $$< > $$@
808+-
809+-endef
810+-
811+-$(eval $(call preprocessCompilerFiles,1))
812+-$(eval $(call preprocessCompilerFiles,2))
813+-$(eval $(call preprocessCompilerFiles,3))
814+-
815+ # -----------------------------------------------------------------------------
816+ # Configuration
817+
818+@@ -369,19 +97,6 @@ ifeq "$(WITH_TERMINFO)" "NO"
819+ compiler_stage2_CONFIGURE_OPTS += --flags=-terminfo
820+ endif
821+
822+-# Careful optimisation of the parser: we don't want to throw everything
823+-# at it, because that takes too long and doesn't buy much, but we do want
824+-# to inline certain key external functions, so we instruct GHC not to
825+-# throw away inlinings as it would normally do in -O0 mode.
826+-# Since GHC version 7.8, we need -fcmm-sink to be
827+-# passed to the compiler. This is required on x86 to avoid the
828+-# register allocator running out of stack slots when compiling this
829+-# module with -fPIC -dynamic.
830+-# See #8182 for all the details
831+-compiler/stage1/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
832+-compiler/stage2/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
833+-compiler/stage3/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
834+-
835+ ifeq "$(GhcProfiled)" "YES"
836+ # If we're profiling GHC then we want SCCs. However, adding -auto-all
837+ # everywhere tends to give a hard-to-read profile, and adds lots of
838+@@ -407,9 +122,6 @@ endif
839+
840+ compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
841+
842+-compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
843+-compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
844+-compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
845+ compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
846+
847+ compiler/stage1/package-data.mk : compiler/ghc.mk
848+@@ -487,10 +199,6 @@ ifneq "$(BINDIST)" "YES"
849+ compiler_stage2_TAGS_HC_OPTS = -package ghc
850+ $(eval $(call tags-package,compiler,stage2))
851+
852+-$(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
853+-$(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
854+-$(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
855+-
856+ COMPILER_INCLUDES_DEPS += $(includes_H_CONFIG)
857+ COMPILER_INCLUDES_DEPS += $(includes_H_PLATFORM)
858+ COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS)
859+@@ -499,9 +207,13 @@ COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
860+ COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
861+ COMPILER_INCLUDES_DEPS += $(includes_DERIVEDCONSTANTS)
862+
863+-$(compiler_stage1_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE1)
864+-$(compiler_stage2_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE2)
865+-$(compiler_stage3_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE3)
866++$(compiler_stage1_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE1) libraries/ghc-prim/dist-boot/ghc_boot_platform.h
867++$(compiler_stage2_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE2) libraries/ghc-prim/dist-install/ghc_boot_platform.h
868++$(compiler_stage3_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE3) libraries/ghc-prim/dist-install/ghc_boot_platform.h
869++
870++compiler_stage1_HC_OPTS += -Ilibraries/ghc-prim/dist-boot -Irts/build
871++compiler_stage2_HC_OPTS += -Ilibraries/ghc-prim/dist-install -Irts/build
872++compiler_stage3_HC_OPTS += -Ilibraries/ghc-prim/dist-install -Irts/build
873+
874+ $(foreach way,$(compiler_stage1_WAYS),\
875+ compiler/stage1/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE1)
876+@@ -511,10 +223,6 @@ $(foreach way,$(compiler_stage3_WAYS),\
877+ compiler/stage3/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE3)
878+
879+
880+-# GHC itself doesn't know about the above dependencies, so we have to
881+-# switch off the recompilation checker for that module:
882+-compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp
883+-
884+ ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
885+ compiler/utils/Util_HC_OPTS += -DDYNAMIC_GHC_PROGRAMS
886+ endif
887+diff --git a/compiler/ghci/ByteCodeInstr.hs b/compiler/ghci/ByteCodeInstr.hs
888+index 07dcd22..cc44033 100644
889+--- a/compiler/ghci/ByteCodeInstr.hs
890++++ b/compiler/ghci/ByteCodeInstr.hs
891+@@ -10,7 +10,7 @@ module ByteCodeInstr (
892+ ) where
893+
894+ #include "HsVersions.h"
895+-#include "../includes/MachDeps.h"
896++#include "MachDeps.h"
897+
898+ import GhcPrelude
899+
900+diff --git a/compiler/ghci/RtClosureInspect.hs b/compiler/ghci/RtClosureInspect.hs
901+index b85322d..a18b50a 100644
902+--- a/compiler/ghci/RtClosureInspect.hs
903++++ b/compiler/ghci/RtClosureInspect.hs
904+@@ -162,7 +162,7 @@ data Closure = Closure { tipe :: ClosureType
905+ instance Outputable ClosureType where
906+ ppr = text . show
907+
908+-#include "../includes/rts/storage/ClosureTypes.h"
909++#include "rts/storage/ClosureTypes.h"
910+
911+ aP_CODE, pAP_CODE :: Int
912+ aP_CODE = AP
913+diff --git a/compiler/main/Config.hs b/compiler/main/Config.hs
914+new file mode 100644
915+index 0000000..f944f7a
916+--- /dev/null
917++++ b/compiler/main/Config.hs
918+@@ -0,0 +1,7 @@
919++{-# LANGUAGE CPP #-}
920++module Config where
921++
922++import GhcPrelude
923++
924++#include "ghc_boot_platform.h"
925++#include "config.hs-incl"
926+\ No newline at end of file
927+diff --git a/compiler/nativeGen/PPC/CodeGen.hs b/compiler/nativeGen/PPC/CodeGen.hs
928+index e2c568c..b0aca64 100644
929+--- a/compiler/nativeGen/PPC/CodeGen.hs
930++++ b/compiler/nativeGen/PPC/CodeGen.hs
931+@@ -22,7 +22,7 @@ where
932+
933+ #include "HsVersions.h"
934+ #include "nativeGen/NCG.h"
935+-#include "../includes/MachDeps.h"
936++#include "MachDeps.h"
937+
938+ -- NCG stuff:
939+ import GhcPrelude
940+diff --git a/compiler/nativeGen/SPARC/CodeGen.hs b/compiler/nativeGen/SPARC/CodeGen.hs
941+index 6dfd589..9d089ef 100644
942+--- a/compiler/nativeGen/SPARC/CodeGen.hs
943++++ b/compiler/nativeGen/SPARC/CodeGen.hs
944+@@ -19,7 +19,7 @@ where
945+
946+ #include "HsVersions.h"
947+ #include "nativeGen/NCG.h"
948+-#include "../includes/MachDeps.h"
949++#include "MachDeps.h"
950+
951+ -- NCG stuff:
952+ import GhcPrelude
953+diff --git a/compiler/nativeGen/X86/CodeGen.hs b/compiler/nativeGen/X86/CodeGen.hs
954+index eb6af1f..d8af5de 100644
955+--- a/compiler/nativeGen/X86/CodeGen.hs
956++++ b/compiler/nativeGen/X86/CodeGen.hs
957+@@ -27,7 +27,7 @@ where
958+
959+ #include "HsVersions.h"
960+ #include "nativeGen/NCG.h"
961+-#include "../includes/MachDeps.h"
962++#include "MachDeps.h"
963+
964+ -- NCG stuff:
965+ import GhcPrelude
966+diff --git a/compiler/parser/Parser.hs b/compiler/parser/Parser.hs
967+index c09ee5f..aab3a3a 100644
968+--- a/compiler/parser/Parser.hs
969++++ b/compiler/parser/Parser.hs
970+@@ -3,6 +3,17 @@
971+ #if __GLASGOW_HASKELL__ >= 710
972+ {-# OPTIONS_GHC -XPartialTypeSignatures #-}
973+ #endif
974++-- Careful optimisation of the parser: we don't want to throw everything
975++-- at it, because that takes too long and doesn't buy much, but we do want
976++-- to inline certain key external functions, so we instruct GHC not to
977++-- throw away inlinings as it would normally do in -O0 mode.
978++-- Since GHC version 7.8, we need -fcmm-sink to be
979++-- passed to the compiler. This is required on x86 to avoid the
980++-- register allocator running out of stack slots when compiling this
981++-- module with -fPIC -dynamic.
982++-- See #8182 for all the details
983++{-# OPTIONS_GHC -O0 -fno-ignore-interface-pragmas -fcmm-sink #-}
984++
985+ -- | This module provides the generated Happy parser for Haskell. It exports
986+ -- a number of parsers which may be used in any library that uses the GHC API.
987+ -- A common usage pattern is to initialize the parser state with a given string
988+@@ -12084,40 +12095,8 @@ sst = setSourceText
989+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
990+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
991+ {-# LINE 1 "<built-in>" #-}
992+-{-# LINE 1 "<command-line>" #-}
993+-{-# LINE 11 "<command-line>" #-}
994+-# 1 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 1 3 4
995+-
996+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
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++{-# LINE 18 "<built-in>" #-}
1027++{-# LINE 1 "/usr/local/Cellar/ghc/8.4.4/lib/ghc-8.4.4/include/ghcversion.h" #-}
1028+
1029+
1030+
1031+@@ -12134,9 +12113,9 @@ sst = setSourceText
1032+
1033+
1034+
1035++{-# LINE 19 "<built-in>" #-}
1036++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
1037+
1038+-{-# LINE 11 "<command-line>" #-}
1039+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
1040+
1041+
1042+
1043+@@ -12152,8 +12131,6 @@ sst = setSourceText
1044+
1045+
1046+
1047+-{-# LINE 11 "<command-line>" #-}
1048+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
1049+
1050+
1051+
1052+@@ -12319,22 +12296,7 @@ sst = setSourceText
1053+
1054+
1055+
1056+-
1057+-
1058+-
1059+-
1060+-
1061+-
1062+-
1063+-
1064+-
1065+-
1066+-
1067+-
1068+-
1069+-
1070+-
1071+-{-# LINE 11 "<command-line>" #-}
1072++{-# LINE 20 "<built-in>" #-}
1073+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
1074+ -- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
1075+
1076+@@ -12360,6 +12322,7 @@ sst = setSourceText
1077+ #define GTE(n,m) (n Happy_GHC_Exts.>=# m)
1078+ #define EQ(n,m) (n Happy_GHC_Exts.==# m)
1079+ #endif
1080++
1081+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
1082+
1083+ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
1084+@@ -12370,11 +12333,20 @@ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
1085+
1086+
1087+
1088++
1089+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
1090+
1091++
1092+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
1093+
1094+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
1095++
1096++
1097++
1098++
1099++
1100++
1101++
1102++
1103+
1104+ infixr 9 `HappyStk`
1105+ data HappyStk a = HappyStk a (HappyStk a)
1106+@@ -12402,7 +12374,7 @@ happyAccept j tk st sts (HappyStk ans _) =
1107+
1108+ happyDoAction i tk st
1109+ = {- nothing -}
1110+-
1111++
1112+
1113+ case action of
1114+ 0# -> {- nothing -}
1115+@@ -12410,11 +12382,11 @@ happyDoAction i tk st
1116+ -1# -> {- nothing -}
1117+ happyAccept i tk st
1118+ n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}
1119+-
1120++
1121+ (happyReduceArr Happy_Data_Array.! rule) i tk st
1122+ where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))
1123+ n -> {- nothing -}
1124+-
1125++
1126+
1127+ happyShift new_state i tk st
1128+ where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#))
1129+@@ -12460,6 +12432,7 @@ data HappyAddr = HappyA# Happy_GHC_Exts.Addr#
1130+ -----------------------------------------------------------------------------
1131+ -- HappyState data type (not arrays)
1132+
1133++
1134+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
1135+
1136+ -----------------------------------------------------------------------------
1137+@@ -12625,3 +12598,4 @@ happyDontSeq a b = b
1138+ {-# NOINLINE happyFail #-}
1139+
1140+ -- end of Happy Template.
1141++
1142+diff --git a/compiler/parser/Parser.y.source b/compiler/parser/Parser.y.source
1143+index dd60b06..c987537 100644
1144+--- a/compiler/parser/Parser.y.source
1145++++ b/compiler/parser/Parser.y.source
1146+@@ -8,6 +8,17 @@
1147+ -- ---------------------------------------------------------------------------
1148+
1149+ {
1150++-- Careful optimisation of the parser: we don't want to throw everything
1151++-- at it, because that takes too long and doesn't buy much, but we do want
1152++-- to inline certain key external functions, so we instruct GHC not to
1153++-- throw away inlinings as it would normally do in -O0 mode.
1154++-- Since GHC version 7.8, we need -fcmm-sink to be
1155++-- passed to the compiler. This is required on x86 to avoid the
1156++-- register allocator running out of stack slots when compiling this
1157++-- module with -fPIC -dynamic.
1158++-- See #8182 for all the details
1159++{-# OPTIONS_GHC -O0 -fno-ignore-interface-pragmas -fcmm-sink #-}
1160++
1161+ -- | This module provides the generated Happy parser for Haskell. It exports
1162+ -- a number of parsers which may be used in any library that uses the GHC API.
1163+ -- A common usage pattern is to initialize the parser state with a given string
1164+diff --git a/compiler/prelude/PrelRules.hs b/compiler/prelude/PrelRules.hs
1165+index 7bc6133..0e560f3 100644
1166+--- a/compiler/prelude/PrelRules.hs
1167++++ b/compiler/prelude/PrelRules.hs
1168+@@ -23,7 +23,7 @@ module PrelRules
1169+ where
1170+
1171+ #include "HsVersions.h"
1172+-#include "../includes/MachDeps.h"
1173++#include "MachDeps.h"
1174+
1175+ import GhcPrelude
1176+
1177+diff --git a/compiler/prelude/PrimOp.hs b/compiler/prelude/PrimOp.hs
1178+index 4eb94e9..32d4fc5 100644
1179+--- a/compiler/prelude/PrimOp.hs
1180++++ b/compiler/prelude/PrimOp.hs
1181+@@ -8,6 +8,11 @@
1182+
1183+ -- The default is a bit too low for the quite large primOpInfo definition
1184+ {-# OPTIONS_GHC -fmax-pmcheck-iterations=10000000 #-}
1185++-- GHC itself doesn't know about the pimop bits, so we have to
1186++-- switch off the recompilation checker for that module:
1187++{-# OPTIONS_GHC -fforce-recomp #-}
1188++
1189++
1190+
1191+ module PrimOp (
1192+ PrimOp(..), PrimOpVecCat(..), allThePrimOps,
1193+diff --git a/compiler/prelude/primops.txt.pp b/compiler/prelude/primops.txt.pp
1194+deleted file mode 100644
1195+index 924ac41..0000000
1196+--- a/compiler/prelude/primops.txt.pp
1197++++ /dev/null
1198+@@ -1,3295 +0,0 @@
1199+------------------------------------------------------------------------
1200+---
1201+--- (c) 2010 The University of Glasgow
1202+---
1203+--- Primitive Operations and Types
1204+---
1205+--- For more information on PrimOps, see
1206+--- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
1207+---
1208+------------------------------------------------------------------------
1209+-
1210+--- This file is processed by the utility program genprimopcode to produce
1211+--- a number of include files within the compiler and optionally to produce
1212+--- human-readable documentation.
1213+---
1214+--- It should first be preprocessed.
1215+---
1216+--- Information on how PrimOps are implemented and the steps necessary to
1217+--- add a new one can be found in the Commentary:
1218+---
1219+--- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
1220+-
1221+--- This file is divided into named sections, each containing or more
1222+--- primop entries. Section headers have the format:
1223+---
1224+--- section "section-name" {description}
1225+---
1226+--- This information is used solely when producing documentation; it is
1227+--- otherwise ignored. The description is optional.
1228+---
1229+--- The format of each primop entry is as follows:
1230+---
1231+--- primop internal-name "name-in-program-text" type category {description} attributes
1232+-
1233+--- The default attribute values which apply if you don't specify
1234+--- other ones. Attribute values can be True, False, or arbitrary
1235+--- text between curly brackets. This is a kludge to enable
1236+--- processors of this file to easily get hold of simple info
1237+--- (eg, out_of_line), whilst avoiding parsing complex expressions
1238+--- needed for strictness info.
1239+---
1240+--- type refers to the general category of the primop. Valid settings include,
1241+---
1242+--- * Compare: A comparison operation of the shape a -> a -> Int#
1243+--- * Monadic: A unary operation of shape a -> a
1244+--- * Dyadic: A binary operation of shape a -> a -> a
1245+--- * GenPrimOp: Any other sort of primop
1246+---
1247+-
1248+--- The vector attribute is rather special. It takes a list of 3-tuples, each of
1249+--- which is of the form <ELEM_TYPE,SCALAR_TYPE,LENGTH>. ELEM_TYPE is the type of
1250+--- the elements in the vector; LENGTH is the length of the vector; and
1251+--- SCALAR_TYPE is the scalar type used to inject to/project from vector
1252+--- element. Note that ELEM_TYPE and SCALAR_TYPE are not the same; for example,
1253+--- to broadcast a scalar value to a vector whose elements are of type Int8, we
1254+--- use an Int#.
1255+-
1256+--- When a primtype or primop has a vector attribute, it is instantiated at each
1257+--- 3-tuple in the list of 3-tuples. That is, the vector attribute allows us to
1258+--- define a family of types or primops. Vector support also adds three new
1259+--- keywords: VECTOR, SCALAR, and VECTUPLE. These keywords are expanded to types
1260+--- derived from the 3-tuple. For the 3-tuple <Int64,INT64,2>, VECTOR expands to
1261+--- Int64X2#, SCALAR expands to INT64, and VECTUPLE expands to (# INT64, INT64
1262+--- #).
1263+-
1264+-defaults
1265+- has_side_effects = False
1266+- out_of_line = False -- See Note Note [PrimOp can_fail and has_side_effects] in PrimOp
1267+- can_fail = False -- See Note Note [PrimOp can_fail and has_side_effects] in PrimOp
1268+- commutable = False
1269+- code_size = { primOpCodeSizeDefault }
1270+- strictness = { \ arity -> mkClosedStrictSig (replicate arity topDmd) topRes }
1271+- fixity = Nothing
1272+- llvm_only = False
1273+- vector = []
1274+-
1275+--- Currently, documentation is produced using latex, so contents of
1276+--- description fields should be legal latex. Descriptions can contain
1277+--- matched pairs of embedded curly brackets.
1278+-
1279+-#include "MachDeps.h"
1280+-
1281+--- We need platform defines (tests for mingw32 below).
1282+-#include "ghc_boot_platform.h"
1283+-
1284+-section "The word size story."
1285+- {Haskell98 specifies that signed integers (type {\tt Int})
1286+- must contain at least 30 bits. GHC always implements {\tt
1287+- Int} using the primitive type {\tt Int\#}, whose size equals
1288+- the {\tt MachDeps.h} constant {\tt WORD\_SIZE\_IN\_BITS}.
1289+- This is normally set based on the {\tt config.h} parameter
1290+- {\tt SIZEOF\_HSWORD}, i.e., 32 bits on 32-bit machines, 64
1291+- bits on 64-bit machines. However, it can also be explicitly
1292+- set to a smaller number, e.g., 31 bits, to allow the
1293+- possibility of using tag bits. Currently GHC itself has only
1294+- 32-bit and 64-bit variants, but 30 or 31-bit code can be
1295+- exported as an external core file for use in other back ends.
1296+-
1297+- GHC also implements a primitive unsigned integer type {\tt
1298+- Word\#} which always has the same number of bits as {\tt
1299+- Int\#}.
1300+-
1301+- In addition, GHC supports families of explicit-sized integers
1302+- and words at 8, 16, 32, and 64 bits, with the usual
1303+- arithmetic operations, comparisons, and a range of
1304+- conversions. The 8-bit and 16-bit sizes are always
1305+- represented as {\tt Int\#} and {\tt Word\#}, and the
1306+- operations implemented in terms of the the primops on these
1307+- types, with suitable range restrictions on the results (using
1308+- the {\tt narrow$n$Int\#} and {\tt narrow$n$Word\#} families
1309+- of primops. The 32-bit sizes are represented using {\tt
1310+- Int\#} and {\tt Word\#} when {\tt WORD\_SIZE\_IN\_BITS}
1311+- $\geq$ 32; otherwise, these are represented using distinct
1312+- primitive types {\tt Int32\#} and {\tt Word32\#}. These (when
1313+- needed) have a complete set of corresponding operations;
1314+- however, nearly all of these are implemented as external C
1315+- functions rather than as primops. Exactly the same story
1316+- applies to the 64-bit sizes. All of these details are hidden
1317+- under the {\tt PrelInt} and {\tt PrelWord} modules, which use
1318+- {\tt \#if}-defs to invoke the appropriate types and
1319+- operators.
1320+-
1321+- Word size also matters for the families of primops for
1322+- indexing/reading/writing fixed-size quantities at offsets
1323+- from an array base, address, or foreign pointer. Here, a
1324+- slightly different approach is taken. The names of these
1325+- primops are fixed, but their {\it types} vary according to
1326+- the value of {\tt WORD\_SIZE\_IN\_BITS}. For example, if word
1327+- size is at least 32 bits then an operator like
1328+- \texttt{indexInt32Array\#} has type {\tt ByteArray\# -> Int\#
1329+- -> Int\#}; otherwise it has type {\tt ByteArray\# -> Int\# ->
1330+- Int32\#}. This approach confines the necessary {\tt
1331+- \#if}-defs to this file; no conditional compilation is needed
1332+- in the files that expose these primops.
1333+-
1334+- Finally, there are strongly deprecated primops for coercing
1335+- between {\tt Addr\#}, the primitive type of machine
1336+- addresses, and {\tt Int\#}. These are pretty bogus anyway,
1337+- but will work on existing 32-bit and 64-bit GHC targets; they
1338+- are completely bogus when tag bits are used in {\tt Int\#},
1339+- so are not available in this case. }
1340+-
1341+--- Define synonyms for indexing ops.
1342+-
1343+-#if WORD_SIZE_IN_BITS < 32
1344+-#define INT32 Int32#
1345+-#define WORD32 Word32#
1346+-#else
1347+-#define INT32 Int#
1348+-#define WORD32 Word#
1349+-#endif
1350+-
1351+-#if WORD_SIZE_IN_BITS < 64
1352+-#define INT64 Int64#
1353+-#define WORD64 Word64#
1354+-#else
1355+-#define INT64 Int#
1356+-#define WORD64 Word#
1357+-#endif
1358+-
1359+-------------------------------------------------------------------------
1360+-section "Char#"
1361+- {Operations on 31-bit characters.}
1362+-------------------------------------------------------------------------
1363+-
1364+-primtype Char#
1365+-
1366+-primop CharGtOp "gtChar#" Compare Char# -> Char# -> Int#
1367+-primop CharGeOp "geChar#" Compare Char# -> Char# -> Int#
1368+-
1369+-primop CharEqOp "eqChar#" Compare
1370+- Char# -> Char# -> Int#
1371+- with commutable = True
1372+-
1373+-primop CharNeOp "neChar#" Compare
1374+- Char# -> Char# -> Int#
1375+- with commutable = True
1376+-
1377+-primop CharLtOp "ltChar#" Compare Char# -> Char# -> Int#
1378+-primop CharLeOp "leChar#" Compare Char# -> Char# -> Int#
1379+-
1380+-primop OrdOp "ord#" GenPrimOp Char# -> Int#
1381+- with code_size = 0
1382+-
1383+-------------------------------------------------------------------------
1384+-section "Int#"
1385+- {Operations on native-size integers (30+ bits).}
1386+-------------------------------------------------------------------------
1387+-
1388+-primtype Int#
1389+-
1390+-primop IntAddOp "+#" Dyadic
1391+- Int# -> Int# -> Int#
1392+- with commutable = True
1393+- fixity = infixl 6
1394+-
1395+-primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
1396+- with fixity = infixl 6
1397+-
1398+-primop IntMulOp "*#"
1399+- Dyadic Int# -> Int# -> Int#
1400+- {Low word of signed integer multiply.}
1401+- with commutable = True
1402+- fixity = infixl 7
1403+-
1404+-primop IntMulMayOfloOp "mulIntMayOflo#"
1405+- Dyadic Int# -> Int# -> Int#
1406+- {Return non-zero if there is any possibility that the upper word of a
1407+- signed integer multiply might contain useful information. Return
1408+- zero only if you are completely sure that no overflow can occur.
1409+- On a 32-bit platform, the recommended implementation is to do a
1410+- 32 x 32 -> 64 signed multiply, and subtract result[63:32] from
1411+- (result[31] >>signed 31). If this is zero, meaning that the
1412+- upper word is merely a sign extension of the lower one, no
1413+- overflow can occur.
1414+-
1415+- On a 64-bit platform it is not always possible to
1416+- acquire the top 64 bits of the result. Therefore, a recommended
1417+- implementation is to take the absolute value of both operands, and
1418+- return 0 iff bits[63:31] of them are zero, since that means that their
1419+- magnitudes fit within 31 bits, so the magnitude of the product must fit
1420+- into 62 bits.
1421+-
1422+- If in doubt, return non-zero, but do make an effort to create the
1423+- correct answer for small args, since otherwise the performance of
1424+- \texttt{(*) :: Integer -> Integer -> Integer} will be poor.
1425+- }
1426+- with commutable = True
1427+-
1428+-primop IntQuotOp "quotInt#" Dyadic
1429+- Int# -> Int# -> Int#
1430+- {Rounds towards zero. The behavior is undefined if the second argument is
1431+- zero.
1432+- }
1433+- with can_fail = True
1434+-
1435+-primop IntRemOp "remInt#" Dyadic
1436+- Int# -> Int# -> Int#
1437+- {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}. The
1438+- behavior is undefined if the second argument is zero.
1439+- }
1440+- with can_fail = True
1441+-
1442+-primop IntQuotRemOp "quotRemInt#" GenPrimOp
1443+- Int# -> Int# -> (# Int#, Int# #)
1444+- {Rounds towards zero.}
1445+- with can_fail = True
1446+-
1447+-primop AndIOp "andI#" Dyadic Int# -> Int# -> Int#
1448+- with commutable = True
1449+-
1450+-primop OrIOp "orI#" Dyadic Int# -> Int# -> Int#
1451+- with commutable = True
1452+-
1453+-primop XorIOp "xorI#" Dyadic Int# -> Int# -> Int#
1454+- with commutable = True
1455+-
1456+-primop NotIOp "notI#" Monadic Int# -> Int#
1457+-
1458+-primop IntNegOp "negateInt#" Monadic Int# -> Int#
1459+-primop IntAddCOp "addIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
1460+- {Add signed integers reporting overflow.
1461+- First member of result is the sum truncated to an {\tt Int#};
1462+- second member is zero if the true sum fits in an {\tt Int#},
1463+- nonzero if overflow occurred (the sum is either too large
1464+- or too small to fit in an {\tt Int#}).}
1465+- with code_size = 2
1466+-
1467+-primop IntSubCOp "subIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
1468+- {Subtract signed integers reporting overflow.
1469+- First member of result is the difference truncated to an {\tt Int#};
1470+- second member is zero if the true difference fits in an {\tt Int#},
1471+- nonzero if overflow occurred (the difference is either too large
1472+- or too small to fit in an {\tt Int#}).}
1473+- with code_size = 2
1474+-
1475+-primop IntGtOp ">#" Compare Int# -> Int# -> Int#
1476+- with fixity = infix 4
1477+-
1478+-primop IntGeOp ">=#" Compare Int# -> Int# -> Int#
1479+- with fixity = infix 4
1480+-
1481+-primop IntEqOp "==#" Compare
1482+- Int# -> Int# -> Int#
1483+- with commutable = True
1484+- fixity = infix 4
1485+-
1486+-primop IntNeOp "/=#" Compare
1487+- Int# -> Int# -> Int#
1488+- with commutable = True
1489+- fixity = infix 4
1490+-
1491+-primop IntLtOp "<#" Compare Int# -> Int# -> Int#
1492+- with fixity = infix 4
1493+-
1494+-primop IntLeOp "<=#" Compare Int# -> Int# -> Int#
1495+- with fixity = infix 4
1496+-
1497+-primop ChrOp "chr#" GenPrimOp Int# -> Char#
1498+- with code_size = 0
1499+-
1500+-primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
1501+- with code_size = 0
1502+-
1503+-primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
1504+-primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
1505+-
1506+-primop Word2FloatOp "word2Float#" GenPrimOp Word# -> Float#
1507+-primop Word2DoubleOp "word2Double#" GenPrimOp Word# -> Double#
1508+-
1509+-primop ISllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int#
1510+- {Shift left. Result undefined if shift amount is not
1511+- in the range 0 to word size - 1 inclusive.}
1512+-primop ISraOp "uncheckedIShiftRA#" GenPrimOp Int# -> Int# -> Int#
1513+- {Shift right arithmetic. Result undefined if shift amount is not
1514+- in the range 0 to word size - 1 inclusive.}
1515+-primop ISrlOp "uncheckedIShiftRL#" GenPrimOp Int# -> Int# -> Int#
1516+- {Shift right logical. Result undefined if shift amount is not
1517+- in the range 0 to word size - 1 inclusive.}
1518+-
1519+-------------------------------------------------------------------------
1520+-section "Word#"
1521+- {Operations on native-sized unsigned words (30+ bits).}
1522+-------------------------------------------------------------------------
1523+-
1524+-primtype Word#
1525+-
1526+-primop WordAddOp "plusWord#" Dyadic Word# -> Word# -> Word#
1527+- with commutable = True
1528+-
1529+-primop WordSubCOp "subWordC#" GenPrimOp Word# -> Word# -> (# Word#, Int# #)
1530+- {Subtract unsigned integers reporting overflow.
1531+- The first element of the pair is the result. The second element is
1532+- the carry flag, which is nonzero on overflow.}
1533+-
1534+--- Returns (# high, low #) (or equivalently, (# carry, low #))
1535+-primop WordAdd2Op "plusWord2#" GenPrimOp
1536+- Word# -> Word# -> (# Word#, Word# #)
1537+- with commutable = True
1538+-
1539+-primop WordSubOp "minusWord#" Dyadic Word# -> Word# -> Word#
1540+-
1541+-primop WordMulOp "timesWord#" Dyadic Word# -> Word# -> Word#
1542+- with commutable = True
1543+-
1544+--- Returns (# high, low #)
1545+-primop WordMul2Op "timesWord2#" GenPrimOp
1546+- Word# -> Word# -> (# Word#, Word# #)
1547+- with commutable = True
1548+-
1549+-primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word#
1550+- with can_fail = True
1551+-
1552+-primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word#
1553+- with can_fail = True
1554+-
1555+-primop WordQuotRemOp "quotRemWord#" GenPrimOp
1556+- Word# -> Word# -> (# Word#, Word# #)
1557+- with can_fail = True
1558+-
1559+--- Takes high word of dividend, then low word of dividend, then divisor.
1560+--- Requires that high word is not divisible by divisor.
1561+-primop WordQuotRem2Op "quotRemWord2#" GenPrimOp
1562+- Word# -> Word# -> Word# -> (# Word#, Word# #)
1563+- with can_fail = True
1564+-
1565+-primop AndOp "and#" Dyadic Word# -> Word# -> Word#
1566+- with commutable = True
1567+-
1568+-primop OrOp "or#" Dyadic Word# -> Word# -> Word#
1569+- with commutable = True
1570+-
1571+-primop XorOp "xor#" Dyadic Word# -> Word# -> Word#
1572+- with commutable = True
1573+-
1574+-primop NotOp "not#" Monadic Word# -> Word#
1575+-
1576+-primop SllOp "uncheckedShiftL#" GenPrimOp Word# -> Int# -> Word#
1577+- {Shift left logical. Result undefined if shift amount is not
1578+- in the range 0 to word size - 1 inclusive.}
1579+-primop SrlOp "uncheckedShiftRL#" GenPrimOp Word# -> Int# -> Word#
1580+- {Shift right logical. Result undefined if shift amount is not
1581+- in the range 0 to word size - 1 inclusive.}
1582+-
1583+-primop Word2IntOp "word2Int#" GenPrimOp Word# -> Int#
1584+- with code_size = 0
1585+-
1586+-primop WordGtOp "gtWord#" Compare Word# -> Word# -> Int#
1587+-primop WordGeOp "geWord#" Compare Word# -> Word# -> Int#
1588+-primop WordEqOp "eqWord#" Compare Word# -> Word# -> Int#
1589+-primop WordNeOp "neWord#" Compare Word# -> Word# -> Int#
1590+-primop WordLtOp "ltWord#" Compare Word# -> Word# -> Int#
1591+-primop WordLeOp "leWord#" Compare Word# -> Word# -> Int#
1592+-
1593+-primop PopCnt8Op "popCnt8#" Monadic Word# -> Word#
1594+- {Count the number of set bits in the lower 8 bits of a word.}
1595+-primop PopCnt16Op "popCnt16#" Monadic Word# -> Word#
1596+- {Count the number of set bits in the lower 16 bits of a word.}
1597+-primop PopCnt32Op "popCnt32#" Monadic Word# -> Word#
1598+- {Count the number of set bits in the lower 32 bits of a word.}
1599+-primop PopCnt64Op "popCnt64#" GenPrimOp WORD64 -> Word#
1600+- {Count the number of set bits in a 64-bit word.}
1601+-primop PopCntOp "popCnt#" Monadic Word# -> Word#
1602+- {Count the number of set bits in a word.}
1603+-
1604+-primop Pdep8Op "pdep8#" Dyadic Word# -> Word# -> Word#
1605+- {Deposit bits to lower 8 bits of a word at locations specified by a mask.}
1606+-primop Pdep16Op "pdep16#" Dyadic Word# -> Word# -> Word#
1607+- {Deposit bits to lower 16 bits of a word at locations specified by a mask.}
1608+-primop Pdep32Op "pdep32#" Dyadic Word# -> Word# -> Word#
1609+- {Deposit bits to lower 32 bits of a word at locations specified by a mask.}
1610+-primop Pdep64Op "pdep64#" GenPrimOp WORD64 -> WORD64 -> WORD64
1611+- {Deposit bits to a word at locations specified by a mask.}
1612+-primop PdepOp "pdep#" Dyadic Word# -> Word# -> Word#
1613+- {Deposit bits to a word at locations specified by a mask.}
1614+-
1615+-primop Pext8Op "pext8#" Dyadic Word# -> Word# -> Word#
1616+- {Extract bits from lower 8 bits of a word at locations specified by a mask.}
1617+-primop Pext16Op "pext16#" Dyadic Word# -> Word# -> Word#
1618+- {Extract bits from lower 16 bits of a word at locations specified by a mask.}
1619+-primop Pext32Op "pext32#" Dyadic Word# -> Word# -> Word#
1620+- {Extract bits from lower 32 bits of a word at locations specified by a mask.}
1621+-primop Pext64Op "pext64#" GenPrimOp WORD64 -> WORD64 -> WORD64
1622+- {Extract bits from a word at locations specified by a mask.}
1623+-primop PextOp "pext#" Dyadic Word# -> Word# -> Word#
1624+- {Extract bits from a word at locations specified by a mask.}
1625+-
1626+-primop Clz8Op "clz8#" Monadic Word# -> Word#
1627+- {Count leading zeros in the lower 8 bits of a word.}
1628+-primop Clz16Op "clz16#" Monadic Word# -> Word#
1629+- {Count leading zeros in the lower 16 bits of a word.}
1630+-primop Clz32Op "clz32#" Monadic Word# -> Word#
1631+- {Count leading zeros in the lower 32 bits of a word.}
1632+-primop Clz64Op "clz64#" GenPrimOp WORD64 -> Word#
1633+- {Count leading zeros in a 64-bit word.}
1634+-primop ClzOp "clz#" Monadic Word# -> Word#
1635+- {Count leading zeros in a word.}
1636+-
1637+-primop Ctz8Op "ctz8#" Monadic Word# -> Word#
1638+- {Count trailing zeros in the lower 8 bits of a word.}
1639+-primop Ctz16Op "ctz16#" Monadic Word# -> Word#
1640+- {Count trailing zeros in the lower 16 bits of a word.}
1641+-primop Ctz32Op "ctz32#" Monadic Word# -> Word#
1642+- {Count trailing zeros in the lower 32 bits of a word.}
1643+-primop Ctz64Op "ctz64#" GenPrimOp WORD64 -> Word#
1644+- {Count trailing zeros in a 64-bit word.}
1645+-primop CtzOp "ctz#" Monadic Word# -> Word#
1646+- {Count trailing zeros in a word.}
1647+-
1648+-primop BSwap16Op "byteSwap16#" Monadic Word# -> Word#
1649+- {Swap bytes in the lower 16 bits of a word. The higher bytes are undefined. }
1650+-primop BSwap32Op "byteSwap32#" Monadic Word# -> Word#
1651+- {Swap bytes in the lower 32 bits of a word. The higher bytes are undefined. }
1652+-primop BSwap64Op "byteSwap64#" Monadic WORD64 -> WORD64
1653+- {Swap bytes in a 64 bits of a word.}
1654+-primop BSwapOp "byteSwap#" Monadic Word# -> Word#
1655+- {Swap bytes in a word.}
1656+-
1657+-------------------------------------------------------------------------
1658+-section "Narrowings"
1659+- {Explicit narrowing of native-sized ints or words.}
1660+-------------------------------------------------------------------------
1661+-
1662+-primop Narrow8IntOp "narrow8Int#" Monadic Int# -> Int#
1663+-primop Narrow16IntOp "narrow16Int#" Monadic Int# -> Int#
1664+-primop Narrow32IntOp "narrow32Int#" Monadic Int# -> Int#
1665+-primop Narrow8WordOp "narrow8Word#" Monadic Word# -> Word#
1666+-primop Narrow16WordOp "narrow16Word#" Monadic Word# -> Word#
1667+-primop Narrow32WordOp "narrow32Word#" Monadic Word# -> Word#
1668+-
1669+-
1670+-#if WORD_SIZE_IN_BITS < 32
1671+-------------------------------------------------------------------------
1672+-section "Int32#"
1673+- {Operations on 32-bit integers ({\tt Int32\#}). This type is only used
1674+- if plain {\tt Int\#} has less than 32 bits. In any case, the operations
1675+- are not primops; they are implemented (if needed) as ccalls instead.}
1676+-------------------------------------------------------------------------
1677+-
1678+-primtype Int32#
1679+-
1680+-------------------------------------------------------------------------
1681+-section "Word32#"
1682+- {Operations on 32-bit unsigned words. This type is only used
1683+- if plain {\tt Word\#} has less than 32 bits. In any case, the operations
1684+- are not primops; they are implemented (if needed) as ccalls instead.}
1685+-------------------------------------------------------------------------
1686+-
1687+-primtype Word32#
1688+-
1689+-#endif
1690+-
1691+-
1692+-#if WORD_SIZE_IN_BITS < 64
1693+-------------------------------------------------------------------------
1694+-section "Int64#"
1695+- {Operations on 64-bit unsigned words. This type is only used
1696+- if plain {\tt Int\#} has less than 64 bits. In any case, the operations
1697+- are not primops; they are implemented (if needed) as ccalls instead.}
1698+-------------------------------------------------------------------------
1699+-
1700+-primtype Int64#
1701+-
1702+-------------------------------------------------------------------------
1703+-section "Word64#"
1704+- {Operations on 64-bit unsigned words. This type is only used
1705+- if plain {\tt Word\#} has less than 64 bits. In any case, the operations
1706+- are not primops; they are implemented (if needed) as ccalls instead.}
1707+-------------------------------------------------------------------------
1708+-
1709+-primtype Word64#
1710+-
1711+-#endif
1712+-
1713+-------------------------------------------------------------------------
1714+-section "Double#"
1715+- {Operations on double-precision (64 bit) floating-point numbers.}
1716+-------------------------------------------------------------------------
1717+-
1718+-primtype Double#
1719+-
1720+-primop DoubleGtOp ">##" Compare Double# -> Double# -> Int#
1721+- with fixity = infix 4
1722+-
1723+-primop DoubleGeOp ">=##" Compare Double# -> Double# -> Int#
1724+- with fixity = infix 4
1725+-
1726+-primop DoubleEqOp "==##" Compare
1727+- Double# -> Double# -> Int#
1728+- with commutable = True
1729+- fixity = infix 4
1730+-
1731+-primop DoubleNeOp "/=##" Compare
1732+- Double# -> Double# -> Int#
1733+- with commutable = True
1734+- fixity = infix 4
1735+-
1736+-primop DoubleLtOp "<##" Compare Double# -> Double# -> Int#
1737+- with fixity = infix 4
1738+-
1739+-primop DoubleLeOp "<=##" Compare Double# -> Double# -> Int#
1740+- with fixity = infix 4
1741+-
1742+-primop DoubleAddOp "+##" Dyadic
1743+- Double# -> Double# -> Double#
1744+- with commutable = True
1745+- fixity = infixl 6
1746+-
1747+-primop DoubleSubOp "-##" Dyadic Double# -> Double# -> Double#
1748+- with fixity = infixl 6
1749+-
1750+-primop DoubleMulOp "*##" Dyadic
1751+- Double# -> Double# -> Double#
1752+- with commutable = True
1753+- fixity = infixl 7
1754+-
1755+-primop DoubleDivOp "/##" Dyadic
1756+- Double# -> Double# -> Double#
1757+- with can_fail = True
1758+- fixity = infixl 7
1759+-
1760+-primop DoubleNegOp "negateDouble#" Monadic Double# -> Double#
1761+-
1762+-primop DoubleFabsOp "fabsDouble#" Monadic Double# -> Double#
1763+-
1764+-primop Double2IntOp "double2Int#" GenPrimOp Double# -> Int#
1765+- {Truncates a {\tt Double#} value to the nearest {\tt Int#}.
1766+- Results are undefined if the truncation if truncation yields
1767+- a value outside the range of {\tt Int#}.}
1768+-
1769+-primop Double2FloatOp "double2Float#" GenPrimOp Double# -> Float#
1770+-
1771+-primop DoubleExpOp "expDouble#" Monadic
1772+- Double# -> Double#
1773+- with
1774+- code_size = { primOpCodeSizeForeignCall }
1775+-
1776+-primop DoubleLogOp "logDouble#" Monadic
1777+- Double# -> Double#
1778+- with
1779+- code_size = { primOpCodeSizeForeignCall }
1780+- can_fail = True
1781+-
1782+-primop DoubleSqrtOp "sqrtDouble#" Monadic
1783+- Double# -> Double#
1784+- with
1785+- code_size = { primOpCodeSizeForeignCall }
1786+-
1787+-primop DoubleSinOp "sinDouble#" Monadic
1788+- Double# -> Double#
1789+- with
1790+- code_size = { primOpCodeSizeForeignCall }
1791+-
1792+-primop DoubleCosOp "cosDouble#" Monadic
1793+- Double# -> Double#
1794+- with
1795+- code_size = { primOpCodeSizeForeignCall }
1796+-
1797+-primop DoubleTanOp "tanDouble#" Monadic
1798+- Double# -> Double#
1799+- with
1800+- code_size = { primOpCodeSizeForeignCall }
1801+-
1802+-primop DoubleAsinOp "asinDouble#" Monadic
1803+- Double# -> Double#
1804+- with
1805+- code_size = { primOpCodeSizeForeignCall }
1806+- can_fail = True
1807+-
1808+-primop DoubleAcosOp "acosDouble#" Monadic
1809+- Double# -> Double#
1810+- with
1811+- code_size = { primOpCodeSizeForeignCall }
1812+- can_fail = True
1813+-
1814+-primop DoubleAtanOp "atanDouble#" Monadic
1815+- Double# -> Double#
1816+- with
1817+- code_size = { primOpCodeSizeForeignCall }
1818+-
1819+-primop DoubleSinhOp "sinhDouble#" Monadic
1820+- Double# -> Double#
1821+- with
1822+- code_size = { primOpCodeSizeForeignCall }
1823+-
1824+-primop DoubleCoshOp "coshDouble#" Monadic
1825+- Double# -> Double#
1826+- with
1827+- code_size = { primOpCodeSizeForeignCall }
1828+-
1829+-primop DoubleTanhOp "tanhDouble#" Monadic
1830+- Double# -> Double#
1831+- with
1832+- code_size = { primOpCodeSizeForeignCall }
1833+-
1834+-primop DoublePowerOp "**##" Dyadic
1835+- Double# -> Double# -> Double#
1836+- {Exponentiation.}
1837+- with
1838+- code_size = { primOpCodeSizeForeignCall }
1839+-
1840+-primop DoubleDecode_2IntOp "decodeDouble_2Int#" GenPrimOp
1841+- Double# -> (# Int#, Word#, Word#, Int# #)
1842+- {Convert to integer.
1843+- First component of the result is -1 or 1, indicating the sign of the
1844+- mantissa. The next two are the high and low 32 bits of the mantissa
1845+- respectively, and the last is the exponent.}
1846+- with out_of_line = True
1847+-
1848+-primop DoubleDecode_Int64Op "decodeDouble_Int64#" GenPrimOp
1849+- Double# -> (# INT64, Int# #)
1850+- {Decode {\tt Double\#} into mantissa and base-2 exponent.}
1851+- with out_of_line = True
1852+-
1853+-------------------------------------------------------------------------
1854+-section "Float#"
1855+- {Operations on single-precision (32-bit) floating-point numbers.}
1856+-------------------------------------------------------------------------
1857+-
1858+-primtype Float#
1859+-
1860+-primop FloatGtOp "gtFloat#" Compare Float# -> Float# -> Int#
1861+-primop FloatGeOp "geFloat#" Compare Float# -> Float# -> Int#
1862+-
1863+-primop FloatEqOp "eqFloat#" Compare
1864+- Float# -> Float# -> Int#
1865+- with commutable = True
1866+-
1867+-primop FloatNeOp "neFloat#" Compare
1868+- Float# -> Float# -> Int#
1869+- with commutable = True
1870+-
1871+-primop FloatLtOp "ltFloat#" Compare Float# -> Float# -> Int#
1872+-primop FloatLeOp "leFloat#" Compare Float# -> Float# -> Int#
1873+-
1874+-primop FloatAddOp "plusFloat#" Dyadic
1875+- Float# -> Float# -> Float#
1876+- with commutable = True
1877+-
1878+-primop FloatSubOp "minusFloat#" Dyadic Float# -> Float# -> Float#
1879+-
1880+-primop FloatMulOp "timesFloat#" Dyadic
1881+- Float# -> Float# -> Float#
1882+- with commutable = True
1883+-
1884+-primop FloatDivOp "divideFloat#" Dyadic
1885+- Float# -> Float# -> Float#
1886+- with can_fail = True
1887+-
1888+-primop FloatNegOp "negateFloat#" Monadic Float# -> Float#
1889+-
1890+-primop FloatFabsOp "fabsFloat#" Monadic Float# -> Float#
1891+-
1892+-primop Float2IntOp "float2Int#" GenPrimOp Float# -> Int#
1893+- {Truncates a {\tt Float#} value to the nearest {\tt Int#}.
1894+- Results are undefined if the truncation if truncation yields
1895+- a value outside the range of {\tt Int#}.}
1896+-
1897+-primop FloatExpOp "expFloat#" Monadic
1898+- Float# -> Float#
1899+- with
1900+- code_size = { primOpCodeSizeForeignCall }
1901+-
1902+-primop FloatLogOp "logFloat#" Monadic
1903+- Float# -> Float#
1904+- with
1905+- code_size = { primOpCodeSizeForeignCall }
1906+- can_fail = True
1907+-
1908+-primop FloatSqrtOp "sqrtFloat#" Monadic
1909+- Float# -> Float#
1910+- with
1911+- code_size = { primOpCodeSizeForeignCall }
1912+-
1913+-primop FloatSinOp "sinFloat#" Monadic
1914+- Float# -> Float#
1915+- with
1916+- code_size = { primOpCodeSizeForeignCall }
1917+-
1918+-primop FloatCosOp "cosFloat#" Monadic
1919+- Float# -> Float#
1920+- with
1921+- code_size = { primOpCodeSizeForeignCall }
1922+-
1923+-primop FloatTanOp "tanFloat#" Monadic
1924+- Float# -> Float#
1925+- with
1926+- code_size = { primOpCodeSizeForeignCall }
1927+-
1928+-primop FloatAsinOp "asinFloat#" Monadic
1929+- Float# -> Float#
1930+- with
1931+- code_size = { primOpCodeSizeForeignCall }
1932+- can_fail = True
1933+-
1934+-primop FloatAcosOp "acosFloat#" Monadic
1935+- Float# -> Float#
1936+- with
1937+- code_size = { primOpCodeSizeForeignCall }
1938+- can_fail = True
1939+-
1940+-primop FloatAtanOp "atanFloat#" Monadic
1941+- Float# -> Float#
1942+- with
1943+- code_size = { primOpCodeSizeForeignCall }
1944+-
1945+-primop FloatSinhOp "sinhFloat#" Monadic
1946+- Float# -> Float#
1947+- with
1948+- code_size = { primOpCodeSizeForeignCall }
1949+-
1950+-primop FloatCoshOp "coshFloat#" Monadic
1951+- Float# -> Float#
1952+- with
1953+- code_size = { primOpCodeSizeForeignCall }
1954+-
1955+-primop FloatTanhOp "tanhFloat#" Monadic
1956+- Float# -> Float#
1957+- with
1958+- code_size = { primOpCodeSizeForeignCall }
1959+-
1960+-primop FloatPowerOp "powerFloat#" Dyadic
1961+- Float# -> Float# -> Float#
1962+- with
1963+- code_size = { primOpCodeSizeForeignCall }
1964+-
1965+-primop Float2DoubleOp "float2Double#" GenPrimOp Float# -> Double#
1966+-
1967+-primop FloatDecode_IntOp "decodeFloat_Int#" GenPrimOp
1968+- Float# -> (# Int#, Int# #)
1969+- {Convert to integers.
1970+- First {\tt Int\#} in result is the mantissa; second is the exponent.}
1971+- with out_of_line = True
1972+-
1973+-------------------------------------------------------------------------
1974+-section "Arrays"
1975+- {Operations on {\tt Array\#}.}
1976+-------------------------------------------------------------------------
1977+-
1978+-primtype Array# a
1979+-
1980+-primtype MutableArray# s a
1981+-
1982+-primop NewArrayOp "newArray#" GenPrimOp
1983+- Int# -> a -> State# s -> (# State# s, MutableArray# s a #)
1984+- {Create a new mutable array with the specified number of elements,
1985+- in the specified state thread,
1986+- with each element containing the specified initial value.}
1987+- with
1988+- out_of_line = True
1989+- has_side_effects = True
1990+-
1991+-primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
1992+- MutableArray# s a -> MutableArray# s a -> Int#
1993+-
1994+-primop ReadArrayOp "readArray#" GenPrimOp
1995+- MutableArray# s a -> Int# -> State# s -> (# State# s, a #)
1996+- {Read from specified index of mutable array. Result is not yet evaluated.}
1997+- with
1998+- has_side_effects = True
1999+- can_fail = True
2000+-
2001+-primop WriteArrayOp "writeArray#" GenPrimOp
2002+- MutableArray# s a -> Int# -> a -> State# s -> State# s
2003+- {Write to specified index of mutable array.}
2004+- with
2005+- has_side_effects = True
2006+- can_fail = True
2007+- code_size = 2 -- card update too
2008+-
2009+-primop SizeofArrayOp "sizeofArray#" GenPrimOp
2010+- Array# a -> Int#
2011+- {Return the number of elements in the array.}
2012+-
2013+-primop SizeofMutableArrayOp "sizeofMutableArray#" GenPrimOp
2014+- MutableArray# s a -> Int#
2015+- {Return the number of elements in the array.}
2016+-
2017+-primop IndexArrayOp "indexArray#" GenPrimOp
2018+- Array# a -> Int# -> (# a #)
2019+- {Read from specified index of immutable array. Result is packaged into
2020+- an unboxed singleton; the result itself is not yet evaluated.}
2021+- with
2022+- can_fail = True
2023+-
2024+-primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
2025+- MutableArray# s a -> State# s -> (# State# s, Array# a #)
2026+- {Make a mutable array immutable, without copying.}
2027+- with
2028+- has_side_effects = True
2029+-
2030+-primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
2031+- Array# a -> State# s -> (# State# s, MutableArray# s a #)
2032+- {Make an immutable array mutable, without copying.}
2033+- with
2034+- out_of_line = True
2035+- has_side_effects = True
2036+-
2037+-primop CopyArrayOp "copyArray#" GenPrimOp
2038+- Array# a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s
2039+- {Given a source array, an offset into the source array, a
2040+- destination array, an offset into the destination array, and a
2041+- number of elements to copy, copy the elements from the source array
2042+- to the destination array. Both arrays must fully contain the
2043+- specified ranges, but this is not checked. The two arrays must not
2044+- be the same array in different states, but this is not checked
2045+- either.}
2046+- with
2047+- out_of_line = True
2048+- has_side_effects = True
2049+- can_fail = True
2050+-
2051+-primop CopyMutableArrayOp "copyMutableArray#" GenPrimOp
2052+- MutableArray# s a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s
2053+- {Given a source array, an offset into the source array, a
2054+- destination array, an offset into the destination array, and a
2055+- number of elements to copy, copy the elements from the source array
2056+- to the destination array. Both arrays must fully contain the
2057+- specified ranges, but this is not checked. In the case where
2058+- the source and destination are the same array the source and
2059+- destination regions may overlap.}
2060+- with
2061+- out_of_line = True
2062+- has_side_effects = True
2063+- can_fail = True
2064+-
2065+-primop CloneArrayOp "cloneArray#" GenPrimOp
2066+- Array# a -> Int# -> Int# -> Array# a
2067+- {Given a source array, an offset into the source array, and a number
2068+- of elements to copy, create a new array with the elements from the
2069+- source array. The provided array must fully contain the specified
2070+- range, but this is not checked.}
2071+- with
2072+- out_of_line = True
2073+- has_side_effects = True
2074+- can_fail = True
2075+-
2076+-primop CloneMutableArrayOp "cloneMutableArray#" GenPrimOp
2077+- MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #)
2078+- {Given a source array, an offset into the source array, and a number
2079+- of elements to copy, create a new array with the elements from the
2080+- source array. The provided array must fully contain the specified
2081+- range, but this is not checked.}
2082+- with
2083+- out_of_line = True
2084+- has_side_effects = True
2085+- can_fail = True
2086+-
2087+-primop FreezeArrayOp "freezeArray#" GenPrimOp
2088+- MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, Array# a #)
2089+- {Given a source array, an offset into the source array, and a number
2090+- of elements to copy, create a new array with the elements from the
2091+- source array. The provided array must fully contain the specified
2092+- range, but this is not checked.}
2093+- with
2094+- out_of_line = True
2095+- has_side_effects = True
2096+- can_fail = True
2097+-
2098+-primop ThawArrayOp "thawArray#" GenPrimOp
2099+- Array# a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #)
2100+- {Given a source array, an offset into the source array, and a number
2101+- of elements to copy, create a new array with the elements from the
2102+- source array. The provided array must fully contain the specified
2103+- range, but this is not checked.}
2104+- with
2105+- out_of_line = True
2106+- has_side_effects = True
2107+- can_fail = True
2108+-
2109+-primop CasArrayOp "casArray#" GenPrimOp
2110+- MutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #)
2111+- {Unsafe, machine-level atomic compare and swap on an element within an Array.}
2112+- with
2113+- out_of_line = True
2114+- has_side_effects = True
2115+-
2116+-
2117+-------------------------------------------------------------------------
2118+-section "Small Arrays"
2119+-
2120+- {Operations on {\tt SmallArray\#}. A {\tt SmallArray\#} works
2121+- just like an {\tt Array\#}, but with different space use and
2122+- performance characteristics (that are often useful with small
2123+- arrays). The {\tt SmallArray\#} and {\tt SmallMutableArray#}
2124+- lack a `card table'. The purpose of a card table is to avoid
2125+- having to scan every element of the array on each GC by
2126+- keeping track of which elements have changed since the last GC
2127+- and only scanning those that have changed. So the consequence
2128+- of there being no card table is that the representation is
2129+- somewhat smaller and the writes are somewhat faster (because
2130+- the card table does not need to be updated). The disadvantage
2131+- of course is that for a {\tt SmallMutableArray#} the whole
2132+- array has to be scanned on each GC. Thus it is best suited for
2133+- use cases where the mutable array is not long lived, e.g.
2134+- where a mutable array is initialised quickly and then frozen
2135+- to become an immutable {\tt SmallArray\#}.
2136+- }
2137+-
2138+-------------------------------------------------------------------------
2139+-
2140+-primtype SmallArray# a
2141+-
2142+-primtype SmallMutableArray# s a
2143+-
2144+-primop NewSmallArrayOp "newSmallArray#" GenPrimOp
2145+- Int# -> a -> State# s -> (# State# s, SmallMutableArray# s a #)
2146+- {Create a new mutable array with the specified number of elements,
2147+- in the specified state thread,
2148+- with each element containing the specified initial value.}
2149+- with
2150+- out_of_line = True
2151+- has_side_effects = True
2152+-
2153+-primop SameSmallMutableArrayOp "sameSmallMutableArray#" GenPrimOp
2154+- SmallMutableArray# s a -> SmallMutableArray# s a -> Int#
2155+-
2156+-primop ReadSmallArrayOp "readSmallArray#" GenPrimOp
2157+- SmallMutableArray# s a -> Int# -> State# s -> (# State# s, a #)
2158+- {Read from specified index of mutable array. Result is not yet evaluated.}
2159+- with
2160+- has_side_effects = True
2161+- can_fail = True
2162+-
2163+-primop WriteSmallArrayOp "writeSmallArray#" GenPrimOp
2164+- SmallMutableArray# s a -> Int# -> a -> State# s -> State# s
2165+- {Write to specified index of mutable array.}
2166+- with
2167+- has_side_effects = True
2168+- can_fail = True
2169+-
2170+-primop SizeofSmallArrayOp "sizeofSmallArray#" GenPrimOp
2171+- SmallArray# a -> Int#
2172+- {Return the number of elements in the array.}
2173+-
2174+-primop SizeofSmallMutableArrayOp "sizeofSmallMutableArray#" GenPrimOp
2175+- SmallMutableArray# s a -> Int#
2176+- {Return the number of elements in the array.}
2177+-
2178+-primop IndexSmallArrayOp "indexSmallArray#" GenPrimOp
2179+- SmallArray# a -> Int# -> (# a #)
2180+- {Read from specified index of immutable array. Result is packaged into
2181+- an unboxed singleton; the result itself is not yet evaluated.}
2182+- with
2183+- can_fail = True
2184+-
2185+-primop UnsafeFreezeSmallArrayOp "unsafeFreezeSmallArray#" GenPrimOp
2186+- SmallMutableArray# s a -> State# s -> (# State# s, SmallArray# a #)
2187+- {Make a mutable array immutable, without copying.}
2188+- with
2189+- has_side_effects = True
2190+-
2191+-primop UnsafeThawSmallArrayOp "unsafeThawSmallArray#" GenPrimOp
2192+- SmallArray# a -> State# s -> (# State# s, SmallMutableArray# s a #)
2193+- {Make an immutable array mutable, without copying.}
2194+- with
2195+- out_of_line = True
2196+- has_side_effects = True
2197+-
2198+--- The code_size is only correct for the case when the copy family of
2199+--- primops aren't inlined. It would be nice to keep track of both.
2200+-
2201+-primop CopySmallArrayOp "copySmallArray#" GenPrimOp
2202+- SmallArray# a -> Int# -> SmallMutableArray# s a -> Int# -> Int# -> State# s -> State# s
2203+- {Given a source array, an offset into the source array, a
2204+- destination array, an offset into the destination array, and a
2205+- number of elements to copy, copy the elements from the source array
2206+- to the destination array. Both arrays must fully contain the
2207+- specified ranges, but this is not checked. The two arrays must not
2208+- be the same array in different states, but this is not checked
2209+- either.}
2210+- with
2211+- out_of_line = True
2212+- has_side_effects = True
2213+- can_fail = True
2214+-
2215+-primop CopySmallMutableArrayOp "copySmallMutableArray#" GenPrimOp
2216+- SmallMutableArray# s a -> Int# -> SmallMutableArray# s a -> Int# -> Int# -> State# s -> State# s
2217+- {Given a source array, an offset into the source array, a
2218+- destination array, an offset into the destination array, and a
2219+- number of elements to copy, copy the elements from the source array
2220+- to the destination array. The source and destination arrays can
2221+- refer to the same array. Both arrays must fully contain the
2222+- specified ranges, but this is not checked.
2223+- The regions are allowed to overlap, although this is only possible when the same
2224+- array is provided as both the source and the destination. }
2225+- with
2226+- out_of_line = True
2227+- has_side_effects = True
2228+- can_fail = True
2229+-
2230+-primop CloneSmallArrayOp "cloneSmallArray#" GenPrimOp
2231+- SmallArray# a -> Int# -> Int# -> SmallArray# a
2232+- {Given a source array, an offset into the source array, and a number
2233+- of elements to copy, create a new array with the elements from the
2234+- source array. The provided array must fully contain the specified
2235+- range, but this is not checked.}
2236+- with
2237+- out_of_line = True
2238+- has_side_effects = True
2239+- can_fail = True
2240+-
2241+-primop CloneSmallMutableArrayOp "cloneSmallMutableArray#" GenPrimOp
2242+- SmallMutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, SmallMutableArray# s a #)
2243+- {Given a source array, an offset into the source array, and a number
2244+- of elements to copy, create a new array with the elements from the
2245+- source array. The provided array must fully contain the specified
2246+- range, but this is not checked.}
2247+- with
2248+- out_of_line = True
2249+- has_side_effects = True
2250+- can_fail = True
2251+-
2252+-primop FreezeSmallArrayOp "freezeSmallArray#" GenPrimOp
2253+- SmallMutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, SmallArray# a #)
2254+- {Given a source array, an offset into the source array, and a number
2255+- of elements to copy, create a new array with the elements from the
2256+- source array. The provided array must fully contain the specified
2257+- range, but this is not checked.}
2258+- with
2259+- out_of_line = True
2260+- has_side_effects = True
2261+- can_fail = True
2262+-
2263+-primop ThawSmallArrayOp "thawSmallArray#" GenPrimOp
2264+- SmallArray# a -> Int# -> Int# -> State# s -> (# State# s, SmallMutableArray# s a #)
2265+- {Given a source array, an offset into the source array, and a number
2266+- of elements to copy, create a new array with the elements from the
2267+- source array. The provided array must fully contain the specified
2268+- range, but this is not checked.}
2269+- with
2270+- out_of_line = True
2271+- has_side_effects = True
2272+- can_fail = True
2273+-
2274+-primop CasSmallArrayOp "casSmallArray#" GenPrimOp
2275+- SmallMutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #)
2276+- {Unsafe, machine-level atomic compare and swap on an element within an array.}
2277+- with
2278+- out_of_line = True
2279+- has_side_effects = True
2280+-
2281+-------------------------------------------------------------------------
2282+-section "Byte Arrays"
2283+- {Operations on {\tt ByteArray\#}. A {\tt ByteArray\#} is a just a region of
2284+- raw memory in the garbage-collected heap, which is not
2285+- scanned for pointers. It carries its own size (in bytes).
2286+- There are
2287+- three sets of operations for accessing byte array contents:
2288+- index for reading from immutable byte arrays, and read/write
2289+- for mutable byte arrays. Each set contains operations for a
2290+- range of useful primitive data types. Each operation takes
2291+- an offset measured in terms of the size of the primitive type
2292+- being read or written.}
2293+-
2294+-------------------------------------------------------------------------
2295+-
2296+-primtype ByteArray#
2297+-
2298+-primtype MutableByteArray# s
2299+-
2300+-primop NewByteArrayOp_Char "newByteArray#" GenPrimOp
2301+- Int# -> State# s -> (# State# s, MutableByteArray# s #)
2302+- {Create a new mutable byte array of specified size (in bytes), in
2303+- the specified state thread.}
2304+- with out_of_line = True
2305+- has_side_effects = True
2306+-
2307+-primop NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp
2308+- Int# -> State# s -> (# State# s, MutableByteArray# s #)
2309+- {Create a mutable byte array that the GC guarantees not to move.}
2310+- with out_of_line = True
2311+- has_side_effects = True
2312+-
2313+-primop NewAlignedPinnedByteArrayOp_Char "newAlignedPinnedByteArray#" GenPrimOp
2314+- Int# -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
2315+- {Create a mutable byte array, aligned by the specified amount, that the GC guarantees not to move.}
2316+- with out_of_line = True
2317+- has_side_effects = True
2318+-
2319+-primop MutableByteArrayIsPinnedOp "isMutableByteArrayPinned#" GenPrimOp
2320+- MutableByteArray# s -> Int#
2321+- {Determine whether a {\tt MutableByteArray\#} is guaranteed not to move
2322+- during GC.}
2323+- with out_of_line = True
2324+-
2325+-primop ByteArrayIsPinnedOp "isByteArrayPinned#" GenPrimOp
2326+- ByteArray# -> Int#
2327+- {Determine whether a {\tt ByteArray\#} is guaranteed not to move during GC.}
2328+- with out_of_line = True
2329+-
2330+-primop ByteArrayContents_Char "byteArrayContents#" GenPrimOp
2331+- ByteArray# -> Addr#
2332+- {Intended for use with pinned arrays; otherwise very unsafe!}
2333+-
2334+-primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
2335+- MutableByteArray# s -> MutableByteArray# s -> Int#
2336+-
2337+-primop ShrinkMutableByteArrayOp_Char "shrinkMutableByteArray#" GenPrimOp
2338+- MutableByteArray# s -> Int# -> State# s -> State# s
2339+- {Shrink mutable byte array to new specified size (in bytes), in
2340+- the specified state thread. The new size argument must be less than or
2341+- equal to the current size as reported by {\tt sizeofMutableArray\#}.}
2342+- with out_of_line = True
2343+- has_side_effects = True
2344+-
2345+-primop ResizeMutableByteArrayOp_Char "resizeMutableByteArray#" GenPrimOp
2346+- MutableByteArray# s -> Int# -> State# s -> (# State# s,MutableByteArray# s #)
2347+- {Resize (unpinned) mutable byte array to new specified size (in bytes).
2348+- The returned {\tt MutableByteArray\#} is either the original
2349+- {\tt MutableByteArray\#} resized in-place or, if not possible, a newly
2350+- allocated (unpinned) {\tt MutableByteArray\#} (with the original content
2351+- copied over).
2352+-
2353+- To avoid undefined behaviour, the original {\tt MutableByteArray\#} shall
2354+- not be accessed anymore after a {\tt resizeMutableByteArray\#} has been
2355+- performed. Moreover, no reference to the old one should be kept in order
2356+- to allow garbage collection of the original {\tt MutableByteArray\#} in
2357+- case a new {\tt MutableByteArray\#} had to be allocated.}
2358+- with out_of_line = True
2359+- has_side_effects = True
2360+-
2361+-primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
2362+- MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)
2363+- {Make a mutable byte array immutable, without copying.}
2364+- with
2365+- has_side_effects = True
2366+-
2367+-primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
2368+- ByteArray# -> Int#
2369+- {Return the size of the array in bytes.}
2370+-
2371+-primop SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
2372+- MutableByteArray# s -> Int#
2373+- {Return the size of the array in bytes. Note that this is deprecated as it is
2374+- unsafe in the presence of concurrent resize operations on the same byte
2375+- array. See {\tt getSizeofMutableByteArray}.}
2376+-
2377+-primop GetSizeofMutableByteArrayOp "getSizeofMutableByteArray#" GenPrimOp
2378+- MutableByteArray# s -> State# s -> (# State# s, Int# #)
2379+- {Return the number of elements in the array.}
2380+-
2381+-primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
2382+- ByteArray# -> Int# -> Char#
2383+- {Read 8-bit character; offset in bytes.}
2384+- with can_fail = True
2385+-
2386+-primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp
2387+- ByteArray# -> Int# -> Char#
2388+- {Read 31-bit character; offset in 4-byte words.}
2389+- with can_fail = True
2390+-
2391+-primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
2392+- ByteArray# -> Int# -> Int#
2393+- with can_fail = True
2394+-
2395+-primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
2396+- ByteArray# -> Int# -> Word#
2397+- with can_fail = True
2398+-
2399+-primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
2400+- ByteArray# -> Int# -> Addr#
2401+- with can_fail = True
2402+-
2403+-primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
2404+- ByteArray# -> Int# -> Float#
2405+- with can_fail = True
2406+-
2407+-primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
2408+- ByteArray# -> Int# -> Double#
2409+- with can_fail = True
2410+-
2411+-primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
2412+- ByteArray# -> Int# -> StablePtr# a
2413+- with can_fail = True
2414+-
2415+-primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
2416+- ByteArray# -> Int# -> Int#
2417+- {Read 8-bit integer; offset in bytes.}
2418+- with can_fail = True
2419+-
2420+-primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
2421+- ByteArray# -> Int# -> Int#
2422+- {Read 16-bit integer; offset in 16-bit words.}
2423+- with can_fail = True
2424+-
2425+-primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
2426+- ByteArray# -> Int# -> INT32
2427+- {Read 32-bit integer; offset in 32-bit words.}
2428+- with can_fail = True
2429+-
2430+-primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
2431+- ByteArray# -> Int# -> INT64
2432+- {Read 64-bit integer; offset in 64-bit words.}
2433+- with can_fail = True
2434+-
2435+-primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
2436+- ByteArray# -> Int# -> Word#
2437+- {Read 8-bit word; offset in bytes.}
2438+- with can_fail = True
2439+-
2440+-primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
2441+- ByteArray# -> Int# -> Word#
2442+- {Read 16-bit word; offset in 16-bit words.}
2443+- with can_fail = True
2444+-
2445+-primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
2446+- ByteArray# -> Int# -> WORD32
2447+- {Read 32-bit word; offset in 32-bit words.}
2448+- with can_fail = True
2449+-
2450+-primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
2451+- ByteArray# -> Int# -> WORD64
2452+- {Read 64-bit word; offset in 64-bit words.}
2453+- with can_fail = True
2454+-
2455+-primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
2456+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
2457+- {Read 8-bit character; offset in bytes.}
2458+- with has_side_effects = True
2459+- can_fail = True
2460+-
2461+-primop ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp
2462+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
2463+- {Read 31-bit character; offset in 4-byte words.}
2464+- with has_side_effects = True
2465+- can_fail = True
2466+-
2467+-primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp
2468+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
2469+- {Read integer; offset in words.}
2470+- with has_side_effects = True
2471+- can_fail = True
2472+-
2473+-primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp
2474+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
2475+- {Read word; offset in words.}
2476+- with has_side_effects = True
2477+- can_fail = True
2478+-
2479+-primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
2480+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)
2481+- with has_side_effects = True
2482+- can_fail = True
2483+-
2484+-primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
2485+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
2486+- with has_side_effects = True
2487+- can_fail = True
2488+-
2489+-primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
2490+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
2491+- with has_side_effects = True
2492+- can_fail = True
2493+-
2494+-primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
2495+- MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
2496+- with has_side_effects = True
2497+- can_fail = True
2498+-
2499+-primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
2500+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
2501+- with has_side_effects = True
2502+- can_fail = True
2503+-
2504+-primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
2505+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
2506+- with has_side_effects = True
2507+- can_fail = True
2508+-
2509+-primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
2510+- MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #)
2511+- with has_side_effects = True
2512+- can_fail = True
2513+-
2514+-primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
2515+- MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #)
2516+- with has_side_effects = True
2517+- can_fail = True
2518+-
2519+-primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
2520+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
2521+- with has_side_effects = True
2522+- can_fail = True
2523+-
2524+-primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
2525+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
2526+- with has_side_effects = True
2527+- can_fail = True
2528+-
2529+-primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
2530+- MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #)
2531+- with has_side_effects = True
2532+- can_fail = True
2533+-
2534+-primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
2535+- MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #)
2536+- with has_side_effects = True
2537+- can_fail = True
2538+-
2539+-primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
2540+- MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
2541+- {Write 8-bit character; offset in bytes.}
2542+- with has_side_effects = True
2543+- can_fail = True
2544+-
2545+-primop WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp
2546+- MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
2547+- {Write 31-bit character; offset in 4-byte words.}
2548+- with has_side_effects = True
2549+- can_fail = True
2550+-
2551+-primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
2552+- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2553+- with has_side_effects = True
2554+- can_fail = True
2555+-
2556+-primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
2557+- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
2558+- with has_side_effects = True
2559+- can_fail = True
2560+-
2561+-primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
2562+- MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s
2563+- with has_side_effects = True
2564+- can_fail = True
2565+-
2566+-primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
2567+- MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
2568+- with has_side_effects = True
2569+- can_fail = True
2570+-
2571+-primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
2572+- MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
2573+- with has_side_effects = True
2574+- can_fail = True
2575+-
2576+-primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
2577+- MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s
2578+- with has_side_effects = True
2579+- can_fail = True
2580+-
2581+-primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
2582+- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2583+- with has_side_effects = True
2584+- can_fail = True
2585+-
2586+-primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
2587+- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2588+- with has_side_effects = True
2589+- can_fail = True
2590+-
2591+-primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
2592+- MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s
2593+- with has_side_effects = True
2594+- can_fail = True
2595+-
2596+-primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
2597+- MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s
2598+- with can_fail = True
2599+- has_side_effects = True
2600+-
2601+-primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
2602+- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
2603+- with has_side_effects = True
2604+- can_fail = True
2605+-
2606+-primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
2607+- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
2608+- with has_side_effects = True
2609+- can_fail = True
2610+-
2611+-primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
2612+- MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s
2613+- with has_side_effects = True
2614+- can_fail = True
2615+-
2616+-primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
2617+- MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s
2618+- with has_side_effects = True
2619+- can_fail = True
2620+-
2621+-primop CompareByteArraysOp "compareByteArrays#" GenPrimOp
2622+- ByteArray# -> Int# -> ByteArray# -> Int# -> Int# -> Int#
2623+- {{\tt compareByteArrays# src1 src1_ofs src2 src2_ofs n} compares
2624+- {\tt n} bytes starting at offset {\tt src1_ofs} in the first
2625+- {\tt ByteArray#} {\tt src1} to the range of {\tt n} bytes
2626+- (i.e. same length) starting at offset {\tt src2_ofs} of the second
2627+- {\tt ByteArray#} {\tt src2}. Both arrays must fully contain the
2628+- specified ranges, but this is not checked. Returns an {\tt Int#}
2629+- less than, equal to, or greater than zero if the range is found,
2630+- respectively, to be byte-wise lexicographically less than, to
2631+- match, or be greater than the second range.}
2632+- with
2633+- can_fail = True
2634+-
2635+-primop CopyByteArrayOp "copyByteArray#" GenPrimOp
2636+- ByteArray# -> Int# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2637+- {{\tt copyByteArray# src src_ofs dst dst_ofs n} copies the range
2638+- starting at offset {\tt src_ofs} of length {\tt n} from the
2639+- {\tt ByteArray#} {\tt src} to the {\tt MutableByteArray#} {\tt dst}
2640+- starting at offset {\tt dst_ofs}. Both arrays must fully contain
2641+- the specified ranges, but this is not checked. The two arrays must
2642+- not be the same array in different states, but this is not checked
2643+- either.}
2644+- with
2645+- has_side_effects = True
2646+- code_size = { primOpCodeSizeForeignCall + 4}
2647+- can_fail = True
2648+-
2649+-primop CopyMutableByteArrayOp "copyMutableByteArray#" GenPrimOp
2650+- MutableByteArray# s -> Int# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2651+- {Copy a range of the first MutableByteArray# to the specified region in the second MutableByteArray#.
2652+- Both arrays must fully contain the specified ranges, but this is not checked. The regions are
2653+- allowed to overlap, although this is only possible when the same array is provided
2654+- as both the source and the destination.}
2655+- with
2656+- has_side_effects = True
2657+- code_size = { primOpCodeSizeForeignCall + 4 }
2658+- can_fail = True
2659+-
2660+-primop CopyByteArrayToAddrOp "copyByteArrayToAddr#" GenPrimOp
2661+- ByteArray# -> Int# -> Addr# -> Int# -> State# s -> State# s
2662+- {Copy a range of the ByteArray# to the memory range starting at the Addr#.
2663+- The ByteArray# and the memory region at Addr# must fully contain the
2664+- specified ranges, but this is not checked. The Addr# must not point into the
2665+- ByteArray# (e.g. if the ByteArray# were pinned), but this is not checked
2666+- either.}
2667+- with
2668+- has_side_effects = True
2669+- code_size = { primOpCodeSizeForeignCall + 4}
2670+- can_fail = True
2671+-
2672+-primop CopyMutableByteArrayToAddrOp "copyMutableByteArrayToAddr#" GenPrimOp
2673+- MutableByteArray# s -> Int# -> Addr# -> Int# -> State# s -> State# s
2674+- {Copy a range of the MutableByteArray# to the memory range starting at the
2675+- Addr#. The MutableByteArray# and the memory region at Addr# must fully
2676+- contain the specified ranges, but this is not checked. The Addr# must not
2677+- point into the MutableByteArray# (e.g. if the MutableByteArray# were
2678+- pinned), but this is not checked either.}
2679+- with
2680+- has_side_effects = True
2681+- code_size = { primOpCodeSizeForeignCall + 4}
2682+- can_fail = True
2683+-
2684+-primop CopyAddrToByteArrayOp "copyAddrToByteArray#" GenPrimOp
2685+- Addr# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2686+- {Copy a memory range starting at the Addr# to the specified range in the
2687+- MutableByteArray#. The memory region at Addr# and the ByteArray# must fully
2688+- contain the specified ranges, but this is not checked. The Addr# must not
2689+- point into the MutableByteArray# (e.g. if the MutableByteArray# were pinned),
2690+- but this is not checked either.}
2691+- with
2692+- has_side_effects = True
2693+- code_size = { primOpCodeSizeForeignCall + 4}
2694+- can_fail = True
2695+-
2696+-primop SetByteArrayOp "setByteArray#" GenPrimOp
2697+- MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> State# s
2698+- {{\tt setByteArray# ba off len c} sets the byte range {\tt [off, off+len]} of
2699+- the {\tt MutableByteArray#} to the byte {\tt c}.}
2700+- with
2701+- has_side_effects = True
2702+- code_size = { primOpCodeSizeForeignCall + 4 }
2703+- can_fail = True
2704+-
2705+--- Atomic operations
2706+-
2707+-primop AtomicReadByteArrayOp_Int "atomicReadIntArray#" GenPrimOp
2708+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
2709+- {Given an array and an offset in Int units, read an element. The
2710+- index is assumed to be in bounds. Implies a full memory barrier.}
2711+- with has_side_effects = True
2712+- can_fail = True
2713+-
2714+-primop AtomicWriteByteArrayOp_Int "atomicWriteIntArray#" GenPrimOp
2715+- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2716+- {Given an array and an offset in Int units, write an element. The
2717+- index is assumed to be in bounds. Implies a full memory barrier.}
2718+- with has_side_effects = True
2719+- can_fail = True
2720+-
2721+-primop CasByteArrayOp_Int "casIntArray#" GenPrimOp
2722+- MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2723+- {Given an array, an offset in Int units, the expected old value, and
2724+- the new value, perform an atomic compare and swap i.e. write the new
2725+- value if the current value matches the provided old value. Returns
2726+- the value of the element before the operation. Implies a full memory
2727+- barrier.}
2728+- with has_side_effects = True
2729+- can_fail = True
2730+-
2731+-primop FetchAddByteArrayOp_Int "fetchAddIntArray#" GenPrimOp
2732+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2733+- {Given an array, and offset in Int units, and a value to add,
2734+- atomically add the value to the element. Returns the value of the
2735+- element before the operation. Implies a full memory barrier.}
2736+- with has_side_effects = True
2737+- can_fail = True
2738+-
2739+-primop FetchSubByteArrayOp_Int "fetchSubIntArray#" GenPrimOp
2740+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2741+- {Given an array, and offset in Int units, and a value to subtract,
2742+- atomically substract the value to the element. Returns the value of
2743+- the element before the operation. Implies a full memory barrier.}
2744+- with has_side_effects = True
2745+- can_fail = True
2746+-
2747+-primop FetchAndByteArrayOp_Int "fetchAndIntArray#" GenPrimOp
2748+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2749+- {Given an array, and offset in Int units, and a value to AND,
2750+- atomically AND the value to the element. Returns the value of the
2751+- element before the operation. Implies a full memory barrier.}
2752+- with has_side_effects = True
2753+- can_fail = True
2754+-
2755+-primop FetchNandByteArrayOp_Int "fetchNandIntArray#" GenPrimOp
2756+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2757+- {Given an array, and offset in Int units, and a value to NAND,
2758+- atomically NAND the value to the element. Returns the value of the
2759+- element before the operation. Implies a full memory barrier.}
2760+- with has_side_effects = True
2761+- can_fail = True
2762+-
2763+-primop FetchOrByteArrayOp_Int "fetchOrIntArray#" GenPrimOp
2764+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2765+- {Given an array, and offset in Int units, and a value to OR,
2766+- atomically OR the value to the element. Returns the value of the
2767+- element before the operation. Implies a full memory barrier.}
2768+- with has_side_effects = True
2769+- can_fail = True
2770+-
2771+-primop FetchXorByteArrayOp_Int "fetchXorIntArray#" GenPrimOp
2772+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2773+- {Given an array, and offset in Int units, and a value to XOR,
2774+- atomically XOR the value to the element. Returns the value of the
2775+- element before the operation. Implies a full memory barrier.}
2776+- with has_side_effects = True
2777+- can_fail = True
2778+-
2779+-
2780+-------------------------------------------------------------------------
2781+-section "Arrays of arrays"
2782+- {Operations on {\tt ArrayArray\#}. An {\tt ArrayArray\#} contains references to {\em unpointed}
2783+- arrays, such as {\tt ByteArray\#s}. Hence, it is not parameterised by the element types,
2784+- just like a {\tt ByteArray\#}, but it needs to be scanned during GC, just like an {\tt Array#}.
2785+- We represent an {\tt ArrayArray\#} exactly as a {\tt Array\#}, but provide element-type-specific
2786+- indexing, reading, and writing.}
2787+-------------------------------------------------------------------------
2788+-
2789+-primtype ArrayArray#
2790+-
2791+-primtype MutableArrayArray# s
2792+-
2793+-primop NewArrayArrayOp "newArrayArray#" GenPrimOp
2794+- Int# -> State# s -> (# State# s, MutableArrayArray# s #)
2795+- {Create a new mutable array of arrays with the specified number of elements,
2796+- in the specified state thread, with each element recursively referring to the
2797+- newly created array.}
2798+- with
2799+- out_of_line = True
2800+- has_side_effects = True
2801+-
2802+-primop SameMutableArrayArrayOp "sameMutableArrayArray#" GenPrimOp
2803+- MutableArrayArray# s -> MutableArrayArray# s -> Int#
2804+-
2805+-primop UnsafeFreezeArrayArrayOp "unsafeFreezeArrayArray#" GenPrimOp
2806+- MutableArrayArray# s -> State# s -> (# State# s, ArrayArray# #)
2807+- {Make a mutable array of arrays immutable, without copying.}
2808+- with
2809+- has_side_effects = True
2810+-
2811+-primop SizeofArrayArrayOp "sizeofArrayArray#" GenPrimOp
2812+- ArrayArray# -> Int#
2813+- {Return the number of elements in the array.}
2814+-
2815+-primop SizeofMutableArrayArrayOp "sizeofMutableArrayArray#" GenPrimOp
2816+- MutableArrayArray# s -> Int#
2817+- {Return the number of elements in the array.}
2818+-
2819+-primop IndexArrayArrayOp_ByteArray "indexByteArrayArray#" GenPrimOp
2820+- ArrayArray# -> Int# -> ByteArray#
2821+- with can_fail = True
2822+-
2823+-primop IndexArrayArrayOp_ArrayArray "indexArrayArrayArray#" GenPrimOp
2824+- ArrayArray# -> Int# -> ArrayArray#
2825+- with can_fail = True
2826+-
2827+-primop ReadArrayArrayOp_ByteArray "readByteArrayArray#" GenPrimOp
2828+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, ByteArray# #)
2829+- with has_side_effects = True
2830+- can_fail = True
2831+-
2832+-primop ReadArrayArrayOp_MutableByteArray "readMutableByteArrayArray#" GenPrimOp
2833+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
2834+- with has_side_effects = True
2835+- can_fail = True
2836+-
2837+-primop ReadArrayArrayOp_ArrayArray "readArrayArrayArray#" GenPrimOp
2838+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, ArrayArray# #)
2839+- with has_side_effects = True
2840+- can_fail = True
2841+-
2842+-primop ReadArrayArrayOp_MutableArrayArray "readMutableArrayArrayArray#" GenPrimOp
2843+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableArrayArray# s #)
2844+- with has_side_effects = True
2845+- can_fail = True
2846+-
2847+-primop WriteArrayArrayOp_ByteArray "writeByteArrayArray#" GenPrimOp
2848+- MutableArrayArray# s -> Int# -> ByteArray# -> State# s -> State# s
2849+- with has_side_effects = True
2850+- can_fail = True
2851+-
2852+-primop WriteArrayArrayOp_MutableByteArray "writeMutableByteArrayArray#" GenPrimOp
2853+- MutableArrayArray# s -> Int# -> MutableByteArray# s -> State# s -> State# s
2854+- with has_side_effects = True
2855+- can_fail = True
2856+-
2857+-primop WriteArrayArrayOp_ArrayArray "writeArrayArrayArray#" GenPrimOp
2858+- MutableArrayArray# s -> Int# -> ArrayArray# -> State# s -> State# s
2859+- with has_side_effects = True
2860+- can_fail = True
2861+-
2862+-primop WriteArrayArrayOp_MutableArrayArray "writeMutableArrayArrayArray#" GenPrimOp
2863+- MutableArrayArray# s -> Int# -> MutableArrayArray# s -> State# s -> State# s
2864+- with has_side_effects = True
2865+- can_fail = True
2866+-
2867+-primop CopyArrayArrayOp "copyArrayArray#" GenPrimOp
2868+- ArrayArray# -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s
2869+- {Copy a range of the ArrayArray# to the specified region in the MutableArrayArray#.
2870+- Both arrays must fully contain the specified ranges, but this is not checked.
2871+- The two arrays must not be the same array in different states, but this is not checked either.}
2872+- with
2873+- out_of_line = True
2874+- has_side_effects = True
2875+- can_fail = True
2876+-
2877+-primop CopyMutableArrayArrayOp "copyMutableArrayArray#" GenPrimOp
2878+- MutableArrayArray# s -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s
2879+- {Copy a range of the first MutableArrayArray# to the specified region in the second
2880+- MutableArrayArray#.
2881+- Both arrays must fully contain the specified ranges, but this is not checked.
2882+- The regions are allowed to overlap, although this is only possible when the same
2883+- array is provided as both the source and the destination.
2884+- }
2885+- with
2886+- out_of_line = True
2887+- has_side_effects = True
2888+- can_fail = True
2889+-
2890+-------------------------------------------------------------------------
2891+-section "Addr#"
2892+-------------------------------------------------------------------------
2893+-
2894+-primtype Addr#
2895+- { An arbitrary machine address assumed to point outside
2896+- the garbage-collected heap. }
2897+-
2898+-pseudoop "nullAddr#" Addr#
2899+- { The null address. }
2900+-
2901+-primop AddrAddOp "plusAddr#" GenPrimOp Addr# -> Int# -> Addr#
2902+-primop AddrSubOp "minusAddr#" GenPrimOp Addr# -> Addr# -> Int#
2903+- {Result is meaningless if two {\tt Addr\#}s are so far apart that their
2904+- difference doesn't fit in an {\tt Int\#}.}
2905+-primop AddrRemOp "remAddr#" GenPrimOp Addr# -> Int# -> Int#
2906+- {Return the remainder when the {\tt Addr\#} arg, treated like an {\tt Int\#},
2907+- is divided by the {\tt Int\#} arg.}
2908+-#if (WORD_SIZE_IN_BITS == 32 || WORD_SIZE_IN_BITS == 64)
2909+-primop Addr2IntOp "addr2Int#" GenPrimOp Addr# -> Int#
2910+- {Coerce directly from address to int. Strongly deprecated.}
2911+- with code_size = 0
2912+-primop Int2AddrOp "int2Addr#" GenPrimOp Int# -> Addr#
2913+- {Coerce directly from int to address. Strongly deprecated.}
2914+- with code_size = 0
2915+-#endif
2916+-
2917+-primop AddrGtOp "gtAddr#" Compare Addr# -> Addr# -> Int#
2918+-primop AddrGeOp "geAddr#" Compare Addr# -> Addr# -> Int#
2919+-primop AddrEqOp "eqAddr#" Compare Addr# -> Addr# -> Int#
2920+-primop AddrNeOp "neAddr#" Compare Addr# -> Addr# -> Int#
2921+-primop AddrLtOp "ltAddr#" Compare Addr# -> Addr# -> Int#
2922+-primop AddrLeOp "leAddr#" Compare Addr# -> Addr# -> Int#
2923+-
2924+-primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
2925+- Addr# -> Int# -> Char#
2926+- {Reads 8-bit character; offset in bytes.}
2927+- with can_fail = True
2928+-
2929+-primop IndexOffAddrOp_WideChar "indexWideCharOffAddr#" GenPrimOp
2930+- Addr# -> Int# -> Char#
2931+- {Reads 31-bit character; offset in 4-byte words.}
2932+- with can_fail = True
2933+-
2934+-primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
2935+- Addr# -> Int# -> Int#
2936+- with can_fail = True
2937+-
2938+-primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
2939+- Addr# -> Int# -> Word#
2940+- with can_fail = True
2941+-
2942+-primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
2943+- Addr# -> Int# -> Addr#
2944+- with can_fail = True
2945+-
2946+-primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
2947+- Addr# -> Int# -> Float#
2948+- with can_fail = True
2949+-
2950+-primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
2951+- Addr# -> Int# -> Double#
2952+- with can_fail = True
2953+-
2954+-primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
2955+- Addr# -> Int# -> StablePtr# a
2956+- with can_fail = True
2957+-
2958+-primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
2959+- Addr# -> Int# -> Int#
2960+- with can_fail = True
2961+-
2962+-primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
2963+- Addr# -> Int# -> Int#
2964+- with can_fail = True
2965+-
2966+-primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
2967+- Addr# -> Int# -> INT32
2968+- with can_fail = True
2969+-
2970+-primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
2971+- Addr# -> Int# -> INT64
2972+- with can_fail = True
2973+-
2974+-primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
2975+- Addr# -> Int# -> Word#
2976+- with can_fail = True
2977+-
2978+-primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
2979+- Addr# -> Int# -> Word#
2980+- with can_fail = True
2981+-
2982+-primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
2983+- Addr# -> Int# -> WORD32
2984+- with can_fail = True
2985+-
2986+-primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
2987+- Addr# -> Int# -> WORD64
2988+- with can_fail = True
2989+-
2990+-primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
2991+- Addr# -> Int# -> State# s -> (# State# s, Char# #)
2992+- {Reads 8-bit character; offset in bytes.}
2993+- with has_side_effects = True
2994+- can_fail = True
2995+-
2996+-primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp
2997+- Addr# -> Int# -> State# s -> (# State# s, Char# #)
2998+- {Reads 31-bit character; offset in 4-byte words.}
2999+- with has_side_effects = True
3000+- can_fail = True
3001+-
3002+-primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
3003+- Addr# -> Int# -> State# s -> (# State# s, Int# #)
3004+- with has_side_effects = True
3005+- can_fail = True
3006+-
3007+-primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
3008+- Addr# -> Int# -> State# s -> (# State# s, Word# #)
3009+- with has_side_effects = True
3010+- can_fail = True
3011+-
3012+-primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
3013+- Addr# -> Int# -> State# s -> (# State# s, Addr# #)
3014+- with has_side_effects = True
3015+- can_fail = True
3016+-
3017+-primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
3018+- Addr# -> Int# -> State# s -> (# State# s, Float# #)
3019+- with has_side_effects = True
3020+- can_fail = True
3021+-
3022+-primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
3023+- Addr# -> Int# -> State# s -> (# State# s, Double# #)
3024+- with has_side_effects = True
3025+- can_fail = True
3026+-
3027+-primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
3028+- Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
3029+- with has_side_effects = True
3030+- can_fail = True
3031+-
3032+-primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
3033+- Addr# -> Int# -> State# s -> (# State# s, Int# #)
3034+- with has_side_effects = True
3035+- can_fail = True
3036+-
3037+-primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
3038+- Addr# -> Int# -> State# s -> (# State# s, Int# #)
3039+- with has_side_effects = True
3040+- can_fail = True
3041+-
3042+-primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
3043+- Addr# -> Int# -> State# s -> (# State# s, INT32 #)
3044+- with has_side_effects = True
3045+- can_fail = True
3046+-
3047+-primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
3048+- Addr# -> Int# -> State# s -> (# State# s, INT64 #)
3049+- with has_side_effects = True
3050+- can_fail = True
3051+-
3052+-primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
3053+- Addr# -> Int# -> State# s -> (# State# s, Word# #)
3054+- with has_side_effects = True
3055+- can_fail = True
3056+-
3057+-primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
3058+- Addr# -> Int# -> State# s -> (# State# s, Word# #)
3059+- with has_side_effects = True
3060+- can_fail = True
3061+-
3062+-primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
3063+- Addr# -> Int# -> State# s -> (# State# s, WORD32 #)
3064+- with has_side_effects = True
3065+- can_fail = True
3066+-
3067+-primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
3068+- Addr# -> Int# -> State# s -> (# State# s, WORD64 #)
3069+- with has_side_effects = True
3070+- can_fail = True
3071+-
3072+-primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
3073+- Addr# -> Int# -> Char# -> State# s -> State# s
3074+- with has_side_effects = True
3075+- can_fail = True
3076+-
3077+-primop WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp
3078+- Addr# -> Int# -> Char# -> State# s -> State# s
3079+- with has_side_effects = True
3080+- can_fail = True
3081+-
3082+-primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
3083+- Addr# -> Int# -> Int# -> State# s -> State# s
3084+- with has_side_effects = True
3085+- can_fail = True
3086+-
3087+-primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
3088+- Addr# -> Int# -> Word# -> State# s -> State# s
3089+- with has_side_effects = True
3090+- can_fail = True
3091+-
3092+-primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
3093+- Addr# -> Int# -> Addr# -> State# s -> State# s
3094+- with has_side_effects = True
3095+- can_fail = True
3096+-
3097+-primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
3098+- Addr# -> Int# -> Float# -> State# s -> State# s
3099+- with has_side_effects = True
3100+- can_fail = True
3101+-
3102+-primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
3103+- Addr# -> Int# -> Double# -> State# s -> State# s
3104+- with has_side_effects = True
3105+- can_fail = True
3106+-
3107+-primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
3108+- Addr# -> Int# -> StablePtr# a -> State# s -> State# s
3109+- with has_side_effects = True
3110+- can_fail = True
3111+-
3112+-primop WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
3113+- Addr# -> Int# -> Int# -> State# s -> State# s
3114+- with has_side_effects = True
3115+- can_fail = True
3116+-
3117+-primop WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
3118+- Addr# -> Int# -> Int# -> State# s -> State# s
3119+- with has_side_effects = True
3120+- can_fail = True
3121+-
3122+-primop WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
3123+- Addr# -> Int# -> INT32 -> State# s -> State# s
3124+- with has_side_effects = True
3125+- can_fail = True
3126+-
3127+-primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
3128+- Addr# -> Int# -> INT64 -> State# s -> State# s
3129+- with has_side_effects = True
3130+- can_fail = True
3131+-
3132+-primop WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
3133+- Addr# -> Int# -> Word# -> State# s -> State# s
3134+- with has_side_effects = True
3135+- can_fail = True
3136+-
3137+-primop WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
3138+- Addr# -> Int# -> Word# -> State# s -> State# s
3139+- with has_side_effects = True
3140+- can_fail = True
3141+-
3142+-primop WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
3143+- Addr# -> Int# -> WORD32 -> State# s -> State# s
3144+- with has_side_effects = True
3145+- can_fail = True
3146+-
3147+-primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
3148+- Addr# -> Int# -> WORD64 -> State# s -> State# s
3149+- with has_side_effects = True
3150+- can_fail = True
3151+-
3152+-------------------------------------------------------------------------
3153+-section "Mutable variables"
3154+- {Operations on MutVar\#s.}
3155+-------------------------------------------------------------------------
3156+-
3157+-primtype MutVar# s a
3158+- {A {\tt MutVar\#} behaves like a single-element mutable array.}
3159+-
3160+-primop NewMutVarOp "newMutVar#" GenPrimOp
3161+- a -> State# s -> (# State# s, MutVar# s a #)
3162+- {Create {\tt MutVar\#} with specified initial value in specified state thread.}
3163+- with
3164+- out_of_line = True
3165+- has_side_effects = True
3166+-
3167+--- Note [Why MutVar# ops can't fail]
3168+--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3169+---
3170+--- We don't label readMutVar# or writeMutVar# as can_fail.
3171+--- This may seem a bit peculiar, because they surely *could*
3172+--- fail spectacularly if passed a pointer to unallocated memory.
3173+--- But MutVar#s are always correct by construction; we never
3174+--- test if a pointer is valid before using it with these operations.
3175+--- So we never have to worry about floating the pointer reference
3176+--- outside a validity test. At the moment, has_side_effects blocks
3177+--- up the relevant optimizations anyway, but we hope to draw finer
3178+--- distinctions soon, which should improve matters for readMutVar#
3179+--- at least.
3180+-
3181+-primop ReadMutVarOp "readMutVar#" GenPrimOp
3182+- MutVar# s a -> State# s -> (# State# s, a #)
3183+- {Read contents of {\tt MutVar\#}. Result is not yet evaluated.}
3184+- with
3185+- -- See Note [Why MutVar# ops can't fail]
3186+- has_side_effects = True
3187+-
3188+-primop WriteMutVarOp "writeMutVar#" GenPrimOp
3189+- MutVar# s a -> a -> State# s -> State# s
3190+- {Write contents of {\tt MutVar\#}.}
3191+- with
3192+- -- See Note [Why MutVar# ops can't fail]
3193+- has_side_effects = True
3194+- code_size = { primOpCodeSizeForeignCall } -- for the write barrier
3195+-
3196+-primop SameMutVarOp "sameMutVar#" GenPrimOp
3197+- MutVar# s a -> MutVar# s a -> Int#
3198+-
3199+--- Note [Why not an unboxed tuple in atomicModifyMutVar#?]
3200+--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3201+---
3202+--- Looking at the type of atomicModifyMutVar#, one might wonder why
3203+--- it doesn't return an unboxed tuple. e.g.,
3204+---
3205+--- MutVar# s a -> (a -> (# a, b #)) -> State# s -> (# State# s, b #)
3206+---
3207+--- The reason is that atomicModifyMutVar# relies on laziness for its atomicity.
3208+--- Given a MutVar# containing x, atomicModifyMutVar# merely replaces the
3209+--- its contents with a thunk of the form (fst (f x)). This can be done using an
3210+--- atomic compare-and-swap as it is merely replacing a pointer.
3211+-
3212+-primop AtomicModifyMutVarOp "atomicModifyMutVar#" GenPrimOp
3213+- MutVar# s a -> (a -> b) -> State# s -> (# State# s, c #)
3214+- { Modify the contents of a {\tt MutVar\#}. Note that this isn't strictly
3215+- speaking the correct type for this function, it should really be
3216+- {\tt MutVar# s a -> (a -> (a,b)) -> State# s -> (# State# s, b #)}, however
3217+- we don't know about pairs here. }
3218+- with
3219+- out_of_line = True
3220+- has_side_effects = True
3221+- can_fail = True
3222+-
3223+-primop CasMutVarOp "casMutVar#" GenPrimOp
3224+- MutVar# s a -> a -> a -> State# s -> (# State# s, Int#, a #)
3225+- with
3226+- out_of_line = True
3227+- has_side_effects = True
3228+-
3229+-------------------------------------------------------------------------
3230+-section "Exceptions"
3231+-------------------------------------------------------------------------
3232+-
3233+--- Note [Strictness for mask/unmask/catch]
3234+--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3235+--- Consider this example, which comes from GHC.IO.Handle.Internals:
3236+--- wantReadableHandle3 f ma b st
3237+--- = case ... of
3238+--- DEFAULT -> case ma of MVar a -> ...
3239+--- 0# -> maskAsynchExceptions# (\st -> case ma of MVar a -> ...)
3240+--- The outer case just decides whether to mask exceptions, but we don't want
3241+--- thereby to hide the strictness in 'ma'! Hence the use of strictApply1Dmd.
3242+---
3243+--- For catch, catchSTM, and catchRetry, we must be extra careful; see
3244+--- Note [Exceptions and strictness] in Demand
3245+-
3246+-primop CatchOp "catch#" GenPrimOp
3247+- (State# RealWorld -> (# State# RealWorld, a #) )
3248+- -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
3249+- -> State# RealWorld
3250+- -> (# State# RealWorld, a #)
3251+- with
3252+- strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
3253+- , lazyApply2Dmd
3254+- , topDmd] topRes }
3255+- -- See Note [Strictness for mask/unmask/catch]
3256+- out_of_line = True
3257+- has_side_effects = True
3258+-
3259+-primop RaiseOp "raise#" GenPrimOp
3260+- b -> o
3261+- -- NB: the type variable "o" is "a", but with OpenKind
3262+- with
3263+- strictness = { \ _arity -> mkClosedStrictSig [topDmd] exnRes }
3264+- -- NB: result is ThrowsExn
3265+- out_of_line = True
3266+- has_side_effects = True
3267+- -- raise# certainly throws a Haskell exception and hence has_side_effects
3268+- -- It doesn't actually make much difference because the fact that it
3269+- -- returns bottom independently ensures that we are careful not to discard
3270+- -- it. But still, it's better to say the Right Thing.
3271+-
3272+--- raiseIO# needs to be a primop, because exceptions in the IO monad
3273+--- must be *precise* - we don't want the strictness analyser turning
3274+--- one kind of bottom into another, as it is allowed to do in pure code.
3275+---
3276+--- But we *do* want to know that it returns bottom after
3277+--- being applied to two arguments, so that this function is strict in y
3278+--- f x y | x>0 = raiseIO blah
3279+--- | y>0 = return 1
3280+--- | otherwise = return 2
3281+---
3282+--- TODO Check that the above notes on @f@ are valid. The function successfully
3283+--- produces an IO exception when compiled without optimization. If we analyze
3284+--- it as strict in @y@, won't we change that behavior under optimization?
3285+--- I thought the rule was that it was okay to replace one valid imprecise
3286+--- exception with another, but not to replace a precise exception with
3287+--- an imprecise one (dfeuer, 2017-03-05).
3288+-
3289+-primop RaiseIOOp "raiseIO#" GenPrimOp
3290+- a -> State# RealWorld -> (# State# RealWorld, b #)
3291+- with
3292+- strictness = { \ _arity -> mkClosedStrictSig [topDmd, topDmd] exnRes }
3293+- out_of_line = True
3294+- has_side_effects = True
3295+-
3296+-primop MaskAsyncExceptionsOp "maskAsyncExceptions#" GenPrimOp
3297+- (State# RealWorld -> (# State# RealWorld, a #))
3298+- -> (State# RealWorld -> (# State# RealWorld, a #))
3299+- with
3300+- strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
3301+- -- See Note [Strictness for mask/unmask/catch]
3302+- out_of_line = True
3303+- has_side_effects = True
3304+-
3305+-primop MaskUninterruptibleOp "maskUninterruptible#" GenPrimOp
3306+- (State# RealWorld -> (# State# RealWorld, a #))
3307+- -> (State# RealWorld -> (# State# RealWorld, a #))
3308+- with
3309+- strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
3310+- out_of_line = True
3311+- has_side_effects = True
3312+-
3313+-primop UnmaskAsyncExceptionsOp "unmaskAsyncExceptions#" GenPrimOp
3314+- (State# RealWorld -> (# State# RealWorld, a #))
3315+- -> (State# RealWorld -> (# State# RealWorld, a #))
3316+- with
3317+- strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
3318+- -- See Note [Strictness for mask/unmask/catch]
3319+- out_of_line = True
3320+- has_side_effects = True
3321+-
3322+-primop MaskStatus "getMaskingState#" GenPrimOp
3323+- State# RealWorld -> (# State# RealWorld, Int# #)
3324+- with
3325+- out_of_line = True
3326+- has_side_effects = True
3327+-
3328+-------------------------------------------------------------------------
3329+-section "STM-accessible Mutable Variables"
3330+-------------------------------------------------------------------------
3331+-
3332+-primtype TVar# s a
3333+-
3334+-primop AtomicallyOp "atomically#" GenPrimOp
3335+- (State# RealWorld -> (# State# RealWorld, a #) )
3336+- -> State# RealWorld -> (# State# RealWorld, a #)
3337+- with
3338+- strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
3339+- -- See Note [Strictness for mask/unmask/catch]
3340+- out_of_line = True
3341+- has_side_effects = True
3342+-
3343+--- NB: retry#'s strictness information specifies it to throw an exception
3344+--- This lets the compiler perform some extra simplifications, since retry#
3345+--- will technically never return.
3346+---
3347+--- This allows the simplifier to replace things like:
3348+--- case retry# s1
3349+--- (# s2, a #) -> e
3350+--- with:
3351+--- retry# s1
3352+--- where 'e' would be unreachable anyway. See Trac #8091.
3353+---
3354+--- Note that it *does not* return botRes as the "exception" that is thrown may be
3355+--- "caught" by catchRetry#. This mistake caused #14171.
3356+-primop RetryOp "retry#" GenPrimOp
3357+- State# RealWorld -> (# State# RealWorld, a #)
3358+- with
3359+- strictness = { \ _arity -> mkClosedStrictSig [topDmd] exnRes }
3360+- out_of_line = True
3361+- has_side_effects = True
3362+-
3363+-primop CatchRetryOp "catchRetry#" GenPrimOp
3364+- (State# RealWorld -> (# State# RealWorld, a #) )
3365+- -> (State# RealWorld -> (# State# RealWorld, a #) )
3366+- -> (State# RealWorld -> (# State# RealWorld, a #) )
3367+- with
3368+- strictness = { \ _arity -> mkClosedStrictSig [ catchArgDmd
3369+- , lazyApply1Dmd
3370+- , topDmd ] topRes }
3371+- -- See Note [Strictness for mask/unmask/catch]
3372+- out_of_line = True
3373+- has_side_effects = True
3374+-
3375+-primop CatchSTMOp "catchSTM#" GenPrimOp
3376+- (State# RealWorld -> (# State# RealWorld, a #) )
3377+- -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
3378+- -> (State# RealWorld -> (# State# RealWorld, a #) )
3379+- with
3380+- strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
3381+- , lazyApply2Dmd
3382+- , topDmd ] topRes }
3383+- -- See Note [Strictness for mask/unmask/catch]
3384+- out_of_line = True
3385+- has_side_effects = True
3386+-
3387+-primop Check "check#" GenPrimOp
3388+- (State# RealWorld -> (# State# RealWorld, a #) )
3389+- -> (State# RealWorld -> State# RealWorld)
3390+- with
3391+- out_of_line = True
3392+- has_side_effects = True
3393+-
3394+-primop NewTVarOp "newTVar#" GenPrimOp
3395+- a
3396+- -> State# s -> (# State# s, TVar# s a #)
3397+- {Create a new {\tt TVar\#} holding a specified initial value.}
3398+- with
3399+- out_of_line = True
3400+- has_side_effects = True
3401+-
3402+-primop ReadTVarOp "readTVar#" GenPrimOp
3403+- TVar# s a
3404+- -> State# s -> (# State# s, a #)
3405+- {Read contents of {\tt TVar\#}. Result is not yet evaluated.}
3406+- with
3407+- out_of_line = True
3408+- has_side_effects = True
3409+-
3410+-primop ReadTVarIOOp "readTVarIO#" GenPrimOp
3411+- TVar# s a
3412+- -> State# s -> (# State# s, a #)
3413+- {Read contents of {\tt TVar\#} outside an STM transaction}
3414+- with
3415+- out_of_line = True
3416+- has_side_effects = True
3417+-
3418+-primop WriteTVarOp "writeTVar#" GenPrimOp
3419+- TVar# s a
3420+- -> a
3421+- -> State# s -> State# s
3422+- {Write contents of {\tt TVar\#}.}
3423+- with
3424+- out_of_line = True
3425+- has_side_effects = True
3426+-
3427+-primop SameTVarOp "sameTVar#" GenPrimOp
3428+- TVar# s a -> TVar# s a -> Int#
3429+-
3430+-
3431+-------------------------------------------------------------------------
3432+-section "Synchronized Mutable Variables"
3433+- {Operations on {\tt MVar\#}s. }
3434+-------------------------------------------------------------------------
3435+-
3436+-primtype MVar# s a
3437+- { A shared mutable variable ({\it not} the same as a {\tt MutVar\#}!).
3438+- (Note: in a non-concurrent implementation, {\tt (MVar\# a)} can be
3439+- represented by {\tt (MutVar\# (Maybe a))}.) }
3440+-
3441+-primop NewMVarOp "newMVar#" GenPrimOp
3442+- State# s -> (# State# s, MVar# s a #)
3443+- {Create new {\tt MVar\#}; initially empty.}
3444+- with
3445+- out_of_line = True
3446+- has_side_effects = True
3447+-
3448+-primop TakeMVarOp "takeMVar#" GenPrimOp
3449+- MVar# s a -> State# s -> (# State# s, a #)
3450+- {If {\tt MVar\#} is empty, block until it becomes full.
3451+- Then remove and return its contents, and set it empty.}
3452+- with
3453+- out_of_line = True
3454+- has_side_effects = True
3455+-
3456+-primop TryTakeMVarOp "tryTakeMVar#" GenPrimOp
3457+- MVar# s a -> State# s -> (# State# s, Int#, a #)
3458+- {If {\tt MVar\#} is empty, immediately return with integer 0 and value undefined.
3459+- Otherwise, return with integer 1 and contents of {\tt MVar\#}, and set {\tt MVar\#} empty.}
3460+- with
3461+- out_of_line = True
3462+- has_side_effects = True
3463+-
3464+-primop PutMVarOp "putMVar#" GenPrimOp
3465+- MVar# s a -> a -> State# s -> State# s
3466+- {If {\tt MVar\#} is full, block until it becomes empty.
3467+- Then store value arg as its new contents.}
3468+- with
3469+- out_of_line = True
3470+- has_side_effects = True
3471+-
3472+-primop TryPutMVarOp "tryPutMVar#" GenPrimOp
3473+- MVar# s a -> a -> State# s -> (# State# s, Int# #)
3474+- {If {\tt MVar\#} is full, immediately return with integer 0.
3475+- Otherwise, store value arg as {\tt MVar\#}'s new contents, and return with integer 1.}
3476+- with
3477+- out_of_line = True
3478+- has_side_effects = True
3479+-
3480+-primop ReadMVarOp "readMVar#" GenPrimOp
3481+- MVar# s a -> State# s -> (# State# s, a #)
3482+- {If {\tt MVar\#} is empty, block until it becomes full.
3483+- Then read its contents without modifying the MVar, without possibility
3484+- of intervention from other threads.}
3485+- with
3486+- out_of_line = True
3487+- has_side_effects = True
3488+-
3489+-primop TryReadMVarOp "tryReadMVar#" GenPrimOp
3490+- MVar# s a -> State# s -> (# State# s, Int#, a #)
3491+- {If {\tt MVar\#} is empty, immediately return with integer 0 and value undefined.
3492+- Otherwise, return with integer 1 and contents of {\tt MVar\#}.}
3493+- with
3494+- out_of_line = True
3495+- has_side_effects = True
3496+-
3497+-primop SameMVarOp "sameMVar#" GenPrimOp
3498+- MVar# s a -> MVar# s a -> Int#
3499+-
3500+-primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
3501+- MVar# s a -> State# s -> (# State# s, Int# #)
3502+- {Return 1 if {\tt MVar\#} is empty; 0 otherwise.}
3503+- with
3504+- out_of_line = True
3505+- has_side_effects = True
3506+-
3507+-------------------------------------------------------------------------
3508+-section "Delay/wait operations"
3509+-------------------------------------------------------------------------
3510+-
3511+-primop DelayOp "delay#" GenPrimOp
3512+- Int# -> State# s -> State# s
3513+- {Sleep specified number of microseconds.}
3514+- with
3515+- has_side_effects = True
3516+- out_of_line = True
3517+-
3518+-primop WaitReadOp "waitRead#" GenPrimOp
3519+- Int# -> State# s -> State# s
3520+- {Block until input is available on specified file descriptor.}
3521+- with
3522+- has_side_effects = True
3523+- out_of_line = True
3524+-
3525+-primop WaitWriteOp "waitWrite#" GenPrimOp
3526+- Int# -> State# s -> State# s
3527+- {Block until output is possible on specified file descriptor.}
3528+- with
3529+- has_side_effects = True
3530+- out_of_line = True
3531+-
3532+-#if defined(mingw32_TARGET_OS)
3533+-primop AsyncReadOp "asyncRead#" GenPrimOp
3534+- Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
3535+- {Asynchronously read bytes from specified file descriptor.}
3536+- with
3537+- has_side_effects = True
3538+- out_of_line = True
3539+-
3540+-primop AsyncWriteOp "asyncWrite#" GenPrimOp
3541+- Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
3542+- {Asynchronously write bytes from specified file descriptor.}
3543+- with
3544+- has_side_effects = True
3545+- out_of_line = True
3546+-
3547+-primop AsyncDoProcOp "asyncDoProc#" GenPrimOp
3548+- Addr# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
3549+- {Asynchronously perform procedure (first arg), passing it 2nd arg.}
3550+- with
3551+- has_side_effects = True
3552+- out_of_line = True
3553+-
3554+-#endif
3555+-
3556+-------------------------------------------------------------------------
3557+-section "Concurrency primitives"
3558+-------------------------------------------------------------------------
3559+-
3560+-primtype State# s
3561+- { {\tt State\#} is the primitive, unlifted type of states. It has
3562+- one type parameter, thus {\tt State\# RealWorld}, or {\tt State\# s},
3563+- where s is a type variable. The only purpose of the type parameter
3564+- is to keep different state threads separate. It is represented by
3565+- nothing at all. }
3566+-
3567+-primtype RealWorld
3568+- { {\tt RealWorld} is deeply magical. It is {\it primitive}, but it is not
3569+- {\it unlifted} (hence {\tt ptrArg}). We never manipulate values of type
3570+- {\tt RealWorld}; it's only used in the type system, to parameterise {\tt State\#}. }
3571+-
3572+-primtype ThreadId#
3573+- {(In a non-concurrent implementation, this can be a singleton
3574+- type, whose (unique) value is returned by {\tt myThreadId\#}. The
3575+- other operations can be omitted.)}
3576+-
3577+-primop ForkOp "fork#" GenPrimOp
3578+- a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
3579+- with
3580+- has_side_effects = True
3581+- out_of_line = True
3582+-
3583+-primop ForkOnOp "forkOn#" GenPrimOp
3584+- Int# -> a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
3585+- with
3586+- has_side_effects = True
3587+- out_of_line = True
3588+-
3589+-primop KillThreadOp "killThread#" GenPrimOp
3590+- ThreadId# -> a -> State# RealWorld -> State# RealWorld
3591+- with
3592+- has_side_effects = True
3593+- out_of_line = True
3594+-
3595+-primop YieldOp "yield#" GenPrimOp
3596+- State# RealWorld -> State# RealWorld
3597+- with
3598+- has_side_effects = True
3599+- out_of_line = True
3600+-
3601+-primop MyThreadIdOp "myThreadId#" GenPrimOp
3602+- State# RealWorld -> (# State# RealWorld, ThreadId# #)
3603+- with
3604+- out_of_line = True
3605+- has_side_effects = True
3606+-
3607+-primop LabelThreadOp "labelThread#" GenPrimOp
3608+- ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
3609+- with
3610+- has_side_effects = True
3611+- out_of_line = True
3612+-
3613+-primop IsCurrentThreadBoundOp "isCurrentThreadBound#" GenPrimOp
3614+- State# RealWorld -> (# State# RealWorld, Int# #)
3615+- with
3616+- out_of_line = True
3617+- has_side_effects = True
3618+-
3619+-primop NoDuplicateOp "noDuplicate#" GenPrimOp
3620+- State# s -> State# s
3621+- with
3622+- out_of_line = True
3623+- has_side_effects = True
3624+-
3625+-primop ThreadStatusOp "threadStatus#" GenPrimOp
3626+- ThreadId# -> State# RealWorld -> (# State# RealWorld, Int#, Int#, Int# #)
3627+- with
3628+- out_of_line = True
3629+- has_side_effects = True
3630+-
3631+-------------------------------------------------------------------------
3632+-section "Weak pointers"
3633+-------------------------------------------------------------------------
3634+-
3635+-primtype Weak# b
3636+-
3637+--- note that tyvar "o" denotes openAlphaTyVar
3638+-
3639+-primop MkWeakOp "mkWeak#" GenPrimOp
3640+- o -> b -> (State# RealWorld -> (# State# RealWorld, c #))
3641+- -> State# RealWorld -> (# State# RealWorld, Weak# b #)
3642+- { {\tt mkWeak# k v finalizer s} creates a weak reference to value {\tt k},
3643+- with an associated reference to some value {\tt v}. If {\tt k} is still
3644+- alive then {\tt v} can be retrieved using {\tt deRefWeak#}. Note that
3645+- the type of {\tt k} must be represented by a pointer (i.e. of kind {\tt
3646+- TYPE 'LiftedRep} or {\tt TYPE 'UnliftedRep}). }
3647+- with
3648+- has_side_effects = True
3649+- out_of_line = True
3650+-
3651+-primop MkWeakNoFinalizerOp "mkWeakNoFinalizer#" GenPrimOp
3652+- o -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #)
3653+- with
3654+- has_side_effects = True
3655+- out_of_line = True
3656+-
3657+-primop AddCFinalizerToWeakOp "addCFinalizerToWeak#" GenPrimOp
3658+- Addr# -> Addr# -> Int# -> Addr# -> Weak# b
3659+- -> State# RealWorld -> (# State# RealWorld, Int# #)
3660+- { {\tt addCFinalizerToWeak# fptr ptr flag eptr w} attaches a C
3661+- function pointer {\tt fptr} to a weak pointer {\tt w} as a finalizer. If
3662+- {\tt flag} is zero, {\tt fptr} will be called with one argument,
3663+- {\tt ptr}. Otherwise, it will be called with two arguments,
3664+- {\tt eptr} and {\tt ptr}. {\tt addCFinalizerToWeak#} returns
3665+- 1 on success, or 0 if {\tt w} is already dead. }
3666+- with
3667+- has_side_effects = True
3668+- out_of_line = True
3669+-
3670+-primop DeRefWeakOp "deRefWeak#" GenPrimOp
3671+- Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
3672+- with
3673+- has_side_effects = True
3674+- out_of_line = True
3675+-
3676+-primop FinalizeWeakOp "finalizeWeak#" GenPrimOp
3677+- Weak# a -> State# RealWorld -> (# State# RealWorld, Int#,
3678+- (State# RealWorld -> (# State# RealWorld, b #) ) #)
3679+- { Finalize a weak pointer. The return value is an unboxed tuple
3680+- containing the new state of the world and an "unboxed Maybe",
3681+- represented by an {\tt Int#} and a (possibly invalid) finalization
3682+- action. An {\tt Int#} of {\tt 1} indicates that the finalizer is valid. The
3683+- return value {\tt b} from the finalizer should be ignored. }
3684+- with
3685+- has_side_effects = True
3686+- out_of_line = True
3687+-
3688+-primop TouchOp "touch#" GenPrimOp
3689+- o -> State# RealWorld -> State# RealWorld
3690+- with
3691+- code_size = { 0 }
3692+- has_side_effects = True
3693+-
3694+-------------------------------------------------------------------------
3695+-section "Stable pointers and names"
3696+-------------------------------------------------------------------------
3697+-
3698+-primtype StablePtr# a
3699+-
3700+-primtype StableName# a
3701+-
3702+-primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
3703+- a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
3704+- with
3705+- has_side_effects = True
3706+- out_of_line = True
3707+-
3708+-primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
3709+- StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
3710+- with
3711+- has_side_effects = True
3712+- out_of_line = True
3713+-
3714+-primop EqStablePtrOp "eqStablePtr#" GenPrimOp
3715+- StablePtr# a -> StablePtr# a -> Int#
3716+- with
3717+- has_side_effects = True
3718+-
3719+-primop MakeStableNameOp "makeStableName#" GenPrimOp
3720+- a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
3721+- with
3722+- has_side_effects = True
3723+- out_of_line = True
3724+-
3725+-primop EqStableNameOp "eqStableName#" GenPrimOp
3726+- StableName# a -> StableName# b -> Int#
3727+-
3728+-primop StableNameToIntOp "stableNameToInt#" GenPrimOp
3729+- StableName# a -> Int#
3730+-
3731+-------------------------------------------------------------------------
3732+-section "Compact normal form"
3733+-------------------------------------------------------------------------
3734+-
3735+-primtype Compact#
3736+-
3737+-primop CompactNewOp "compactNew#" GenPrimOp
3738+- Word# -> State# RealWorld -> (# State# RealWorld, Compact# #)
3739+- { Create a new Compact with the given size (in bytes, not words).
3740+- The size is rounded up to a multiple of the allocator block size,
3741+- and capped to one mega block. }
3742+- with
3743+- has_side_effects = True
3744+- out_of_line = True
3745+-
3746+-primop CompactResizeOp "compactResize#" GenPrimOp
3747+- Compact# -> Word# -> State# RealWorld ->
3748+- State# RealWorld
3749+- { Set the new allocation size of the compact. This value (in bytes)
3750+- determines the size of each block in the compact chain. }
3751+- with
3752+- has_side_effects = True
3753+- out_of_line = True
3754+-
3755+-primop CompactContainsOp "compactContains#" GenPrimOp
3756+- Compact# -> a -> State# RealWorld -> (# State# RealWorld, Int# #)
3757+- { Returns 1# if the object is contained in the compact, 0# otherwise. }
3758+- with
3759+- out_of_line = True
3760+-
3761+-primop CompactContainsAnyOp "compactContainsAny#" GenPrimOp
3762+- a -> State# RealWorld -> (# State# RealWorld, Int# #)
3763+- { Returns 1# if the object is in any compact at all, 0# otherwise. }
3764+- with
3765+- out_of_line = True
3766+-
3767+-primop CompactGetFirstBlockOp "compactGetFirstBlock#" GenPrimOp
3768+- Compact# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)
3769+- { Returns the address and the size (in bytes) of the first block of
3770+- a compact. }
3771+- with
3772+- out_of_line = True
3773+-
3774+-primop CompactGetNextBlockOp "compactGetNextBlock#" GenPrimOp
3775+- Compact# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)
3776+- { Given a compact and the address of one its blocks, returns the
3777+- next block and its size, or #nullAddr if the argument was the
3778+- last block in the compact. }
3779+- with
3780+- out_of_line = True
3781+-
3782+-primop CompactAllocateBlockOp "compactAllocateBlock#" GenPrimOp
3783+- Word# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr# #)
3784+- { Attempt to allocate a compact block with the given size (in
3785+- bytes) at the given address. The first argument is a hint to
3786+- the allocator, allocation might be satisfied at a different
3787+- address (which is returned).
3788+- The resulting block is not known to the GC until
3789+- compactFixupPointers# is called on it, and care must be taken
3790+- so that the address does not escape or memory will be leaked.
3791+- }
3792+- with
3793+- has_side_effects = True
3794+- out_of_line = True
3795+-
3796+-primop CompactFixupPointersOp "compactFixupPointers#" GenPrimOp
3797+- Addr# -> Addr# -> State# RealWorld -> (# State# RealWorld, Compact#, Addr# #)
3798+- { Given the pointer to the first block of a compact, and the
3799+- address of the root object in the old address space, fix up
3800+- the internal pointers inside the compact to account for
3801+- a different position in memory than when it was serialized.
3802+- This method must be called exactly once after importing
3803+- a serialized compact, and returns the new compact and
3804+- the new adjusted root address. }
3805+- with
3806+- has_side_effects = True
3807+- out_of_line = True
3808+-
3809+-primop CompactAdd "compactAdd#" GenPrimOp
3810+- Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #)
3811+- { Recursively add a closure and its transitive closure to a
3812+- {\texttt Compact\#}, evaluating any unevaluated components at the
3813+- same time. Note: {\texttt compactAdd\#} is not thread-safe, so
3814+- only one thread may call {\texttt compactAdd\#} with a particular
3815+- {\texttt Compact#} at any given time. The primop does not
3816+- enforce any mutual exclusion; the caller is expected to
3817+- arrange this. }
3818+- with
3819+- has_side_effects = True
3820+- out_of_line = True
3821+-
3822+-primop CompactAddWithSharing "compactAddWithSharing#" GenPrimOp
3823+- Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #)
3824+- { Like {\texttt compactAdd\#}, but retains sharing and cycles
3825+- during compaction. }
3826+- with
3827+- has_side_effects = True
3828+- out_of_line = True
3829+-
3830+-primop CompactSize "compactSize#" GenPrimOp
3831+- Compact# -> State# RealWorld -> (# State# RealWorld, Word# #)
3832+- { Return the size (in bytes) of the total amount of data in the Compact# }
3833+- with
3834+- has_side_effects = True
3835+- out_of_line = True
3836+-
3837+-------------------------------------------------------------------------
3838+-section "Unsafe pointer equality"
3839+--- (#1 Bad Guy: Alastair Reid :)
3840+-------------------------------------------------------------------------
3841+-
3842+-primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
3843+- a -> a -> Int#
3844+- { Returns {\texttt 1\#} if the given pointers are equal and {\texttt 0\#} otherwise. }
3845+- with
3846+- can_fail = True -- See Note [reallyUnsafePtrEquality#]
3847+-
3848+-
3849+--- Note [reallyUnsafePtrEquality#]
3850+--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3851+---
3852+--- reallyUnsafePtrEquality# can't actually fail, per se, but we mark it can_fail
3853+--- anyway. Until 5a9a1738023a, GHC considered primops okay for speculation only
3854+--- when their arguments were known to be forced. This was unnecessarily
3855+--- conservative, but it prevented reallyUnsafePtrEquality# from floating out of
3856+--- places where its arguments were known to be forced. Unfortunately, GHC could
3857+--- sometimes lose track of whether those arguments were forced, leading to let/app
3858+--- invariant failures (see Trac 13027 and the discussion in Trac 11444). Now that
3859+--- ok_for_speculation skips over lifted arguments, we need to explicitly prevent
3860+--- reallyUnsafePtrEquality# from floating out. The reasons are closely related
3861+--- to those described in Note [dataToTag#], although the consequences are less
3862+--- severe. Imagine if we had
3863+---
3864+--- \x y . case x of x'
3865+--- DEFAULT ->
3866+--- case y of y'
3867+--- DEFAULT ->
3868+--- let eq = reallyUnsafePtrEquality# x' y'
3869+--- in ...
3870+---
3871+--- If the let floats out, we'll get
3872+---
3873+--- \x y . let eq = reallyUnsafePtrEquality# x y
3874+--- in case x of ...
3875+---
3876+--- The trouble is that pointer equality between thunks is very different
3877+--- from pointer equality between the values those thunks reduce to, and the latter
3878+--- is typically much more precise.
3879+-
3880+-------------------------------------------------------------------------
3881+-section "Parallelism"
3882+-------------------------------------------------------------------------
3883+-
3884+-primop ParOp "par#" GenPrimOp
3885+- a -> Int#
3886+- with
3887+- -- Note that Par is lazy to avoid that the sparked thing
3888+- -- gets evaluated strictly, which it should *not* be
3889+- has_side_effects = True
3890+- code_size = { primOpCodeSizeForeignCall }
3891+-
3892+-primop SparkOp "spark#" GenPrimOp
3893+- a -> State# s -> (# State# s, a #)
3894+- with has_side_effects = True
3895+- code_size = { primOpCodeSizeForeignCall }
3896+-
3897+-primop SeqOp "seq#" GenPrimOp
3898+- a -> State# s -> (# State# s, a #)
3899+- -- See Note [seq# magic] in PrelRules
3900+-
3901+-primop GetSparkOp "getSpark#" GenPrimOp
3902+- State# s -> (# State# s, Int#, a #)
3903+- with
3904+- has_side_effects = True
3905+- out_of_line = True
3906+-
3907+-primop NumSparks "numSparks#" GenPrimOp
3908+- State# s -> (# State# s, Int# #)
3909+- { Returns the number of sparks in the local spark pool. }
3910+- with
3911+- has_side_effects = True
3912+- out_of_line = True
3913+-
3914+-------------------------------------------------------------------------
3915+-section "Tag to enum stuff"
3916+- {Convert back and forth between values of enumerated types
3917+- and small integers.}
3918+-------------------------------------------------------------------------
3919+-
3920+-primop DataToTagOp "dataToTag#" GenPrimOp
3921+- a -> Int# -- Zero-indexed; the first constructor has tag zero
3922+- with
3923+- can_fail = True -- See Note [dataToTag#]
3924+- strictness = { \ _arity -> mkClosedStrictSig [evalDmd] topRes }
3925+- -- dataToTag# must have an evaluated argument
3926+-
3927+-primop TagToEnumOp "tagToEnum#" GenPrimOp
3928+- Int# -> a
3929+-
3930+-{- Note [dataToTag#]
3931+-~~~~~~~~~~~~~~~~~~~~
3932+-The dataToTag# primop should always be applied to an evaluated argument.
3933+-The way to ensure this is to invoke it via the 'getTag' wrapper in GHC.Base:
3934+- getTag :: a -> Int#
3935+- getTag !x = dataToTag# x
3936+-
3937+-But now consider
3938+- \z. case x of y -> let v = dataToTag# y in ...
3939+-
3940+-To improve floating, the FloatOut pass (deliberately) does a
3941+-binder-swap on the case, to give
3942+- \z. case x of y -> let v = dataToTag# x in ...
3943+-
3944+-Now FloatOut might float that v-binding outside the \z. But that is
3945+-bad because that might mean x gest evaluated much too early! (CorePrep
3946+-adds an eval to a dataToTag# call, to ensure that the argument really is
3947+-evaluated; see CorePrep Note [dataToTag magic].)
3948+-
3949+-Solution: make DataToTag into a can_fail primop. That will stop it floating
3950+-(see Note [PrimOp can_fail and has_side_effects] in PrimOp). It's a bit of
3951+-a hack but never mind.
3952+--}
3953+-
3954+-------------------------------------------------------------------------
3955+-section "Bytecode operations"
3956+- {Support for manipulating bytecode objects used by the interpreter and
3957+- linker.
3958+-
3959+- Bytecode objects are heap objects which represent top-level bindings and
3960+- contain a list of instructions and data needed by these instructions.}
3961+-------------------------------------------------------------------------
3962+-
3963+-primtype BCO#
3964+- { Primitive bytecode type. }
3965+-
3966+-primop AddrToAnyOp "addrToAny#" GenPrimOp
3967+- Addr# -> (# a #)
3968+- { Convert an {\tt Addr\#} to a followable Any type. }
3969+- with
3970+- code_size = 0
3971+-
3972+-primop AnyToAddrOp "anyToAddr#" GenPrimOp
3973+- a -> State# RealWorld -> (# State# RealWorld, Addr# #)
3974+- { Retrieve the address of any Haskell value. This is
3975+- essentially an {\texttt unsafeCoerce\#}, but if implemented as such
3976+- the core lint pass complains and fails to compile.
3977+- As a primop, it is opaque to core/stg, and only appears
3978+- in cmm (where the copy propagation pass will get rid of it).
3979+- Note that "a" must be a value, not a thunk! It's too late
3980+- for strictness analysis to enforce this, so you're on your
3981+- own to guarantee this. Also note that {\texttt Addr\#} is not a GC
3982+- pointer - up to you to guarantee that it does not become
3983+- a dangling pointer immediately after you get it.}
3984+- with
3985+- code_size = 0
3986+-
3987+-primop MkApUpd0_Op "mkApUpd0#" GenPrimOp
3988+- BCO# -> (# a #)
3989+- { Wrap a BCO in a {\tt AP_UPD} thunk which will be updated with the value of
3990+- the BCO when evaluated. }
3991+- with
3992+- out_of_line = True
3993+-
3994+-primop NewBCOOp "newBCO#" GenPrimOp
3995+- ByteArray# -> ByteArray# -> Array# a -> Int# -> ByteArray# -> State# s -> (# State# s, BCO# #)
3996+- { {\tt newBCO\# instrs lits ptrs arity bitmap} creates a new bytecode object. The
3997+- resulting object encodes a function of the given arity with the instructions
3998+- encoded in {\tt instrs}, and a static reference table usage bitmap given by
3999+- {\tt bitmap}. }
4000+- with
4001+- has_side_effects = True
4002+- out_of_line = True
4003+-
4004+-primop UnpackClosureOp "unpackClosure#" GenPrimOp
4005+- a -> (# Addr#, Array# b, ByteArray# #)
4006+- { {\tt unpackClosure\# closure} copies non-pointers and pointers in the
4007+- payload of the given closure into two new arrays, and returns a pointer to
4008+- the first word of the closure's info table, a pointer array for the
4009+- pointers in the payload, and a non-pointer array for the non-pointers in
4010+- the payload. }
4011+- with
4012+- out_of_line = True
4013+-
4014+-primop GetApStackValOp "getApStackVal#" GenPrimOp
4015+- a -> Int# -> (# Int#, b #)
4016+- with
4017+- out_of_line = True
4018+-
4019+-------------------------------------------------------------------------
4020+-section "Misc"
4021+- {These aren't nearly as wired in as Etc...}
4022+-------------------------------------------------------------------------
4023+-
4024+-primop GetCCSOfOp "getCCSOf#" GenPrimOp
4025+- a -> State# s -> (# State# s, Addr# #)
4026+-
4027+-primop GetCurrentCCSOp "getCurrentCCS#" GenPrimOp
4028+- a -> State# s -> (# State# s, Addr# #)
4029+- { Returns the current {\tt CostCentreStack} (value is {\tt NULL} if
4030+- not profiling). Takes a dummy argument which can be used to
4031+- avoid the call to {\tt getCurrentCCS\#} being floated out by the
4032+- simplifier, which would result in an uninformative stack
4033+- ("CAF"). }
4034+-
4035+-primop ClearCCSOp "clearCCS#" GenPrimOp
4036+- (State# s -> (# State# s, a #)) -> State# s -> (# State# s, a #)
4037+- { Run the supplied IO action with an empty CCS. For example, this
4038+- is used by the interpreter to run an interpreted computation
4039+- without the call stack showing that it was invoked from GHC. }
4040+- with
4041+- out_of_line = True
4042+-
4043+-------------------------------------------------------------------------
4044+-section "Etc"
4045+- {Miscellaneous built-ins}
4046+-------------------------------------------------------------------------
4047+-
4048+-primtype Proxy# a
4049+- { The type constructor {\tt Proxy#} is used to bear witness to some
4050+- type variable. It's used when you want to pass around proxy values
4051+- for doing things like modelling type applications. A {\tt Proxy#}
4052+- is not only unboxed, it also has a polymorphic kind, and has no
4053+- runtime representation, being totally free. }
4054+-
4055+-pseudoop "proxy#"
4056+- Proxy# a
4057+- { Witness for an unboxed {\tt Proxy#} value, which has no runtime
4058+- representation. }
4059+-
4060+-pseudoop "seq"
4061+- a -> b -> b
4062+- { The value of {\tt seq a b} is bottom if {\tt a} is bottom, and
4063+- otherwise equal to {\tt b}. In other words, it evaluates the first
4064+- argument {\tt a} to weak head normal form (WHNF). {\tt seq} is usually
4065+- introduced to improve performance by avoiding unneeded laziness.
4066+-
4067+- A note on evaluation order: the expression {\tt seq a b} does
4068+- {\it not} guarantee that {\tt a} will be evaluated before {\tt b}.
4069+- The only guarantee given by {\tt seq} is that the both {\tt a}
4070+- and {\tt b} will be evaluated before {\tt seq} returns a value.
4071+- In particular, this means that {\tt b} may be evaluated before
4072+- {\tt a}. If you need to guarantee a specific order of evaluation,
4073+- you must use the function {\tt pseq} from the "parallel" package. }
4074+-
4075+-pseudoop "unsafeCoerce#"
4076+- a -> b
4077+- { The function {\tt unsafeCoerce\#} allows you to side-step the typechecker entirely. That
4078+- is, it allows you to coerce any type into any other type. If you use this function,
4079+- you had better get it right, otherwise segmentation faults await. It is generally
4080+- used when you want to write a program that you know is well-typed, but where Haskell's
4081+- type system is not expressive enough to prove that it is well typed.
4082+-
4083+- The following uses of {\tt unsafeCoerce\#} are supposed to work (i.e. not lead to
4084+- spurious compile-time or run-time crashes):
4085+-
4086+- * Casting any lifted type to {\tt Any}
4087+-
4088+- * Casting {\tt Any} back to the real type
4089+-
4090+- * Casting an unboxed type to another unboxed type of the same size.
4091+- (Casting between floating-point and integral types does not work.
4092+- See the {\tt GHC.Float} module for functions to do work.)
4093+-
4094+- * Casting between two types that have the same runtime representation. One case is when
4095+- the two types differ only in "phantom" type parameters, for example
4096+- {\tt Ptr Int} to {\tt Ptr Float}, or {\tt [Int]} to {\tt [Float]} when the list is
4097+- known to be empty. Also, a {\tt newtype} of a type {\tt T} has the same representation
4098+- at runtime as {\tt T}.
4099+-
4100+- Other uses of {\tt unsafeCoerce\#} are undefined. In particular, you should not use
4101+- {\tt unsafeCoerce\#} to cast a T to an algebraic data type D, unless T is also
4102+- an algebraic data type. For example, do not cast {\tt Int->Int} to {\tt Bool}, even if
4103+- you later cast that {\tt Bool} back to {\tt Int->Int} before applying it. The reasons
4104+- have to do with GHC's internal representation details (for the cognoscenti, data values
4105+- can be entered but function closures cannot). If you want a safe type to cast things
4106+- to, use {\tt Any}, which is not an algebraic data type.
4107+-
4108+- }
4109+-
4110+--- NB. It is tempting to think that casting a value to a type that it doesn't have is safe
4111+--- as long as you don't "do anything" with the value in its cast form, such as seq on it. This
4112+--- isn't the case: the compiler can insert seqs itself, and if these happen at the wrong type,
4113+--- Bad Things Might Happen. See bug #1616: in this case we cast a function of type (a,b) -> (a,b)
4114+--- to () -> () and back again. The strictness analyser saw that the function was strict, but
4115+--- the wrapper had type () -> (), and hence the wrapper de-constructed the (), the worker re-constructed
4116+--- a new (), with the result that the code ended up with "case () of (a,b) -> ...".
4117+-
4118+-primop TraceEventOp "traceEvent#" GenPrimOp
4119+- Addr# -> State# s -> State# s
4120+- { Emits an event via the RTS tracing framework. The contents
4121+- of the event is the zero-terminated byte string passed as the first
4122+- argument. The event will be emitted either to the .eventlog file,
4123+- or to stderr, depending on the runtime RTS flags. }
4124+- with
4125+- has_side_effects = True
4126+- out_of_line = True
4127+-
4128+-primop TraceMarkerOp "traceMarker#" GenPrimOp
4129+- Addr# -> State# s -> State# s
4130+- { Emits a marker event via the RTS tracing framework. The contents
4131+- of the event is the zero-terminated byte string passed as the first
4132+- argument. The event will be emitted either to the .eventlog file,
4133+- or to stderr, depending on the runtime RTS flags. }
4134+- with
4135+- has_side_effects = True
4136+- out_of_line = True
4137+-
4138+-------------------------------------------------------------------------
4139+-section "Safe coercions"
4140+-------------------------------------------------------------------------
4141+-
4142+-pseudoop "coerce"
4143+- Coercible a b => a -> b
4144+- { The function {\tt coerce} allows you to safely convert between values of
4145+- types that have the same representation with no run-time overhead. In the
4146+- simplest case you can use it instead of a newtype constructor, to go from
4147+- the newtype's concrete type to the abstract type. But it also works in
4148+- more complicated settings, e.g. converting a list of newtypes to a list of
4149+- concrete types.
4150+- }
4151+-
4152+-------------------------------------------------------------------------
4153+-section "SIMD Vectors"
4154+- {Operations on SIMD vectors.}
4155+-------------------------------------------------------------------------
4156+-
4157+-#define ALL_VECTOR_TYPES \
4158+- [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
4159+- ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
4160+- ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
4161+- ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,WORD32,4>,<Word64,WORD64,2> \
4162+- ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,WORD32,8>,<Word64,WORD64,4> \
4163+- ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,WORD32,16>,<Word64,WORD64,8> \
4164+- ,<Float,Float#,4>,<Double,Double#,2> \
4165+- ,<Float,Float#,8>,<Double,Double#,4> \
4166+- ,<Float,Float#,16>,<Double,Double#,8>]
4167+-
4168+-#define SIGNED_VECTOR_TYPES \
4169+- [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
4170+- ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
4171+- ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
4172+- ,<Float,Float#,4>,<Double,Double#,2> \
4173+- ,<Float,Float#,8>,<Double,Double#,4> \
4174+- ,<Float,Float#,16>,<Double,Double#,8>]
4175+-
4176+-#define FLOAT_VECTOR_TYPES \
4177+- [<Float,Float#,4>,<Double,Double#,2> \
4178+- ,<Float,Float#,8>,<Double,Double#,4> \
4179+- ,<Float,Float#,16>,<Double,Double#,8>]
4180+-
4181+-#define INT_VECTOR_TYPES \
4182+- [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
4183+- ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
4184+- ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
4185+- ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,WORD32,4>,<Word64,WORD64,2> \
4186+- ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,WORD32,8>,<Word64,WORD64,4> \
4187+- ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,WORD32,16>,<Word64,WORD64,8>]
4188+-
4189+-primtype VECTOR
4190+- with llvm_only = True
4191+- vector = ALL_VECTOR_TYPES
4192+-
4193+-primop VecBroadcastOp "broadcast#" GenPrimOp
4194+- SCALAR -> VECTOR
4195+- { Broadcast a scalar to all elements of a vector. }
4196+- with llvm_only = True
4197+- vector = ALL_VECTOR_TYPES
4198+-
4199+-primop VecPackOp "pack#" GenPrimOp
4200+- VECTUPLE -> VECTOR
4201+- { Pack the elements of an unboxed tuple into a vector. }
4202+- with llvm_only = True
4203+- vector = ALL_VECTOR_TYPES
4204+-
4205+-primop VecUnpackOp "unpack#" GenPrimOp
4206+- VECTOR -> VECTUPLE
4207+- { Unpack the elements of a vector into an unboxed tuple. #}
4208+- with llvm_only = True
4209+- vector = ALL_VECTOR_TYPES
4210+-
4211+-primop VecInsertOp "insert#" GenPrimOp
4212+- VECTOR -> SCALAR -> Int# -> VECTOR
4213+- { Insert a scalar at the given position in a vector. }
4214+- with can_fail = True
4215+- llvm_only = True
4216+- vector = ALL_VECTOR_TYPES
4217+-
4218+-primop VecAddOp "plus#" Dyadic
4219+- VECTOR -> VECTOR -> VECTOR
4220+- { Add two vectors element-wise. }
4221+- with commutable = True
4222+- llvm_only = True
4223+- vector = ALL_VECTOR_TYPES
4224+-
4225+-primop VecSubOp "minus#" Dyadic
4226+- VECTOR -> VECTOR -> VECTOR
4227+- { Subtract two vectors element-wise. }
4228+- with llvm_only = True
4229+- vector = ALL_VECTOR_TYPES
4230+-
4231+-primop VecMulOp "times#" Dyadic
4232+- VECTOR -> VECTOR -> VECTOR
4233+- { Multiply two vectors element-wise. }
4234+- with commutable = True
4235+- llvm_only = True
4236+- vector = ALL_VECTOR_TYPES
4237+-
4238+-primop VecDivOp "divide#" Dyadic
4239+- VECTOR -> VECTOR -> VECTOR
4240+- { Divide two vectors element-wise. }
4241+- with can_fail = True
4242+- llvm_only = True
4243+- vector = FLOAT_VECTOR_TYPES
4244+-
4245+-primop VecQuotOp "quot#" Dyadic
4246+- VECTOR -> VECTOR -> VECTOR
4247+- { Rounds towards zero element-wise. }
4248+- with can_fail = True
4249+- llvm_only = True
4250+- vector = INT_VECTOR_TYPES
4251+-
4252+-primop VecRemOp "rem#" Dyadic
4253+- VECTOR -> VECTOR -> VECTOR
4254+- { Satisfies \texttt{(quot\# x y) times\# y plus\# (rem\# x y) == x}. }
4255+- with can_fail = True
4256+- llvm_only = True
4257+- vector = INT_VECTOR_TYPES
4258+-
4259+-primop VecNegOp "negate#" Monadic
4260+- VECTOR -> VECTOR
4261+- { Negate element-wise. }
4262+- with llvm_only = True
4263+- vector = SIGNED_VECTOR_TYPES
4264+-
4265+-primop VecIndexByteArrayOp "indexArray#" GenPrimOp
4266+- ByteArray# -> Int# -> VECTOR
4267+- { Read a vector from specified index of immutable array. }
4268+- with can_fail = True
4269+- llvm_only = True
4270+- vector = ALL_VECTOR_TYPES
4271+-
4272+-primop VecReadByteArrayOp "readArray#" GenPrimOp
4273+- MutableByteArray# s -> Int# -> State# s -> (# State# s, VECTOR #)
4274+- { Read a vector from specified index of mutable array. }
4275+- with has_side_effects = True
4276+- can_fail = True
4277+- llvm_only = True
4278+- vector = ALL_VECTOR_TYPES
4279+-
4280+-primop VecWriteByteArrayOp "writeArray#" GenPrimOp
4281+- MutableByteArray# s -> Int# -> VECTOR -> State# s -> State# s
4282+- { Write a vector to specified index of mutable array. }
4283+- with has_side_effects = True
4284+- can_fail = True
4285+- llvm_only = True
4286+- vector = ALL_VECTOR_TYPES
4287+-
4288+-primop VecIndexOffAddrOp "indexOffAddr#" GenPrimOp
4289+- Addr# -> Int# -> VECTOR
4290+- { Reads vector; offset in bytes. }
4291+- with can_fail = True
4292+- llvm_only = True
4293+- vector = ALL_VECTOR_TYPES
4294+-
4295+-primop VecReadOffAddrOp "readOffAddr#" GenPrimOp
4296+- Addr# -> Int# -> State# s -> (# State# s, VECTOR #)
4297+- { Reads vector; offset in bytes. }
4298+- with has_side_effects = True
4299+- can_fail = True
4300+- llvm_only = True
4301+- vector = ALL_VECTOR_TYPES
4302+-
4303+-primop VecWriteOffAddrOp "writeOffAddr#" GenPrimOp
4304+- Addr# -> Int# -> VECTOR -> State# s -> State# s
4305+- { Write vector; offset in bytes. }
4306+- with has_side_effects = True
4307+- can_fail = True
4308+- llvm_only = True
4309+- vector = ALL_VECTOR_TYPES
4310+-
4311+-
4312+-primop VecIndexScalarByteArrayOp "indexArrayAs#" GenPrimOp
4313+- ByteArray# -> Int# -> VECTOR
4314+- { Read a vector from specified index of immutable array of scalars; offset is in scalar elements. }
4315+- with can_fail = True
4316+- llvm_only = True
4317+- vector = ALL_VECTOR_TYPES
4318+-
4319+-primop VecReadScalarByteArrayOp "readArrayAs#" GenPrimOp
4320+- MutableByteArray# s -> Int# -> State# s -> (# State# s, VECTOR #)
4321+- { Read a vector from specified index of mutable array of scalars; offset is in scalar elements. }
4322+- with has_side_effects = True
4323+- can_fail = True
4324+- llvm_only = True
4325+- vector = ALL_VECTOR_TYPES
4326+-
4327+-primop VecWriteScalarByteArrayOp "writeArrayAs#" GenPrimOp
4328+- MutableByteArray# s -> Int# -> VECTOR -> State# s -> State# s
4329+- { Write a vector to specified index of mutable array of scalars; offset is in scalar elements. }
4330+- with has_side_effects = True
4331+- can_fail = True
4332+- llvm_only = True
4333+- vector = ALL_VECTOR_TYPES
4334+-
4335+-primop VecIndexScalarOffAddrOp "indexOffAddrAs#" GenPrimOp
4336+- Addr# -> Int# -> VECTOR
4337+- { Reads vector; offset in scalar elements. }
4338+- with can_fail = True
4339+- llvm_only = True
4340+- vector = ALL_VECTOR_TYPES
4341+-
4342+-primop VecReadScalarOffAddrOp "readOffAddrAs#" GenPrimOp
4343+- Addr# -> Int# -> State# s -> (# State# s, VECTOR #)
4344+- { Reads vector; offset in scalar elements. }
4345+- with has_side_effects = True
4346+- can_fail = True
4347+- llvm_only = True
4348+- vector = ALL_VECTOR_TYPES
4349+-
4350+-primop VecWriteScalarOffAddrOp "writeOffAddrAs#" GenPrimOp
4351+- Addr# -> Int# -> VECTOR -> State# s -> State# s
4352+- { Write vector; offset in scalar elements. }
4353+- with has_side_effects = True
4354+- can_fail = True
4355+- llvm_only = True
4356+- vector = ALL_VECTOR_TYPES
4357+-
4358+-------------------------------------------------------------------------
4359+-
4360+-section "Prefetch"
4361+- {Prefetch operations: Note how every prefetch operation has a name
4362+- with the pattern prefetch*N#, where N is either 0,1,2, or 3.
4363+-
4364+- This suffix number, N, is the "locality level" of the prefetch, following the
4365+- convention in GCC and other compilers.
4366+- Higher locality numbers correspond to the memory being loaded in more
4367+- levels of the cpu cache, and being retained after initial use. The naming
4368+- convention follows the naming convention of the prefetch intrinsic found
4369+- in the GCC and Clang C compilers.
4370+-
4371+- On the LLVM backend, prefetch*N# uses the LLVM prefetch intrinsic
4372+- with locality level N. The code generated by LLVM is target architecture
4373+- dependent, but should agree with the GHC NCG on x86 systems.
4374+-
4375+- On the Sparc and PPC native backends, prefetch*N is a No-Op.
4376+-
4377+- On the x86 NCG, N=0 will generate prefetchNTA,
4378+- N=1 generates prefetcht2, N=2 generates prefetcht1, and
4379+- N=3 generates prefetcht0.
4380+-
4381+- For streaming workloads, the prefetch*0 operations are recommended.
4382+- For workloads which do many reads or writes to a memory location in a short period of time,
4383+- prefetch*3 operations are recommended.
4384+-
4385+- For further reading about prefetch and associated systems performance optimization,
4386+- the instruction set and optimization manuals by Intel and other CPU vendors are
4387+- excellent starting place.
4388+-
4389+-
4390+- The "Intel 64 and IA-32 Architectures Optimization Reference Manual" is
4391+- especially a helpful read, even if your software is meant for other CPU
4392+- architectures or vendor hardware. The manual can be found at
4393+- http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-optimization-manual.html .
4394+-
4395+- The {\tt prefetch*} family of operations has the order of operations
4396+- determined by passing around the {\tt State#} token.
4397+-
4398+- To get a "pure" version of these operations, use {\tt inlinePerformIO} which is quite safe in this context.
4399+-
4400+- It is important to note that while the prefetch operations will never change the
4401+- answer to a pure computation, They CAN change the memory locations resident
4402+- in a CPU cache and that may change the performance and timing characteristics
4403+- of an application. The prefetch operations are marked has_side_effects=True
4404+- to reflect that these operations have side effects with respect to the runtime
4405+- performance characteristics of the resulting code. Additionally, if the prefetchValue
4406+- operations did not have this attribute, GHC does a float out transformation that
4407+- results in a let/app violation, at least with the current design.
4408+- }
4409+-
4410+-
4411+-
4412+-------------------------------------------------------------------------
4413+-
4414+-
4415+---- the Int# argument for prefetch is the byte offset on the byteArray or Addr#
4416+-
4417+----
4418+-primop PrefetchByteArrayOp3 "prefetchByteArray3#" GenPrimOp
4419+- ByteArray# -> Int# -> State# s -> State# s
4420+- with has_side_effects = True
4421+-
4422+-primop PrefetchMutableByteArrayOp3 "prefetchMutableByteArray3#" GenPrimOp
4423+- MutableByteArray# s -> Int# -> State# s -> State# s
4424+- with has_side_effects = True
4425+-
4426+-primop PrefetchAddrOp3 "prefetchAddr3#" GenPrimOp
4427+- Addr# -> Int# -> State# s -> State# s
4428+- with has_side_effects = True
4429+-
4430+-primop PrefetchValueOp3 "prefetchValue3#" GenPrimOp
4431+- a -> State# s -> State# s
4432+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4433+- has_side_effects = True
4434+-----
4435+-
4436+-primop PrefetchByteArrayOp2 "prefetchByteArray2#" GenPrimOp
4437+- ByteArray# -> Int# -> State# s -> State# s
4438+- with has_side_effects = True
4439+-
4440+-primop PrefetchMutableByteArrayOp2 "prefetchMutableByteArray2#" GenPrimOp
4441+- MutableByteArray# s -> Int# -> State# s -> State# s
4442+- with has_side_effects = True
4443+-
4444+-primop PrefetchAddrOp2 "prefetchAddr2#" GenPrimOp
4445+- Addr# -> Int# -> State# s -> State# s
4446+- with has_side_effects = True
4447+-
4448+-primop PrefetchValueOp2 "prefetchValue2#" GenPrimOp
4449+- a -> State# s -> State# s
4450+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4451+- has_side_effects = True
4452+-----
4453+-
4454+-primop PrefetchByteArrayOp1 "prefetchByteArray1#" GenPrimOp
4455+- ByteArray# -> Int# -> State# s -> State# s
4456+- with has_side_effects = True
4457+-
4458+-primop PrefetchMutableByteArrayOp1 "prefetchMutableByteArray1#" GenPrimOp
4459+- MutableByteArray# s -> Int# -> State# s -> State# s
4460+- with has_side_effects = True
4461+-
4462+-primop PrefetchAddrOp1 "prefetchAddr1#" GenPrimOp
4463+- Addr# -> Int# -> State# s -> State# s
4464+- with has_side_effects = True
4465+-
4466+-primop PrefetchValueOp1 "prefetchValue1#" GenPrimOp
4467+- a -> State# s -> State# s
4468+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4469+- has_side_effects = True
4470+-----
4471+-
4472+-primop PrefetchByteArrayOp0 "prefetchByteArray0#" GenPrimOp
4473+- ByteArray# -> Int# -> State# s -> State# s
4474+- with has_side_effects = True
4475+-
4476+-primop PrefetchMutableByteArrayOp0 "prefetchMutableByteArray0#" GenPrimOp
4477+- MutableByteArray# s -> Int# -> State# s -> State# s
4478+- with has_side_effects = True
4479+-
4480+-primop PrefetchAddrOp0 "prefetchAddr0#" GenPrimOp
4481+- Addr# -> Int# -> State# s -> State# s
4482+- with has_side_effects = True
4483+-
4484+-primop PrefetchValueOp0 "prefetchValue0#" GenPrimOp
4485+- a -> State# s -> State# s
4486+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4487+- has_side_effects = True
4488+-
4489+-------------------------------------------------------------------------
4490+---- ---
4491+-------------------------------------------------------------------------
4492+-
4493+-thats_all_folks
4494+diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs
4495+index c3c8ae3..32fb8f5 100644
4496+--- a/compiler/utils/Binary.hs
4497++++ b/compiler/utils/Binary.hs
4498+@@ -58,7 +58,7 @@ module Binary
4499+ #include "HsVersions.h"
4500+
4501+ -- The *host* architecture version:
4502+-#include "../includes/MachDeps.h"
4503++#include "MachDeps.h"
4504+
4505+ import GhcPrelude
4506+
4507+diff --git a/ghc.mk b/ghc.mk
4508+index 38c165d..7cb7913 100644
4509+--- a/ghc.mk
4510++++ b/ghc.mk
4511+@@ -593,26 +593,6 @@ BOOT_LIBS = $(foreach lib,$(PACKAGES_STAGE0),$(libraries/$(lib)_dist-boot_v_LIB)
4512+ # Only build internal interpreter support for the stage2 ghci lib
4513+ libraries/ghci_dist-install_CONFIGURE_OPTS += --flags=ghci
4514+
4515+-# ----------------------------------------
4516+-# Special magic for the ghc-prim package
4517+-
4518+-# We want the ghc-prim package to include the GHC.Prim module when it
4519+-# is registered, but not when it is built, because GHC.Prim is not a
4520+-# real source module, it is built-in to GHC.
4521+-
4522+-# Strip it out again before building the package:
4523+-define libraries/ghc-prim_PACKAGE_MAGIC
4524+-libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
4525+-endef
4526+-
4527+-PRIMOPS_TXT_STAGE1 = compiler/stage1/build/primops.txt
4528+-
4529+-libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $$(genprimopcode_INPLACE) $(PRIMOPS_TXT_STAGE1) | $$(dir $$@)/.
4530+- "$(genprimopcode_INPLACE)" --make-haskell-wrappers < $(PRIMOPS_TXT_STAGE1) >$@
4531+-
4532+-# Required so that Haddock documents the primops.
4533+-libraries/ghc-prim_dist-install_EXTRA_HADDOCK_SRCS = libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
4534+-
4535+ # ----------------------------------------
4536+ # Special magic for the integer package
4537+
4538+diff --git a/ghc/ghc.mk b/ghc/ghc.mk
4539+index 20fa142..ad4b7c2 100644
4540+--- a/ghc/ghc.mk
4541++++ b/ghc/ghc.mk
4542+@@ -14,10 +14,6 @@ ghc_USES_CABAL = YES
4543+ ghc_PACKAGE = ghc-bin
4544+ ghc_EXECUTABLE = ghc
4545+
4546+-ghc_stage1_CONFIGURE_OPTS += --flags=stage1
4547+-ghc_stage2_CONFIGURE_OPTS += --flags=stage2
4548+-ghc_stage3_CONFIGURE_OPTS += --flags=stage3
4549+-
4550+ ifeq "$(GhcWithInterpreter)" "YES"
4551+ ghc_stage2_CONFIGURE_OPTS += --flags=ghci
4552+ ghc_stage3_CONFIGURE_OPTS += --flags=ghci
4553+@@ -121,9 +117,9 @@ ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(foreach lib,$(PACKAGES_STAGE1),$(lib
4554+ endif
4555+
4556+ # Modules here import HsVersions.h, so we need ghc_boot_platform.h
4557+-$(ghc_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
4558+-$(ghc_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
4559+-$(ghc_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
4560++$(ghc_stage1_depfile_haskell) : libraries/ghc-prim/dist-boot/$(PLATFORM_H)
4561++$(ghc_stage2_depfile_haskell) : libraries/ghc-prim/dist-install/$(PLATFORM_H)
4562++$(ghc_stage3_depfile_haskell) : libraries/ghc-prim/dist-install/$(PLATFORM_H)
4563+
4564+ all_ghc_stage1 : $(GHC_STAGE1)
4565+ all_ghc_stage2 : $(GHC_STAGE2)
4566+@@ -173,6 +169,12 @@ endif
4567+ INSTALL_LIBS += settings
4568+ INSTALL_LIBS += llvm-targets
4569+
4570++# A rather nasty hack needed because we still have headers in
4571++# ghc-prim and rts.
4572++ghc_stage1_HC_OPTS += -Irts/build -Ilibraries/ghc-prim/dist-boot
4573++ghc_stage2_HC_OPTS += -Irts/build -Ilibraries/ghc-prim/dist-install
4574++ghc_stage3_HC_OPTS += -Irts/build -Ilibraries/ghc-prim/dist-install
4575++
4576+ ifeq "$(Windows_Host)" "NO"
4577+ install: install_ghc_link
4578+ .PHONY: install_ghc_link
4579+diff --git a/includes/ghc.mk b/includes/ghc.mk
4580+index d08ecfb..9358950 100644
4581+--- a/includes/ghc.mk
4582++++ b/includes/ghc.mk
4583+@@ -229,4 +229,6 @@ install_includes :
4584+ $(INSTALL_HEADER) $(INSTALL_OPTS) includes/$d/*.h "$(DESTDIR)$(ghcheaderdir)/$d/" && \
4585+ ) true
4586+ $(INSTALL_HEADER) $(INSTALL_OPTS) $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_VERSION) $(includes_DERIVEDCONSTANTS) "$(DESTDIR)$(ghcheaderdir)/"
4587++ $(INSTALL_HEADER) rts/build/*.h rts/build/*.hs-incl includes/CodeGen.Platform.hs "$(DESTDIR)$(ghcheaderdir)/"
4588++ $(INSTALL_HEADER) $(includes_GHCCONSTANTS_HASKELL_TYPE) $(includes_GHCCONSTANTS_HASKELL_VALUE) $(includes_GHCCONSTANTS_HASKELL_WRAPPERS) $(includes_GHCCONSTANTS_HASKELL_EXPORTS) "$(DESTDIR)$(ghcheaderdir)/"
4589+
4590+diff --git a/libraries/ghc-prim/ghc-prim.cabal b/libraries/ghc-prim/ghc-prim.cabal
4591+index f395c9f..099ebeb 100644
4592+--- a/libraries/ghc-prim/ghc-prim.cabal
4593++++ b/libraries/ghc-prim/ghc-prim.cabal
4594+@@ -12,6 +12,16 @@ build-type: Custom
4595+ description:
4596+ This package contains the primitive types and operations supplied by GHC.
4597+
4598++Flag boot
4599++ Description: Is this stage 1?
4600++ Default: False
4601++ Manual: True
4602++
4603++Flag install
4604++ Description: Is this stage 2?
4605++ Default: True
4606++ Manual: True
4607++
4608+ extra-source-files: changelog.md
4609+
4610+ source-repository head
4611+@@ -81,3 +91,27 @@ Library
4612+ -- We need to set the unit ID to ghc-prim (without a version number)
4613+ -- as it's magic.
4614+ ghc-options: -this-unit-id ghc-prim
4615++
4616++ if flag(boot)
4617++ include-dirs: dist-boot
4618++ else
4619++ if flag(install)
4620++ include-dirs: dist-install
4621++
4622++ install-includes:
4623++ ghc_boot_platform.h
4624++ primop-data-decl.hs-incl
4625++ primop-tag.hs-incl
4626++ primop-list.hs-incl
4627++ primop-has-side-effects.hs-incl
4628++ primop-out-of-line.hs-incl
4629++ primop-commutable.hs-incl
4630++ primop-code-size.hs-incl
4631++ primop-can-fail.hs-incl
4632++ primop-strictness.hs-incl
4633++ primop-fixity.hs-incl
4634++ primop-primop-info.hs-incl
4635++ primop-vector-uniques.hs-incl
4636++ primop-vector-tys.hs-incl
4637++ primop-vector-tys-exports.hs-incl
4638++ primop-vector-tycons.hs-incl
4639+\ No newline at end of file
4640+diff --git a/libraries/ghc-prim/ghc.mk b/libraries/ghc-prim/ghc.mk
4641+index 03740bf..5b09478 100644
4642+--- a/libraries/ghc-prim/ghc.mk
4643++++ b/libraries/ghc-prim/ghc.mk
4644+@@ -1,5 +1,202 @@
4645+ libraries/ghc-prim_PACKAGE = ghc-prim
4646+ libraries/ghc-prim_dist-install_GROUP = libraries
4647++
4648++libraries/ghc-prim_stage1_CONFIGURE_OPTS += --flags=boot
4649++libraries/ghc-prim_stage2_CONFIGURE_OPTS += --flags=install
4650++libraries/ghc-prim_stage3_CONFIGURE_OPTS += --flags=install
4651++
4652++
4653++# ----------------------------------------
4654++# Special magic for the ghc-prim package
4655++
4656++# We want the ghc-prim package to include the GHC.Prim module when it
4657++# is registered, but not when it is built, because GHC.Prim is not a
4658++# real source module, it is built-in to GHC.
4659++
4660++# Strip it out again before building the package:
4661++define libraries/ghc-prim_PACKAGE_MAGIC
4662++libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
4663++endef
4664++
4665++PRIMOPS_TXT_STAGE1 = libraries/ghc-prim/dist-boot/primops.txt
4666++
4667++libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $$(genprimopcode_INPLACE) $(PRIMOPS_TXT_STAGE1) | $$(dir $$@)/.
4668++ "$(genprimopcode_INPLACE)" --make-haskell-wrappers < $(PRIMOPS_TXT_STAGE1) >$@
4669++
4670++# Required so that Haddock documents the primops.
4671++libraries/ghc-prim_dist-install_EXTRA_HADDOCK_SRCS = libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
4672++
4673++
4674++# -----------------------------------------------------------------------------
4675++# Create platform includes
4676++
4677++# Here we generate a little header file containing CPP symbols that GHC
4678++# uses to determine which platform it is building on/for. The platforms
4679++# can differ between stage1 and stage2 if we're cross-compiling, so we
4680++# need one of these header files per stage.
4681++
4682++PLATFORM_H = ghc_boot_platform.h
4683++
4684++libraries/ghc-prim/dist-boot/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
4685++ $(call removeFiles,$@)
4686++ @echo "Creating $@..."
4687++ @echo "#ifndef __PLATFORM_H__" >> $@
4688++ @echo "#define __PLATFORM_H__" >> $@
4689++ @echo >> $@
4690++ @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
4691++ @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
4692++ @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
4693++ @echo >> $@
4694++ @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
4695++ @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
4696++ @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
4697++ @echo >> $@
4698++ @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
4699++ @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
4700++ @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
4701++ @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
4702++ @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
4703++ @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
4704++ @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@
4705++ @echo >> $@
4706++ @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
4707++ @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
4708++ @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
4709++ @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
4710++ @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
4711++ @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
4712++ @echo >> $@
4713++ @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
4714++ @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
4715++ @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
4716++ @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
4717++ @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
4718++ @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
4719++ @echo >> $@
4720++ @echo "#endif /* __PLATFORM_H__ */" >> $@
4721++ @echo "Done."
4722++
4723++# For stage2 and above, the BUILD platform is the HOST of stage1, and
4724++# the HOST platform is the TARGET of stage1. The TARGET remains the same
4725++# (stage1 is the cross-compiler, not stage2).
4726++libraries/ghc-prim/dist-install/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
4727++ $(call removeFiles,$@)
4728++ @echo "Creating $@..."
4729++ @echo "#ifndef __PLATFORM_H__" >> $@
4730++ @echo "#define __PLATFORM_H__" >> $@
4731++ @echo >> $@
4732++ @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
4733++ @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
4734++ @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
4735++ @echo >> $@
4736++ @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
4737++ @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
4738++ @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
4739++ @echo >> $@
4740++ @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
4741++ @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
4742++ @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
4743++ @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
4744++ @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
4745++ @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
4746++ @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@
4747++ @echo >> $@
4748++ @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
4749++ @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
4750++ @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
4751++ @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
4752++ @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
4753++ @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
4754++ @echo >> $@
4755++ @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
4756++ @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
4757++ @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
4758++ @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
4759++ @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
4760++ @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
4761++ @echo >> $@
4762++ @echo "#endif /* __PLATFORM_H__ */" >> $@
4763++ @echo "Done."
4764++
4765++# ----------------------------------------------------------------------------
4766++# Generate supporting stuff for prelude/PrimOp.hs
4767++# from prelude/primops.txt
4768++
4769++PRIMOP_BITS_NAMES = primop-data-decl.hs-incl \
4770++ primop-tag.hs-incl \
4771++ primop-list.hs-incl \
4772++ primop-has-side-effects.hs-incl \
4773++ primop-out-of-line.hs-incl \
4774++ primop-commutable.hs-incl \
4775++ primop-code-size.hs-incl \
4776++ primop-can-fail.hs-incl \
4777++ primop-strictness.hs-incl \
4778++ primop-fixity.hs-incl \
4779++ primop-primop-info.hs-incl \
4780++ primop-vector-uniques.hs-incl \
4781++ primop-vector-tys.hs-incl \
4782++ primop-vector-tys-exports.hs-incl \
4783++ primop-vector-tycons.hs-incl
4784++
4785++PRIMOP_BITS_STAGE1 = $(addprefix libraries/ghc-prim/dist-boot/,$(PRIMOP_BITS_NAMES))
4786++PRIMOP_BITS_STAGE2 = $(addprefix libraries/ghc-prim/dist-install/,$(PRIMOP_BITS_NAMES))
4787++PRIMOP_BITS_STAGE3 = $(addprefix libraries/ghc-prim/dist-install/,$(PRIMOP_BITS_NAMES))
4788++
4789++compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
4790++compiler_CPP_OPTS += ${GhcCppOpts}
4791++
4792++# We add these paths to the Haskell compiler's #include search path list since
4793++# we must avoid #including files by paths relative to the source file as Hadrian
4794++# moves the build artifacts out of the source tree. See #8040.
4795++compiler_HC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
4796++
4797++define preprocessCompilerFiles
4798++# $0 = stage
4799++libraries/ghc-prim/$1/primops.txt: libraries/ghc-prim/primops.txt.pp libraries/ghc-prim/$1/$$(PLATFORM_H)
4800++ $$(HS_CPP) -P $$(compiler_CPP_OPTS) -Ilibraries/ghc-prim/$1 -x c $$< | grep -v '^#pragma GCC' > $$@
4801++
4802++libraries/ghc-prim/$1/primop-data-decl.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4803++ "$$(genprimopcode_INPLACE)" --data-decl < $$< > $$@
4804++libraries/ghc-prim/$1/primop-tag.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4805++ "$$(genprimopcode_INPLACE)" --primop-tag < $$< > $$@
4806++libraries/ghc-prim/$1/primop-list.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4807++ "$$(genprimopcode_INPLACE)" --primop-list < $$< > $$@
4808++libraries/ghc-prim/$1/primop-has-side-effects.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4809++ "$$(genprimopcode_INPLACE)" --has-side-effects < $$< > $$@
4810++libraries/ghc-prim/$1/primop-out-of-line.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4811++ "$$(genprimopcode_INPLACE)" --out-of-line < $$< > $$@
4812++libraries/ghc-prim/$1/primop-commutable.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4813++ "$$(genprimopcode_INPLACE)" --commutable < $$< > $$@
4814++libraries/ghc-prim/$1/primop-code-size.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4815++ "$$(genprimopcode_INPLACE)" --code-size < $$< > $$@
4816++libraries/ghc-prim/$1/primop-can-fail.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4817++ "$$(genprimopcode_INPLACE)" --can-fail < $$< > $$@
4818++libraries/ghc-prim/$1/primop-strictness.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4819++ "$$(genprimopcode_INPLACE)" --strictness < $$< > $$@
4820++libraries/ghc-prim/$1/primop-fixity.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4821++ "$$(genprimopcode_INPLACE)" --fixity < $$< > $$@
4822++libraries/ghc-prim/$1/primop-primop-info.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4823++ "$$(genprimopcode_INPLACE)" --primop-primop-info < $$< > $$@
4824++libraries/ghc-prim/$1/primop-vector-uniques.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4825++ "$$(genprimopcode_INPLACE)" --primop-vector-uniques < $$< > $$@
4826++libraries/ghc-prim/$1/primop-vector-tys.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4827++ "$$(genprimopcode_INPLACE)" --primop-vector-tys < $$< > $$@
4828++libraries/ghc-prim/$1/primop-vector-tys-exports.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4829++ "$$(genprimopcode_INPLACE)" --primop-vector-tys-exports < $$< > $$@
4830++libraries/ghc-prim/$1/primop-vector-tycons.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4831++ "$$(genprimopcode_INPLACE)" --primop-vector-tycons < $$< > $$@
4832++
4833++# Usages aren't used any more; but the generator
4834++# can still generate them if we want them back
4835++libraries/ghc-prim/$1/primop-usage.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4836++ "$$(genprimopcode_INPLACE)" --usage < $$< > $$@
4837++
4838++endef
4839++
4840++$(eval $(call preprocessCompilerFiles,dist-boot))
4841++$(eval $(call preprocessCompilerFiles,dist-install))
4842++
4843++
4844+ $(if $(filter ghc-prim,$(PACKAGES_STAGE0)),$(eval $(call build-package,libraries/ghc-prim,dist-boot,0)))
4845+ $(if $(filter ghc-prim,$(PACKAGES_STAGE1)),$(eval $(call build-package,libraries/ghc-prim,dist-install,1)))
4846+ $(if $(filter ghc-prim,$(PACKAGES_STAGE2)),$(eval $(call build-package,libraries/ghc-prim,dist-install,2)))
4847+diff --git a/libraries/ghc-prim/primops.txt.pp b/libraries/ghc-prim/primops.txt.pp
4848+new file mode 100644
4849+index 0000000..924ac41
4850+--- /dev/null
4851++++ b/libraries/ghc-prim/primops.txt.pp
4852+@@ -0,0 +1,3295 @@
4853++-----------------------------------------------------------------------
4854++--
4855++-- (c) 2010 The University of Glasgow
4856++--
4857++-- Primitive Operations and Types
4858++--
4859++-- For more information on PrimOps, see
4860++-- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
4861++--
4862++-----------------------------------------------------------------------
4863++
4864++-- This file is processed by the utility program genprimopcode to produce
4865++-- a number of include files within the compiler and optionally to produce
4866++-- human-readable documentation.
4867++--
4868++-- It should first be preprocessed.
4869++--
4870++-- Information on how PrimOps are implemented and the steps necessary to
4871++-- add a new one can be found in the Commentary:
4872++--
4873++-- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
4874++
4875++-- This file is divided into named sections, each containing or more
4876++-- primop entries. Section headers have the format:
4877++--
4878++-- section "section-name" {description}
4879++--
4880++-- This information is used solely when producing documentation; it is
4881++-- otherwise ignored. The description is optional.
4882++--
4883++-- The format of each primop entry is as follows:
4884++--
4885++-- primop internal-name "name-in-program-text" type category {description} attributes
4886++
4887++-- The default attribute values which apply if you don't specify
4888++-- other ones. Attribute values can be True, False, or arbitrary
4889++-- text between curly brackets. This is a kludge to enable
4890++-- processors of this file to easily get hold of simple info
4891++-- (eg, out_of_line), whilst avoiding parsing complex expressions
4892++-- needed for strictness info.
4893++--
4894++-- type refers to the general category of the primop. Valid settings include,
4895++--
4896++-- * Compare: A comparison operation of the shape a -> a -> Int#
4897++-- * Monadic: A unary operation of shape a -> a
4898++-- * Dyadic: A binary operation of shape a -> a -> a
4899++-- * GenPrimOp: Any other sort of primop
4900++--
4901++
4902++-- The vector attribute is rather special. It takes a list of 3-tuples, each of
4903++-- which is of the form <ELEM_TYPE,SCALAR_TYPE,LENGTH>. ELEM_TYPE is the type of
4904++-- the elements in the vector; LENGTH is the length of the vector; and
4905++-- SCALAR_TYPE is the scalar type used to inject to/project from vector
4906++-- element. Note that ELEM_TYPE and SCALAR_TYPE are not the same; for example,
4907++-- to broadcast a scalar value to a vector whose elements are of type Int8, we
4908++-- use an Int#.
4909++
4910++-- When a primtype or primop has a vector attribute, it is instantiated at each
4911++-- 3-tuple in the list of 3-tuples. That is, the vector attribute allows us to
4912++-- define a family of types or primops. Vector support also adds three new
4913++-- keywords: VECTOR, SCALAR, and VECTUPLE. These keywords are expanded to types
4914++-- derived from the 3-tuple. For the 3-tuple <Int64,INT64,2>, VECTOR expands to
4915++-- Int64X2#, SCALAR expands to INT64, and VECTUPLE expands to (# INT64, INT64
4916++-- #).
4917++
4918++defaults
4919++ has_side_effects = False
4920++ out_of_line = False -- See Note Note [PrimOp can_fail and has_side_effects] in PrimOp
4921++ can_fail = False -- See Note Note [PrimOp can_fail and has_side_effects] in PrimOp
4922++ commutable = False
4923++ code_size = { primOpCodeSizeDefault }
4924++ strictness = { \ arity -> mkClosedStrictSig (replicate arity topDmd) topRes }
4925++ fixity = Nothing
4926++ llvm_only = False
4927++ vector = []
4928++
4929++-- Currently, documentation is produced using latex, so contents of
4930++-- description fields should be legal latex. Descriptions can contain
4931++-- matched pairs of embedded curly brackets.
4932++
4933++#include "MachDeps.h"
4934++
4935++-- We need platform defines (tests for mingw32 below).
4936++#include "ghc_boot_platform.h"
4937++
4938++section "The word size story."
4939++ {Haskell98 specifies that signed integers (type {\tt Int})
4940++ must contain at least 30 bits. GHC always implements {\tt
4941++ Int} using the primitive type {\tt Int\#}, whose size equals
4942++ the {\tt MachDeps.h} constant {\tt WORD\_SIZE\_IN\_BITS}.
4943++ This is normally set based on the {\tt config.h} parameter
4944++ {\tt SIZEOF\_HSWORD}, i.e., 32 bits on 32-bit machines, 64
4945++ bits on 64-bit machines. However, it can also be explicitly
4946++ set to a smaller number, e.g., 31 bits, to allow the
4947++ possibility of using tag bits. Currently GHC itself has only
4948++ 32-bit and 64-bit variants, but 30 or 31-bit code can be
4949++ exported as an external core file for use in other back ends.
4950++
4951++ GHC also implements a primitive unsigned integer type {\tt
4952++ Word\#} which always has the same number of bits as {\tt
4953++ Int\#}.
4954++
4955++ In addition, GHC supports families of explicit-sized integers
4956++ and words at 8, 16, 32, and 64 bits, with the usual
4957++ arithmetic operations, comparisons, and a range of
4958++ conversions. The 8-bit and 16-bit sizes are always
4959++ represented as {\tt Int\#} and {\tt Word\#}, and the
4960++ operations implemented in terms of the the primops on these
4961++ types, with suitable range restrictions on the results (using
4962++ the {\tt narrow$n$Int\#} and {\tt narrow$n$Word\#} families
4963++ of primops. The 32-bit sizes are represented using {\tt
4964++ Int\#} and {\tt Word\#} when {\tt WORD\_SIZE\_IN\_BITS}
4965++ $\geq$ 32; otherwise, these are represented using distinct
4966++ primitive types {\tt Int32\#} and {\tt Word32\#}. These (when
4967++ needed) have a complete set of corresponding operations;
4968++ however, nearly all of these are implemented as external C
4969++ functions rather than as primops. Exactly the same story
4970++ applies to the 64-bit sizes. All of these details are hidden
4971++ under the {\tt PrelInt} and {\tt PrelWord} modules, which use
4972++ {\tt \#if}-defs to invoke the appropriate types and
4973++ operators.
4974++
4975++ Word size also matters for the families of primops for
4976++ indexing/reading/writing fixed-size quantities at offsets
4977++ from an array base, address, or foreign pointer. Here, a
4978++ slightly different approach is taken. The names of these
4979++ primops are fixed, but their {\it types} vary according to
4980++ the value of {\tt WORD\_SIZE\_IN\_BITS}. For example, if word
4981++ size is at least 32 bits then an operator like
4982++ \texttt{indexInt32Array\#} has type {\tt ByteArray\# -> Int\#
4983++ -> Int\#}; otherwise it has type {\tt ByteArray\# -> Int\# ->
4984++ Int32\#}. This approach confines the necessary {\tt
4985++ \#if}-defs to this file; no conditional compilation is needed
4986++ in the files that expose these primops.
4987++
4988++ Finally, there are strongly deprecated primops for coercing
4989++ between {\tt Addr\#}, the primitive type of machine
4990++ addresses, and {\tt Int\#}. These are pretty bogus anyway,
4991++ but will work on existing 32-bit and 64-bit GHC targets; they
4992++ are completely bogus when tag bits are used in {\tt Int\#},
4993++ so are not available in this case. }
4994++
4995++-- Define synonyms for indexing ops.
4996++
4997++#if WORD_SIZE_IN_BITS < 32
4998++#define INT32 Int32#
4999++#define WORD32 Word32#
5000++#else
5001++#define INT32 Int#
5002++#define WORD32 Word#
5003++#endif
5004++
5005++#if WORD_SIZE_IN_BITS < 64
5006++#define INT64 Int64#
5007++#define WORD64 Word64#
5008++#else
5009++#define INT64 Int#
5010++#define WORD64 Word#
5011++#endif
5012++
5013++------------------------------------------------------------------------
5014++section "Char#"
5015++ {Operations on 31-bit characters.}
5016++------------------------------------------------------------------------
5017++
5018++primtype Char#
5019++
5020++primop CharGtOp "gtChar#" Compare Char# -> Char# -> Int#
5021++primop CharGeOp "geChar#" Compare Char# -> Char# -> Int#
5022++
5023++primop CharEqOp "eqChar#" Compare
5024++ Char# -> Char# -> Int#
5025++ with commutable = True
5026++
5027++primop CharNeOp "neChar#" Compare
5028++ Char# -> Char# -> Int#
5029++ with commutable = True
5030++
5031++primop CharLtOp "ltChar#" Compare Char# -> Char# -> Int#
5032++primop CharLeOp "leChar#" Compare Char# -> Char# -> Int#
5033++
5034++primop OrdOp "ord#" GenPrimOp Char# -> Int#
5035++ with code_size = 0
5036++
5037++------------------------------------------------------------------------
5038++section "Int#"
5039++ {Operations on native-size integers (30+ bits).}
5040++------------------------------------------------------------------------
5041++
5042++primtype Int#
5043++
5044++primop IntAddOp "+#" Dyadic
5045++ Int# -> Int# -> Int#
5046++ with commutable = True
5047++ fixity = infixl 6
5048++
5049++primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
5050++ with fixity = infixl 6
5051++
5052++primop IntMulOp "*#"
5053++ Dyadic Int# -> Int# -> Int#
5054++ {Low word of signed integer multiply.}
5055++ with commutable = True
5056++ fixity = infixl 7
5057++
5058++primop IntMulMayOfloOp "mulIntMayOflo#"
5059++ Dyadic Int# -> Int# -> Int#
5060++ {Return non-zero if there is any possibility that the upper word of a
5061++ signed integer multiply might contain useful information. Return
5062++ zero only if you are completely sure that no overflow can occur.
5063++ On a 32-bit platform, the recommended implementation is to do a
5064++ 32 x 32 -> 64 signed multiply, and subtract result[63:32] from
5065++ (result[31] >>signed 31). If this is zero, meaning that the
5066++ upper word is merely a sign extension of the lower one, no
5067++ overflow can occur.
5068++
5069++ On a 64-bit platform it is not always possible to
5070++ acquire the top 64 bits of the result. Therefore, a recommended
5071++ implementation is to take the absolute value of both operands, and
5072++ return 0 iff bits[63:31] of them are zero, since that means that their
5073++ magnitudes fit within 31 bits, so the magnitude of the product must fit
5074++ into 62 bits.
5075++
5076++ If in doubt, return non-zero, but do make an effort to create the
5077++ correct answer for small args, since otherwise the performance of
5078++ \texttt{(*) :: Integer -> Integer -> Integer} will be poor.
5079++ }
5080++ with commutable = True
5081++
5082++primop IntQuotOp "quotInt#" Dyadic
5083++ Int# -> Int# -> Int#
5084++ {Rounds towards zero. The behavior is undefined if the second argument is
5085++ zero.
5086++ }
5087++ with can_fail = True
5088++
5089++primop IntRemOp "remInt#" Dyadic
5090++ Int# -> Int# -> Int#
5091++ {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}. The
5092++ behavior is undefined if the second argument is zero.
5093++ }
5094++ with can_fail = True
5095++
5096++primop IntQuotRemOp "quotRemInt#" GenPrimOp
5097++ Int# -> Int# -> (# Int#, Int# #)
5098++ {Rounds towards zero.}
5099++ with can_fail = True
5100++
5101++primop AndIOp "andI#" Dyadic Int# -> Int# -> Int#
5102++ with commutable = True
5103++
5104++primop OrIOp "orI#" Dyadic Int# -> Int# -> Int#
5105++ with commutable = True
5106++
5107++primop XorIOp "xorI#" Dyadic Int# -> Int# -> Int#
5108++ with commutable = True
5109++
5110++primop NotIOp "notI#" Monadic Int# -> Int#
5111++
5112++primop IntNegOp "negateInt#" Monadic Int# -> Int#
5113++primop IntAddCOp "addIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
5114++ {Add signed integers reporting overflow.
5115++ First member of result is the sum truncated to an {\tt Int#};
5116++ second member is zero if the true sum fits in an {\tt Int#},
5117++ nonzero if overflow occurred (the sum is either too large
5118++ or too small to fit in an {\tt Int#}).}
5119++ with code_size = 2
5120++
5121++primop IntSubCOp "subIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
5122++ {Subtract signed integers reporting overflow.
5123++ First member of result is the difference truncated to an {\tt Int#};
5124++ second member is zero if the true difference fits in an {\tt Int#},
5125++ nonzero if overflow occurred (the difference is either too large
5126++ or too small to fit in an {\tt Int#}).}
5127++ with code_size = 2
5128++
5129++primop IntGtOp ">#" Compare Int# -> Int# -> Int#
5130++ with fixity = infix 4
5131++
5132++primop IntGeOp ">=#" Compare Int# -> Int# -> Int#
5133++ with fixity = infix 4
5134++
5135++primop IntEqOp "==#" Compare
5136++ Int# -> Int# -> Int#
5137++ with commutable = True
5138++ fixity = infix 4
5139++
5140++primop IntNeOp "/=#" Compare
5141++ Int# -> Int# -> Int#
5142++ with commutable = True
5143++ fixity = infix 4
5144++
5145++primop IntLtOp "<#" Compare Int# -> Int# -> Int#
5146++ with fixity = infix 4
5147++
5148++primop IntLeOp "<=#" Compare Int# -> Int# -> Int#
5149++ with fixity = infix 4
5150++
5151++primop ChrOp "chr#" GenPrimOp Int# -> Char#
5152++ with code_size = 0
5153++
5154++primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
5155++ with code_size = 0
5156++
5157++primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
5158++primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
5159++
5160++primop Word2FloatOp "word2Float#" GenPrimOp Word# -> Float#
5161++primop Word2DoubleOp "word2Double#" GenPrimOp Word# -> Double#
5162++
5163++primop ISllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int#
5164++ {Shift left. Result undefined if shift amount is not
5165++ in the range 0 to word size - 1 inclusive.}
5166++primop ISraOp "uncheckedIShiftRA#" GenPrimOp Int# -> Int# -> Int#
5167++ {Shift right arithmetic. Result undefined if shift amount is not
5168++ in the range 0 to word size - 1 inclusive.}
5169++primop ISrlOp "uncheckedIShiftRL#" GenPrimOp Int# -> Int# -> Int#
5170++ {Shift right logical. Result undefined if shift amount is not
5171++ in the range 0 to word size - 1 inclusive.}
5172++
5173++------------------------------------------------------------------------
5174++section "Word#"
5175++ {Operations on native-sized unsigned words (30+ bits).}
5176++------------------------------------------------------------------------
5177++
5178++primtype Word#
5179++
5180++primop WordAddOp "plusWord#" Dyadic Word# -> Word# -> Word#
5181++ with commutable = True
5182++
5183++primop WordSubCOp "subWordC#" GenPrimOp Word# -> Word# -> (# Word#, Int# #)
5184++ {Subtract unsigned integers reporting overflow.
5185++ The first element of the pair is the result. The second element is
5186++ the carry flag, which is nonzero on overflow.}
5187++
5188++-- Returns (# high, low #) (or equivalently, (# carry, low #))
5189++primop WordAdd2Op "plusWord2#" GenPrimOp
5190++ Word# -> Word# -> (# Word#, Word# #)
5191++ with commutable = True
5192++
5193++primop WordSubOp "minusWord#" Dyadic Word# -> Word# -> Word#
5194++
5195++primop WordMulOp "timesWord#" Dyadic Word# -> Word# -> Word#
5196++ with commutable = True
5197++
5198++-- Returns (# high, low #)
5199++primop WordMul2Op "timesWord2#" GenPrimOp
5200++ Word# -> Word# -> (# Word#, Word# #)
5201++ with commutable = True
5202++
5203++primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word#
5204++ with can_fail = True
5205++
5206++primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word#
5207++ with can_fail = True
5208++
5209++primop WordQuotRemOp "quotRemWord#" GenPrimOp
5210++ Word# -> Word# -> (# Word#, Word# #)
5211++ with can_fail = True
5212++
5213++-- Takes high word of dividend, then low word of dividend, then divisor.
5214++-- Requires that high word is not divisible by divisor.
5215++primop WordQuotRem2Op "quotRemWord2#" GenPrimOp
5216++ Word# -> Word# -> Word# -> (# Word#, Word# #)
5217++ with can_fail = True
5218++
5219++primop AndOp "and#" Dyadic Word# -> Word# -> Word#
5220++ with commutable = True
5221++
5222++primop OrOp "or#" Dyadic Word# -> Word# -> Word#
5223++ with commutable = True
5224++
5225++primop XorOp "xor#" Dyadic Word# -> Word# -> Word#
5226++ with commutable = True
5227++
5228++primop NotOp "not#" Monadic Word# -> Word#
5229++
5230++primop SllOp "uncheckedShiftL#" GenPrimOp Word# -> Int# -> Word#
5231++ {Shift left logical. Result undefined if shift amount is not
5232++ in the range 0 to word size - 1 inclusive.}
5233++primop SrlOp "uncheckedShiftRL#" GenPrimOp Word# -> Int# -> Word#
5234++ {Shift right logical. Result undefined if shift amount is not
5235++ in the range 0 to word size - 1 inclusive.}
5236++
5237++primop Word2IntOp "word2Int#" GenPrimOp Word# -> Int#
5238++ with code_size = 0
5239++
5240++primop WordGtOp "gtWord#" Compare Word# -> Word# -> Int#
5241++primop WordGeOp "geWord#" Compare Word# -> Word# -> Int#
5242++primop WordEqOp "eqWord#" Compare Word# -> Word# -> Int#
5243++primop WordNeOp "neWord#" Compare Word# -> Word# -> Int#
5244++primop WordLtOp "ltWord#" Compare Word# -> Word# -> Int#
5245++primop WordLeOp "leWord#" Compare Word# -> Word# -> Int#
5246++
5247++primop PopCnt8Op "popCnt8#" Monadic Word# -> Word#
5248++ {Count the number of set bits in the lower 8 bits of a word.}
5249++primop PopCnt16Op "popCnt16#" Monadic Word# -> Word#
5250++ {Count the number of set bits in the lower 16 bits of a word.}
5251++primop PopCnt32Op "popCnt32#" Monadic Word# -> Word#
5252++ {Count the number of set bits in the lower 32 bits of a word.}
5253++primop PopCnt64Op "popCnt64#" GenPrimOp WORD64 -> Word#
5254++ {Count the number of set bits in a 64-bit word.}
5255++primop PopCntOp "popCnt#" Monadic Word# -> Word#
5256++ {Count the number of set bits in a word.}
5257++
5258++primop Pdep8Op "pdep8#" Dyadic Word# -> Word# -> Word#
5259++ {Deposit bits to lower 8 bits of a word at locations specified by a mask.}
5260++primop Pdep16Op "pdep16#" Dyadic Word# -> Word# -> Word#
5261++ {Deposit bits to lower 16 bits of a word at locations specified by a mask.}
5262++primop Pdep32Op "pdep32#" Dyadic Word# -> Word# -> Word#
5263++ {Deposit bits to lower 32 bits of a word at locations specified by a mask.}
5264++primop Pdep64Op "pdep64#" GenPrimOp WORD64 -> WORD64 -> WORD64
5265++ {Deposit bits to a word at locations specified by a mask.}
5266++primop PdepOp "pdep#" Dyadic Word# -> Word# -> Word#
5267++ {Deposit bits to a word at locations specified by a mask.}
5268++
5269++primop Pext8Op "pext8#" Dyadic Word# -> Word# -> Word#
5270++ {Extract bits from lower 8 bits of a word at locations specified by a mask.}
5271++primop Pext16Op "pext16#" Dyadic Word# -> Word# -> Word#
5272++ {Extract bits from lower 16 bits of a word at locations specified by a mask.}
5273++primop Pext32Op "pext32#" Dyadic Word# -> Word# -> Word#
5274++ {Extract bits from lower 32 bits of a word at locations specified by a mask.}
5275++primop Pext64Op "pext64#" GenPrimOp WORD64 -> WORD64 -> WORD64
5276++ {Extract bits from a word at locations specified by a mask.}
5277++primop PextOp "pext#" Dyadic Word# -> Word# -> Word#
5278++ {Extract bits from a word at locations specified by a mask.}
5279++
5280++primop Clz8Op "clz8#" Monadic Word# -> Word#
5281++ {Count leading zeros in the lower 8 bits of a word.}
5282++primop Clz16Op "clz16#" Monadic Word# -> Word#
5283++ {Count leading zeros in the lower 16 bits of a word.}
5284++primop Clz32Op "clz32#" Monadic Word# -> Word#
5285++ {Count leading zeros in the lower 32 bits of a word.}
5286++primop Clz64Op "clz64#" GenPrimOp WORD64 -> Word#
5287++ {Count leading zeros in a 64-bit word.}
5288++primop ClzOp "clz#" Monadic Word# -> Word#
5289++ {Count leading zeros in a word.}
5290++
5291++primop Ctz8Op "ctz8#" Monadic Word# -> Word#
5292++ {Count trailing zeros in the lower 8 bits of a word.}
5293++primop Ctz16Op "ctz16#" Monadic Word# -> Word#
5294++ {Count trailing zeros in the lower 16 bits of a word.}
5295++primop Ctz32Op "ctz32#" Monadic Word# -> Word#
5296++ {Count trailing zeros in the lower 32 bits of a word.}
5297++primop Ctz64Op "ctz64#" GenPrimOp WORD64 -> Word#
5298++ {Count trailing zeros in a 64-bit word.}
5299++primop CtzOp "ctz#" Monadic Word# -> Word#
5300++ {Count trailing zeros in a word.}
5301++
5302++primop BSwap16Op "byteSwap16#" Monadic Word# -> Word#
5303++ {Swap bytes in the lower 16 bits of a word. The higher bytes are undefined. }
5304++primop BSwap32Op "byteSwap32#" Monadic Word# -> Word#
5305++ {Swap bytes in the lower 32 bits of a word. The higher bytes are undefined. }
5306++primop BSwap64Op "byteSwap64#" Monadic WORD64 -> WORD64
5307++ {Swap bytes in a 64 bits of a word.}
5308++primop BSwapOp "byteSwap#" Monadic Word# -> Word#
5309++ {Swap bytes in a word.}
5310++
5311++------------------------------------------------------------------------
5312++section "Narrowings"
5313++ {Explicit narrowing of native-sized ints or words.}
5314++------------------------------------------------------------------------
5315++
5316++primop Narrow8IntOp "narrow8Int#" Monadic Int# -> Int#
5317++primop Narrow16IntOp "narrow16Int#" Monadic Int# -> Int#
5318++primop Narrow32IntOp "narrow32Int#" Monadic Int# -> Int#
5319++primop Narrow8WordOp "narrow8Word#" Monadic Word# -> Word#
5320++primop Narrow16WordOp "narrow16Word#" Monadic Word# -> Word#
5321++primop Narrow32WordOp "narrow32Word#" Monadic Word# -> Word#
5322++
5323++
5324++#if WORD_SIZE_IN_BITS < 32
5325++------------------------------------------------------------------------
5326++section "Int32#"
5327++ {Operations on 32-bit integers ({\tt Int32\#}). This type is only used
5328++ if plain {\tt Int\#} has less than 32 bits. In any case, the operations
5329++ are not primops; they are implemented (if needed) as ccalls instead.}
5330++------------------------------------------------------------------------
5331++
5332++primtype Int32#
5333++
5334++------------------------------------------------------------------------
5335++section "Word32#"
5336++ {Operations on 32-bit unsigned words. This type is only used
5337++ if plain {\tt Word\#} has less than 32 bits. In any case, the operations
5338++ are not primops; they are implemented (if needed) as ccalls instead.}
5339++------------------------------------------------------------------------
5340++
5341++primtype Word32#
5342++
5343++#endif
5344++
5345++
5346++#if WORD_SIZE_IN_BITS < 64
5347++------------------------------------------------------------------------
5348++section "Int64#"
5349++ {Operations on 64-bit unsigned words. This type is only used
5350++ if plain {\tt Int\#} has less than 64 bits. In any case, the operations
5351++ are not primops; they are implemented (if needed) as ccalls instead.}
5352++------------------------------------------------------------------------
5353++
5354++primtype Int64#
5355++
5356++------------------------------------------------------------------------
5357++section "Word64#"
5358++ {Operations on 64-bit unsigned words. This type is only used
5359++ if plain {\tt Word\#} has less than 64 bits. In any case, the operations
5360++ are not primops; they are implemented (if needed) as ccalls instead.}
5361++------------------------------------------------------------------------
5362++
5363++primtype Word64#
5364++
5365++#endif
5366++
5367++------------------------------------------------------------------------
5368++section "Double#"
5369++ {Operations on double-precision (64 bit) floating-point numbers.}
5370++------------------------------------------------------------------------
5371++
5372++primtype Double#
5373++
5374++primop DoubleGtOp ">##" Compare Double# -> Double# -> Int#
5375++ with fixity = infix 4
5376++
5377++primop DoubleGeOp ">=##" Compare Double# -> Double# -> Int#
5378++ with fixity = infix 4
5379++
5380++primop DoubleEqOp "==##" Compare
5381++ Double# -> Double# -> Int#
5382++ with commutable = True
5383++ fixity = infix 4
5384++
5385++primop DoubleNeOp "/=##" Compare
5386++ Double# -> Double# -> Int#
5387++ with commutable = True
5388++ fixity = infix 4
5389++
5390++primop DoubleLtOp "<##" Compare Double# -> Double# -> Int#
5391++ with fixity = infix 4
5392++
5393++primop DoubleLeOp "<=##" Compare Double# -> Double# -> Int#
5394++ with fixity = infix 4
5395++
5396++primop DoubleAddOp "+##" Dyadic
5397++ Double# -> Double# -> Double#
5398++ with commutable = True
5399++ fixity = infixl 6
5400++
5401++primop DoubleSubOp "-##" Dyadic Double# -> Double# -> Double#
5402++ with fixity = infixl 6
5403++
5404++primop DoubleMulOp "*##" Dyadic
5405++ Double# -> Double# -> Double#
5406++ with commutable = True
5407++ fixity = infixl 7
5408++
5409++primop DoubleDivOp "/##" Dyadic
5410++ Double# -> Double# -> Double#
5411++ with can_fail = True
5412++ fixity = infixl 7
5413++
5414++primop DoubleNegOp "negateDouble#" Monadic Double# -> Double#
5415++
5416++primop DoubleFabsOp "fabsDouble#" Monadic Double# -> Double#
5417++
5418++primop Double2IntOp "double2Int#" GenPrimOp Double# -> Int#
5419++ {Truncates a {\tt Double#} value to the nearest {\tt Int#}.
5420++ Results are undefined if the truncation if truncation yields
5421++ a value outside the range of {\tt Int#}.}
5422++
5423++primop Double2FloatOp "double2Float#" GenPrimOp Double# -> Float#
5424++
5425++primop DoubleExpOp "expDouble#" Monadic
5426++ Double# -> Double#
5427++ with
5428++ code_size = { primOpCodeSizeForeignCall }
5429++
5430++primop DoubleLogOp "logDouble#" Monadic
5431++ Double# -> Double#
5432++ with
5433++ code_size = { primOpCodeSizeForeignCall }
5434++ can_fail = True
5435++
5436++primop DoubleSqrtOp "sqrtDouble#" Monadic
5437++ Double# -> Double#
5438++ with
5439++ code_size = { primOpCodeSizeForeignCall }
5440++
5441++primop DoubleSinOp "sinDouble#" Monadic
5442++ Double# -> Double#
5443++ with
5444++ code_size = { primOpCodeSizeForeignCall }
5445++
5446++primop DoubleCosOp "cosDouble#" Monadic
5447++ Double# -> Double#
5448++ with
5449++ code_size = { primOpCodeSizeForeignCall }
5450++
5451++primop DoubleTanOp "tanDouble#" Monadic
5452++ Double# -> Double#
5453++ with
5454++ code_size = { primOpCodeSizeForeignCall }
5455++
5456++primop DoubleAsinOp "asinDouble#" Monadic
5457++ Double# -> Double#
5458++ with
5459++ code_size = { primOpCodeSizeForeignCall }
5460++ can_fail = True
5461++
5462++primop DoubleAcosOp "acosDouble#" Monadic
5463++ Double# -> Double#
5464++ with
5465++ code_size = { primOpCodeSizeForeignCall }
5466++ can_fail = True
5467++
5468++primop DoubleAtanOp "atanDouble#" Monadic
5469++ Double# -> Double#
5470++ with
5471++ code_size = { primOpCodeSizeForeignCall }
5472++
5473++primop DoubleSinhOp "sinhDouble#" Monadic
5474++ Double# -> Double#
5475++ with
5476++ code_size = { primOpCodeSizeForeignCall }
5477++
5478++primop DoubleCoshOp "coshDouble#" Monadic
5479++ Double# -> Double#
5480++ with
5481++ code_size = { primOpCodeSizeForeignCall }
5482++
5483++primop DoubleTanhOp "tanhDouble#" Monadic
5484++ Double# -> Double#
5485++ with
5486++ code_size = { primOpCodeSizeForeignCall }
5487++
5488++primop DoublePowerOp "**##" Dyadic
5489++ Double# -> Double# -> Double#
5490++ {Exponentiation.}
5491++ with
5492++ code_size = { primOpCodeSizeForeignCall }
5493++
5494++primop DoubleDecode_2IntOp "decodeDouble_2Int#" GenPrimOp
5495++ Double# -> (# Int#, Word#, Word#, Int# #)
5496++ {Convert to integer.
5497++ First component of the result is -1 or 1, indicating the sign of the
5498++ mantissa. The next two are the high and low 32 bits of the mantissa
5499++ respectively, and the last is the exponent.}
5500++ with out_of_line = True
5501++
5502++primop DoubleDecode_Int64Op "decodeDouble_Int64#" GenPrimOp
5503++ Double# -> (# INT64, Int# #)
5504++ {Decode {\tt Double\#} into mantissa and base-2 exponent.}
5505++ with out_of_line = True
5506++
5507++------------------------------------------------------------------------
5508++section "Float#"
5509++ {Operations on single-precision (32-bit) floating-point numbers.}
5510++------------------------------------------------------------------------
5511++
5512++primtype Float#
5513++
5514++primop FloatGtOp "gtFloat#" Compare Float# -> Float# -> Int#
5515++primop FloatGeOp "geFloat#" Compare Float# -> Float# -> Int#
5516++
5517++primop FloatEqOp "eqFloat#" Compare
5518++ Float# -> Float# -> Int#
5519++ with commutable = True
5520++
5521++primop FloatNeOp "neFloat#" Compare
5522++ Float# -> Float# -> Int#
5523++ with commutable = True
5524++
5525++primop FloatLtOp "ltFloat#" Compare Float# -> Float# -> Int#
5526++primop FloatLeOp "leFloat#" Compare Float# -> Float# -> Int#
5527++
5528++primop FloatAddOp "plusFloat#" Dyadic
5529++ Float# -> Float# -> Float#
5530++ with commutable = True
5531++
5532++primop FloatSubOp "minusFloat#" Dyadic Float# -> Float# -> Float#
5533++
5534++primop FloatMulOp "timesFloat#" Dyadic
5535++ Float# -> Float# -> Float#
5536++ with commutable = True
5537++
5538++primop FloatDivOp "divideFloat#" Dyadic
5539++ Float# -> Float# -> Float#
5540++ with can_fail = True
5541++
5542++primop FloatNegOp "negateFloat#" Monadic Float# -> Float#
5543++
5544++primop FloatFabsOp "fabsFloat#" Monadic Float# -> Float#
5545++
5546++primop Float2IntOp "float2Int#" GenPrimOp Float# -> Int#
5547++ {Truncates a {\tt Float#} value to the nearest {\tt Int#}.
5548++ Results are undefined if the truncation if truncation yields
5549++ a value outside the range of {\tt Int#}.}
5550++
5551++primop FloatExpOp "expFloat#" Monadic
5552++ Float# -> Float#
5553++ with
5554++ code_size = { primOpCodeSizeForeignCall }
5555++
5556++primop FloatLogOp "logFloat#" Monadic
5557++ Float# -> Float#
5558++ with
5559++ code_size = { primOpCodeSizeForeignCall }
5560++ can_fail = True
5561++
5562++primop FloatSqrtOp "sqrtFloat#" Monadic
5563++ Float# -> Float#
5564++ with
5565++ code_size = { primOpCodeSizeForeignCall }
5566++
5567++primop FloatSinOp "sinFloat#" Monadic
5568++ Float# -> Float#
5569++ with
5570++ code_size = { primOpCodeSizeForeignCall }
5571++
5572++primop FloatCosOp "cosFloat#" Monadic
5573++ Float# -> Float#
5574++ with
5575++ code_size = { primOpCodeSizeForeignCall }
5576++
5577++primop FloatTanOp "tanFloat#" Monadic
5578++ Float# -> Float#
5579++ with
5580++ code_size = { primOpCodeSizeForeignCall }
5581++
5582++primop FloatAsinOp "asinFloat#" Monadic
5583++ Float# -> Float#
5584++ with
5585++ code_size = { primOpCodeSizeForeignCall }
5586++ can_fail = True
5587++
5588++primop FloatAcosOp "acosFloat#" Monadic
5589++ Float# -> Float#
5590++ with
5591++ code_size = { primOpCodeSizeForeignCall }
5592++ can_fail = True
5593++
5594++primop FloatAtanOp "atanFloat#" Monadic
5595++ Float# -> Float#
5596++ with
5597++ code_size = { primOpCodeSizeForeignCall }
5598++
5599++primop FloatSinhOp "sinhFloat#" Monadic
5600++ Float# -> Float#
5601++ with
5602++ code_size = { primOpCodeSizeForeignCall }
5603++
5604++primop FloatCoshOp "coshFloat#" Monadic
5605++ Float# -> Float#
5606++ with
5607++ code_size = { primOpCodeSizeForeignCall }
5608++
5609++primop FloatTanhOp "tanhFloat#" Monadic
5610++ Float# -> Float#
5611++ with
5612++ code_size = { primOpCodeSizeForeignCall }
5613++
5614++primop FloatPowerOp "powerFloat#" Dyadic
5615++ Float# -> Float# -> Float#
5616++ with
5617++ code_size = { primOpCodeSizeForeignCall }
5618++
5619++primop Float2DoubleOp "float2Double#" GenPrimOp Float# -> Double#
5620++
5621++primop FloatDecode_IntOp "decodeFloat_Int#" GenPrimOp
5622++ Float# -> (# Int#, Int# #)
5623++ {Convert to integers.
5624++ First {\tt Int\#} in result is the mantissa; second is the exponent.}
5625++ with out_of_line = True
5626++
5627++------------------------------------------------------------------------
5628++section "Arrays"
5629++ {Operations on {\tt Array\#}.}
5630++------------------------------------------------------------------------
5631++
5632++primtype Array# a
5633++
5634++primtype MutableArray# s a
5635++
5636++primop NewArrayOp "newArray#" GenPrimOp
5637++ Int# -> a -> State# s -> (# State# s, MutableArray# s a #)
5638++ {Create a new mutable array with the specified number of elements,
5639++ in the specified state thread,
5640++ with each element containing the specified initial value.}
5641++ with
5642++ out_of_line = True
5643++ has_side_effects = True
5644++
5645++primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
5646++ MutableArray# s a -> MutableArray# s a -> Int#
5647++
5648++primop ReadArrayOp "readArray#" GenPrimOp
5649++ MutableArray# s a -> Int# -> State# s -> (# State# s, a #)
5650++ {Read from specified index of mutable array. Result is not yet evaluated.}
5651++ with
5652++ has_side_effects = True
5653++ can_fail = True
5654++
5655++primop WriteArrayOp "writeArray#" GenPrimOp
5656++ MutableArray# s a -> Int# -> a -> State# s -> State# s
5657++ {Write to specified index of mutable array.}
5658++ with
5659++ has_side_effects = True
5660++ can_fail = True
5661++ code_size = 2 -- card update too
5662++
5663++primop SizeofArrayOp "sizeofArray#" GenPrimOp
5664++ Array# a -> Int#
5665++ {Return the number of elements in the array.}
5666++
5667++primop SizeofMutableArrayOp "sizeofMutableArray#" GenPrimOp
5668++ MutableArray# s a -> Int#
5669++ {Return the number of elements in the array.}
5670++
5671++primop IndexArrayOp "indexArray#" GenPrimOp
5672++ Array# a -> Int# -> (# a #)
5673++ {Read from specified index of immutable array. Result is packaged into
5674++ an unboxed singleton; the result itself is not yet evaluated.}
5675++ with
5676++ can_fail = True
5677++
5678++primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
5679++ MutableArray# s a -> State# s -> (# State# s, Array# a #)
5680++ {Make a mutable array immutable, without copying.}
5681++ with
5682++ has_side_effects = True
5683++
5684++primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
5685++ Array# a -> State# s -> (# State# s, MutableArray# s a #)
5686++ {Make an immutable array mutable, without copying.}
5687++ with
5688++ out_of_line = True
5689++ has_side_effects = True
5690++
5691++primop CopyArrayOp "copyArray#" GenPrimOp
5692++ Array# a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s
5693++ {Given a source array, an offset into the source array, a
5694++ destination array, an offset into the destination array, and a
5695++ number of elements to copy, copy the elements from the source array
5696++ to the destination array. Both arrays must fully contain the
5697++ specified ranges, but this is not checked. The two arrays must not
5698++ be the same array in different states, but this is not checked
5699++ either.}
5700++ with
5701++ out_of_line = True
5702++ has_side_effects = True
5703++ can_fail = True
5704++
5705++primop CopyMutableArrayOp "copyMutableArray#" GenPrimOp
5706++ MutableArray# s a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s
5707++ {Given a source array, an offset into the source array, a
5708++ destination array, an offset into the destination array, and a
5709++ number of elements to copy, copy the elements from the source array
5710++ to the destination array. Both arrays must fully contain the
5711++ specified ranges, but this is not checked. In the case where
5712++ the source and destination are the same array the source and
5713++ destination regions may overlap.}
5714++ with
5715++ out_of_line = True
5716++ has_side_effects = True
5717++ can_fail = True
5718++
5719++primop CloneArrayOp "cloneArray#" GenPrimOp
5720++ Array# a -> Int# -> Int# -> Array# a
5721++ {Given a source array, an offset into the source array, and a number
5722++ of elements to copy, create a new array with the elements from the
5723++ source array. The provided array must fully contain the specified
5724++ range, but this is not checked.}
5725++ with
5726++ out_of_line = True
5727++ has_side_effects = True
5728++ can_fail = True
5729++
5730++primop CloneMutableArrayOp "cloneMutableArray#" GenPrimOp
5731++ MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #)
5732++ {Given a source array, an offset into the source array, and a number
5733++ of elements to copy, create a new array with the elements from the
5734++ source array. The provided array must fully contain the specified
5735++ range, but this is not checked.}
5736++ with
5737++ out_of_line = True
5738++ has_side_effects = True
5739++ can_fail = True
5740++
5741++primop FreezeArrayOp "freezeArray#" GenPrimOp
5742++ MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, Array# a #)
5743++ {Given a source array, an offset into the source array, and a number
5744++ of elements to copy, create a new array with the elements from the
5745++ source array. The provided array must fully contain the specified
5746++ range, but this is not checked.}
5747++ with
5748++ out_of_line = True
5749++ has_side_effects = True
5750++ can_fail = True
5751++
5752++primop ThawArrayOp "thawArray#" GenPrimOp
5753++ Array# a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #)
5754++ {Given a source array, an offset into the source array, and a number
5755++ of elements to copy, create a new array with the elements from the
5756++ source array. The provided array must fully contain the specified
5757++ range, but this is not checked.}
5758++ with
5759++ out_of_line = True
5760++ has_side_effects = True
5761++ can_fail = True
5762++
5763++primop CasArrayOp "casArray#" GenPrimOp
5764++ MutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #)
5765++ {Unsafe, machine-level atomic compare and swap on an element within an Array.}
5766++ with
5767++ out_of_line = True
5768++ has_side_effects = True
5769++
5770++
5771++------------------------------------------------------------------------
5772++section "Small Arrays"
5773++
5774++ {Operations on {\tt SmallArray\#}. A {\tt SmallArray\#} works
5775++ just like an {\tt Array\#}, but with different space use and
5776++ performance characteristics (that are often useful with small
5777++ arrays). The {\tt SmallArray\#} and {\tt SmallMutableArray#}
5778++ lack a `card table'. The purpose of a card table is to avoid
5779++ having to scan every element of the array on each GC by
5780++ keeping track of which elements have changed since the last GC
5781++ and only scanning those that have changed. So the consequence
5782++ of there being no card table is that the representation is
5783++ somewhat smaller and the writes are somewhat faster (because
5784++ the card table does not need to be updated). The disadvantage
5785++ of course is that for a {\tt SmallMutableArray#} the whole
5786++ array has to be scanned on each GC. Thus it is best suited for
5787++ use cases where the mutable array is not long lived, e.g.
5788++ where a mutable array is initialised quickly and then frozen
5789++ to become an immutable {\tt SmallArray\#}.
5790++ }
5791++
5792++------------------------------------------------------------------------
5793++
5794++primtype SmallArray# a
5795++
5796++primtype SmallMutableArray# s a
5797++
5798++primop NewSmallArrayOp "newSmallArray#" GenPrimOp
5799++ Int# -> a -> State# s -> (# State# s, SmallMutableArray# s a #)
5800++ {Create a new mutable array with the specified number of elements,
5801++ in the specified state thread,
5802++ with each element containing the specified initial value.}
5803++ with
5804++ out_of_line = True
5805++ has_side_effects = True
5806++
5807++primop SameSmallMutableArrayOp "sameSmallMutableArray#" GenPrimOp
5808++ SmallMutableArray# s a -> SmallMutableArray# s a -> Int#
5809++
5810++primop ReadSmallArrayOp "readSmallArray#" GenPrimOp
5811++ SmallMutableArray# s a -> Int# -> State# s -> (# State# s, a #)
5812++ {Read from specified index of mutable array. Result is not yet evaluated.}
5813++ with
5814++ has_side_effects = True
5815++ can_fail = True
5816++
5817++primop WriteSmallArrayOp "writeSmallArray#" GenPrimOp
5818++ SmallMutableArray# s a -> Int# -> a -> State# s -> State# s
5819++ {Write to specified index of mutable array.}
5820++ with
5821++ has_side_effects = True
5822++ can_fail = True
5823++
5824++primop SizeofSmallArrayOp "sizeofSmallArray#" GenPrimOp
5825++ SmallArray# a -> Int#
5826++ {Return the number of elements in the array.}
5827++
5828++primop SizeofSmallMutableArrayOp "sizeofSmallMutableArray#" GenPrimOp
5829++ SmallMutableArray# s a -> Int#
5830++ {Return the number of elements in the array.}
5831++
5832++primop IndexSmallArrayOp "indexSmallArray#" GenPrimOp
5833++ SmallArray# a -> Int# -> (# a #)
5834++ {Read from specified index of immutable array. Result is packaged into
5835++ an unboxed singleton; the result itself is not yet evaluated.}
5836++ with
5837++ can_fail = True
5838++
5839++primop UnsafeFreezeSmallArrayOp "unsafeFreezeSmallArray#" GenPrimOp
5840++ SmallMutableArray# s a -> State# s -> (# State# s, SmallArray# a #)
5841++ {Make a mutable array immutable, without copying.}
5842++ with
5843++ has_side_effects = True
5844++
5845++primop UnsafeThawSmallArrayOp "unsafeThawSmallArray#" GenPrimOp
5846++ SmallArray# a -> State# s -> (# State# s, SmallMutableArray# s a #)
5847++ {Make an immutable array mutable, without copying.}
5848++ with
5849++ out_of_line = True
5850++ has_side_effects = True
5851++
5852++-- The code_size is only correct for the case when the copy family of
5853++-- primops aren't inlined. It would be nice to keep track of both.
5854++
5855++primop CopySmallArrayOp "copySmallArray#" GenPrimOp
5856++ SmallArray# a -> Int# -> SmallMutableArray# s a -> Int# -> Int# -> State# s -> State# s
5857++ {Given a source array, an offset into the source array, a
5858++ destination array, an offset into the destination array, and a
5859++ number of elements to copy, copy the elements from the source array
5860++ to the destination array. Both arrays must fully contain the
5861++ specified ranges, but this is not checked. The two arrays must not
5862++ be the same array in different states, but this is not checked
5863++ either.}
5864++ with
5865++ out_of_line = True
5866++ has_side_effects = True
5867++ can_fail = True
5868++
5869++primop CopySmallMutableArrayOp "copySmallMutableArray#" GenPrimOp
5870++ SmallMutableArray# s a -> Int# -> SmallMutableArray# s a -> Int# -> Int# -> State# s -> State# s
5871++ {Given a source array, an offset into the source array, a
5872++ destination array, an offset into the destination array, and a
5873++ number of elements to copy, copy the elements from the source array
5874++ to the destination array. The source and destination arrays can
5875++ refer to the same array. Both arrays must fully contain the
5876++ specified ranges, but this is not checked.
5877++ The regions are allowed to overlap, although this is only possible when the same
5878++ array is provided as both the source and the destination. }
5879++ with
5880++ out_of_line = True
5881++ has_side_effects = True
5882++ can_fail = True
5883++
5884++primop CloneSmallArrayOp "cloneSmallArray#" GenPrimOp
5885++ SmallArray# a -> Int# -> Int# -> SmallArray# a
5886++ {Given a source array, an offset into the source array, and a number
5887++ of elements to copy, create a new array with the elements from the
5888++ source array. The provided array must fully contain the specified
5889++ range, but this is not checked.}
5890++ with
5891++ out_of_line = True
5892++ has_side_effects = True
5893++ can_fail = True
5894++
5895++primop CloneSmallMutableArrayOp "cloneSmallMutableArray#" GenPrimOp
5896++ SmallMutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, SmallMutableArray# s a #)
5897++ {Given a source array, an offset into the source array, and a number
5898++ of elements to copy, create a new array with the elements from the
5899++ source array. The provided array must fully contain the specified
5900++ range, but this is not checked.}
5901++ with
5902++ out_of_line = True
5903++ has_side_effects = True
5904++ can_fail = True
5905++
5906++primop FreezeSmallArrayOp "freezeSmallArray#" GenPrimOp
5907++ SmallMutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, SmallArray# a #)
5908++ {Given a source array, an offset into the source array, and a number
5909++ of elements to copy, create a new array with the elements from the
5910++ source array. The provided array must fully contain the specified
5911++ range, but this is not checked.}
5912++ with
5913++ out_of_line = True
5914++ has_side_effects = True
5915++ can_fail = True
5916++
5917++primop ThawSmallArrayOp "thawSmallArray#" GenPrimOp
5918++ SmallArray# a -> Int# -> Int# -> State# s -> (# State# s, SmallMutableArray# s a #)
5919++ {Given a source array, an offset into the source array, and a number
5920++ of elements to copy, create a new array with the elements from the
5921++ source array. The provided array must fully contain the specified
5922++ range, but this is not checked.}
5923++ with
5924++ out_of_line = True
5925++ has_side_effects = True
5926++ can_fail = True
5927++
5928++primop CasSmallArrayOp "casSmallArray#" GenPrimOp
5929++ SmallMutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #)
5930++ {Unsafe, machine-level atomic compare and swap on an element within an array.}
5931++ with
5932++ out_of_line = True
5933++ has_side_effects = True
5934++
5935++------------------------------------------------------------------------
5936++section "Byte Arrays"
5937++ {Operations on {\tt ByteArray\#}. A {\tt ByteArray\#} is a just a region of
5938++ raw memory in the garbage-collected heap, which is not
5939++ scanned for pointers. It carries its own size (in bytes).
5940++ There are
5941++ three sets of operations for accessing byte array contents:
5942++ index for reading from immutable byte arrays, and read/write
5943++ for mutable byte arrays. Each set contains operations for a
5944++ range of useful primitive data types. Each operation takes
5945++ an offset measured in terms of the size of the primitive type
5946++ being read or written.}
5947++
5948++------------------------------------------------------------------------
5949++
5950++primtype ByteArray#
5951++
5952++primtype MutableByteArray# s
5953++
5954++primop NewByteArrayOp_Char "newByteArray#" GenPrimOp
5955++ Int# -> State# s -> (# State# s, MutableByteArray# s #)
5956++ {Create a new mutable byte array of specified size (in bytes), in
5957++ the specified state thread.}
5958++ with out_of_line = True
5959++ has_side_effects = True
5960++
5961++primop NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp
5962++ Int# -> State# s -> (# State# s, MutableByteArray# s #)
5963++ {Create a mutable byte array that the GC guarantees not to move.}
5964++ with out_of_line = True
5965++ has_side_effects = True
5966++
5967++primop NewAlignedPinnedByteArrayOp_Char "newAlignedPinnedByteArray#" GenPrimOp
5968++ Int# -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
5969++ {Create a mutable byte array, aligned by the specified amount, that the GC guarantees not to move.}
5970++ with out_of_line = True
5971++ has_side_effects = True
5972++
5973++primop MutableByteArrayIsPinnedOp "isMutableByteArrayPinned#" GenPrimOp
5974++ MutableByteArray# s -> Int#
5975++ {Determine whether a {\tt MutableByteArray\#} is guaranteed not to move
5976++ during GC.}
5977++ with out_of_line = True
5978++
5979++primop ByteArrayIsPinnedOp "isByteArrayPinned#" GenPrimOp
5980++ ByteArray# -> Int#
5981++ {Determine whether a {\tt ByteArray\#} is guaranteed not to move during GC.}
5982++ with out_of_line = True
5983++
5984++primop ByteArrayContents_Char "byteArrayContents#" GenPrimOp
5985++ ByteArray# -> Addr#
5986++ {Intended for use with pinned arrays; otherwise very unsafe!}
5987++
5988++primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
5989++ MutableByteArray# s -> MutableByteArray# s -> Int#
5990++
5991++primop ShrinkMutableByteArrayOp_Char "shrinkMutableByteArray#" GenPrimOp
5992++ MutableByteArray# s -> Int# -> State# s -> State# s
5993++ {Shrink mutable byte array to new specified size (in bytes), in
5994++ the specified state thread. The new size argument must be less than or
5995++ equal to the current size as reported by {\tt sizeofMutableArray\#}.}
5996++ with out_of_line = True
5997++ has_side_effects = True
5998++
5999++primop ResizeMutableByteArrayOp_Char "resizeMutableByteArray#" GenPrimOp
6000++ MutableByteArray# s -> Int# -> State# s -> (# State# s,MutableByteArray# s #)
6001++ {Resize (unpinned) mutable byte array to new specified size (in bytes).
6002++ The returned {\tt MutableByteArray\#} is either the original
6003++ {\tt MutableByteArray\#} resized in-place or, if not possible, a newly
6004++ allocated (unpinned) {\tt MutableByteArray\#} (with the original content
6005++ copied over).
6006++
6007++ To avoid undefined behaviour, the original {\tt MutableByteArray\#} shall
6008++ not be accessed anymore after a {\tt resizeMutableByteArray\#} has been
6009++ performed. Moreover, no reference to the old one should be kept in order
6010++ to allow garbage collection of the original {\tt MutableByteArray\#} in
6011++ case a new {\tt MutableByteArray\#} had to be allocated.}
6012++ with out_of_line = True
6013++ has_side_effects = True
6014++
6015++primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
6016++ MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)
6017++ {Make a mutable byte array immutable, without copying.}
6018++ with
6019++ has_side_effects = True
6020++
6021++primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
6022++ ByteArray# -> Int#
6023++ {Return the size of the array in bytes.}
6024++
6025++primop SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
6026++ MutableByteArray# s -> Int#
6027++ {Return the size of the array in bytes. Note that this is deprecated as it is
6028++ unsafe in the presence of concurrent resize operations on the same byte
6029++ array. See {\tt getSizeofMutableByteArray}.}
6030++
6031++primop GetSizeofMutableByteArrayOp "getSizeofMutableByteArray#" GenPrimOp
6032++ MutableByteArray# s -> State# s -> (# State# s, Int# #)
6033++ {Return the number of elements in the array.}
6034++
6035++primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
6036++ ByteArray# -> Int# -> Char#
6037++ {Read 8-bit character; offset in bytes.}
6038++ with can_fail = True
6039++
6040++primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp
6041++ ByteArray# -> Int# -> Char#
6042++ {Read 31-bit character; offset in 4-byte words.}
6043++ with can_fail = True
6044++
6045++primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
6046++ ByteArray# -> Int# -> Int#
6047++ with can_fail = True
6048++
6049++primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
6050++ ByteArray# -> Int# -> Word#
6051++ with can_fail = True
6052++
6053++primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
6054++ ByteArray# -> Int# -> Addr#
6055++ with can_fail = True
6056++
6057++primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
6058++ ByteArray# -> Int# -> Float#
6059++ with can_fail = True
6060++
6061++primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
6062++ ByteArray# -> Int# -> Double#
6063++ with can_fail = True
6064++
6065++primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
6066++ ByteArray# -> Int# -> StablePtr# a
6067++ with can_fail = True
6068++
6069++primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
6070++ ByteArray# -> Int# -> Int#
6071++ {Read 8-bit integer; offset in bytes.}
6072++ with can_fail = True
6073++
6074++primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
6075++ ByteArray# -> Int# -> Int#
6076++ {Read 16-bit integer; offset in 16-bit words.}
6077++ with can_fail = True
6078++
6079++primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
6080++ ByteArray# -> Int# -> INT32
6081++ {Read 32-bit integer; offset in 32-bit words.}
6082++ with can_fail = True
6083++
6084++primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
6085++ ByteArray# -> Int# -> INT64
6086++ {Read 64-bit integer; offset in 64-bit words.}
6087++ with can_fail = True
6088++
6089++primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
6090++ ByteArray# -> Int# -> Word#
6091++ {Read 8-bit word; offset in bytes.}
6092++ with can_fail = True
6093++
6094++primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
6095++ ByteArray# -> Int# -> Word#
6096++ {Read 16-bit word; offset in 16-bit words.}
6097++ with can_fail = True
6098++
6099++primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
6100++ ByteArray# -> Int# -> WORD32
6101++ {Read 32-bit word; offset in 32-bit words.}
6102++ with can_fail = True
6103++
6104++primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
6105++ ByteArray# -> Int# -> WORD64
6106++ {Read 64-bit word; offset in 64-bit words.}
6107++ with can_fail = True
6108++
6109++primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
6110++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
6111++ {Read 8-bit character; offset in bytes.}
6112++ with has_side_effects = True
6113++ can_fail = True
6114++
6115++primop ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp
6116++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
6117++ {Read 31-bit character; offset in 4-byte words.}
6118++ with has_side_effects = True
6119++ can_fail = True
6120++
6121++primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp
6122++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
6123++ {Read integer; offset in words.}
6124++ with has_side_effects = True
6125++ can_fail = True
6126++
6127++primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp
6128++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
6129++ {Read word; offset in words.}
6130++ with has_side_effects = True
6131++ can_fail = True
6132++
6133++primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
6134++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)
6135++ with has_side_effects = True
6136++ can_fail = True
6137++
6138++primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
6139++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
6140++ with has_side_effects = True
6141++ can_fail = True
6142++
6143++primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
6144++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
6145++ with has_side_effects = True
6146++ can_fail = True
6147++
6148++primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
6149++ MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
6150++ with has_side_effects = True
6151++ can_fail = True
6152++
6153++primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
6154++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
6155++ with has_side_effects = True
6156++ can_fail = True
6157++
6158++primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
6159++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
6160++ with has_side_effects = True
6161++ can_fail = True
6162++
6163++primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
6164++ MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #)
6165++ with has_side_effects = True
6166++ can_fail = True
6167++
6168++primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
6169++ MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #)
6170++ with has_side_effects = True
6171++ can_fail = True
6172++
6173++primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
6174++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
6175++ with has_side_effects = True
6176++ can_fail = True
6177++
6178++primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
6179++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
6180++ with has_side_effects = True
6181++ can_fail = True
6182++
6183++primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
6184++ MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #)
6185++ with has_side_effects = True
6186++ can_fail = True
6187++
6188++primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
6189++ MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #)
6190++ with has_side_effects = True
6191++ can_fail = True
6192++
6193++primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
6194++ MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
6195++ {Write 8-bit character; offset in bytes.}
6196++ with has_side_effects = True
6197++ can_fail = True
6198++
6199++primop WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp
6200++ MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
6201++ {Write 31-bit character; offset in 4-byte words.}
6202++ with has_side_effects = True
6203++ can_fail = True
6204++
6205++primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
6206++ MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6207++ with has_side_effects = True
6208++ can_fail = True
6209++
6210++primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
6211++ MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
6212++ with has_side_effects = True
6213++ can_fail = True
6214++
6215++primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
6216++ MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s
6217++ with has_side_effects = True
6218++ can_fail = True
6219++
6220++primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
6221++ MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
6222++ with has_side_effects = True
6223++ can_fail = True
6224++
6225++primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
6226++ MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
6227++ with has_side_effects = True
6228++ can_fail = True
6229++
6230++primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
6231++ MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s
6232++ with has_side_effects = True
6233++ can_fail = True
6234++
6235++primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
6236++ MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6237++ with has_side_effects = True
6238++ can_fail = True
6239++
6240++primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
6241++ MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6242++ with has_side_effects = True
6243++ can_fail = True
6244++
6245++primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
6246++ MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s
6247++ with has_side_effects = True
6248++ can_fail = True
6249++
6250++primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
6251++ MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s
6252++ with can_fail = True
6253++ has_side_effects = True
6254++
6255++primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
6256++ MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
6257++ with has_side_effects = True
6258++ can_fail = True
6259++
6260++primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
6261++ MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
6262++ with has_side_effects = True
6263++ can_fail = True
6264++
6265++primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
6266++ MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s
6267++ with has_side_effects = True
6268++ can_fail = True
6269++
6270++primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
6271++ MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s
6272++ with has_side_effects = True
6273++ can_fail = True
6274++
6275++primop CompareByteArraysOp "compareByteArrays#" GenPrimOp
6276++ ByteArray# -> Int# -> ByteArray# -> Int# -> Int# -> Int#
6277++ {{\tt compareByteArrays# src1 src1_ofs src2 src2_ofs n} compares
6278++ {\tt n} bytes starting at offset {\tt src1_ofs} in the first
6279++ {\tt ByteArray#} {\tt src1} to the range of {\tt n} bytes
6280++ (i.e. same length) starting at offset {\tt src2_ofs} of the second
6281++ {\tt ByteArray#} {\tt src2}. Both arrays must fully contain the
6282++ specified ranges, but this is not checked. Returns an {\tt Int#}
6283++ less than, equal to, or greater than zero if the range is found,
6284++ respectively, to be byte-wise lexicographically less than, to
6285++ match, or be greater than the second range.}
6286++ with
6287++ can_fail = True
6288++
6289++primop CopyByteArrayOp "copyByteArray#" GenPrimOp
6290++ ByteArray# -> Int# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6291++ {{\tt copyByteArray# src src_ofs dst dst_ofs n} copies the range
6292++ starting at offset {\tt src_ofs} of length {\tt n} from the
6293++ {\tt ByteArray#} {\tt src} to the {\tt MutableByteArray#} {\tt dst}
6294++ starting at offset {\tt dst_ofs}. Both arrays must fully contain
6295++ the specified ranges, but this is not checked. The two arrays must
6296++ not be the same array in different states, but this is not checked
6297++ either.}
6298++ with
6299++ has_side_effects = True
6300++ code_size = { primOpCodeSizeForeignCall + 4}
6301++ can_fail = True
6302++
6303++primop CopyMutableByteArrayOp "copyMutableByteArray#" GenPrimOp
6304++ MutableByteArray# s -> Int# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6305++ {Copy a range of the first MutableByteArray# to the specified region in the second MutableByteArray#.
6306++ Both arrays must fully contain the specified ranges, but this is not checked. The regions are
6307++ allowed to overlap, although this is only possible when the same array is provided
6308++ as both the source and the destination.}
6309++ with
6310++ has_side_effects = True
6311++ code_size = { primOpCodeSizeForeignCall + 4 }
6312++ can_fail = True
6313++
6314++primop CopyByteArrayToAddrOp "copyByteArrayToAddr#" GenPrimOp
6315++ ByteArray# -> Int# -> Addr# -> Int# -> State# s -> State# s
6316++ {Copy a range of the ByteArray# to the memory range starting at the Addr#.
6317++ The ByteArray# and the memory region at Addr# must fully contain the
6318++ specified ranges, but this is not checked. The Addr# must not point into the
6319++ ByteArray# (e.g. if the ByteArray# were pinned), but this is not checked
6320++ either.}
6321++ with
6322++ has_side_effects = True
6323++ code_size = { primOpCodeSizeForeignCall + 4}
6324++ can_fail = True
6325++
6326++primop CopyMutableByteArrayToAddrOp "copyMutableByteArrayToAddr#" GenPrimOp
6327++ MutableByteArray# s -> Int# -> Addr# -> Int# -> State# s -> State# s
6328++ {Copy a range of the MutableByteArray# to the memory range starting at the
6329++ Addr#. The MutableByteArray# and the memory region at Addr# must fully
6330++ contain the specified ranges, but this is not checked. The Addr# must not
6331++ point into the MutableByteArray# (e.g. if the MutableByteArray# were
6332++ pinned), but this is not checked either.}
6333++ with
6334++ has_side_effects = True
6335++ code_size = { primOpCodeSizeForeignCall + 4}
6336++ can_fail = True
6337++
6338++primop CopyAddrToByteArrayOp "copyAddrToByteArray#" GenPrimOp
6339++ Addr# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6340++ {Copy a memory range starting at the Addr# to the specified range in the
6341++ MutableByteArray#. The memory region at Addr# and the ByteArray# must fully
6342++ contain the specified ranges, but this is not checked. The Addr# must not
6343++ point into the MutableByteArray# (e.g. if the MutableByteArray# were pinned),
6344++ but this is not checked either.}
6345++ with
6346++ has_side_effects = True
6347++ code_size = { primOpCodeSizeForeignCall + 4}
6348++ can_fail = True
6349++
6350++primop SetByteArrayOp "setByteArray#" GenPrimOp
6351++ MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> State# s
6352++ {{\tt setByteArray# ba off len c} sets the byte range {\tt [off, off+len]} of
6353++ the {\tt MutableByteArray#} to the byte {\tt c}.}
6354++ with
6355++ has_side_effects = True
6356++ code_size = { primOpCodeSizeForeignCall + 4 }
6357++ can_fail = True
6358++
6359++-- Atomic operations
6360++
6361++primop AtomicReadByteArrayOp_Int "atomicReadIntArray#" GenPrimOp
6362++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
6363++ {Given an array and an offset in Int units, read an element. The
6364++ index is assumed to be in bounds. Implies a full memory barrier.}
6365++ with has_side_effects = True
6366++ can_fail = True
6367++
6368++primop AtomicWriteByteArrayOp_Int "atomicWriteIntArray#" GenPrimOp
6369++ MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6370++ {Given an array and an offset in Int units, write an element. The
6371++ index is assumed to be in bounds. Implies a full memory barrier.}
6372++ with has_side_effects = True
6373++ can_fail = True
6374++
6375++primop CasByteArrayOp_Int "casIntArray#" GenPrimOp
6376++ MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6377++ {Given an array, an offset in Int units, the expected old value, and
6378++ the new value, perform an atomic compare and swap i.e. write the new
6379++ value if the current value matches the provided old value. Returns
6380++ the value of the element before the operation. Implies a full memory
6381++ barrier.}
6382++ with has_side_effects = True
6383++ can_fail = True
6384++
6385++primop FetchAddByteArrayOp_Int "fetchAddIntArray#" GenPrimOp
6386++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6387++ {Given an array, and offset in Int units, and a value to add,
6388++ atomically add the value to the element. Returns the value of the
6389++ element before the operation. Implies a full memory barrier.}
6390++ with has_side_effects = True
6391++ can_fail = True
6392++
6393++primop FetchSubByteArrayOp_Int "fetchSubIntArray#" GenPrimOp
6394++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6395++ {Given an array, and offset in Int units, and a value to subtract,
6396++ atomically substract the value to the element. Returns the value of
6397++ the element before the operation. Implies a full memory barrier.}
6398++ with has_side_effects = True
6399++ can_fail = True
6400++
6401++primop FetchAndByteArrayOp_Int "fetchAndIntArray#" GenPrimOp
6402++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6403++ {Given an array, and offset in Int units, and a value to AND,
6404++ atomically AND the value to the element. Returns the value of the
6405++ element before the operation. Implies a full memory barrier.}
6406++ with has_side_effects = True
6407++ can_fail = True
6408++
6409++primop FetchNandByteArrayOp_Int "fetchNandIntArray#" GenPrimOp
6410++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6411++ {Given an array, and offset in Int units, and a value to NAND,
6412++ atomically NAND the value to the element. Returns the value of the
6413++ element before the operation. Implies a full memory barrier.}
6414++ with has_side_effects = True
6415++ can_fail = True
6416++
6417++primop FetchOrByteArrayOp_Int "fetchOrIntArray#" GenPrimOp
6418++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6419++ {Given an array, and offset in Int units, and a value to OR,
6420++ atomically OR the value to the element. Returns the value of the
6421++ element before the operation. Implies a full memory barrier.}
6422++ with has_side_effects = True
6423++ can_fail = True
6424++
6425++primop FetchXorByteArrayOp_Int "fetchXorIntArray#" GenPrimOp
6426++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6427++ {Given an array, and offset in Int units, and a value to XOR,
6428++ atomically XOR the value to the element. Returns the value of the
6429++ element before the operation. Implies a full memory barrier.}
6430++ with has_side_effects = True
6431++ can_fail = True
6432++
6433++
6434++------------------------------------------------------------------------
6435++section "Arrays of arrays"
6436++ {Operations on {\tt ArrayArray\#}. An {\tt ArrayArray\#} contains references to {\em unpointed}
6437++ arrays, such as {\tt ByteArray\#s}. Hence, it is not parameterised by the element types,
6438++ just like a {\tt ByteArray\#}, but it needs to be scanned during GC, just like an {\tt Array#}.
6439++ We represent an {\tt ArrayArray\#} exactly as a {\tt Array\#}, but provide element-type-specific
6440++ indexing, reading, and writing.}
6441++------------------------------------------------------------------------
6442++
6443++primtype ArrayArray#
6444++
6445++primtype MutableArrayArray# s
6446++
6447++primop NewArrayArrayOp "newArrayArray#" GenPrimOp
6448++ Int# -> State# s -> (# State# s, MutableArrayArray# s #)
6449++ {Create a new mutable array of arrays with the specified number of elements,
6450++ in the specified state thread, with each element recursively referring to the
6451++ newly created array.}
6452++ with
6453++ out_of_line = True
6454++ has_side_effects = True
6455++
6456++primop SameMutableArrayArrayOp "sameMutableArrayArray#" GenPrimOp
6457++ MutableArrayArray# s -> MutableArrayArray# s -> Int#
6458++
6459++primop UnsafeFreezeArrayArrayOp "unsafeFreezeArrayArray#" GenPrimOp
6460++ MutableArrayArray# s -> State# s -> (# State# s, ArrayArray# #)
6461++ {Make a mutable array of arrays immutable, without copying.}
6462++ with
6463++ has_side_effects = True
6464++
6465++primop SizeofArrayArrayOp "sizeofArrayArray#" GenPrimOp
6466++ ArrayArray# -> Int#
6467++ {Return the number of elements in the array.}
6468++
6469++primop SizeofMutableArrayArrayOp "sizeofMutableArrayArray#" GenPrimOp
6470++ MutableArrayArray# s -> Int#
6471++ {Return the number of elements in the array.}
6472++
6473++primop IndexArrayArrayOp_ByteArray "indexByteArrayArray#" GenPrimOp
6474++ ArrayArray# -> Int# -> ByteArray#
6475++ with can_fail = True
6476++
6477++primop IndexArrayArrayOp_ArrayArray "indexArrayArrayArray#" GenPrimOp
6478++ ArrayArray# -> Int# -> ArrayArray#
6479++ with can_fail = True
6480++
6481++primop ReadArrayArrayOp_ByteArray "readByteArrayArray#" GenPrimOp
6482++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, ByteArray# #)
6483++ with has_side_effects = True
6484++ can_fail = True
6485++
6486++primop ReadArrayArrayOp_MutableByteArray "readMutableByteArrayArray#" GenPrimOp
6487++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
6488++ with has_side_effects = True
6489++ can_fail = True
6490++
6491++primop ReadArrayArrayOp_ArrayArray "readArrayArrayArray#" GenPrimOp
6492++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, ArrayArray# #)
6493++ with has_side_effects = True
6494++ can_fail = True
6495++
6496++primop ReadArrayArrayOp_MutableArrayArray "readMutableArrayArrayArray#" GenPrimOp
6497++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableArrayArray# s #)
6498++ with has_side_effects = True
6499++ can_fail = True
6500++
6501++primop WriteArrayArrayOp_ByteArray "writeByteArrayArray#" GenPrimOp
6502++ MutableArrayArray# s -> Int# -> ByteArray# -> State# s -> State# s
6503++ with has_side_effects = True
6504++ can_fail = True
6505++
6506++primop WriteArrayArrayOp_MutableByteArray "writeMutableByteArrayArray#" GenPrimOp
6507++ MutableArrayArray# s -> Int# -> MutableByteArray# s -> State# s -> State# s
6508++ with has_side_effects = True
6509++ can_fail = True
6510++
6511++primop WriteArrayArrayOp_ArrayArray "writeArrayArrayArray#" GenPrimOp
6512++ MutableArrayArray# s -> Int# -> ArrayArray# -> State# s -> State# s
6513++ with has_side_effects = True
6514++ can_fail = True
6515++
6516++primop WriteArrayArrayOp_MutableArrayArray "writeMutableArrayArrayArray#" GenPrimOp
6517++ MutableArrayArray# s -> Int# -> MutableArrayArray# s -> State# s -> State# s
6518++ with has_side_effects = True
6519++ can_fail = True
6520++
6521++primop CopyArrayArrayOp "copyArrayArray#" GenPrimOp
6522++ ArrayArray# -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s
6523++ {Copy a range of the ArrayArray# to the specified region in the MutableArrayArray#.
6524++ Both arrays must fully contain the specified ranges, but this is not checked.
6525++ The two arrays must not be the same array in different states, but this is not checked either.}
6526++ with
6527++ out_of_line = True
6528++ has_side_effects = True
6529++ can_fail = True
6530++
6531++primop CopyMutableArrayArrayOp "copyMutableArrayArray#" GenPrimOp
6532++ MutableArrayArray# s -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s
6533++ {Copy a range of the first MutableArrayArray# to the specified region in the second
6534++ MutableArrayArray#.
6535++ Both arrays must fully contain the specified ranges, but this is not checked.
6536++ The regions are allowed to overlap, although this is only possible when the same
6537++ array is provided as both the source and the destination.
6538++ }
6539++ with
6540++ out_of_line = True
6541++ has_side_effects = True
6542++ can_fail = True
6543++
6544++------------------------------------------------------------------------
6545++section "Addr#"
6546++------------------------------------------------------------------------
6547++
6548++primtype Addr#
6549++ { An arbitrary machine address assumed to point outside
6550++ the garbage-collected heap. }
6551++
6552++pseudoop "nullAddr#" Addr#
6553++ { The null address. }
6554++
6555++primop AddrAddOp "plusAddr#" GenPrimOp Addr# -> Int# -> Addr#
6556++primop AddrSubOp "minusAddr#" GenPrimOp Addr# -> Addr# -> Int#
6557++ {Result is meaningless if two {\tt Addr\#}s are so far apart that their
6558++ difference doesn't fit in an {\tt Int\#}.}
6559++primop AddrRemOp "remAddr#" GenPrimOp Addr# -> Int# -> Int#
6560++ {Return the remainder when the {\tt Addr\#} arg, treated like an {\tt Int\#},
6561++ is divided by the {\tt Int\#} arg.}
6562++#if (WORD_SIZE_IN_BITS == 32 || WORD_SIZE_IN_BITS == 64)
6563++primop Addr2IntOp "addr2Int#" GenPrimOp Addr# -> Int#
6564++ {Coerce directly from address to int. Strongly deprecated.}
6565++ with code_size = 0
6566++primop Int2AddrOp "int2Addr#" GenPrimOp Int# -> Addr#
6567++ {Coerce directly from int to address. Strongly deprecated.}
6568++ with code_size = 0
6569++#endif
6570++
6571++primop AddrGtOp "gtAddr#" Compare Addr# -> Addr# -> Int#
6572++primop AddrGeOp "geAddr#" Compare Addr# -> Addr# -> Int#
6573++primop AddrEqOp "eqAddr#" Compare Addr# -> Addr# -> Int#
6574++primop AddrNeOp "neAddr#" Compare Addr# -> Addr# -> Int#
6575++primop AddrLtOp "ltAddr#" Compare Addr# -> Addr# -> Int#
6576++primop AddrLeOp "leAddr#" Compare Addr# -> Addr# -> Int#
6577++
6578++primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
6579++ Addr# -> Int# -> Char#
6580++ {Reads 8-bit character; offset in bytes.}
6581++ with can_fail = True
6582++
6583++primop IndexOffAddrOp_WideChar "indexWideCharOffAddr#" GenPrimOp
6584++ Addr# -> Int# -> Char#
6585++ {Reads 31-bit character; offset in 4-byte words.}
6586++ with can_fail = True
6587++
6588++primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
6589++ Addr# -> Int# -> Int#
6590++ with can_fail = True
6591++
6592++primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
6593++ Addr# -> Int# -> Word#
6594++ with can_fail = True
6595++
6596++primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
6597++ Addr# -> Int# -> Addr#
6598++ with can_fail = True
6599++
6600++primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
6601++ Addr# -> Int# -> Float#
6602++ with can_fail = True
6603++
6604++primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
6605++ Addr# -> Int# -> Double#
6606++ with can_fail = True
6607++
6608++primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
6609++ Addr# -> Int# -> StablePtr# a
6610++ with can_fail = True
6611++
6612++primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
6613++ Addr# -> Int# -> Int#
6614++ with can_fail = True
6615++
6616++primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
6617++ Addr# -> Int# -> Int#
6618++ with can_fail = True
6619++
6620++primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
6621++ Addr# -> Int# -> INT32
6622++ with can_fail = True
6623++
6624++primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
6625++ Addr# -> Int# -> INT64
6626++ with can_fail = True
6627++
6628++primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
6629++ Addr# -> Int# -> Word#
6630++ with can_fail = True
6631++
6632++primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
6633++ Addr# -> Int# -> Word#
6634++ with can_fail = True
6635++
6636++primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
6637++ Addr# -> Int# -> WORD32
6638++ with can_fail = True
6639++
6640++primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
6641++ Addr# -> Int# -> WORD64
6642++ with can_fail = True
6643++
6644++primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
6645++ Addr# -> Int# -> State# s -> (# State# s, Char# #)
6646++ {Reads 8-bit character; offset in bytes.}
6647++ with has_side_effects = True
6648++ can_fail = True
6649++
6650++primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp
6651++ Addr# -> Int# -> State# s -> (# State# s, Char# #)
6652++ {Reads 31-bit character; offset in 4-byte words.}
6653++ with has_side_effects = True
6654++ can_fail = True
6655++
6656++primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
6657++ Addr# -> Int# -> State# s -> (# State# s, Int# #)
6658++ with has_side_effects = True
6659++ can_fail = True
6660++
6661++primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
6662++ Addr# -> Int# -> State# s -> (# State# s, Word# #)
6663++ with has_side_effects = True
6664++ can_fail = True
6665++
6666++primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
6667++ Addr# -> Int# -> State# s -> (# State# s, Addr# #)
6668++ with has_side_effects = True
6669++ can_fail = True
6670++
6671++primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
6672++ Addr# -> Int# -> State# s -> (# State# s, Float# #)
6673++ with has_side_effects = True
6674++ can_fail = True
6675++
6676++primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
6677++ Addr# -> Int# -> State# s -> (# State# s, Double# #)
6678++ with has_side_effects = True
6679++ can_fail = True
6680++
6681++primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
6682++ Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
6683++ with has_side_effects = True
6684++ can_fail = True
6685++
6686++primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
6687++ Addr# -> Int# -> State# s -> (# State# s, Int# #)
6688++ with has_side_effects = True
6689++ can_fail = True
6690++
6691++primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
6692++ Addr# -> Int# -> State# s -> (# State# s, Int# #)
6693++ with has_side_effects = True
6694++ can_fail = True
6695++
6696++primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
6697++ Addr# -> Int# -> State# s -> (# State# s, INT32 #)
6698++ with has_side_effects = True
6699++ can_fail = True
6700++
6701++primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
6702++ Addr# -> Int# -> State# s -> (# State# s, INT64 #)
6703++ with has_side_effects = True
6704++ can_fail = True
6705++
6706++primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
6707++ Addr# -> Int# -> State# s -> (# State# s, Word# #)
6708++ with has_side_effects = True
6709++ can_fail = True
6710++
6711++primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
6712++ Addr# -> Int# -> State# s -> (# State# s, Word# #)
6713++ with has_side_effects = True
6714++ can_fail = True
6715++
6716++primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
6717++ Addr# -> Int# -> State# s -> (# State# s, WORD32 #)
6718++ with has_side_effects = True
6719++ can_fail = True
6720++
6721++primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
6722++ Addr# -> Int# -> State# s -> (# State# s, WORD64 #)
6723++ with has_side_effects = True
6724++ can_fail = True
6725++
6726++primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
6727++ Addr# -> Int# -> Char# -> State# s -> State# s
6728++ with has_side_effects = True
6729++ can_fail = True
6730++
6731++primop WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp
6732++ Addr# -> Int# -> Char# -> State# s -> State# s
6733++ with has_side_effects = True
6734++ can_fail = True
6735++
6736++primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
6737++ Addr# -> Int# -> Int# -> State# s -> State# s
6738++ with has_side_effects = True
6739++ can_fail = True
6740++
6741++primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
6742++ Addr# -> Int# -> Word# -> State# s -> State# s
6743++ with has_side_effects = True
6744++ can_fail = True
6745++
6746++primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
6747++ Addr# -> Int# -> Addr# -> State# s -> State# s
6748++ with has_side_effects = True
6749++ can_fail = True
6750++
6751++primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
6752++ Addr# -> Int# -> Float# -> State# s -> State# s
6753++ with has_side_effects = True
6754++ can_fail = True
6755++
6756++primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
6757++ Addr# -> Int# -> Double# -> State# s -> State# s
6758++ with has_side_effects = True
6759++ can_fail = True
6760++
6761++primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
6762++ Addr# -> Int# -> StablePtr# a -> State# s -> State# s
6763++ with has_side_effects = True
6764++ can_fail = True
6765++
6766++primop WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
6767++ Addr# -> Int# -> Int# -> State# s -> State# s
6768++ with has_side_effects = True
6769++ can_fail = True
6770++
6771++primop WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
6772++ Addr# -> Int# -> Int# -> State# s -> State# s
6773++ with has_side_effects = True
6774++ can_fail = True
6775++
6776++primop WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
6777++ Addr# -> Int# -> INT32 -> State# s -> State# s
6778++ with has_side_effects = True
6779++ can_fail = True
6780++
6781++primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
6782++ Addr# -> Int# -> INT64 -> State# s -> State# s
6783++ with has_side_effects = True
6784++ can_fail = True
6785++
6786++primop WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
6787++ Addr# -> Int# -> Word# -> State# s -> State# s
6788++ with has_side_effects = True
6789++ can_fail = True
6790++
6791++primop WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
6792++ Addr# -> Int# -> Word# -> State# s -> State# s
6793++ with has_side_effects = True
6794++ can_fail = True
6795++
6796++primop WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
6797++ Addr# -> Int# -> WORD32 -> State# s -> State# s
6798++ with has_side_effects = True
6799++ can_fail = True
6800++
6801++primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
6802++ Addr# -> Int# -> WORD64 -> State# s -> State# s
6803++ with has_side_effects = True
6804++ can_fail = True
6805++
6806++------------------------------------------------------------------------
6807++section "Mutable variables"
6808++ {Operations on MutVar\#s.}
6809++------------------------------------------------------------------------
6810++
6811++primtype MutVar# s a
6812++ {A {\tt MutVar\#} behaves like a single-element mutable array.}
6813++
6814++primop NewMutVarOp "newMutVar#" GenPrimOp
6815++ a -> State# s -> (# State# s, MutVar# s a #)
6816++ {Create {\tt MutVar\#} with specified initial value in specified state thread.}
6817++ with
6818++ out_of_line = True
6819++ has_side_effects = True
6820++
6821++-- Note [Why MutVar# ops can't fail]
6822++-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6823++--
6824++-- We don't label readMutVar# or writeMutVar# as can_fail.
6825++-- This may seem a bit peculiar, because they surely *could*
6826++-- fail spectacularly if passed a pointer to unallocated memory.
6827++-- But MutVar#s are always correct by construction; we never
6828++-- test if a pointer is valid before using it with these operations.
6829++-- So we never have to worry about floating the pointer reference
6830++-- outside a validity test. At the moment, has_side_effects blocks
6831++-- up the relevant optimizations anyway, but we hope to draw finer
6832++-- distinctions soon, which should improve matters for readMutVar#
6833++-- at least.
6834++
6835++primop ReadMutVarOp "readMutVar#" GenPrimOp
6836++ MutVar# s a -> State# s -> (# State# s, a #)
6837++ {Read contents of {\tt MutVar\#}. Result is not yet evaluated.}
6838++ with
6839++ -- See Note [Why MutVar# ops can't fail]
6840++ has_side_effects = True
6841++
6842++primop WriteMutVarOp "writeMutVar#" GenPrimOp
6843++ MutVar# s a -> a -> State# s -> State# s
6844++ {Write contents of {\tt MutVar\#}.}
6845++ with
6846++ -- See Note [Why MutVar# ops can't fail]
6847++ has_side_effects = True
6848++ code_size = { primOpCodeSizeForeignCall } -- for the write barrier
6849++
6850++primop SameMutVarOp "sameMutVar#" GenPrimOp
6851++ MutVar# s a -> MutVar# s a -> Int#
6852++
6853++-- Note [Why not an unboxed tuple in atomicModifyMutVar#?]
6854++-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6855++--
6856++-- Looking at the type of atomicModifyMutVar#, one might wonder why
6857++-- it doesn't return an unboxed tuple. e.g.,
6858++--
6859++-- MutVar# s a -> (a -> (# a, b #)) -> State# s -> (# State# s, b #)
6860++--
6861++-- The reason is that atomicModifyMutVar# relies on laziness for its atomicity.
6862++-- Given a MutVar# containing x, atomicModifyMutVar# merely replaces the
6863++-- its contents with a thunk of the form (fst (f x)). This can be done using an
6864++-- atomic compare-and-swap as it is merely replacing a pointer.
6865++
6866++primop AtomicModifyMutVarOp "atomicModifyMutVar#" GenPrimOp
6867++ MutVar# s a -> (a -> b) -> State# s -> (# State# s, c #)
6868++ { Modify the contents of a {\tt MutVar\#}. Note that this isn't strictly
6869++ speaking the correct type for this function, it should really be
6870++ {\tt MutVar# s a -> (a -> (a,b)) -> State# s -> (# State# s, b #)}, however
6871++ we don't know about pairs here. }
6872++ with
6873++ out_of_line = True
6874++ has_side_effects = True
6875++ can_fail = True
6876++
6877++primop CasMutVarOp "casMutVar#" GenPrimOp
6878++ MutVar# s a -> a -> a -> State# s -> (# State# s, Int#, a #)
6879++ with
6880++ out_of_line = True
6881++ has_side_effects = True
6882++
6883++------------------------------------------------------------------------
6884++section "Exceptions"
6885++------------------------------------------------------------------------
6886++
6887++-- Note [Strictness for mask/unmask/catch]
6888++-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6889++-- Consider this example, which comes from GHC.IO.Handle.Internals:
6890++-- wantReadableHandle3 f ma b st
6891++-- = case ... of
6892++-- DEFAULT -> case ma of MVar a -> ...
6893++-- 0# -> maskAsynchExceptions# (\st -> case ma of MVar a -> ...)
6894++-- The outer case just decides whether to mask exceptions, but we don't want
6895++-- thereby to hide the strictness in 'ma'! Hence the use of strictApply1Dmd.
6896++--
6897++-- For catch, catchSTM, and catchRetry, we must be extra careful; see
6898++-- Note [Exceptions and strictness] in Demand
6899++
6900++primop CatchOp "catch#" GenPrimOp
6901++ (State# RealWorld -> (# State# RealWorld, a #) )
6902++ -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
6903++ -> State# RealWorld
6904++ -> (# State# RealWorld, a #)
6905++ with
6906++ strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
6907++ , lazyApply2Dmd
6908++ , topDmd] topRes }
6909++ -- See Note [Strictness for mask/unmask/catch]
6910++ out_of_line = True
6911++ has_side_effects = True
6912++
6913++primop RaiseOp "raise#" GenPrimOp
6914++ b -> o
6915++ -- NB: the type variable "o" is "a", but with OpenKind
6916++ with
6917++ strictness = { \ _arity -> mkClosedStrictSig [topDmd] exnRes }
6918++ -- NB: result is ThrowsExn
6919++ out_of_line = True
6920++ has_side_effects = True
6921++ -- raise# certainly throws a Haskell exception and hence has_side_effects
6922++ -- It doesn't actually make much difference because the fact that it
6923++ -- returns bottom independently ensures that we are careful not to discard
6924++ -- it. But still, it's better to say the Right Thing.
6925++
6926++-- raiseIO# needs to be a primop, because exceptions in the IO monad
6927++-- must be *precise* - we don't want the strictness analyser turning
6928++-- one kind of bottom into another, as it is allowed to do in pure code.
6929++--
6930++-- But we *do* want to know that it returns bottom after
6931++-- being applied to two arguments, so that this function is strict in y
6932++-- f x y | x>0 = raiseIO blah
6933++-- | y>0 = return 1
6934++-- | otherwise = return 2
6935++--
6936++-- TODO Check that the above notes on @f@ are valid. The function successfully
6937++-- produces an IO exception when compiled without optimization. If we analyze
6938++-- it as strict in @y@, won't we change that behavior under optimization?
6939++-- I thought the rule was that it was okay to replace one valid imprecise
6940++-- exception with another, but not to replace a precise exception with
6941++-- an imprecise one (dfeuer, 2017-03-05).
6942++
6943++primop RaiseIOOp "raiseIO#" GenPrimOp
6944++ a -> State# RealWorld -> (# State# RealWorld, b #)
6945++ with
6946++ strictness = { \ _arity -> mkClosedStrictSig [topDmd, topDmd] exnRes }
6947++ out_of_line = True
6948++ has_side_effects = True
6949++
6950++primop MaskAsyncExceptionsOp "maskAsyncExceptions#" GenPrimOp
6951++ (State# RealWorld -> (# State# RealWorld, a #))
6952++ -> (State# RealWorld -> (# State# RealWorld, a #))
6953++ with
6954++ strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
6955++ -- See Note [Strictness for mask/unmask/catch]
6956++ out_of_line = True
6957++ has_side_effects = True
6958++
6959++primop MaskUninterruptibleOp "maskUninterruptible#" GenPrimOp
6960++ (State# RealWorld -> (# State# RealWorld, a #))
6961++ -> (State# RealWorld -> (# State# RealWorld, a #))
6962++ with
6963++ strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
6964++ out_of_line = True
6965++ has_side_effects = True
6966++
6967++primop UnmaskAsyncExceptionsOp "unmaskAsyncExceptions#" GenPrimOp
6968++ (State# RealWorld -> (# State# RealWorld, a #))
6969++ -> (State# RealWorld -> (# State# RealWorld, a #))
6970++ with
6971++ strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
6972++ -- See Note [Strictness for mask/unmask/catch]
6973++ out_of_line = True
6974++ has_side_effects = True
6975++
6976++primop MaskStatus "getMaskingState#" GenPrimOp
6977++ State# RealWorld -> (# State# RealWorld, Int# #)
6978++ with
6979++ out_of_line = True
6980++ has_side_effects = True
6981++
6982++------------------------------------------------------------------------
6983++section "STM-accessible Mutable Variables"
6984++------------------------------------------------------------------------
6985++
6986++primtype TVar# s a
6987++
6988++primop AtomicallyOp "atomically#" GenPrimOp
6989++ (State# RealWorld -> (# State# RealWorld, a #) )
6990++ -> State# RealWorld -> (# State# RealWorld, a #)
6991++ with
6992++ strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
6993++ -- See Note [Strictness for mask/unmask/catch]
6994++ out_of_line = True
6995++ has_side_effects = True
6996++
6997++-- NB: retry#'s strictness information specifies it to throw an exception
6998++-- This lets the compiler perform some extra simplifications, since retry#
6999++-- will technically never return.
7000++--
7001++-- This allows the simplifier to replace things like:
7002++-- case retry# s1
7003++-- (# s2, a #) -> e
7004++-- with:
7005++-- retry# s1
7006++-- where 'e' would be unreachable anyway. See Trac #8091.
7007++--
7008++-- Note that it *does not* return botRes as the "exception" that is thrown may be
7009++-- "caught" by catchRetry#. This mistake caused #14171.
7010++primop RetryOp "retry#" GenPrimOp
7011++ State# RealWorld -> (# State# RealWorld, a #)
7012++ with
7013++ strictness = { \ _arity -> mkClosedStrictSig [topDmd] exnRes }
7014++ out_of_line = True
7015++ has_side_effects = True
7016++
7017++primop CatchRetryOp "catchRetry#" GenPrimOp
7018++ (State# RealWorld -> (# State# RealWorld, a #) )
7019++ -> (State# RealWorld -> (# State# RealWorld, a #) )
7020++ -> (State# RealWorld -> (# State# RealWorld, a #) )
7021++ with
7022++ strictness = { \ _arity -> mkClosedStrictSig [ catchArgDmd
7023++ , lazyApply1Dmd
7024++ , topDmd ] topRes }
7025++ -- See Note [Strictness for mask/unmask/catch]
7026++ out_of_line = True
7027++ has_side_effects = True
7028++
7029++primop CatchSTMOp "catchSTM#" GenPrimOp
7030++ (State# RealWorld -> (# State# RealWorld, a #) )
7031++ -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
7032++ -> (State# RealWorld -> (# State# RealWorld, a #) )
7033++ with
7034++ strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
7035++ , lazyApply2Dmd
7036++ , topDmd ] topRes }
7037++ -- See Note [Strictness for mask/unmask/catch]
7038++ out_of_line = True
7039++ has_side_effects = True
7040++
7041++primop Check "check#" GenPrimOp
7042++ (State# RealWorld -> (# State# RealWorld, a #) )
7043++ -> (State# RealWorld -> State# RealWorld)
7044++ with
7045++ out_of_line = True
7046++ has_side_effects = True
7047++
7048++primop NewTVarOp "newTVar#" GenPrimOp
7049++ a
7050++ -> State# s -> (# State# s, TVar# s a #)
7051++ {Create a new {\tt TVar\#} holding a specified initial value.}
7052++ with
7053++ out_of_line = True
7054++ has_side_effects = True
7055++
7056++primop ReadTVarOp "readTVar#" GenPrimOp
7057++ TVar# s a
7058++ -> State# s -> (# State# s, a #)
7059++ {Read contents of {\tt TVar\#}. Result is not yet evaluated.}
7060++ with
7061++ out_of_line = True
7062++ has_side_effects = True
7063++
7064++primop ReadTVarIOOp "readTVarIO#" GenPrimOp
7065++ TVar# s a
7066++ -> State# s -> (# State# s, a #)
7067++ {Read contents of {\tt TVar\#} outside an STM transaction}
7068++ with
7069++ out_of_line = True
7070++ has_side_effects = True
7071++
7072++primop WriteTVarOp "writeTVar#" GenPrimOp
7073++ TVar# s a
7074++ -> a
7075++ -> State# s -> State# s
7076++ {Write contents of {\tt TVar\#}.}
7077++ with
7078++ out_of_line = True
7079++ has_side_effects = True
7080++
7081++primop SameTVarOp "sameTVar#" GenPrimOp
7082++ TVar# s a -> TVar# s a -> Int#
7083++
7084++
7085++------------------------------------------------------------------------
7086++section "Synchronized Mutable Variables"
7087++ {Operations on {\tt MVar\#}s. }
7088++------------------------------------------------------------------------
7089++
7090++primtype MVar# s a
7091++ { A shared mutable variable ({\it not} the same as a {\tt MutVar\#}!).
7092++ (Note: in a non-concurrent implementation, {\tt (MVar\# a)} can be
7093++ represented by {\tt (MutVar\# (Maybe a))}.) }
7094++
7095++primop NewMVarOp "newMVar#" GenPrimOp
7096++ State# s -> (# State# s, MVar# s a #)
7097++ {Create new {\tt MVar\#}; initially empty.}
7098++ with
7099++ out_of_line = True
7100++ has_side_effects = True
7101++
7102++primop TakeMVarOp "takeMVar#" GenPrimOp
7103++ MVar# s a -> State# s -> (# State# s, a #)
7104++ {If {\tt MVar\#} is empty, block until it becomes full.
7105++ Then remove and return its contents, and set it empty.}
7106++ with
7107++ out_of_line = True
7108++ has_side_effects = True
7109++
7110++primop TryTakeMVarOp "tryTakeMVar#" GenPrimOp
7111++ MVar# s a -> State# s -> (# State# s, Int#, a #)
7112++ {If {\tt MVar\#} is empty, immediately return with integer 0 and value undefined.
7113++ Otherwise, return with integer 1 and contents of {\tt MVar\#}, and set {\tt MVar\#} empty.}
7114++ with
7115++ out_of_line = True
7116++ has_side_effects = True
7117++
7118++primop PutMVarOp "putMVar#" GenPrimOp
7119++ MVar# s a -> a -> State# s -> State# s
7120++ {If {\tt MVar\#} is full, block until it becomes empty.
7121++ Then store value arg as its new contents.}
7122++ with
7123++ out_of_line = True
7124++ has_side_effects = True
7125++
7126++primop TryPutMVarOp "tryPutMVar#" GenPrimOp
7127++ MVar# s a -> a -> State# s -> (# State# s, Int# #)
7128++ {If {\tt MVar\#} is full, immediately return with integer 0.
7129++ Otherwise, store value arg as {\tt MVar\#}'s new contents, and return with integer 1.}
7130++ with
7131++ out_of_line = True
7132++ has_side_effects = True
7133++
7134++primop ReadMVarOp "readMVar#" GenPrimOp
7135++ MVar# s a -> State# s -> (# State# s, a #)
7136++ {If {\tt MVar\#} is empty, block until it becomes full.
7137++ Then read its contents without modifying the MVar, without possibility
7138++ of intervention from other threads.}
7139++ with
7140++ out_of_line = True
7141++ has_side_effects = True
7142++
7143++primop TryReadMVarOp "tryReadMVar#" GenPrimOp
7144++ MVar# s a -> State# s -> (# State# s, Int#, a #)
7145++ {If {\tt MVar\#} is empty, immediately return with integer 0 and value undefined.
7146++ Otherwise, return with integer 1 and contents of {\tt MVar\#}.}
7147++ with
7148++ out_of_line = True
7149++ has_side_effects = True
7150++
7151++primop SameMVarOp "sameMVar#" GenPrimOp
7152++ MVar# s a -> MVar# s a -> Int#
7153++
7154++primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
7155++ MVar# s a -> State# s -> (# State# s, Int# #)
7156++ {Return 1 if {\tt MVar\#} is empty; 0 otherwise.}
7157++ with
7158++ out_of_line = True
7159++ has_side_effects = True
7160++
7161++------------------------------------------------------------------------
7162++section "Delay/wait operations"
7163++------------------------------------------------------------------------
7164++
7165++primop DelayOp "delay#" GenPrimOp
7166++ Int# -> State# s -> State# s
7167++ {Sleep specified number of microseconds.}
7168++ with
7169++ has_side_effects = True
7170++ out_of_line = True
7171++
7172++primop WaitReadOp "waitRead#" GenPrimOp
7173++ Int# -> State# s -> State# s
7174++ {Block until input is available on specified file descriptor.}
7175++ with
7176++ has_side_effects = True
7177++ out_of_line = True
7178++
7179++primop WaitWriteOp "waitWrite#" GenPrimOp
7180++ Int# -> State# s -> State# s
7181++ {Block until output is possible on specified file descriptor.}
7182++ with
7183++ has_side_effects = True
7184++ out_of_line = True
7185++
7186++#if defined(mingw32_TARGET_OS)
7187++primop AsyncReadOp "asyncRead#" GenPrimOp
7188++ Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
7189++ {Asynchronously read bytes from specified file descriptor.}
7190++ with
7191++ has_side_effects = True
7192++ out_of_line = True
7193++
7194++primop AsyncWriteOp "asyncWrite#" GenPrimOp
7195++ Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
7196++ {Asynchronously write bytes from specified file descriptor.}
7197++ with
7198++ has_side_effects = True
7199++ out_of_line = True
7200++
7201++primop AsyncDoProcOp "asyncDoProc#" GenPrimOp
7202++ Addr# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
7203++ {Asynchronously perform procedure (first arg), passing it 2nd arg.}
7204++ with
7205++ has_side_effects = True
7206++ out_of_line = True
7207++
7208++#endif
7209++
7210++------------------------------------------------------------------------
7211++section "Concurrency primitives"
7212++------------------------------------------------------------------------
7213++
7214++primtype State# s
7215++ { {\tt State\#} is the primitive, unlifted type of states. It has
7216++ one type parameter, thus {\tt State\# RealWorld}, or {\tt State\# s},
7217++ where s is a type variable. The only purpose of the type parameter
7218++ is to keep different state threads separate. It is represented by
7219++ nothing at all. }
7220++
7221++primtype RealWorld
7222++ { {\tt RealWorld} is deeply magical. It is {\it primitive}, but it is not
7223++ {\it unlifted} (hence {\tt ptrArg}). We never manipulate values of type
7224++ {\tt RealWorld}; it's only used in the type system, to parameterise {\tt State\#}. }
7225++
7226++primtype ThreadId#
7227++ {(In a non-concurrent implementation, this can be a singleton
7228++ type, whose (unique) value is returned by {\tt myThreadId\#}. The
7229++ other operations can be omitted.)}
7230++
7231++primop ForkOp "fork#" GenPrimOp
7232++ a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
7233++ with
7234++ has_side_effects = True
7235++ out_of_line = True
7236++
7237++primop ForkOnOp "forkOn#" GenPrimOp
7238++ Int# -> a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
7239++ with
7240++ has_side_effects = True
7241++ out_of_line = True
7242++
7243++primop KillThreadOp "killThread#" GenPrimOp
7244++ ThreadId# -> a -> State# RealWorld -> State# RealWorld
7245++ with
7246++ has_side_effects = True
7247++ out_of_line = True
7248++
7249++primop YieldOp "yield#" GenPrimOp
7250++ State# RealWorld -> State# RealWorld
7251++ with
7252++ has_side_effects = True
7253++ out_of_line = True
7254++
7255++primop MyThreadIdOp "myThreadId#" GenPrimOp
7256++ State# RealWorld -> (# State# RealWorld, ThreadId# #)
7257++ with
7258++ out_of_line = True
7259++ has_side_effects = True
7260++
7261++primop LabelThreadOp "labelThread#" GenPrimOp
7262++ ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
7263++ with
7264++ has_side_effects = True
7265++ out_of_line = True
7266++
7267++primop IsCurrentThreadBoundOp "isCurrentThreadBound#" GenPrimOp
7268++ State# RealWorld -> (# State# RealWorld, Int# #)
7269++ with
7270++ out_of_line = True
7271++ has_side_effects = True
7272++
7273++primop NoDuplicateOp "noDuplicate#" GenPrimOp
7274++ State# s -> State# s
7275++ with
7276++ out_of_line = True
7277++ has_side_effects = True
7278++
7279++primop ThreadStatusOp "threadStatus#" GenPrimOp
7280++ ThreadId# -> State# RealWorld -> (# State# RealWorld, Int#, Int#, Int# #)
7281++ with
7282++ out_of_line = True
7283++ has_side_effects = True
7284++
7285++------------------------------------------------------------------------
7286++section "Weak pointers"
7287++------------------------------------------------------------------------
7288++
7289++primtype Weak# b
7290++
7291++-- note that tyvar "o" denotes openAlphaTyVar
7292++
7293++primop MkWeakOp "mkWeak#" GenPrimOp
7294++ o -> b -> (State# RealWorld -> (# State# RealWorld, c #))
7295++ -> State# RealWorld -> (# State# RealWorld, Weak# b #)
7296++ { {\tt mkWeak# k v finalizer s} creates a weak reference to value {\tt k},
7297++ with an associated reference to some value {\tt v}. If {\tt k} is still
7298++ alive then {\tt v} can be retrieved using {\tt deRefWeak#}. Note that
7299++ the type of {\tt k} must be represented by a pointer (i.e. of kind {\tt
7300++ TYPE 'LiftedRep} or {\tt TYPE 'UnliftedRep}). }
7301++ with
7302++ has_side_effects = True
7303++ out_of_line = True
7304++
7305++primop MkWeakNoFinalizerOp "mkWeakNoFinalizer#" GenPrimOp
7306++ o -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #)
7307++ with
7308++ has_side_effects = True
7309++ out_of_line = True
7310++
7311++primop AddCFinalizerToWeakOp "addCFinalizerToWeak#" GenPrimOp
7312++ Addr# -> Addr# -> Int# -> Addr# -> Weak# b
7313++ -> State# RealWorld -> (# State# RealWorld, Int# #)
7314++ { {\tt addCFinalizerToWeak# fptr ptr flag eptr w} attaches a C
7315++ function pointer {\tt fptr} to a weak pointer {\tt w} as a finalizer. If
7316++ {\tt flag} is zero, {\tt fptr} will be called with one argument,
7317++ {\tt ptr}. Otherwise, it will be called with two arguments,
7318++ {\tt eptr} and {\tt ptr}. {\tt addCFinalizerToWeak#} returns
7319++ 1 on success, or 0 if {\tt w} is already dead. }
7320++ with
7321++ has_side_effects = True
7322++ out_of_line = True
7323++
7324++primop DeRefWeakOp "deRefWeak#" GenPrimOp
7325++ Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
7326++ with
7327++ has_side_effects = True
7328++ out_of_line = True
7329++
7330++primop FinalizeWeakOp "finalizeWeak#" GenPrimOp
7331++ Weak# a -> State# RealWorld -> (# State# RealWorld, Int#,
7332++ (State# RealWorld -> (# State# RealWorld, b #) ) #)
7333++ { Finalize a weak pointer. The return value is an unboxed tuple
7334++ containing the new state of the world and an "unboxed Maybe",
7335++ represented by an {\tt Int#} and a (possibly invalid) finalization
7336++ action. An {\tt Int#} of {\tt 1} indicates that the finalizer is valid. The
7337++ return value {\tt b} from the finalizer should be ignored. }
7338++ with
7339++ has_side_effects = True
7340++ out_of_line = True
7341++
7342++primop TouchOp "touch#" GenPrimOp
7343++ o -> State# RealWorld -> State# RealWorld
7344++ with
7345++ code_size = { 0 }
7346++ has_side_effects = True
7347++
7348++------------------------------------------------------------------------
7349++section "Stable pointers and names"
7350++------------------------------------------------------------------------
7351++
7352++primtype StablePtr# a
7353++
7354++primtype StableName# a
7355++
7356++primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
7357++ a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
7358++ with
7359++ has_side_effects = True
7360++ out_of_line = True
7361++
7362++primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
7363++ StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
7364++ with
7365++ has_side_effects = True
7366++ out_of_line = True
7367++
7368++primop EqStablePtrOp "eqStablePtr#" GenPrimOp
7369++ StablePtr# a -> StablePtr# a -> Int#
7370++ with
7371++ has_side_effects = True
7372++
7373++primop MakeStableNameOp "makeStableName#" GenPrimOp
7374++ a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
7375++ with
7376++ has_side_effects = True
7377++ out_of_line = True
7378++
7379++primop EqStableNameOp "eqStableName#" GenPrimOp
7380++ StableName# a -> StableName# b -> Int#
7381++
7382++primop StableNameToIntOp "stableNameToInt#" GenPrimOp
7383++ StableName# a -> Int#
7384++
7385++------------------------------------------------------------------------
7386++section "Compact normal form"
7387++------------------------------------------------------------------------
7388++
7389++primtype Compact#
7390++
7391++primop CompactNewOp "compactNew#" GenPrimOp
7392++ Word# -> State# RealWorld -> (# State# RealWorld, Compact# #)
7393++ { Create a new Compact with the given size (in bytes, not words).
7394++ The size is rounded up to a multiple of the allocator block size,
7395++ and capped to one mega block. }
7396++ with
7397++ has_side_effects = True
7398++ out_of_line = True
7399++
7400++primop CompactResizeOp "compactResize#" GenPrimOp
7401++ Compact# -> Word# -> State# RealWorld ->
7402++ State# RealWorld
7403++ { Set the new allocation size of the compact. This value (in bytes)
7404++ determines the size of each block in the compact chain. }
7405++ with
7406++ has_side_effects = True
7407++ out_of_line = True
7408++
7409++primop CompactContainsOp "compactContains#" GenPrimOp
7410++ Compact# -> a -> State# RealWorld -> (# State# RealWorld, Int# #)
7411++ { Returns 1# if the object is contained in the compact, 0# otherwise. }
7412++ with
7413++ out_of_line = True
7414++
7415++primop CompactContainsAnyOp "compactContainsAny#" GenPrimOp
7416++ a -> State# RealWorld -> (# State# RealWorld, Int# #)
7417++ { Returns 1# if the object is in any compact at all, 0# otherwise. }
7418++ with
7419++ out_of_line = True
7420++
7421++primop CompactGetFirstBlockOp "compactGetFirstBlock#" GenPrimOp
7422++ Compact# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)
7423++ { Returns the address and the size (in bytes) of the first block of
7424++ a compact. }
7425++ with
7426++ out_of_line = True
7427++
7428++primop CompactGetNextBlockOp "compactGetNextBlock#" GenPrimOp
7429++ Compact# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)
7430++ { Given a compact and the address of one its blocks, returns the
7431++ next block and its size, or #nullAddr if the argument was the
7432++ last block in the compact. }
7433++ with
7434++ out_of_line = True
7435++
7436++primop CompactAllocateBlockOp "compactAllocateBlock#" GenPrimOp
7437++ Word# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr# #)
7438++ { Attempt to allocate a compact block with the given size (in
7439++ bytes) at the given address. The first argument is a hint to
7440++ the allocator, allocation might be satisfied at a different
7441++ address (which is returned).
7442++ The resulting block is not known to the GC until
7443++ compactFixupPointers# is called on it, and care must be taken
7444++ so that the address does not escape or memory will be leaked.
7445++ }
7446++ with
7447++ has_side_effects = True
7448++ out_of_line = True
7449++
7450++primop CompactFixupPointersOp "compactFixupPointers#" GenPrimOp
7451++ Addr# -> Addr# -> State# RealWorld -> (# State# RealWorld, Compact#, Addr# #)
7452++ { Given the pointer to the first block of a compact, and the
7453++ address of the root object in the old address space, fix up
7454++ the internal pointers inside the compact to account for
7455++ a different position in memory than when it was serialized.
7456++ This method must be called exactly once after importing
7457++ a serialized compact, and returns the new compact and
7458++ the new adjusted root address. }
7459++ with
7460++ has_side_effects = True
7461++ out_of_line = True
7462++
7463++primop CompactAdd "compactAdd#" GenPrimOp
7464++ Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #)
7465++ { Recursively add a closure and its transitive closure to a
7466++ {\texttt Compact\#}, evaluating any unevaluated components at the
7467++ same time. Note: {\texttt compactAdd\#} is not thread-safe, so
7468++ only one thread may call {\texttt compactAdd\#} with a particular
7469++ {\texttt Compact#} at any given time. The primop does not
7470++ enforce any mutual exclusion; the caller is expected to
7471++ arrange this. }
7472++ with
7473++ has_side_effects = True
7474++ out_of_line = True
7475++
7476++primop CompactAddWithSharing "compactAddWithSharing#" GenPrimOp
7477++ Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #)
7478++ { Like {\texttt compactAdd\#}, but retains sharing and cycles
7479++ during compaction. }
7480++ with
7481++ has_side_effects = True
7482++ out_of_line = True
7483++
7484++primop CompactSize "compactSize#" GenPrimOp
7485++ Compact# -> State# RealWorld -> (# State# RealWorld, Word# #)
7486++ { Return the size (in bytes) of the total amount of data in the Compact# }
7487++ with
7488++ has_side_effects = True
7489++ out_of_line = True
7490++
7491++------------------------------------------------------------------------
7492++section "Unsafe pointer equality"
7493++-- (#1 Bad Guy: Alastair Reid :)
7494++------------------------------------------------------------------------
7495++
7496++primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
7497++ a -> a -> Int#
7498++ { Returns {\texttt 1\#} if the given pointers are equal and {\texttt 0\#} otherwise. }
7499++ with
7500++ can_fail = True -- See Note [reallyUnsafePtrEquality#]
7501++
7502++
7503++-- Note [reallyUnsafePtrEquality#]
7504++-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7505++--
7506++-- reallyUnsafePtrEquality# can't actually fail, per se, but we mark it can_fail
7507++-- anyway. Until 5a9a1738023a, GHC considered primops okay for speculation only
7508++-- when their arguments were known to be forced. This was unnecessarily
7509++-- conservative, but it prevented reallyUnsafePtrEquality# from floating out of
7510++-- places where its arguments were known to be forced. Unfortunately, GHC could
7511++-- sometimes lose track of whether those arguments were forced, leading to let/app
7512++-- invariant failures (see Trac 13027 and the discussion in Trac 11444). Now that
7513++-- ok_for_speculation skips over lifted arguments, we need to explicitly prevent
7514++-- reallyUnsafePtrEquality# from floating out. The reasons are closely related
7515++-- to those described in Note [dataToTag#], although the consequences are less
7516++-- severe. Imagine if we had
7517++--
7518++-- \x y . case x of x'
7519++-- DEFAULT ->
7520++-- case y of y'
7521++-- DEFAULT ->
7522++-- let eq = reallyUnsafePtrEquality# x' y'
7523++-- in ...
7524++--
7525++-- If the let floats out, we'll get
7526++--
7527++-- \x y . let eq = reallyUnsafePtrEquality# x y
7528++-- in case x of ...
7529++--
7530++-- The trouble is that pointer equality between thunks is very different
7531++-- from pointer equality between the values those thunks reduce to, and the latter
7532++-- is typically much more precise.
7533++
7534++------------------------------------------------------------------------
7535++section "Parallelism"
7536++------------------------------------------------------------------------
7537++
7538++primop ParOp "par#" GenPrimOp
7539++ a -> Int#
7540++ with
7541++ -- Note that Par is lazy to avoid that the sparked thing
7542++ -- gets evaluated strictly, which it should *not* be
7543++ has_side_effects = True
7544++ code_size = { primOpCodeSizeForeignCall }
7545++
7546++primop SparkOp "spark#" GenPrimOp
7547++ a -> State# s -> (# State# s, a #)
7548++ with has_side_effects = True
7549++ code_size = { primOpCodeSizeForeignCall }
7550++
7551++primop SeqOp "seq#" GenPrimOp
7552++ a -> State# s -> (# State# s, a #)
7553++ -- See Note [seq# magic] in PrelRules
7554++
7555++primop GetSparkOp "getSpark#" GenPrimOp
7556++ State# s -> (# State# s, Int#, a #)
7557++ with
7558++ has_side_effects = True
7559++ out_of_line = True
7560++
7561++primop NumSparks "numSparks#" GenPrimOp
7562++ State# s -> (# State# s, Int# #)
7563++ { Returns the number of sparks in the local spark pool. }
7564++ with
7565++ has_side_effects = True
7566++ out_of_line = True
7567++
7568++------------------------------------------------------------------------
7569++section "Tag to enum stuff"
7570++ {Convert back and forth between values of enumerated types
7571++ and small integers.}
7572++------------------------------------------------------------------------
7573++
7574++primop DataToTagOp "dataToTag#" GenPrimOp
7575++ a -> Int# -- Zero-indexed; the first constructor has tag zero
7576++ with
7577++ can_fail = True -- See Note [dataToTag#]
7578++ strictness = { \ _arity -> mkClosedStrictSig [evalDmd] topRes }
7579++ -- dataToTag# must have an evaluated argument
7580++
7581++primop TagToEnumOp "tagToEnum#" GenPrimOp
7582++ Int# -> a
7583++
7584++{- Note [dataToTag#]
7585++~~~~~~~~~~~~~~~~~~~~
7586++The dataToTag# primop should always be applied to an evaluated argument.
7587++The way to ensure this is to invoke it via the 'getTag' wrapper in GHC.Base:
7588++ getTag :: a -> Int#
7589++ getTag !x = dataToTag# x
7590++
7591++But now consider
7592++ \z. case x of y -> let v = dataToTag# y in ...
7593++
7594++To improve floating, the FloatOut pass (deliberately) does a
7595++binder-swap on the case, to give
7596++ \z. case x of y -> let v = dataToTag# x in ...
7597++
7598++Now FloatOut might float that v-binding outside the \z. But that is
7599++bad because that might mean x gest evaluated much too early! (CorePrep
7600++adds an eval to a dataToTag# call, to ensure that the argument really is
7601++evaluated; see CorePrep Note [dataToTag magic].)
7602++
7603++Solution: make DataToTag into a can_fail primop. That will stop it floating
7604++(see Note [PrimOp can_fail and has_side_effects] in PrimOp). It's a bit of
7605++a hack but never mind.
7606++-}
7607++
7608++------------------------------------------------------------------------
7609++section "Bytecode operations"
7610++ {Support for manipulating bytecode objects used by the interpreter and
7611++ linker.
7612++
7613++ Bytecode objects are heap objects which represent top-level bindings and
7614++ contain a list of instructions and data needed by these instructions.}
7615++------------------------------------------------------------------------
7616++
7617++primtype BCO#
7618++ { Primitive bytecode type. }
7619++
7620++primop AddrToAnyOp "addrToAny#" GenPrimOp
7621++ Addr# -> (# a #)
7622++ { Convert an {\tt Addr\#} to a followable Any type. }
7623++ with
7624++ code_size = 0
7625++
7626++primop AnyToAddrOp "anyToAddr#" GenPrimOp
7627++ a -> State# RealWorld -> (# State# RealWorld, Addr# #)
7628++ { Retrieve the address of any Haskell value. This is
7629++ essentially an {\texttt unsafeCoerce\#}, but if implemented as such
7630++ the core lint pass complains and fails to compile.
7631++ As a primop, it is opaque to core/stg, and only appears
7632++ in cmm (where the copy propagation pass will get rid of it).
7633++ Note that "a" must be a value, not a thunk! It's too late
7634++ for strictness analysis to enforce this, so you're on your
7635++ own to guarantee this. Also note that {\texttt Addr\#} is not a GC
7636++ pointer - up to you to guarantee that it does not become
7637++ a dangling pointer immediately after you get it.}
7638++ with
7639++ code_size = 0
7640++
7641++primop MkApUpd0_Op "mkApUpd0#" GenPrimOp
7642++ BCO# -> (# a #)
7643++ { Wrap a BCO in a {\tt AP_UPD} thunk which will be updated with the value of
7644++ the BCO when evaluated. }
7645++ with
7646++ out_of_line = True
7647++
7648++primop NewBCOOp "newBCO#" GenPrimOp
7649++ ByteArray# -> ByteArray# -> Array# a -> Int# -> ByteArray# -> State# s -> (# State# s, BCO# #)
7650++ { {\tt newBCO\# instrs lits ptrs arity bitmap} creates a new bytecode object. The
7651++ resulting object encodes a function of the given arity with the instructions
7652++ encoded in {\tt instrs}, and a static reference table usage bitmap given by
7653++ {\tt bitmap}. }
7654++ with
7655++ has_side_effects = True
7656++ out_of_line = True
7657++
7658++primop UnpackClosureOp "unpackClosure#" GenPrimOp
7659++ a -> (# Addr#, Array# b, ByteArray# #)
7660++ { {\tt unpackClosure\# closure} copies non-pointers and pointers in the
7661++ payload of the given closure into two new arrays, and returns a pointer to
7662++ the first word of the closure's info table, a pointer array for the
7663++ pointers in the payload, and a non-pointer array for the non-pointers in
7664++ the payload. }
7665++ with
7666++ out_of_line = True
7667++
7668++primop GetApStackValOp "getApStackVal#" GenPrimOp
7669++ a -> Int# -> (# Int#, b #)
7670++ with
7671++ out_of_line = True
7672++
7673++------------------------------------------------------------------------
7674++section "Misc"
7675++ {These aren't nearly as wired in as Etc...}
7676++------------------------------------------------------------------------
7677++
7678++primop GetCCSOfOp "getCCSOf#" GenPrimOp
7679++ a -> State# s -> (# State# s, Addr# #)
7680++
7681++primop GetCurrentCCSOp "getCurrentCCS#" GenPrimOp
7682++ a -> State# s -> (# State# s, Addr# #)
7683++ { Returns the current {\tt CostCentreStack} (value is {\tt NULL} if
7684++ not profiling). Takes a dummy argument which can be used to
7685++ avoid the call to {\tt getCurrentCCS\#} being floated out by the
7686++ simplifier, which would result in an uninformative stack
7687++ ("CAF"). }
7688++
7689++primop ClearCCSOp "clearCCS#" GenPrimOp
7690++ (State# s -> (# State# s, a #)) -> State# s -> (# State# s, a #)
7691++ { Run the supplied IO action with an empty CCS. For example, this
7692++ is used by the interpreter to run an interpreted computation
7693++ without the call stack showing that it was invoked from GHC. }
7694++ with
7695++ out_of_line = True
7696++
7697++------------------------------------------------------------------------
7698++section "Etc"
7699++ {Miscellaneous built-ins}
7700++------------------------------------------------------------------------
7701++
7702++primtype Proxy# a
7703++ { The type constructor {\tt Proxy#} is used to bear witness to some
7704++ type variable. It's used when you want to pass around proxy values
7705++ for doing things like modelling type applications. A {\tt Proxy#}
7706++ is not only unboxed, it also has a polymorphic kind, and has no
7707++ runtime representation, being totally free. }
7708++
7709++pseudoop "proxy#"
7710++ Proxy# a
7711++ { Witness for an unboxed {\tt Proxy#} value, which has no runtime
7712++ representation. }
7713++
7714++pseudoop "seq"
7715++ a -> b -> b
7716++ { The value of {\tt seq a b} is bottom if {\tt a} is bottom, and
7717++ otherwise equal to {\tt b}. In other words, it evaluates the first
7718++ argument {\tt a} to weak head normal form (WHNF). {\tt seq} is usually
7719++ introduced to improve performance by avoiding unneeded laziness.
7720++
7721++ A note on evaluation order: the expression {\tt seq a b} does
7722++ {\it not} guarantee that {\tt a} will be evaluated before {\tt b}.
7723++ The only guarantee given by {\tt seq} is that the both {\tt a}
7724++ and {\tt b} will be evaluated before {\tt seq} returns a value.
7725++ In particular, this means that {\tt b} may be evaluated before
7726++ {\tt a}. If you need to guarantee a specific order of evaluation,
7727++ you must use the function {\tt pseq} from the "parallel" package. }
7728++
7729++pseudoop "unsafeCoerce#"
7730++ a -> b
7731++ { The function {\tt unsafeCoerce\#} allows you to side-step the typechecker entirely. That
7732++ is, it allows you to coerce any type into any other type. If you use this function,
7733++ you had better get it right, otherwise segmentation faults await. It is generally
7734++ used when you want to write a program that you know is well-typed, but where Haskell's
7735++ type system is not expressive enough to prove that it is well typed.
7736++
7737++ The following uses of {\tt unsafeCoerce\#} are supposed to work (i.e. not lead to
7738++ spurious compile-time or run-time crashes):
7739++
7740++ * Casting any lifted type to {\tt Any}
7741++
7742++ * Casting {\tt Any} back to the real type
7743++
7744++ * Casting an unboxed type to another unboxed type of the same size.
7745++ (Casting between floating-point and integral types does not work.
7746++ See the {\tt GHC.Float} module for functions to do work.)
7747++
7748++ * Casting between two types that have the same runtime representation. One case is when
7749++ the two types differ only in "phantom" type parameters, for example
7750++ {\tt Ptr Int} to {\tt Ptr Float}, or {\tt [Int]} to {\tt [Float]} when the list is
7751++ known to be empty. Also, a {\tt newtype} of a type {\tt T} has the same representation
7752++ at runtime as {\tt T}.
7753++
7754++ Other uses of {\tt unsafeCoerce\#} are undefined. In particular, you should not use
7755++ {\tt unsafeCoerce\#} to cast a T to an algebraic data type D, unless T is also
7756++ an algebraic data type. For example, do not cast {\tt Int->Int} to {\tt Bool}, even if
7757++ you later cast that {\tt Bool} back to {\tt Int->Int} before applying it. The reasons
7758++ have to do with GHC's internal representation details (for the cognoscenti, data values
7759++ can be entered but function closures cannot). If you want a safe type to cast things
7760++ to, use {\tt Any}, which is not an algebraic data type.
7761++
7762++ }
7763++
7764++-- NB. It is tempting to think that casting a value to a type that it doesn't have is safe
7765++-- as long as you don't "do anything" with the value in its cast form, such as seq on it. This
7766++-- isn't the case: the compiler can insert seqs itself, and if these happen at the wrong type,
7767++-- Bad Things Might Happen. See bug #1616: in this case we cast a function of type (a,b) -> (a,b)
7768++-- to () -> () and back again. The strictness analyser saw that the function was strict, but
7769++-- the wrapper had type () -> (), and hence the wrapper de-constructed the (), the worker re-constructed
7770++-- a new (), with the result that the code ended up with "case () of (a,b) -> ...".
7771++
7772++primop TraceEventOp "traceEvent#" GenPrimOp
7773++ Addr# -> State# s -> State# s
7774++ { Emits an event via the RTS tracing framework. The contents
7775++ of the event is the zero-terminated byte string passed as the first
7776++ argument. The event will be emitted either to the .eventlog file,
7777++ or to stderr, depending on the runtime RTS flags. }
7778++ with
7779++ has_side_effects = True
7780++ out_of_line = True
7781++
7782++primop TraceMarkerOp "traceMarker#" GenPrimOp
7783++ Addr# -> State# s -> State# s
7784++ { Emits a marker event via the RTS tracing framework. The contents
7785++ of the event is the zero-terminated byte string passed as the first
7786++ argument. The event will be emitted either to the .eventlog file,
7787++ or to stderr, depending on the runtime RTS flags. }
7788++ with
7789++ has_side_effects = True
7790++ out_of_line = True
7791++
7792++------------------------------------------------------------------------
7793++section "Safe coercions"
7794++------------------------------------------------------------------------
7795++
7796++pseudoop "coerce"
7797++ Coercible a b => a -> b
7798++ { The function {\tt coerce} allows you to safely convert between values of
7799++ types that have the same representation with no run-time overhead. In the
7800++ simplest case you can use it instead of a newtype constructor, to go from
7801++ the newtype's concrete type to the abstract type. But it also works in
7802++ more complicated settings, e.g. converting a list of newtypes to a list of
7803++ concrete types.
7804++ }
7805++
7806++------------------------------------------------------------------------
7807++section "SIMD Vectors"
7808++ {Operations on SIMD vectors.}
7809++------------------------------------------------------------------------
7810++
7811++#define ALL_VECTOR_TYPES \
7812++ [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
7813++ ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
7814++ ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
7815++ ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,WORD32,4>,<Word64,WORD64,2> \
7816++ ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,WORD32,8>,<Word64,WORD64,4> \
7817++ ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,WORD32,16>,<Word64,WORD64,8> \
7818++ ,<Float,Float#,4>,<Double,Double#,2> \
7819++ ,<Float,Float#,8>,<Double,Double#,4> \
7820++ ,<Float,Float#,16>,<Double,Double#,8>]
7821++
7822++#define SIGNED_VECTOR_TYPES \
7823++ [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
7824++ ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
7825++ ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
7826++ ,<Float,Float#,4>,<Double,Double#,2> \
7827++ ,<Float,Float#,8>,<Double,Double#,4> \
7828++ ,<Float,Float#,16>,<Double,Double#,8>]
7829++
7830++#define FLOAT_VECTOR_TYPES \
7831++ [<Float,Float#,4>,<Double,Double#,2> \
7832++ ,<Float,Float#,8>,<Double,Double#,4> \
7833++ ,<Float,Float#,16>,<Double,Double#,8>]
7834++
7835++#define INT_VECTOR_TYPES \
7836++ [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
7837++ ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
7838++ ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
7839++ ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,WORD32,4>,<Word64,WORD64,2> \
7840++ ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,WORD32,8>,<Word64,WORD64,4> \
7841++ ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,WORD32,16>,<Word64,WORD64,8>]
7842++
7843++primtype VECTOR
7844++ with llvm_only = True
7845++ vector = ALL_VECTOR_TYPES
7846++
7847++primop VecBroadcastOp "broadcast#" GenPrimOp
7848++ SCALAR -> VECTOR
7849++ { Broadcast a scalar to all elements of a vector. }
7850++ with llvm_only = True
7851++ vector = ALL_VECTOR_TYPES
7852++
7853++primop VecPackOp "pack#" GenPrimOp
7854++ VECTUPLE -> VECTOR
7855++ { Pack the elements of an unboxed tuple into a vector. }
7856++ with llvm_only = True
7857++ vector = ALL_VECTOR_TYPES
7858++
7859++primop VecUnpackOp "unpack#" GenPrimOp
7860++ VECTOR -> VECTUPLE
7861++ { Unpack the elements of a vector into an unboxed tuple. #}
7862++ with llvm_only = True
7863++ vector = ALL_VECTOR_TYPES
7864++
7865++primop VecInsertOp "insert#" GenPrimOp
7866++ VECTOR -> SCALAR -> Int# -> VECTOR
7867++ { Insert a scalar at the given position in a vector. }
7868++ with can_fail = True
7869++ llvm_only = True
7870++ vector = ALL_VECTOR_TYPES
7871++
7872++primop VecAddOp "plus#" Dyadic
7873++ VECTOR -> VECTOR -> VECTOR
7874++ { Add two vectors element-wise. }
7875++ with commutable = True
7876++ llvm_only = True
7877++ vector = ALL_VECTOR_TYPES
7878++
7879++primop VecSubOp "minus#" Dyadic
7880++ VECTOR -> VECTOR -> VECTOR
7881++ { Subtract two vectors element-wise. }
7882++ with llvm_only = True
7883++ vector = ALL_VECTOR_TYPES
7884++
7885++primop VecMulOp "times#" Dyadic
7886++ VECTOR -> VECTOR -> VECTOR
7887++ { Multiply two vectors element-wise. }
7888++ with commutable = True
7889++ llvm_only = True
7890++ vector = ALL_VECTOR_TYPES
7891++
7892++primop VecDivOp "divide#" Dyadic
7893++ VECTOR -> VECTOR -> VECTOR
7894++ { Divide two vectors element-wise. }
7895++ with can_fail = True
7896++ llvm_only = True
7897++ vector = FLOAT_VECTOR_TYPES
7898++
7899++primop VecQuotOp "quot#" Dyadic
7900++ VECTOR -> VECTOR -> VECTOR
7901++ { Rounds towards zero element-wise. }
7902++ with can_fail = True
7903++ llvm_only = True
7904++ vector = INT_VECTOR_TYPES
7905++
7906++primop VecRemOp "rem#" Dyadic
7907++ VECTOR -> VECTOR -> VECTOR
7908++ { Satisfies \texttt{(quot\# x y) times\# y plus\# (rem\# x y) == x}. }
7909++ with can_fail = True
7910++ llvm_only = True
7911++ vector = INT_VECTOR_TYPES
7912++
7913++primop VecNegOp "negate#" Monadic
7914++ VECTOR -> VECTOR
7915++ { Negate element-wise. }
7916++ with llvm_only = True
7917++ vector = SIGNED_VECTOR_TYPES
7918++
7919++primop VecIndexByteArrayOp "indexArray#" GenPrimOp
7920++ ByteArray# -> Int# -> VECTOR
7921++ { Read a vector from specified index of immutable array. }
7922++ with can_fail = True
7923++ llvm_only = True
7924++ vector = ALL_VECTOR_TYPES
7925++
7926++primop VecReadByteArrayOp "readArray#" GenPrimOp
7927++ MutableByteArray# s -> Int# -> State# s -> (# State# s, VECTOR #)
7928++ { Read a vector from specified index of mutable array. }
7929++ with has_side_effects = True
7930++ can_fail = True
7931++ llvm_only = True
7932++ vector = ALL_VECTOR_TYPES
7933++
7934++primop VecWriteByteArrayOp "writeArray#" GenPrimOp
7935++ MutableByteArray# s -> Int# -> VECTOR -> State# s -> State# s
7936++ { Write a vector to specified index of mutable array. }
7937++ with has_side_effects = True
7938++ can_fail = True
7939++ llvm_only = True
7940++ vector = ALL_VECTOR_TYPES
7941++
7942++primop VecIndexOffAddrOp "indexOffAddr#" GenPrimOp
7943++ Addr# -> Int# -> VECTOR
7944++ { Reads vector; offset in bytes. }
7945++ with can_fail = True
7946++ llvm_only = True
7947++ vector = ALL_VECTOR_TYPES
7948++
7949++primop VecReadOffAddrOp "readOffAddr#" GenPrimOp
7950++ Addr# -> Int# -> State# s -> (# State# s, VECTOR #)
7951++ { Reads vector; offset in bytes. }
7952++ with has_side_effects = True
7953++ can_fail = True
7954++ llvm_only = True
7955++ vector = ALL_VECTOR_TYPES
7956++
7957++primop VecWriteOffAddrOp "writeOffAddr#" GenPrimOp
7958++ Addr# -> Int# -> VECTOR -> State# s -> State# s
7959++ { Write vector; offset in bytes. }
7960++ with has_side_effects = True
7961++ can_fail = True
7962++ llvm_only = True
7963++ vector = ALL_VECTOR_TYPES
7964++
7965++
7966++primop VecIndexScalarByteArrayOp "indexArrayAs#" GenPrimOp
7967++ ByteArray# -> Int# -> VECTOR
7968++ { Read a vector from specified index of immutable array of scalars; offset is in scalar elements. }
7969++ with can_fail = True
7970++ llvm_only = True
7971++ vector = ALL_VECTOR_TYPES
7972++
7973++primop VecReadScalarByteArrayOp "readArrayAs#" GenPrimOp
7974++ MutableByteArray# s -> Int# -> State# s -> (# State# s, VECTOR #)
7975++ { Read a vector from specified index of mutable array of scalars; offset is in scalar elements. }
7976++ with has_side_effects = True
7977++ can_fail = True
7978++ llvm_only = True
7979++ vector = ALL_VECTOR_TYPES
7980++
7981++primop VecWriteScalarByteArrayOp "writeArrayAs#" GenPrimOp
7982++ MutableByteArray# s -> Int# -> VECTOR -> State# s -> State# s
7983++ { Write a vector to specified index of mutable array of scalars; offset is in scalar elements. }
7984++ with has_side_effects = True
7985++ can_fail = True
7986++ llvm_only = True
7987++ vector = ALL_VECTOR_TYPES
7988++
7989++primop VecIndexScalarOffAddrOp "indexOffAddrAs#" GenPrimOp
7990++ Addr# -> Int# -> VECTOR
7991++ { Reads vector; offset in scalar elements. }
7992++ with can_fail = True
7993++ llvm_only = True
7994++ vector = ALL_VECTOR_TYPES
7995++
7996++primop VecReadScalarOffAddrOp "readOffAddrAs#" GenPrimOp
7997++ Addr# -> Int# -> State# s -> (# State# s, VECTOR #)
7998++ { Reads vector; offset in scalar elements. }
7999++ with has_side_effects = True
8000++ can_fail = True
8001++ llvm_only = True
8002++ vector = ALL_VECTOR_TYPES
8003++
8004++primop VecWriteScalarOffAddrOp "writeOffAddrAs#" GenPrimOp
8005++ Addr# -> Int# -> VECTOR -> State# s -> State# s
8006++ { Write vector; offset in scalar elements. }
8007++ with has_side_effects = True
8008++ can_fail = True
8009++ llvm_only = True
8010++ vector = ALL_VECTOR_TYPES
8011++
8012++------------------------------------------------------------------------
8013++
8014++section "Prefetch"
8015++ {Prefetch operations: Note how every prefetch operation has a name
8016++ with the pattern prefetch*N#, where N is either 0,1,2, or 3.
8017++
8018++ This suffix number, N, is the "locality level" of the prefetch, following the
8019++ convention in GCC and other compilers.
8020++ Higher locality numbers correspond to the memory being loaded in more
8021++ levels of the cpu cache, and being retained after initial use. The naming
8022++ convention follows the naming convention of the prefetch intrinsic found
8023++ in the GCC and Clang C compilers.
8024++
8025++ On the LLVM backend, prefetch*N# uses the LLVM prefetch intrinsic
8026++ with locality level N. The code generated by LLVM is target architecture
8027++ dependent, but should agree with the GHC NCG on x86 systems.
8028++
8029++ On the Sparc and PPC native backends, prefetch*N is a No-Op.
8030++
8031++ On the x86 NCG, N=0 will generate prefetchNTA,
8032++ N=1 generates prefetcht2, N=2 generates prefetcht1, and
8033++ N=3 generates prefetcht0.
8034++
8035++ For streaming workloads, the prefetch*0 operations are recommended.
8036++ For workloads which do many reads or writes to a memory location in a short period of time,
8037++ prefetch*3 operations are recommended.
8038++
8039++ For further reading about prefetch and associated systems performance optimization,
8040++ the instruction set and optimization manuals by Intel and other CPU vendors are
8041++ excellent starting place.
8042++
8043++
8044++ The "Intel 64 and IA-32 Architectures Optimization Reference Manual" is
8045++ especially a helpful read, even if your software is meant for other CPU
8046++ architectures or vendor hardware. The manual can be found at
8047++ http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-optimization-manual.html .
8048++
8049++ The {\tt prefetch*} family of operations has the order of operations
8050++ determined by passing around the {\tt State#} token.
8051++
8052++ To get a "pure" version of these operations, use {\tt inlinePerformIO} which is quite safe in this context.
8053++
8054++ It is important to note that while the prefetch operations will never change the
8055++ answer to a pure computation, They CAN change the memory locations resident
8056++ in a CPU cache and that may change the performance and timing characteristics
8057++ of an application. The prefetch operations are marked has_side_effects=True
8058++ to reflect that these operations have side effects with respect to the runtime
8059++ performance characteristics of the resulting code. Additionally, if the prefetchValue
8060++ operations did not have this attribute, GHC does a float out transformation that
8061++ results in a let/app violation, at least with the current design.
8062++ }
8063++
8064++
8065++
8066++------------------------------------------------------------------------
8067++
8068++
8069++--- the Int# argument for prefetch is the byte offset on the byteArray or Addr#
8070++
8071++---
8072++primop PrefetchByteArrayOp3 "prefetchByteArray3#" GenPrimOp
8073++ ByteArray# -> Int# -> State# s -> State# s
8074++ with has_side_effects = True
8075++
8076++primop PrefetchMutableByteArrayOp3 "prefetchMutableByteArray3#" GenPrimOp
8077++ MutableByteArray# s -> Int# -> State# s -> State# s
8078++ with has_side_effects = True
8079++
8080++primop PrefetchAddrOp3 "prefetchAddr3#" GenPrimOp
8081++ Addr# -> Int# -> State# s -> State# s
8082++ with has_side_effects = True
8083++
8084++primop PrefetchValueOp3 "prefetchValue3#" GenPrimOp
8085++ a -> State# s -> State# s
8086++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8087++ has_side_effects = True
8088++----
8089++
8090++primop PrefetchByteArrayOp2 "prefetchByteArray2#" GenPrimOp
8091++ ByteArray# -> Int# -> State# s -> State# s
8092++ with has_side_effects = True
8093++
8094++primop PrefetchMutableByteArrayOp2 "prefetchMutableByteArray2#" GenPrimOp
8095++ MutableByteArray# s -> Int# -> State# s -> State# s
8096++ with has_side_effects = True
8097++
8098++primop PrefetchAddrOp2 "prefetchAddr2#" GenPrimOp
8099++ Addr# -> Int# -> State# s -> State# s
8100++ with has_side_effects = True
8101++
8102++primop PrefetchValueOp2 "prefetchValue2#" GenPrimOp
8103++ a -> State# s -> State# s
8104++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8105++ has_side_effects = True
8106++----
8107++
8108++primop PrefetchByteArrayOp1 "prefetchByteArray1#" GenPrimOp
8109++ ByteArray# -> Int# -> State# s -> State# s
8110++ with has_side_effects = True
8111++
8112++primop PrefetchMutableByteArrayOp1 "prefetchMutableByteArray1#" GenPrimOp
8113++ MutableByteArray# s -> Int# -> State# s -> State# s
8114++ with has_side_effects = True
8115++
8116++primop PrefetchAddrOp1 "prefetchAddr1#" GenPrimOp
8117++ Addr# -> Int# -> State# s -> State# s
8118++ with has_side_effects = True
8119++
8120++primop PrefetchValueOp1 "prefetchValue1#" GenPrimOp
8121++ a -> State# s -> State# s
8122++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8123++ has_side_effects = True
8124++----
8125++
8126++primop PrefetchByteArrayOp0 "prefetchByteArray0#" GenPrimOp
8127++ ByteArray# -> Int# -> State# s -> State# s
8128++ with has_side_effects = True
8129++
8130++primop PrefetchMutableByteArrayOp0 "prefetchMutableByteArray0#" GenPrimOp
8131++ MutableByteArray# s -> Int# -> State# s -> State# s
8132++ with has_side_effects = True
8133++
8134++primop PrefetchAddrOp0 "prefetchAddr0#" GenPrimOp
8135++ Addr# -> Int# -> State# s -> State# s
8136++ with has_side_effects = True
8137++
8138++primop PrefetchValueOp0 "prefetchValue0#" GenPrimOp
8139++ a -> State# s -> State# s
8140++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8141++ has_side_effects = True
8142++
8143++------------------------------------------------------------------------
8144++--- ---
8145++------------------------------------------------------------------------
8146++
8147++thats_all_folks
8148+diff --git a/rts/build/HsVersions.h b/rts/build/HsVersions.h
8149+new file mode 100644
8150+index 0000000..a4ec3e4
8151+--- /dev/null
8152++++ b/rts/build/HsVersions.h
8153+@@ -0,0 +1,65 @@
8154++#pragma once
8155++
8156++#if 0
8157++
8158++IMPORTANT! If you put extra tabs/spaces in these macro definitions,
8159++you will screw up the layout where they are used in case expressions!
8160++
8161++(This is cpp-dependent, of course)
8162++
8163++#endif
8164++
8165++/* Useful in the headers that we share with the RTS */
8166++#define COMPILING_GHC 1
8167++
8168++/* Pull in all the platform defines for this build (foo_TARGET_ARCH etc.) */
8169++#include "ghc_boot_platform.h"
8170++
8171++/* Pull in the autoconf defines (HAVE_FOO), but don't include
8172++ * ghcconfig.h, because that will include ghcplatform.h which has the
8173++ * wrong platform settings for the compiler (it has the platform
8174++ * settings for the target plat instead). */
8175++#include "ghcautoconf.h"
8176++
8177++#define GLOBAL_VAR(name,value,ty) \
8178++{-# NOINLINE name #-}; \
8179++name :: IORef (ty); \
8180++name = Util.global (value);
8181++
8182++#define GLOBAL_VAR_M(name,value,ty) \
8183++{-# NOINLINE name #-}; \
8184++name :: IORef (ty); \
8185++name = Util.globalM (value);
8186++
8187++
8188++#define SHARED_GLOBAL_VAR(name,accessor,saccessor,value,ty) \
8189++{-# NOINLINE name #-}; \
8190++name :: IORef (ty); \
8191++name = Util.sharedGlobal (value) (accessor); \
8192++foreign import ccall unsafe saccessor \
8193++ accessor :: Ptr (IORef a) -> IO (Ptr (IORef a));
8194++
8195++#define SHARED_GLOBAL_VAR_M(name,accessor,saccessor,value,ty) \
8196++{-# NOINLINE name #-}; \
8197++name :: IORef (ty); \
8198++name = Util.sharedGlobalM (value) (accessor); \
8199++foreign import ccall unsafe saccessor \
8200++ accessor :: Ptr (IORef a) -> IO (Ptr (IORef a));
8201++
8202++
8203++#define ASSERT(e) if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else
8204++#define ASSERT2(e,msg) if debugIsOn && not (e) then (assertPprPanic __FILE__ __LINE__ (msg)) else
8205++#define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg)) $
8206++
8207++-- Examples: Assuming flagSet :: String -> m Bool
8208++--
8209++-- do { c <- getChar; MASSERT( isUpper c ); ... }
8210++-- do { c <- getChar; MASSERT2( isUpper c, text "Bad" ); ... }
8211++-- do { str <- getStr; ASSERTM( flagSet str ); .. }
8212++-- do { str <- getStr; ASSERTM2( flagSet str, text "Bad" ); .. }
8213++-- do { str <- getStr; WARNM2( flagSet str, text "Flag is set" ); .. }
8214++#define MASSERT(e) ASSERT(e) return ()
8215++#define MASSERT2(e,msg) ASSERT2(e,msg) return ()
8216++#define ASSERTM(e) do { bool <- e; MASSERT(bool) }
8217++#define ASSERTM2(e,msg) do { bool <- e; MASSERT2(bool,msg) }
8218++#define WARNM2(e,msg) do { bool <- e; WARN(bool, msg) return () }
8219+diff --git a/rts/ghc.mk b/rts/ghc.mk
8220+index 761cc43..457d394 100644
8221+--- a/rts/ghc.mk
8222++++ b/rts/ghc.mk
8223+@@ -34,6 +34,95 @@ rts_dist_WAYS = $(rts_WAYS)
8224+ ALL_RTS_LIBS = $(foreach way,$(rts_WAYS),rts/dist/build/libHSrts$($(way)_libsuf))
8225+ $(eval $(call all-target,rts,$(ALL_RTS_LIBS)))
8226+
8227++
8228++rts/build/config.hs-incl : mk/config.mk mk/project.mk | $$(dir $$@)/.
8229++ $(call removeFiles,$@)
8230++ @echo 'Creating $@ ... '
8231++ @echo 'data IntegerLibrary = IntegerGMP' >> $@
8232++ @echo ' | IntegerSimple' >> $@
8233++ @echo ' deriving Eq' >> $@
8234++ @echo >> $@
8235++ @echo 'cBuildPlatformString :: String' >> $@
8236++ @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@
8237++ @echo 'cHostPlatformString :: String' >> $@
8238++ @echo 'cHostPlatformString = HostPlatform_NAME' >> $@
8239++ @echo 'cTargetPlatformString :: String' >> $@
8240++ @echo 'cTargetPlatformString = TargetPlatform_NAME' >> $@
8241++ @echo >> $@
8242++ @echo 'cProjectName :: String' >> $@
8243++ @echo 'cProjectName = "$(ProjectName)"' >> $@
8244++ @echo 'cProjectGitCommitId :: String' >> $@
8245++ @echo 'cProjectGitCommitId = "$(ProjectGitCommitId)"' >> $@
8246++ @echo 'cProjectVersion :: String' >> $@
8247++ @echo 'cProjectVersion = "$(ProjectVersion)"' >> $@
8248++ @echo 'cProjectVersionInt :: String' >> $@
8249++ @echo 'cProjectVersionInt = "$(ProjectVersionInt)"' >> $@
8250++ @echo 'cProjectPatchLevel :: String' >> $@
8251++ @echo 'cProjectPatchLevel = "$(ProjectPatchLevel)"' >> $@
8252++ @echo 'cProjectPatchLevel1 :: String' >> $@
8253++ @echo 'cProjectPatchLevel1 = "$(ProjectPatchLevel1)"' >> $@
8254++ @echo 'cProjectPatchLevel2 :: String' >> $@
8255++ @echo 'cProjectPatchLevel2 = "$(ProjectPatchLevel2)"' >> $@
8256++ @echo 'cBooterVersion :: String' >> $@
8257++ @echo 'cBooterVersion = "$(GhcVersion)"' >> $@
8258++ @echo 'cStage :: String' >> $@
8259++ @echo 'cStage = show (STAGE :: Int)' >> $@
8260++ @echo 'cIntegerLibraryType :: IntegerLibrary' >> $@
8261++ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
8262++ @echo 'cIntegerLibraryType = IntegerGMP' >> $@
8263++else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
8264++ @echo 'cIntegerLibraryType = IntegerSimple' >> $@
8265++else ifneq "$(CLEANING)" "YES"
8266++$(error Unknown integer library)
8267++endif
8268++ @echo 'cSupportsSplitObjs :: String' >> $@
8269++ @echo 'cSupportsSplitObjs = "$(SupportsSplitObjs)"' >> $@
8270++ @echo 'cGhcWithInterpreter :: String' >> $@
8271++ @echo 'cGhcWithInterpreter = "$(GhcWithInterpreter)"' >> $@
8272++ @echo 'cGhcWithNativeCodeGen :: String' >> $@
8273++ @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"' >> $@
8274++ @echo 'cGhcWithSMP :: String' >> $@
8275++ @echo 'cGhcWithSMP = "$(GhcWithSMP)"' >> $@
8276++ @echo 'cGhcRTSWays :: String' >> $@
8277++ @echo 'cGhcRTSWays = "$(GhcRTSWays)"' >> $@
8278++ @echo 'cGhcRtsWithLibdw :: Bool' >> $@
8279++ifeq "$(GhcRtsWithLibdw)" "YES"
8280++ @echo 'cGhcRtsWithLibdw = True' >> $@
8281++else
8282++ @echo 'cGhcRtsWithLibdw = False' >> $@
8283++endif
8284++ @echo 'cGhcEnableTablesNextToCode :: String' >> $@
8285++ @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
8286++ @echo 'cLeadingUnderscore :: String' >> $@
8287++ @echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
8288++ @echo 'cGHC_UNLIT_PGM :: String' >> $@
8289++ @echo 'cGHC_UNLIT_PGM = "$(utils/unlit_dist_PROG)"' >> $@
8290++ @echo 'cGHC_SPLIT_PGM :: String' >> $@
8291++ @echo 'cGHC_SPLIT_PGM = "$(driver/split_dist_PROG)"' >> $@
8292++ @echo 'cLibFFI :: Bool' >> $@
8293++ifeq "$(UseLibFFIForAdjustors)" "YES"
8294++ @echo 'cLibFFI = True' >> $@
8295++else
8296++ @echo 'cLibFFI = False' >> $@
8297++endif
8298++# Note that GhcThreaded just reflects the Makefile variable setting.
8299++# In particular, the stage1 compiler is never actually compiled with
8300++# -threaded, but it will nevertheless have cGhcThreaded = True.
8301++# The "+RTS --info" output will show what RTS GHC is really using.
8302++ @echo 'cGhcThreaded :: Bool' >> $@
8303++ifeq "$(GhcThreaded)" "YES"
8304++ @echo 'cGhcThreaded = True' >> $@
8305++else
8306++ @echo 'cGhcThreaded = False' >> $@
8307++endif
8308++ @echo 'cGhcDebugged :: Bool' >> $@
8309++ifeq "$(GhcDebugged)" "YES"
8310++ @echo 'cGhcDebugged = True' >> $@
8311++else
8312++ @echo 'cGhcDebugged = False' >> $@
8313++endif
8314++ @echo done.
8315++
8316+ # -----------------------------------------------------------------------------
8317+ # Defining the sources
8318+
8319+diff --git a/rts/rts.cabal b/rts/rts.cabal
8320+index f8f1e2e..52c3a4f 100644
8321+--- a/rts/rts.cabal
8322++++ b/rts/rts.cabal
8323+@@ -7,7 +7,7 @@ build-type: Simple
8324+ flag libm
8325+ default: True
8326+ flag librt
8327+- default: True
8328++ default: False
8329+ flag libdl
8330+ default: True
8331+ flag ffi
8332+@@ -23,7 +23,7 @@ flag libdw
8333+ flag 64bit
8334+ default: False
8335+ flag leading-underscore
8336+- default: False
8337++ default: True
8338+
8339+ library
8340+ -- rts is a wired in package and
8341+@@ -80,6 +80,11 @@ library
8342+ ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h
8343+ -- ^ from ../includes
8344+ DerivedConstants.h ffi.h ffitarget.h
8345++ GHCConstantsHaskellType.hs GHCConstantsHaskellWrappers.hs
8346++ CodeGen.Platform.hs
8347++ platformConstants
8348++ config.hs-incl
8349++ HsVersions.h
8350+ -- ^ generated
8351+ rts/Adjustor.h
8352+ rts/BlockSignals.h
8353+diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in
8354+index 664a8f1..717a5a1 100644
8355+--- a/rts/rts.cabal.in
8356++++ b/rts/rts.cabal.in
8357+@@ -80,6 +80,11 @@ library
8358+ ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h
8359+ -- ^ from ../includes
8360+ DerivedConstants.h ffi.h ffitarget.h
8361++ GHCConstantsHaskellType.hs GHCConstantsHaskellWrappers.hs
8362++ CodeGen.Platform.hs
8363++ platformConstants
8364++ config.hs-incl
8365++ HsVersions.h
8366+ -- ^ generated
8367+ rts/Adjustor.h
8368+ rts/BlockSignals.h
8369+diff --git a/utils/genapply/Main.hs b/utils/genapply/Main.hs
8370+index b30c9f8..150c8c8 100644
8371+--- a/utils/genapply/Main.hs
8372++++ b/utils/genapply/Main.hs
8373+@@ -17,7 +17,7 @@ module Main(main) where
8374+ #include "../../includes/rts/Constants.h"
8375+
8376+ -- Needed for TAG_BITS
8377+-#include "../../includes/MachDeps.h"
8378++#include "MachDeps.h"
8379+
8380+ #if MIN_VERSION_base(4,11,0)
8381+ import Prelude hiding ((<>))
8382+diff --git a/utils/genprimopcode/Parser.hs b/utils/genprimopcode/Parser.hs
8383+index a4d2800..e9cbeaf 100644
8384+--- a/utils/genprimopcode/Parser.hs
8385++++ b/utils/genprimopcode/Parser.hs
8386+@@ -940,11 +940,9 @@ parse = run_parser parsex
8387+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8388+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8389+ {-# LINE 1 "<built-in>" #-}
8390+-{-# LINE 1 "<command-line>" #-}
8391+-{-# LINE 11 "<command-line>" #-}
8392+-# 1 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 1 3 4
8393++{-# LINE 18 "<built-in>" #-}
8394++{-# LINE 1 "/usr/local/Cellar/ghc/8.4.4/lib/ghc-8.4.4/include/ghcversion.h" #-}
8395+
8396+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
8397+
8398+
8399+
8400+@@ -960,6 +958,8 @@ parse = run_parser parsex
8401+
8402+
8403+
8404++{-# LINE 19 "<built-in>" #-}
8405++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
8406+
8407+
8408+
8409+@@ -991,8 +991,6 @@ parse = run_parser parsex
8410+
8411+
8412+
8413+-{-# LINE 11 "<command-line>" #-}
8414+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
8415+
8416+
8417+
8418+@@ -1008,8 +1006,6 @@ parse = run_parser parsex
8419+
8420+
8421+
8422+-{-# LINE 11 "<command-line>" #-}
8423+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
8424+
8425+
8426+
8427+@@ -1145,52 +1141,7 @@ parse = run_parser parsex
8428+
8429+
8430+
8431+-
8432+-
8433+-
8434+-
8435+-
8436+-
8437+-
8438+-
8439+-
8440+-
8441+-
8442+-
8443+-
8444+-
8445+-
8446+-
8447+-
8448+-
8449+-
8450+-
8451+-
8452+-
8453+-
8454+-
8455+-
8456+-
8457+-
8458+-
8459+-
8460+-
8461+-
8462+-
8463+-
8464+-
8465+-
8466+-
8467+-
8468+-
8469+-
8470+-
8471+-
8472+-
8473+-
8474+-
8475+-
8476+-{-# LINE 11 "<command-line>" #-}
8477++{-# LINE 20 "<built-in>" #-}
8478+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8479+ -- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
8480+
8481+@@ -1216,6 +1167,7 @@ parse = run_parser parsex
8482+ #define GTE(n,m) (n Happy_GHC_Exts.>=# m)
8483+ #define EQ(n,m) (n Happy_GHC_Exts.==# m)
8484+ #endif
8485++
8486+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
8487+
8488+ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
8489+@@ -1226,11 +1178,20 @@ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
8490+
8491+
8492+
8493++
8494+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
8495+
8496++
8497+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
8498+
8499+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
8500++
8501++
8502++
8503++
8504++
8505++
8506++
8507++
8508+
8509+ infixr 9 `HappyStk`
8510+ data HappyStk a = HappyStk a (HappyStk a)
8511+@@ -1258,7 +1219,7 @@ happyAccept j tk st sts (HappyStk ans _) =
8512+
8513+ happyDoAction i tk st
8514+ = {- nothing -}
8515+-
8516++
8517+
8518+ case action of
8519+ 0# -> {- nothing -}
8520+@@ -1266,11 +1227,11 @@ happyDoAction i tk st
8521+ -1# -> {- nothing -}
8522+ happyAccept i tk st
8523+ n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}
8524+-
8525++
8526+ (happyReduceArr Happy_Data_Array.! rule) i tk st
8527+ where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))
8528+ n -> {- nothing -}
8529+-
8530++
8531+
8532+ happyShift new_state i tk st
8533+ where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#))
8534+@@ -1316,6 +1277,7 @@ data HappyAddr = HappyA# Happy_GHC_Exts.Addr#
8535+ -----------------------------------------------------------------------------
8536+ -- HappyState data type (not arrays)
8537+
8538++
8539+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
8540+
8541+ -----------------------------------------------------------------------------
8542+@@ -1481,3 +1443,4 @@ happyDontSeq a b = b
8543+ {-# NOINLINE happyFail #-}
8544+
8545+ -- end of Happy Template.
8546++
8547+diff --git a/utils/hpc/HpcParser.hs b/utils/hpc/HpcParser.hs
8548+index 4160e75..58dc1b0 100644
8549+--- a/utils/hpc/HpcParser.hs
8550++++ b/utils/hpc/HpcParser.hs
8551+@@ -409,11 +409,9 @@ happyError e = error $ show (take 10 e)
8552+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8553+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8554+ {-# LINE 1 "<built-in>" #-}
8555+-{-# LINE 1 "<command-line>" #-}
8556+-{-# LINE 11 "<command-line>" #-}
8557+-# 1 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 1 3 4
8558++{-# LINE 18 "<built-in>" #-}
8559++{-# LINE 1 "/usr/local/Cellar/ghc/8.4.4/lib/ghc-8.4.4/include/ghcversion.h" #-}
8560+
8561+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
8562+
8563+
8564+
8565+@@ -429,6 +427,8 @@ happyError e = error $ show (take 10 e)
8566+
8567+
8568+
8569++{-# LINE 19 "<built-in>" #-}
8570++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
8571+
8572+
8573+
8574+@@ -460,8 +460,6 @@ happyError e = error $ show (take 10 e)
8575+
8576+
8577+
8578+-{-# LINE 11 "<command-line>" #-}
8579+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
8580+
8581+
8582+
8583+@@ -477,8 +475,6 @@ happyError e = error $ show (take 10 e)
8584+
8585+
8586+
8587+-{-# LINE 11 "<command-line>" #-}
8588+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
8589+
8590+
8591+
8592+@@ -614,52 +610,7 @@ happyError e = error $ show (take 10 e)
8593+
8594+
8595+
8596+-
8597+-
8598+-
8599+-
8600+-
8601+-
8602+-
8603+-
8604+-
8605+-
8606+-
8607+-
8608+-
8609+-
8610+-
8611+-
8612+-
8613+-
8614+-
8615+-
8616+-
8617+-
8618+-
8619+-
8620+-
8621+-
8622+-
8623+-
8624+-
8625+-
8626+-
8627+-
8628+-
8629+-
8630+-
8631+-
8632+-
8633+-
8634+-
8635+-
8636+-
8637+-
8638+-
8639+-
8640+-
8641+-{-# LINE 11 "<command-line>" #-}
8642++{-# LINE 20 "<built-in>" #-}
8643+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8644+ -- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
8645+
8646+@@ -685,6 +636,7 @@ happyError e = error $ show (take 10 e)
8647+ #define GTE(n,m) (n Happy_GHC_Exts.>=# m)
8648+ #define EQ(n,m) (n Happy_GHC_Exts.==# m)
8649+ #endif
8650++
8651+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
8652+
8653+ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
8654+@@ -695,11 +647,20 @@ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
8655+
8656+
8657+
8658++
8659+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
8660+
8661++
8662+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
8663+
8664+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
8665++
8666++
8667++
8668++
8669++
8670++
8671++
8672++
8673+
8674+ infixr 9 `HappyStk`
8675+ data HappyStk a = HappyStk a (HappyStk a)
8676+@@ -727,7 +688,7 @@ happyAccept j tk st sts (HappyStk ans _) =
8677+
8678+ happyDoAction i tk st
8679+ = {- nothing -}
8680+-
8681++
8682+
8683+ case action of
8684+ 0# -> {- nothing -}
8685+@@ -735,11 +696,11 @@ happyDoAction i tk st
8686+ -1# -> {- nothing -}
8687+ happyAccept i tk st
8688+ n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}
8689+-
8690++
8691+ (happyReduceArr Happy_Data_Array.! rule) i tk st
8692+ where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))
8693+ n -> {- nothing -}
8694+-
8695++
8696+
8697+ happyShift new_state i tk st
8698+ where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#))
8699+@@ -785,6 +746,7 @@ data HappyAddr = HappyA# Happy_GHC_Exts.Addr#
8700+ -----------------------------------------------------------------------------
8701+ -- HappyState data type (not arrays)
8702+
8703++
8704+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
8705+
8706+ -----------------------------------------------------------------------------
8707+@@ -950,3 +912,4 @@ happyDontSeq a b = b
8708+ {-# NOINLINE happyFail #-}
8709+
8710+ -- end of Happy Template.
8711++