@@ -0,0 +1,8711 @@
1+diff --git a/GIT_COMMIT_ID b/GIT_COMMIT_ID
2+index b28416b..d739f3b 100644
6+-3bed09b2efd3df678c5d0752d2cdfba20d7c4863
7+\ No newline at end of file
8++-n 39e711436400ecde05961224fa37759f2c2ff862
9+diff --git a/boot b/boot
10+index 7dc2983..7bf2196 100755
13+@@ -113,12 +113,13 @@ def boot_pkgs():
14+ elif len(cabals) == 1:
17+- if os.path.isfile(cabal):
18++ ghc_mk = os.path.join(package, 'ghc.mk')
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]
25+- ghc_mk = os.path.join(package, 'ghc.mk')
26+ print('Creating %s' % ghc_mk)
27+ with open(ghc_mk, 'w') as f:
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
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!
42+-(This is cpp-dependent, of course)
46+-/* Useful in the headers that we share with the RTS */
47+-#define COMPILING_GHC 1
49+-/* Pull in all the platform defines for this build (foo_TARGET_ARCH etc.) */
50+-#include "ghc_boot_platform.h"
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"
58+-#define GLOBAL_VAR(name,value,ty) \
59+-{-# NOINLINE name #-}; \
60+-name :: IORef (ty); \
61+-name = Util.global (value);
63+-#define GLOBAL_VAR_M(name,value,ty) \
64+-{-# NOINLINE name #-}; \
65+-name :: IORef (ty); \
66+-name = Util.globalM (value);
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));
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));
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)) $
88+--- Examples: Assuming flagSet :: String -> m Bool
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 (
107+ #include "HsVersions.h"
108+-#include "../includes/MachDeps.h"
109++#include "MachDeps.h"
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" #-}
127+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
131+@@ -3177,6 +3175,8 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
135++{-# LINE 19 "<built-in>" #-}
136++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
140+@@ -3208,8 +3208,6 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
144+-{-# LINE 11 "<command-line>" #-}
145+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
149+@@ -3225,8 +3223,6 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
153+-{-# LINE 11 "<command-line>" #-}
154+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
158+@@ -3362,52 +3358,7 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
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
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)
217+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
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
225+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
228+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
230+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
241+ data HappyStk a = HappyStk a (HappyStk a)
242+@@ -3475,7 +3436,7 @@ happyAccept j tk st sts (HappyStk ans _) =
244+ happyDoAction i tk st
251+@@ -3483,11 +3444,11 @@ happyDoAction i tk st
252+ -1# -> {- nothing -}
254+ n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}
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#))))))
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)
270+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
272+ -----------------------------------------------------------------------------
273+@@ -3698,3 +3660,4 @@ happyDontSeq a b = b
274+ {-# NOINLINE happyFail #-}
276+ -- end of Happy Template.
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
286+-#include "../includes/rts/storage/FunTypes.h"
287++#include "rts/storage/FunTypes.h"
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
299+-#include "../HsVersions.h"
300+-#include "../includes/MachDeps.h"
301++#include "HsVersions.h"
302++#include "MachDeps.h"
306+@@ -424,8 +424,8 @@ cardTableSizeW dflags elems =
307+ -----------------------------------------------------------------------------
308+ -- deriving the RTS closure type from an SMRep
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
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
323+ #define MACHREGS_NO_REGS 0
324+ #define MACHREGS_arm 1
325+-#include "../../../../includes/CodeGen.Platform.hs"
326++#include "CodeGen.Platform.hs"
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
334+ #define MACHREGS_NO_REGS 0
335+ #define MACHREGS_aarch64 1
336+-#include "../../../../includes/CodeGen.Platform.hs"
337++#include "CodeGen.Platform.hs"
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
346+ #define MACHREGS_NO_REGS 1
347+-#include "../../../../includes/CodeGen.Platform.hs"
348++#include "CodeGen.Platform.hs"
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
356+ #define MACHREGS_NO_REGS 0
357+ #define MACHREGS_powerpc 1
358+-#include "../../../../includes/CodeGen.Platform.hs"
359++#include "CodeGen.Platform.hs"
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"
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
378+ #define MACHREGS_NO_REGS 0
379+ #define MACHREGS_sparc 1
380+-#include "../../../../includes/CodeGen.Platform.hs"
381++#include "CodeGen.Platform.hs"
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
389+ #define MACHREGS_NO_REGS 0
390+ #define MACHREGS_i386 1
391+-#include "../../../../includes/CodeGen.Platform.hs"
392++#include "CodeGen.Platform.hs"
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
400+ #define MACHREGS_NO_REGS 0
401+ #define MACHREGS_x86_64 1
402+-#include "../../../../includes/CodeGen.Platform.hs"
403++#include "CodeGen.Platform.hs"
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,
413+-#include "../includes/MachDeps.h"
414++#include "MachDeps.h"
416+ #include "HsVersions.h"
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+ -------------------------------------------------------------------------
425+ -- bring in ARG_P, ARG_N, etc.
426+-#include "../includes/rts/storage/FunTypes.h"
427++#include "rts/storage/FunTypes.h"
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
437+ Cabal-Version: >=1.10
446+ Description: Build GHCi support.
451++ Description: Build GHC with terminfo support on non-Windows platforms.
456+- Description: Is this stage 1?
457++ Description: Build Stage1 GHC (STAGE=1)
462+- Description: Is this stage 2?
464++ Description: Build Stage1 GHC (STAGE=2)
469+- Description: Is this stage 3?
470++ Description: Build Stage1 GHC (STAGE=3)
475+- Description: Build GHC with terminfo support on non-Windows platforms.
480+ Default-Language: Haskell2010
482+@@ -66,6 +72,9 @@ Library
483+ ghc-boot-th == @ProjectVersionMunged@,
484+ ghci == @ProjectVersionMunged@
486++ build-tool-depends: alex:alex,
490+ Build-Depends: Win32 >= 2.3 && < 2.7
492+@@ -79,6 +88,15 @@ Library
493+ -Wnoncanonical-monadfail-instances
494+ -Wnoncanonical-monoid-instances
497++ ghc-options: -DSTAGE=1
500++ ghc-options: -DSTAGE=2
503++ ghc-options: -DSTAGE=3
507+ Include-Dirs: ../rts/dist/build @FFIIncludeDir@
508+@@ -118,17 +136,6 @@ Library
510+ GHC-Options: -this-unit-id ghc
513+- Include-Dirs: stage1
516+- Include-Dirs: stage2
519+- Include-Dirs: stage2
521+- Install-Includes: HsVersions.h, ghc_boot_platform.h
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
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
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)
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' >> $@
551+- @echo 'import GhcPrelude' >> $@
553+- @echo '#include "ghc_boot_platform.h"' >> $@
555+- @echo 'data IntegerLibrary = IntegerGMP' >> $@
556+- @echo ' | IntegerSimple' >> $@
557+- @echo ' deriving Eq' >> $@
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' >> $@
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)
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' >> $@
608+- @echo 'cGhcRtsWithLibdw = False' >> $@
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' >> $@
622+- @echo 'cLibFFI = False' >> $@
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' >> $@
632+- @echo 'cGhcThreaded = False' >> $@
634+- @echo 'cGhcDebugged :: Bool' >> $@
635+-ifeq "$(GhcDebugged)" "YES"
636+- @echo 'cGhcDebugged = True' >> $@
638+- @echo 'cGhcDebugged = False' >> $@
642+-# -----------------------------------------------------------------------------
643+-# Create platform includes
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.
650+-PLATFORM_H = ghc_boot_platform.h
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__" >> $@
658+- @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
659+- @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
660+- @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
662+- @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
663+- @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
664+- @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
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)\"" >> $@
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)\"" >> $@
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)\"" >> $@
688+- @echo "#endif /* __PLATFORM_H__ */" >> $@
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__" >> $@
700+- @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
701+- @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
702+- @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
704+- @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
705+- @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
706+- @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
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)\"" >> $@
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)\"" >> $@
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)\"" >> $@
730+- @echo "#endif /* __PLATFORM_H__ */" >> $@
733+-compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
736+-# ----------------------------------------------------------------------------
737+-# Generate supporting stuff for prelude/PrimOp.hs
738+-# from prelude/primops.txt
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
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))
760+-compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
761+-compiler_CPP_OPTS += ${GhcCppOpts}
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))
768+-define preprocessCompilerFiles
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' > $$@
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 < $$< > $$@
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 < $$< > $$@
811+-$(eval $(call preprocessCompilerFiles,1))
812+-$(eval $(call preprocessCompilerFiles,2))
813+-$(eval $(call preprocessCompilerFiles,3))
815+ # -----------------------------------------------------------------------------
818+@@ -369,19 +97,6 @@ ifeq "$(WITH_TERMINFO)" "NO"
819+ compiler_stage2_CONFIGURE_OPTS += --flags=-terminfo
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
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
840+ compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
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
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))
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)
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)
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
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
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)
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
884+ ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
885+ compiler/utils/Util_HC_OPTS += -DDYNAMIC_GHC_PROGRAMS
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 (
894+ #include "HsVersions.h"
895+-#include "../includes/MachDeps.h"
896++#include "MachDeps.h"
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
908+-#include "../includes/rts/storage/ClosureTypes.h"
909++#include "rts/storage/ClosureTypes.h"
911+ aP_CODE, pAP_CODE :: Int
913+diff --git a/compiler/main/Config.hs b/compiler/main/Config.hs
915+index 0000000..f944f7a
917++++ b/compiler/main/Config.hs
919++{-# LANGUAGE CPP #-}
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
933+ #include "HsVersions.h"
934+ #include "nativeGen/NCG.h"
935+-#include "../includes/MachDeps.h"
936++#include "MachDeps.h"
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
946+ #include "HsVersions.h"
947+ #include "nativeGen/NCG.h"
948+-#include "../includes/MachDeps.h"
949++#include "MachDeps.h"
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
959+ #include "HsVersions.h"
960+ #include "nativeGen/NCG.h"
961+-#include "../includes/MachDeps.h"
962++#include "MachDeps.h"
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
971+ #if __GLASGOW_HASKELL__ >= 710
972+ {-# OPTIONS_GHC -XPartialTypeSignatures #-}
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 #-}
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
996+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
1026++{-# LINE 18 "<built-in>" #-}
1027++{-# LINE 1 "/usr/local/Cellar/ghc/8.4.4/lib/ghc-8.4.4/include/ghcversion.h" #-}
1031+@@ -12134,9 +12113,9 @@ sst = setSourceText
1035++{-# LINE 19 "<built-in>" #-}
1036++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
1038+-{-# LINE 11 "<command-line>" #-}
1039+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
1043+@@ -12152,8 +12131,6 @@ sst = setSourceText
1047+-{-# LINE 11 "<command-line>" #-}
1048+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
1052+@@ -12319,22 +12296,7 @@ sst = setSourceText
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
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)
1081+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
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
1089+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
1092+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
1094+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
1104+ infixr 9 `HappyStk`
1105+ data HappyStk a = HappyStk a (HappyStk a)
1106+@@ -12402,7 +12374,7 @@ happyAccept j tk st sts (HappyStk ans _) =
1108+ happyDoAction i tk st
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 -}
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#))))))
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)
1134+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
1136+ -----------------------------------------------------------------------------
1137+@@ -12625,3 +12598,4 @@ happyDontSeq a b = b
1138+ {-# NOINLINE happyFail #-}
1140+ -- end of Happy Template.
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
1147+ -- ---------------------------------------------------------------------------
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 #-}
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
1171+ #include "HsVersions.h"
1172+-#include "../includes/MachDeps.h"
1173++#include "MachDeps.h"
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
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 #-}
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
1199+------------------------------------------------------------------------
1201+--- (c) 2010 The University of Glasgow
1203+--- Primitive Operations and Types
1205+--- For more information on PrimOps, see
1206+--- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
1208+------------------------------------------------------------------------
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.
1214+--- It should first be preprocessed.
1216+--- Information on how PrimOps are implemented and the steps necessary to
1217+--- add a new one can be found in the Commentary:
1219+--- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
1221+--- This file is divided into named sections, each containing or more
1222+--- primop entries. Section headers have the format:
1224+--- section "section-name" {description}
1226+--- This information is used solely when producing documentation; it is
1227+--- otherwise ignored. The description is optional.
1229+--- The format of each primop entry is as follows:
1231+--- primop internal-name "name-in-program-text" type category {description} attributes
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.
1240+--- type refers to the general category of the primop. Valid settings include,
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
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
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
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 }
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.
1279+-#include "MachDeps.h"
1281+--- We need platform defines (tests for mingw32 below).
1282+-#include "ghc_boot_platform.h"
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.
1297+- GHC also implements a primitive unsigned integer type {\tt
1298+- Word\#} which always has the same number of bits as {\tt
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
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.
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. }
1341+--- Define synonyms for indexing ops.
1343+-#if WORD_SIZE_IN_BITS < 32
1344+-#define INT32 Int32#
1345+-#define WORD32 Word32#
1348+-#define WORD32 Word#
1351+-#if WORD_SIZE_IN_BITS < 64
1352+-#define INT64 Int64#
1353+-#define WORD64 Word64#
1356+-#define WORD64 Word#
1359+-------------------------------------------------------------------------
1361+- {Operations on 31-bit characters.}
1362+-------------------------------------------------------------------------
1366+-primop CharGtOp "gtChar#" Compare Char# -> Char# -> Int#
1367+-primop CharGeOp "geChar#" Compare Char# -> Char# -> Int#
1369+-primop CharEqOp "eqChar#" Compare
1370+- Char# -> Char# -> Int#
1371+- with commutable = True
1373+-primop CharNeOp "neChar#" Compare
1374+- Char# -> Char# -> Int#
1375+- with commutable = True
1377+-primop CharLtOp "ltChar#" Compare Char# -> Char# -> Int#
1378+-primop CharLeOp "leChar#" Compare Char# -> Char# -> Int#
1380+-primop OrdOp "ord#" GenPrimOp Char# -> Int#
1381+- with code_size = 0
1383+-------------------------------------------------------------------------
1385+- {Operations on native-size integers (30+ bits).}
1386+-------------------------------------------------------------------------
1390+-primop IntAddOp "+#" Dyadic
1391+- Int# -> Int# -> Int#
1392+- with commutable = True
1395+-primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
1396+- with fixity = infixl 6
1398+-primop IntMulOp "*#"
1399+- Dyadic Int# -> Int# -> Int#
1400+- {Low word of signed integer multiply.}
1401+- with commutable = True
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.
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
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.
1426+- with commutable = True
1428+-primop IntQuotOp "quotInt#" Dyadic
1429+- Int# -> Int# -> Int#
1430+- {Rounds towards zero. The behavior is undefined if the second argument is
1433+- with can_fail = True
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.
1440+- with can_fail = True
1442+-primop IntQuotRemOp "quotRemInt#" GenPrimOp
1443+- Int# -> Int# -> (# Int#, Int# #)
1444+- {Rounds towards zero.}
1445+- with can_fail = True
1447+-primop AndIOp "andI#" Dyadic Int# -> Int# -> Int#
1448+- with commutable = True
1450+-primop OrIOp "orI#" Dyadic Int# -> Int# -> Int#
1451+- with commutable = True
1453+-primop XorIOp "xorI#" Dyadic Int# -> Int# -> Int#
1454+- with commutable = True
1456+-primop NotIOp "notI#" Monadic Int# -> Int#
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
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
1475+-primop IntGtOp ">#" Compare Int# -> Int# -> Int#
1476+- with fixity = infix 4
1478+-primop IntGeOp ">=#" Compare Int# -> Int# -> Int#
1479+- with fixity = infix 4
1481+-primop IntEqOp "==#" Compare
1482+- Int# -> Int# -> Int#
1483+- with commutable = True
1486+-primop IntNeOp "/=#" Compare
1487+- Int# -> Int# -> Int#
1488+- with commutable = True
1491+-primop IntLtOp "<#" Compare Int# -> Int# -> Int#
1492+- with fixity = infix 4
1494+-primop IntLeOp "<=#" Compare Int# -> Int# -> Int#
1495+- with fixity = infix 4
1497+-primop ChrOp "chr#" GenPrimOp Int# -> Char#
1498+- with code_size = 0
1500+-primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
1501+- with code_size = 0
1503+-primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
1504+-primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
1506+-primop Word2FloatOp "word2Float#" GenPrimOp Word# -> Float#
1507+-primop Word2DoubleOp "word2Double#" GenPrimOp Word# -> Double#
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.}
1519+-------------------------------------------------------------------------
1521+- {Operations on native-sized unsigned words (30+ bits).}
1522+-------------------------------------------------------------------------
1526+-primop WordAddOp "plusWord#" Dyadic Word# -> Word# -> Word#
1527+- with commutable = True
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.}
1534+--- Returns (# high, low #) (or equivalently, (# carry, low #))
1535+-primop WordAdd2Op "plusWord2#" GenPrimOp
1536+- Word# -> Word# -> (# Word#, Word# #)
1537+- with commutable = True
1539+-primop WordSubOp "minusWord#" Dyadic Word# -> Word# -> Word#
1541+-primop WordMulOp "timesWord#" Dyadic Word# -> Word# -> Word#
1542+- with commutable = True
1544+--- Returns (# high, low #)
1545+-primop WordMul2Op "timesWord2#" GenPrimOp
1546+- Word# -> Word# -> (# Word#, Word# #)
1547+- with commutable = True
1549+-primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word#
1550+- with can_fail = True
1552+-primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word#
1553+- with can_fail = True
1555+-primop WordQuotRemOp "quotRemWord#" GenPrimOp
1556+- Word# -> Word# -> (# Word#, Word# #)
1557+- with can_fail = True
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
1565+-primop AndOp "and#" Dyadic Word# -> Word# -> Word#
1566+- with commutable = True
1568+-primop OrOp "or#" Dyadic Word# -> Word# -> Word#
1569+- with commutable = True
1571+-primop XorOp "xor#" Dyadic Word# -> Word# -> Word#
1572+- with commutable = True
1574+-primop NotOp "not#" Monadic Word# -> Word#
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.}
1583+-primop Word2IntOp "word2Int#" GenPrimOp Word# -> Int#
1584+- with code_size = 0
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#
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.}
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.}
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.}
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.}
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.}
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.}
1657+-------------------------------------------------------------------------
1658+-section "Narrowings"
1659+- {Explicit narrowing of native-sized ints or words.}
1660+-------------------------------------------------------------------------
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#
1670+-#if WORD_SIZE_IN_BITS < 32
1671+-------------------------------------------------------------------------
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+-------------------------------------------------------------------------
1680+-------------------------------------------------------------------------
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+-------------------------------------------------------------------------
1692+-#if WORD_SIZE_IN_BITS < 64
1693+-------------------------------------------------------------------------
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+-------------------------------------------------------------------------
1702+-------------------------------------------------------------------------
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+-------------------------------------------------------------------------
1713+-------------------------------------------------------------------------
1715+- {Operations on double-precision (64 bit) floating-point numbers.}
1716+-------------------------------------------------------------------------
1720+-primop DoubleGtOp ">##" Compare Double# -> Double# -> Int#
1721+- with fixity = infix 4
1723+-primop DoubleGeOp ">=##" Compare Double# -> Double# -> Int#
1724+- with fixity = infix 4
1726+-primop DoubleEqOp "==##" Compare
1727+- Double# -> Double# -> Int#
1728+- with commutable = True
1731+-primop DoubleNeOp "/=##" Compare
1732+- Double# -> Double# -> Int#
1733+- with commutable = True
1736+-primop DoubleLtOp "<##" Compare Double# -> Double# -> Int#
1737+- with fixity = infix 4
1739+-primop DoubleLeOp "<=##" Compare Double# -> Double# -> Int#
1740+- with fixity = infix 4
1742+-primop DoubleAddOp "+##" Dyadic
1743+- Double# -> Double# -> Double#
1744+- with commutable = True
1747+-primop DoubleSubOp "-##" Dyadic Double# -> Double# -> Double#
1748+- with fixity = infixl 6
1750+-primop DoubleMulOp "*##" Dyadic
1751+- Double# -> Double# -> Double#
1752+- with commutable = True
1755+-primop DoubleDivOp "/##" Dyadic
1756+- Double# -> Double# -> Double#
1757+- with can_fail = True
1760+-primop DoubleNegOp "negateDouble#" Monadic Double# -> Double#
1762+-primop DoubleFabsOp "fabsDouble#" Monadic Double# -> Double#
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#}.}
1769+-primop Double2FloatOp "double2Float#" GenPrimOp Double# -> Float#
1771+-primop DoubleExpOp "expDouble#" Monadic
1772+- Double# -> Double#
1774+- code_size = { primOpCodeSizeForeignCall }
1776+-primop DoubleLogOp "logDouble#" Monadic
1777+- Double# -> Double#
1779+- code_size = { primOpCodeSizeForeignCall }
1782+-primop DoubleSqrtOp "sqrtDouble#" Monadic
1783+- Double# -> Double#
1785+- code_size = { primOpCodeSizeForeignCall }
1787+-primop DoubleSinOp "sinDouble#" Monadic
1788+- Double# -> Double#
1790+- code_size = { primOpCodeSizeForeignCall }
1792+-primop DoubleCosOp "cosDouble#" Monadic
1793+- Double# -> Double#
1795+- code_size = { primOpCodeSizeForeignCall }
1797+-primop DoubleTanOp "tanDouble#" Monadic
1798+- Double# -> Double#
1800+- code_size = { primOpCodeSizeForeignCall }
1802+-primop DoubleAsinOp "asinDouble#" Monadic
1803+- Double# -> Double#
1805+- code_size = { primOpCodeSizeForeignCall }
1808+-primop DoubleAcosOp "acosDouble#" Monadic
1809+- Double# -> Double#
1811+- code_size = { primOpCodeSizeForeignCall }
1814+-primop DoubleAtanOp "atanDouble#" Monadic
1815+- Double# -> Double#
1817+- code_size = { primOpCodeSizeForeignCall }
1819+-primop DoubleSinhOp "sinhDouble#" Monadic
1820+- Double# -> Double#
1822+- code_size = { primOpCodeSizeForeignCall }
1824+-primop DoubleCoshOp "coshDouble#" Monadic
1825+- Double# -> Double#
1827+- code_size = { primOpCodeSizeForeignCall }
1829+-primop DoubleTanhOp "tanhDouble#" Monadic
1830+- Double# -> Double#
1832+- code_size = { primOpCodeSizeForeignCall }
1834+-primop DoublePowerOp "**##" Dyadic
1835+- Double# -> Double# -> Double#
1838+- code_size = { primOpCodeSizeForeignCall }
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
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
1853+-------------------------------------------------------------------------
1855+- {Operations on single-precision (32-bit) floating-point numbers.}
1856+-------------------------------------------------------------------------
1860+-primop FloatGtOp "gtFloat#" Compare Float# -> Float# -> Int#
1861+-primop FloatGeOp "geFloat#" Compare Float# -> Float# -> Int#
1863+-primop FloatEqOp "eqFloat#" Compare
1864+- Float# -> Float# -> Int#
1865+- with commutable = True
1867+-primop FloatNeOp "neFloat#" Compare
1868+- Float# -> Float# -> Int#
1869+- with commutable = True
1871+-primop FloatLtOp "ltFloat#" Compare Float# -> Float# -> Int#
1872+-primop FloatLeOp "leFloat#" Compare Float# -> Float# -> Int#
1874+-primop FloatAddOp "plusFloat#" Dyadic
1875+- Float# -> Float# -> Float#
1876+- with commutable = True
1878+-primop FloatSubOp "minusFloat#" Dyadic Float# -> Float# -> Float#
1880+-primop FloatMulOp "timesFloat#" Dyadic
1881+- Float# -> Float# -> Float#
1882+- with commutable = True
1884+-primop FloatDivOp "divideFloat#" Dyadic
1885+- Float# -> Float# -> Float#
1886+- with can_fail = True
1888+-primop FloatNegOp "negateFloat#" Monadic Float# -> Float#
1890+-primop FloatFabsOp "fabsFloat#" Monadic Float# -> Float#
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#}.}
1897+-primop FloatExpOp "expFloat#" Monadic
1900+- code_size = { primOpCodeSizeForeignCall }
1902+-primop FloatLogOp "logFloat#" Monadic
1905+- code_size = { primOpCodeSizeForeignCall }
1908+-primop FloatSqrtOp "sqrtFloat#" Monadic
1911+- code_size = { primOpCodeSizeForeignCall }
1913+-primop FloatSinOp "sinFloat#" Monadic
1916+- code_size = { primOpCodeSizeForeignCall }
1918+-primop FloatCosOp "cosFloat#" Monadic
1921+- code_size = { primOpCodeSizeForeignCall }
1923+-primop FloatTanOp "tanFloat#" Monadic
1926+- code_size = { primOpCodeSizeForeignCall }
1928+-primop FloatAsinOp "asinFloat#" Monadic
1931+- code_size = { primOpCodeSizeForeignCall }
1934+-primop FloatAcosOp "acosFloat#" Monadic
1937+- code_size = { primOpCodeSizeForeignCall }
1940+-primop FloatAtanOp "atanFloat#" Monadic
1943+- code_size = { primOpCodeSizeForeignCall }
1945+-primop FloatSinhOp "sinhFloat#" Monadic
1948+- code_size = { primOpCodeSizeForeignCall }
1950+-primop FloatCoshOp "coshFloat#" Monadic
1953+- code_size = { primOpCodeSizeForeignCall }
1955+-primop FloatTanhOp "tanhFloat#" Monadic
1958+- code_size = { primOpCodeSizeForeignCall }
1960+-primop FloatPowerOp "powerFloat#" Dyadic
1961+- Float# -> Float# -> Float#
1963+- code_size = { primOpCodeSizeForeignCall }
1965+-primop Float2DoubleOp "float2Double#" GenPrimOp Float# -> Double#
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
1973+-------------------------------------------------------------------------
1975+- {Operations on {\tt Array\#}.}
1976+-------------------------------------------------------------------------
1980+-primtype MutableArray# s a
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.}
1988+- out_of_line = True
1989+- has_side_effects = True
1991+-primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
1992+- MutableArray# s a -> MutableArray# s a -> Int#
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.}
1998+- has_side_effects = True
2001+-primop WriteArrayOp "writeArray#" GenPrimOp
2002+- MutableArray# s a -> Int# -> a -> State# s -> State# s
2003+- {Write to specified index of mutable array.}
2005+- has_side_effects = True
2007+- code_size = 2 -- card update too
2009+-primop SizeofArrayOp "sizeofArray#" GenPrimOp
2011+- {Return the number of elements in the array.}
2013+-primop SizeofMutableArrayOp "sizeofMutableArray#" GenPrimOp
2014+- MutableArray# s a -> Int#
2015+- {Return the number of elements in the array.}
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.}
2024+-primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
2025+- MutableArray# s a -> State# s -> (# State# s, Array# a #)
2026+- {Make a mutable array immutable, without copying.}
2028+- has_side_effects = True
2030+-primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
2031+- Array# a -> State# s -> (# State# s, MutableArray# s a #)
2032+- {Make an immutable array mutable, without copying.}
2034+- out_of_line = True
2035+- has_side_effects = True
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
2047+- out_of_line = True
2048+- has_side_effects = True
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.}
2061+- out_of_line = True
2062+- has_side_effects = True
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.}
2072+- out_of_line = True
2073+- has_side_effects = True
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.}
2083+- out_of_line = True
2084+- has_side_effects = True
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.}
2094+- out_of_line = True
2095+- has_side_effects = True
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.}
2105+- out_of_line = True
2106+- has_side_effects = True
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.}
2113+- out_of_line = True
2114+- has_side_effects = True
2117+-------------------------------------------------------------------------
2118+-section "Small Arrays"
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\#}.
2138+-------------------------------------------------------------------------
2140+-primtype SmallArray# a
2142+-primtype SmallMutableArray# s a
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.}
2150+- out_of_line = True
2151+- has_side_effects = True
2153+-primop SameSmallMutableArrayOp "sameSmallMutableArray#" GenPrimOp
2154+- SmallMutableArray# s a -> SmallMutableArray# s a -> Int#
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.}
2160+- has_side_effects = True
2163+-primop WriteSmallArrayOp "writeSmallArray#" GenPrimOp
2164+- SmallMutableArray# s a -> Int# -> a -> State# s -> State# s
2165+- {Write to specified index of mutable array.}
2167+- has_side_effects = True
2170+-primop SizeofSmallArrayOp "sizeofSmallArray#" GenPrimOp
2171+- SmallArray# a -> Int#
2172+- {Return the number of elements in the array.}
2174+-primop SizeofSmallMutableArrayOp "sizeofSmallMutableArray#" GenPrimOp
2175+- SmallMutableArray# s a -> Int#
2176+- {Return the number of elements in the array.}
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.}
2185+-primop UnsafeFreezeSmallArrayOp "unsafeFreezeSmallArray#" GenPrimOp
2186+- SmallMutableArray# s a -> State# s -> (# State# s, SmallArray# a #)
2187+- {Make a mutable array immutable, without copying.}
2189+- has_side_effects = True
2191+-primop UnsafeThawSmallArrayOp "unsafeThawSmallArray#" GenPrimOp
2192+- SmallArray# a -> State# s -> (# State# s, SmallMutableArray# s a #)
2193+- {Make an immutable array mutable, without copying.}
2195+- out_of_line = True
2196+- has_side_effects = True
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.
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
2211+- out_of_line = True
2212+- has_side_effects = True
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. }
2226+- out_of_line = True
2227+- has_side_effects = True
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.}
2237+- out_of_line = True
2238+- has_side_effects = True
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.}
2248+- out_of_line = True
2249+- has_side_effects = True
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.}
2259+- out_of_line = True
2260+- has_side_effects = True
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.}
2270+- out_of_line = True
2271+- has_side_effects = True
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.}
2278+- out_of_line = True
2279+- has_side_effects = True
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).
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.}
2294+-------------------------------------------------------------------------
2296+-primtype ByteArray#
2298+-primtype MutableByteArray# s
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
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
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
2319+-primop MutableByteArrayIsPinnedOp "isMutableByteArrayPinned#" GenPrimOp
2320+- MutableByteArray# s -> Int#
2321+- {Determine whether a {\tt MutableByteArray\#} is guaranteed not to move
2323+- with out_of_line = True
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
2330+-primop ByteArrayContents_Char "byteArrayContents#" GenPrimOp
2331+- ByteArray# -> Addr#
2332+- {Intended for use with pinned arrays; otherwise very unsafe!}
2334+-primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
2335+- MutableByteArray# s -> MutableByteArray# s -> Int#
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
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
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
2361+-primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
2362+- MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)
2363+- {Make a mutable byte array immutable, without copying.}
2365+- has_side_effects = True
2367+-primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
2368+- ByteArray# -> Int#
2369+- {Return the size of the array in bytes.}
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}.}
2377+-primop GetSizeofMutableByteArrayOp "getSizeofMutableByteArray#" GenPrimOp
2378+- MutableByteArray# s -> State# s -> (# State# s, Int# #)
2379+- {Return the number of elements in the array.}
2381+-primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
2382+- ByteArray# -> Int# -> Char#
2383+- {Read 8-bit character; offset in bytes.}
2384+- with can_fail = True
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
2391+-primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
2392+- ByteArray# -> Int# -> Int#
2393+- with can_fail = True
2395+-primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
2396+- ByteArray# -> Int# -> Word#
2397+- with can_fail = True
2399+-primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
2400+- ByteArray# -> Int# -> Addr#
2401+- with can_fail = True
2403+-primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
2404+- ByteArray# -> Int# -> Float#
2405+- with can_fail = True
2407+-primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
2408+- ByteArray# -> Int# -> Double#
2409+- with can_fail = True
2411+-primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
2412+- ByteArray# -> Int# -> StablePtr# a
2413+- with can_fail = True
2415+-primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
2416+- ByteArray# -> Int# -> Int#
2417+- {Read 8-bit integer; offset in bytes.}
2418+- with can_fail = True
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
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
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
2435+-primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
2436+- ByteArray# -> Int# -> Word#
2437+- {Read 8-bit word; offset in bytes.}
2438+- with can_fail = True
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
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
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
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
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
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
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
2479+-primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
2480+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)
2481+- with has_side_effects = True
2484+-primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
2485+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
2486+- with has_side_effects = True
2489+-primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
2490+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
2491+- with has_side_effects = True
2494+-primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
2495+- MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
2496+- with has_side_effects = True
2499+-primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
2500+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
2501+- with has_side_effects = True
2504+-primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
2505+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
2506+- with has_side_effects = True
2509+-primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
2510+- MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #)
2511+- with has_side_effects = True
2514+-primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
2515+- MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #)
2516+- with has_side_effects = True
2519+-primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
2520+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
2521+- with has_side_effects = True
2524+-primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
2525+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
2526+- with has_side_effects = True
2529+-primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
2530+- MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #)
2531+- with has_side_effects = True
2534+-primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
2535+- MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #)
2536+- with has_side_effects = True
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
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
2551+-primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
2552+- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2553+- with has_side_effects = True
2556+-primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
2557+- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
2558+- with has_side_effects = True
2561+-primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
2562+- MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s
2563+- with has_side_effects = True
2566+-primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
2567+- MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
2568+- with has_side_effects = True
2571+-primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
2572+- MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
2573+- with has_side_effects = True
2576+-primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
2577+- MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s
2578+- with has_side_effects = True
2581+-primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
2582+- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2583+- with has_side_effects = True
2586+-primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
2587+- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2588+- with has_side_effects = True
2591+-primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
2592+- MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s
2593+- with has_side_effects = True
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
2601+-primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
2602+- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
2603+- with has_side_effects = True
2606+-primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
2607+- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
2608+- with has_side_effects = True
2611+-primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
2612+- MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s
2613+- with has_side_effects = True
2616+-primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
2617+- MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s
2618+- with has_side_effects = True
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.}
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
2645+- has_side_effects = True
2646+- code_size = { primOpCodeSizeForeignCall + 4}
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.}
2656+- has_side_effects = True
2657+- code_size = { primOpCodeSizeForeignCall + 4 }
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
2668+- has_side_effects = True
2669+- code_size = { primOpCodeSizeForeignCall + 4}
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.}
2680+- has_side_effects = True
2681+- code_size = { primOpCodeSizeForeignCall + 4}
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.}
2692+- has_side_effects = True
2693+- code_size = { primOpCodeSizeForeignCall + 4}
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}.}
2701+- has_side_effects = True
2702+- code_size = { primOpCodeSizeForeignCall + 4 }
2705+--- Atomic operations
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
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
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
2728+- with has_side_effects = True
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
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
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
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
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
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
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+-------------------------------------------------------------------------
2789+-primtype ArrayArray#
2791+-primtype MutableArrayArray# s
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.}
2799+- out_of_line = True
2800+- has_side_effects = True
2802+-primop SameMutableArrayArrayOp "sameMutableArrayArray#" GenPrimOp
2803+- MutableArrayArray# s -> MutableArrayArray# s -> Int#
2805+-primop UnsafeFreezeArrayArrayOp "unsafeFreezeArrayArray#" GenPrimOp
2806+- MutableArrayArray# s -> State# s -> (# State# s, ArrayArray# #)
2807+- {Make a mutable array of arrays immutable, without copying.}
2809+- has_side_effects = True
2811+-primop SizeofArrayArrayOp "sizeofArrayArray#" GenPrimOp
2812+- ArrayArray# -> Int#
2813+- {Return the number of elements in the array.}
2815+-primop SizeofMutableArrayArrayOp "sizeofMutableArrayArray#" GenPrimOp
2816+- MutableArrayArray# s -> Int#
2817+- {Return the number of elements in the array.}
2819+-primop IndexArrayArrayOp_ByteArray "indexByteArrayArray#" GenPrimOp
2820+- ArrayArray# -> Int# -> ByteArray#
2821+- with can_fail = True
2823+-primop IndexArrayArrayOp_ArrayArray "indexArrayArrayArray#" GenPrimOp
2824+- ArrayArray# -> Int# -> ArrayArray#
2825+- with can_fail = True
2827+-primop ReadArrayArrayOp_ByteArray "readByteArrayArray#" GenPrimOp
2828+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, ByteArray# #)
2829+- with has_side_effects = True
2832+-primop ReadArrayArrayOp_MutableByteArray "readMutableByteArrayArray#" GenPrimOp
2833+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
2834+- with has_side_effects = True
2837+-primop ReadArrayArrayOp_ArrayArray "readArrayArrayArray#" GenPrimOp
2838+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, ArrayArray# #)
2839+- with has_side_effects = True
2842+-primop ReadArrayArrayOp_MutableArrayArray "readMutableArrayArrayArray#" GenPrimOp
2843+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableArrayArray# s #)
2844+- with has_side_effects = True
2847+-primop WriteArrayArrayOp_ByteArray "writeByteArrayArray#" GenPrimOp
2848+- MutableArrayArray# s -> Int# -> ByteArray# -> State# s -> State# s
2849+- with has_side_effects = True
2852+-primop WriteArrayArrayOp_MutableByteArray "writeMutableByteArrayArray#" GenPrimOp
2853+- MutableArrayArray# s -> Int# -> MutableByteArray# s -> State# s -> State# s
2854+- with has_side_effects = True
2857+-primop WriteArrayArrayOp_ArrayArray "writeArrayArrayArray#" GenPrimOp
2858+- MutableArrayArray# s -> Int# -> ArrayArray# -> State# s -> State# s
2859+- with has_side_effects = True
2862+-primop WriteArrayArrayOp_MutableArrayArray "writeMutableArrayArrayArray#" GenPrimOp
2863+- MutableArrayArray# s -> Int# -> MutableArrayArray# s -> State# s -> State# s
2864+- with has_side_effects = True
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.}
2873+- out_of_line = True
2874+- has_side_effects = True
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.
2886+- out_of_line = True
2887+- has_side_effects = True
2890+-------------------------------------------------------------------------
2892+-------------------------------------------------------------------------
2895+- { An arbitrary machine address assumed to point outside
2896+- the garbage-collected heap. }
2898+-pseudoop "nullAddr#" Addr#
2899+- { The null address. }
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
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#
2924+-primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
2925+- Addr# -> Int# -> Char#
2926+- {Reads 8-bit character; offset in bytes.}
2927+- with can_fail = True
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
2934+-primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
2935+- Addr# -> Int# -> Int#
2936+- with can_fail = True
2938+-primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
2939+- Addr# -> Int# -> Word#
2940+- with can_fail = True
2942+-primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
2943+- Addr# -> Int# -> Addr#
2944+- with can_fail = True
2946+-primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
2947+- Addr# -> Int# -> Float#
2948+- with can_fail = True
2950+-primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
2951+- Addr# -> Int# -> Double#
2952+- with can_fail = True
2954+-primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
2955+- Addr# -> Int# -> StablePtr# a
2956+- with can_fail = True
2958+-primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
2959+- Addr# -> Int# -> Int#
2960+- with can_fail = True
2962+-primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
2963+- Addr# -> Int# -> Int#
2964+- with can_fail = True
2966+-primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
2967+- Addr# -> Int# -> INT32
2968+- with can_fail = True
2970+-primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
2971+- Addr# -> Int# -> INT64
2972+- with can_fail = True
2974+-primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
2975+- Addr# -> Int# -> Word#
2976+- with can_fail = True
2978+-primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
2979+- Addr# -> Int# -> Word#
2980+- with can_fail = True
2982+-primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
2983+- Addr# -> Int# -> WORD32
2984+- with can_fail = True
2986+-primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
2987+- Addr# -> Int# -> WORD64
2988+- with can_fail = True
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
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
3002+-primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
3003+- Addr# -> Int# -> State# s -> (# State# s, Int# #)
3004+- with has_side_effects = True
3007+-primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
3008+- Addr# -> Int# -> State# s -> (# State# s, Word# #)
3009+- with has_side_effects = True
3012+-primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
3013+- Addr# -> Int# -> State# s -> (# State# s, Addr# #)
3014+- with has_side_effects = True
3017+-primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
3018+- Addr# -> Int# -> State# s -> (# State# s, Float# #)
3019+- with has_side_effects = True
3022+-primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
3023+- Addr# -> Int# -> State# s -> (# State# s, Double# #)
3024+- with has_side_effects = True
3027+-primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
3028+- Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
3029+- with has_side_effects = True
3032+-primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
3033+- Addr# -> Int# -> State# s -> (# State# s, Int# #)
3034+- with has_side_effects = True
3037+-primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
3038+- Addr# -> Int# -> State# s -> (# State# s, Int# #)
3039+- with has_side_effects = True
3042+-primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
3043+- Addr# -> Int# -> State# s -> (# State# s, INT32 #)
3044+- with has_side_effects = True
3047+-primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
3048+- Addr# -> Int# -> State# s -> (# State# s, INT64 #)
3049+- with has_side_effects = True
3052+-primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
3053+- Addr# -> Int# -> State# s -> (# State# s, Word# #)
3054+- with has_side_effects = True
3057+-primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
3058+- Addr# -> Int# -> State# s -> (# State# s, Word# #)
3059+- with has_side_effects = True
3062+-primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
3063+- Addr# -> Int# -> State# s -> (# State# s, WORD32 #)
3064+- with has_side_effects = True
3067+-primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
3068+- Addr# -> Int# -> State# s -> (# State# s, WORD64 #)
3069+- with has_side_effects = True
3072+-primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
3073+- Addr# -> Int# -> Char# -> State# s -> State# s
3074+- with has_side_effects = True
3077+-primop WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp
3078+- Addr# -> Int# -> Char# -> State# s -> State# s
3079+- with has_side_effects = True
3082+-primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
3083+- Addr# -> Int# -> Int# -> State# s -> State# s
3084+- with has_side_effects = True
3087+-primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
3088+- Addr# -> Int# -> Word# -> State# s -> State# s
3089+- with has_side_effects = True
3092+-primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
3093+- Addr# -> Int# -> Addr# -> State# s -> State# s
3094+- with has_side_effects = True
3097+-primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
3098+- Addr# -> Int# -> Float# -> State# s -> State# s
3099+- with has_side_effects = True
3102+-primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
3103+- Addr# -> Int# -> Double# -> State# s -> State# s
3104+- with has_side_effects = True
3107+-primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
3108+- Addr# -> Int# -> StablePtr# a -> State# s -> State# s
3109+- with has_side_effects = True
3112+-primop WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
3113+- Addr# -> Int# -> Int# -> State# s -> State# s
3114+- with has_side_effects = True
3117+-primop WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
3118+- Addr# -> Int# -> Int# -> State# s -> State# s
3119+- with has_side_effects = True
3122+-primop WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
3123+- Addr# -> Int# -> INT32 -> State# s -> State# s
3124+- with has_side_effects = True
3127+-primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
3128+- Addr# -> Int# -> INT64 -> State# s -> State# s
3129+- with has_side_effects = True
3132+-primop WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
3133+- Addr# -> Int# -> Word# -> State# s -> State# s
3134+- with has_side_effects = True
3137+-primop WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
3138+- Addr# -> Int# -> Word# -> State# s -> State# s
3139+- with has_side_effects = True
3142+-primop WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
3143+- Addr# -> Int# -> WORD32 -> State# s -> State# s
3144+- with has_side_effects = True
3147+-primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
3148+- Addr# -> Int# -> WORD64 -> State# s -> State# s
3149+- with has_side_effects = True
3152+-------------------------------------------------------------------------
3153+-section "Mutable variables"
3154+- {Operations on MutVar\#s.}
3155+-------------------------------------------------------------------------
3157+-primtype MutVar# s a
3158+- {A {\tt MutVar\#} behaves like a single-element mutable array.}
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.}
3164+- out_of_line = True
3165+- has_side_effects = True
3167+--- Note [Why MutVar# ops can't fail]
3168+--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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#
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.}
3185+- -- See Note [Why MutVar# ops can't fail]
3186+- has_side_effects = True
3188+-primop WriteMutVarOp "writeMutVar#" GenPrimOp
3189+- MutVar# s a -> a -> State# s -> State# s
3190+- {Write contents of {\tt MutVar\#}.}
3192+- -- See Note [Why MutVar# ops can't fail]
3193+- has_side_effects = True
3194+- code_size = { primOpCodeSizeForeignCall } -- for the write barrier
3196+-primop SameMutVarOp "sameMutVar#" GenPrimOp
3197+- MutVar# s a -> MutVar# s a -> Int#
3199+--- Note [Why not an unboxed tuple in atomicModifyMutVar#?]
3200+--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3202+--- Looking at the type of atomicModifyMutVar#, one might wonder why
3203+--- it doesn't return an unboxed tuple. e.g.,
3205+--- MutVar# s a -> (a -> (# a, b #)) -> State# s -> (# State# s, b #)
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.
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. }
3219+- out_of_line = True
3220+- has_side_effects = True
3223+-primop CasMutVarOp "casMutVar#" GenPrimOp
3224+- MutVar# s a -> a -> a -> State# s -> (# State# s, Int#, a #)
3226+- out_of_line = True
3227+- has_side_effects = True
3229+-------------------------------------------------------------------------
3230+-section "Exceptions"
3231+-------------------------------------------------------------------------
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
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.
3243+--- For catch, catchSTM, and catchRetry, we must be extra careful; see
3244+--- Note [Exceptions and strictness] in Demand
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 #)
3252+- strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
3254+- , topDmd] topRes }
3255+- -- See Note [Strictness for mask/unmask/catch]
3256+- out_of_line = True
3257+- has_side_effects = True
3259+-primop RaiseOp "raise#" GenPrimOp
3261+- -- NB: the type variable "o" is "a", but with OpenKind
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.
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.
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
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).
3289+-primop RaiseIOOp "raiseIO#" GenPrimOp
3290+- a -> State# RealWorld -> (# State# RealWorld, b #)
3292+- strictness = { \ _arity -> mkClosedStrictSig [topDmd, topDmd] exnRes }
3293+- out_of_line = True
3294+- has_side_effects = True
3296+-primop MaskAsyncExceptionsOp "maskAsyncExceptions#" GenPrimOp
3297+- (State# RealWorld -> (# State# RealWorld, a #))
3298+- -> (State# RealWorld -> (# State# RealWorld, a #))
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
3305+-primop MaskUninterruptibleOp "maskUninterruptible#" GenPrimOp
3306+- (State# RealWorld -> (# State# RealWorld, a #))
3307+- -> (State# RealWorld -> (# State# RealWorld, a #))
3309+- strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
3310+- out_of_line = True
3311+- has_side_effects = True
3313+-primop UnmaskAsyncExceptionsOp "unmaskAsyncExceptions#" GenPrimOp
3314+- (State# RealWorld -> (# State# RealWorld, a #))
3315+- -> (State# RealWorld -> (# State# RealWorld, a #))
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
3322+-primop MaskStatus "getMaskingState#" GenPrimOp
3323+- State# RealWorld -> (# State# RealWorld, Int# #)
3325+- out_of_line = True
3326+- has_side_effects = True
3328+-------------------------------------------------------------------------
3329+-section "STM-accessible Mutable Variables"
3330+-------------------------------------------------------------------------
3334+-primop AtomicallyOp "atomically#" GenPrimOp
3335+- (State# RealWorld -> (# State# RealWorld, a #) )
3336+- -> State# RealWorld -> (# State# RealWorld, a #)
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
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.
3347+--- This allows the simplifier to replace things like:
3349+--- (# s2, a #) -> e
3352+--- where 'e' would be unreachable anyway. See Trac #8091.
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 #)
3359+- strictness = { \ _arity -> mkClosedStrictSig [topDmd] exnRes }
3360+- out_of_line = True
3361+- has_side_effects = True
3363+-primop CatchRetryOp "catchRetry#" GenPrimOp
3364+- (State# RealWorld -> (# State# RealWorld, a #) )
3365+- -> (State# RealWorld -> (# State# RealWorld, a #) )
3366+- -> (State# RealWorld -> (# State# RealWorld, a #) )
3368+- strictness = { \ _arity -> mkClosedStrictSig [ catchArgDmd
3370+- , topDmd ] topRes }
3371+- -- See Note [Strictness for mask/unmask/catch]
3372+- out_of_line = True
3373+- has_side_effects = True
3375+-primop CatchSTMOp "catchSTM#" GenPrimOp
3376+- (State# RealWorld -> (# State# RealWorld, a #) )
3377+- -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
3378+- -> (State# RealWorld -> (# State# RealWorld, a #) )
3380+- strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
3382+- , topDmd ] topRes }
3383+- -- See Note [Strictness for mask/unmask/catch]
3384+- out_of_line = True
3385+- has_side_effects = True
3387+-primop Check "check#" GenPrimOp
3388+- (State# RealWorld -> (# State# RealWorld, a #) )
3389+- -> (State# RealWorld -> State# RealWorld)
3391+- out_of_line = True
3392+- has_side_effects = True
3394+-primop NewTVarOp "newTVar#" GenPrimOp
3396+- -> State# s -> (# State# s, TVar# s a #)
3397+- {Create a new {\tt TVar\#} holding a specified initial value.}
3399+- out_of_line = True
3400+- has_side_effects = True
3402+-primop ReadTVarOp "readTVar#" GenPrimOp
3404+- -> State# s -> (# State# s, a #)
3405+- {Read contents of {\tt TVar\#}. Result is not yet evaluated.}
3407+- out_of_line = True
3408+- has_side_effects = True
3410+-primop ReadTVarIOOp "readTVarIO#" GenPrimOp
3412+- -> State# s -> (# State# s, a #)
3413+- {Read contents of {\tt TVar\#} outside an STM transaction}
3415+- out_of_line = True
3416+- has_side_effects = True
3418+-primop WriteTVarOp "writeTVar#" GenPrimOp
3421+- -> State# s -> State# s
3422+- {Write contents of {\tt TVar\#}.}
3424+- out_of_line = True
3425+- has_side_effects = True
3427+-primop SameTVarOp "sameTVar#" GenPrimOp
3428+- TVar# s a -> TVar# s a -> Int#
3431+-------------------------------------------------------------------------
3432+-section "Synchronized Mutable Variables"
3433+- {Operations on {\tt MVar\#}s. }
3434+-------------------------------------------------------------------------
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))}.) }
3441+-primop NewMVarOp "newMVar#" GenPrimOp
3442+- State# s -> (# State# s, MVar# s a #)
3443+- {Create new {\tt MVar\#}; initially empty.}
3445+- out_of_line = True
3446+- has_side_effects = True
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.}
3453+- out_of_line = True
3454+- has_side_effects = True
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.}
3461+- out_of_line = True
3462+- has_side_effects = True
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.}
3469+- out_of_line = True
3470+- has_side_effects = True
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.}
3477+- out_of_line = True
3478+- has_side_effects = True
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.}
3486+- out_of_line = True
3487+- has_side_effects = True
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\#}.}
3494+- out_of_line = True
3495+- has_side_effects = True
3497+-primop SameMVarOp "sameMVar#" GenPrimOp
3498+- MVar# s a -> MVar# s a -> Int#
3500+-primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
3501+- MVar# s a -> State# s -> (# State# s, Int# #)
3502+- {Return 1 if {\tt MVar\#} is empty; 0 otherwise.}
3504+- out_of_line = True
3505+- has_side_effects = True
3507+-------------------------------------------------------------------------
3508+-section "Delay/wait operations"
3509+-------------------------------------------------------------------------
3511+-primop DelayOp "delay#" GenPrimOp
3512+- Int# -> State# s -> State# s
3513+- {Sleep specified number of microseconds.}
3515+- has_side_effects = True
3516+- out_of_line = True
3518+-primop WaitReadOp "waitRead#" GenPrimOp
3519+- Int# -> State# s -> State# s
3520+- {Block until input is available on specified file descriptor.}
3522+- has_side_effects = True
3523+- out_of_line = True
3525+-primop WaitWriteOp "waitWrite#" GenPrimOp
3526+- Int# -> State# s -> State# s
3527+- {Block until output is possible on specified file descriptor.}
3529+- has_side_effects = True
3530+- out_of_line = True
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.}
3537+- has_side_effects = True
3538+- out_of_line = True
3540+-primop AsyncWriteOp "asyncWrite#" GenPrimOp
3541+- Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
3542+- {Asynchronously write bytes from specified file descriptor.}
3544+- has_side_effects = True
3545+- out_of_line = True
3547+-primop AsyncDoProcOp "asyncDoProc#" GenPrimOp
3548+- Addr# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
3549+- {Asynchronously perform procedure (first arg), passing it 2nd arg.}
3551+- has_side_effects = True
3552+- out_of_line = True
3556+-------------------------------------------------------------------------
3557+-section "Concurrency primitives"
3558+-------------------------------------------------------------------------
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
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\#}. }
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.)}
3577+-primop ForkOp "fork#" GenPrimOp
3578+- a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
3580+- has_side_effects = True
3581+- out_of_line = True
3583+-primop ForkOnOp "forkOn#" GenPrimOp
3584+- Int# -> a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
3586+- has_side_effects = True
3587+- out_of_line = True
3589+-primop KillThreadOp "killThread#" GenPrimOp
3590+- ThreadId# -> a -> State# RealWorld -> State# RealWorld
3592+- has_side_effects = True
3593+- out_of_line = True
3595+-primop YieldOp "yield#" GenPrimOp
3596+- State# RealWorld -> State# RealWorld
3598+- has_side_effects = True
3599+- out_of_line = True
3601+-primop MyThreadIdOp "myThreadId#" GenPrimOp
3602+- State# RealWorld -> (# State# RealWorld, ThreadId# #)
3604+- out_of_line = True
3605+- has_side_effects = True
3607+-primop LabelThreadOp "labelThread#" GenPrimOp
3608+- ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
3610+- has_side_effects = True
3611+- out_of_line = True
3613+-primop IsCurrentThreadBoundOp "isCurrentThreadBound#" GenPrimOp
3614+- State# RealWorld -> (# State# RealWorld, Int# #)
3616+- out_of_line = True
3617+- has_side_effects = True
3619+-primop NoDuplicateOp "noDuplicate#" GenPrimOp
3620+- State# s -> State# s
3622+- out_of_line = True
3623+- has_side_effects = True
3625+-primop ThreadStatusOp "threadStatus#" GenPrimOp
3626+- ThreadId# -> State# RealWorld -> (# State# RealWorld, Int#, Int#, Int# #)
3628+- out_of_line = True
3629+- has_side_effects = True
3631+-------------------------------------------------------------------------
3632+-section "Weak pointers"
3633+-------------------------------------------------------------------------
3637+--- note that tyvar "o" denotes openAlphaTyVar
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}). }
3648+- has_side_effects = True
3649+- out_of_line = True
3651+-primop MkWeakNoFinalizerOp "mkWeakNoFinalizer#" GenPrimOp
3652+- o -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #)
3654+- has_side_effects = True
3655+- out_of_line = True
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. }
3667+- has_side_effects = True
3668+- out_of_line = True
3670+-primop DeRefWeakOp "deRefWeak#" GenPrimOp
3671+- Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
3673+- has_side_effects = True
3674+- out_of_line = True
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. }
3685+- has_side_effects = True
3686+- out_of_line = True
3688+-primop TouchOp "touch#" GenPrimOp
3689+- o -> State# RealWorld -> State# RealWorld
3692+- has_side_effects = True
3694+-------------------------------------------------------------------------
3695+-section "Stable pointers and names"
3696+-------------------------------------------------------------------------
3698+-primtype StablePtr# a
3700+-primtype StableName# a
3702+-primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
3703+- a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
3705+- has_side_effects = True
3706+- out_of_line = True
3708+-primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
3709+- StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
3711+- has_side_effects = True
3712+- out_of_line = True
3714+-primop EqStablePtrOp "eqStablePtr#" GenPrimOp
3715+- StablePtr# a -> StablePtr# a -> Int#
3717+- has_side_effects = True
3719+-primop MakeStableNameOp "makeStableName#" GenPrimOp
3720+- a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
3722+- has_side_effects = True
3723+- out_of_line = True
3725+-primop EqStableNameOp "eqStableName#" GenPrimOp
3726+- StableName# a -> StableName# b -> Int#
3728+-primop StableNameToIntOp "stableNameToInt#" GenPrimOp
3729+- StableName# a -> Int#
3731+-------------------------------------------------------------------------
3732+-section "Compact normal form"
3733+-------------------------------------------------------------------------
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. }
3743+- has_side_effects = True
3744+- out_of_line = True
3746+-primop CompactResizeOp "compactResize#" GenPrimOp
3747+- Compact# -> Word# -> 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. }
3752+- has_side_effects = True
3753+- out_of_line = True
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. }
3759+- out_of_line = True
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. }
3765+- out_of_line = True
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
3772+- out_of_line = True
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. }
3780+- out_of_line = True
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.
3793+- has_side_effects = True
3794+- out_of_line = True
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. }
3806+- has_side_effects = True
3807+- out_of_line = True
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
3819+- has_side_effects = True
3820+- out_of_line = True
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. }
3827+- has_side_effects = True
3828+- out_of_line = True
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# }
3834+- has_side_effects = True
3835+- out_of_line = True
3837+-------------------------------------------------------------------------
3838+-section "Unsafe pointer equality"
3839+--- (#1 Bad Guy: Alastair Reid :)
3840+-------------------------------------------------------------------------
3842+-primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
3844+- { Returns {\texttt 1\#} if the given pointers are equal and {\texttt 0\#} otherwise. }
3846+- can_fail = True -- See Note [reallyUnsafePtrEquality#]
3849+--- Note [reallyUnsafePtrEquality#]
3850+--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
3864+--- \x y . case x of x'
3868+--- let eq = reallyUnsafePtrEquality# x' y'
3871+--- If the let floats out, we'll get
3873+--- \x y . let eq = reallyUnsafePtrEquality# x y
3874+--- in case x of ...
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.
3880+-------------------------------------------------------------------------
3881+-section "Parallelism"
3882+-------------------------------------------------------------------------
3884+-primop ParOp "par#" GenPrimOp
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 }
3892+-primop SparkOp "spark#" GenPrimOp
3893+- a -> State# s -> (# State# s, a #)
3894+- with has_side_effects = True
3895+- code_size = { primOpCodeSizeForeignCall }
3897+-primop SeqOp "seq#" GenPrimOp
3898+- a -> State# s -> (# State# s, a #)
3899+- -- See Note [seq# magic] in PrelRules
3901+-primop GetSparkOp "getSpark#" GenPrimOp
3902+- State# s -> (# State# s, Int#, a #)
3904+- has_side_effects = True
3905+- out_of_line = True
3907+-primop NumSparks "numSparks#" GenPrimOp
3908+- State# s -> (# State# s, Int# #)
3909+- { Returns the number of sparks in the local spark pool. }
3911+- has_side_effects = True
3912+- out_of_line = True
3914+-------------------------------------------------------------------------
3915+-section "Tag to enum stuff"
3916+- {Convert back and forth between values of enumerated types
3917+- and small integers.}
3918+-------------------------------------------------------------------------
3920+-primop DataToTagOp "dataToTag#" GenPrimOp
3921+- a -> Int# -- Zero-indexed; the first constructor has tag zero
3923+- can_fail = True -- See Note [dataToTag#]
3924+- strictness = { \ _arity -> mkClosedStrictSig [evalDmd] topRes }
3925+- -- dataToTag# must have an evaluated argument
3927+-primop TagToEnumOp "tagToEnum#" GenPrimOp
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
3938+- \z. case x of y -> let v = dataToTag# y in ...
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 ...
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].)
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.
3954+-------------------------------------------------------------------------
3955+-section "Bytecode operations"
3956+- {Support for manipulating bytecode objects used by the interpreter and
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+-------------------------------------------------------------------------
3964+- { Primitive bytecode type. }
3966+-primop AddrToAnyOp "addrToAny#" GenPrimOp
3968+- { Convert an {\tt Addr\#} to a followable Any type. }
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.}
3987+-primop MkApUpd0_Op "mkApUpd0#" GenPrimOp
3989+- { Wrap a BCO in a {\tt AP_UPD} thunk which will be updated with the value of
3990+- the BCO when evaluated. }
3992+- out_of_line = True
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
4001+- has_side_effects = True
4002+- out_of_line = True
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
4012+- out_of_line = True
4014+-primop GetApStackValOp "getApStackVal#" GenPrimOp
4015+- a -> Int# -> (# Int#, b #)
4017+- out_of_line = True
4019+-------------------------------------------------------------------------
4021+- {These aren't nearly as wired in as Etc...}
4022+-------------------------------------------------------------------------
4024+-primop GetCCSOfOp "getCCSOf#" GenPrimOp
4025+- a -> State# s -> (# State# s, Addr# #)
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
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. }
4041+- out_of_line = True
4043+-------------------------------------------------------------------------
4045+- {Miscellaneous built-ins}
4046+-------------------------------------------------------------------------
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. }
4057+- { Witness for an unboxed {\tt Proxy#} value, which has no runtime
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.
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. }
4075+-pseudoop "unsafeCoerce#"
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.
4083+- The following uses of {\tt unsafeCoerce\#} are supposed to work (i.e. not lead to
4084+- spurious compile-time or run-time crashes):
4086+- * Casting any lifted type to {\tt Any}
4088+- * Casting {\tt Any} back to the real type
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.)
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}.
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.
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) -> ...".
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. }
4125+- has_side_effects = True
4126+- out_of_line = True
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. }
4135+- has_side_effects = True
4136+- out_of_line = True
4138+-------------------------------------------------------------------------
4139+-section "Safe coercions"
4140+-------------------------------------------------------------------------
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
4152+-------------------------------------------------------------------------
4153+-section "SIMD Vectors"
4154+- {Operations on SIMD vectors.}
4155+-------------------------------------------------------------------------
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>]
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>]
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>]
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>]
4190+- with llvm_only = True
4191+- vector = ALL_VECTOR_TYPES
4193+-primop VecBroadcastOp "broadcast#" GenPrimOp
4195+- { Broadcast a scalar to all elements of a vector. }
4196+- with llvm_only = True
4197+- vector = ALL_VECTOR_TYPES
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
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
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
4216+- vector = ALL_VECTOR_TYPES
4218+-primop VecAddOp "plus#" Dyadic
4219+- VECTOR -> VECTOR -> VECTOR
4220+- { Add two vectors element-wise. }
4221+- with commutable = True
4223+- vector = ALL_VECTOR_TYPES
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
4231+-primop VecMulOp "times#" Dyadic
4232+- VECTOR -> VECTOR -> VECTOR
4233+- { Multiply two vectors element-wise. }
4234+- with commutable = True
4236+- vector = ALL_VECTOR_TYPES
4238+-primop VecDivOp "divide#" Dyadic
4239+- VECTOR -> VECTOR -> VECTOR
4240+- { Divide two vectors element-wise. }
4241+- with can_fail = True
4243+- vector = FLOAT_VECTOR_TYPES
4245+-primop VecQuotOp "quot#" Dyadic
4246+- VECTOR -> VECTOR -> VECTOR
4247+- { Rounds towards zero element-wise. }
4248+- with can_fail = True
4250+- vector = INT_VECTOR_TYPES
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
4257+- vector = INT_VECTOR_TYPES
4259+-primop VecNegOp "negate#" Monadic
4261+- { Negate element-wise. }
4262+- with llvm_only = True
4263+- vector = SIGNED_VECTOR_TYPES
4265+-primop VecIndexByteArrayOp "indexArray#" GenPrimOp
4266+- ByteArray# -> Int# -> VECTOR
4267+- { Read a vector from specified index of immutable array. }
4268+- with can_fail = True
4270+- vector = ALL_VECTOR_TYPES
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
4278+- vector = ALL_VECTOR_TYPES
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
4286+- vector = ALL_VECTOR_TYPES
4288+-primop VecIndexOffAddrOp "indexOffAddr#" GenPrimOp
4289+- Addr# -> Int# -> VECTOR
4290+- { Reads vector; offset in bytes. }
4291+- with can_fail = True
4293+- vector = ALL_VECTOR_TYPES
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
4301+- vector = ALL_VECTOR_TYPES
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
4309+- vector = ALL_VECTOR_TYPES
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
4317+- vector = ALL_VECTOR_TYPES
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
4325+- vector = ALL_VECTOR_TYPES
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
4333+- vector = ALL_VECTOR_TYPES
4335+-primop VecIndexScalarOffAddrOp "indexOffAddrAs#" GenPrimOp
4336+- Addr# -> Int# -> VECTOR
4337+- { Reads vector; offset in scalar elements. }
4338+- with can_fail = True
4340+- vector = ALL_VECTOR_TYPES
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
4348+- vector = ALL_VECTOR_TYPES
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
4356+- vector = ALL_VECTOR_TYPES
4358+-------------------------------------------------------------------------
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.
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.
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.
4375+- On the Sparc and PPC native backends, prefetch*N is a No-Op.
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.
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.
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.
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 .
4395+- The {\tt prefetch*} family of operations has the order of operations
4396+- determined by passing around the {\tt State#} token.
4398+- To get a "pure" version of these operations, use {\tt inlinePerformIO} which is quite safe in this context.
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.
4412+-------------------------------------------------------------------------
4415+---- the Int# argument for prefetch is the byte offset on the byteArray or Addr#
4418+-primop PrefetchByteArrayOp3 "prefetchByteArray3#" GenPrimOp
4419+- ByteArray# -> Int# -> State# s -> State# s
4420+- with has_side_effects = True
4422+-primop PrefetchMutableByteArrayOp3 "prefetchMutableByteArray3#" GenPrimOp
4423+- MutableByteArray# s -> Int# -> State# s -> State# s
4424+- with has_side_effects = True
4426+-primop PrefetchAddrOp3 "prefetchAddr3#" GenPrimOp
4427+- Addr# -> Int# -> State# s -> State# s
4428+- with has_side_effects = True
4430+-primop PrefetchValueOp3 "prefetchValue3#" GenPrimOp
4431+- a -> State# s -> State# s
4432+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4433+- has_side_effects = True
4436+-primop PrefetchByteArrayOp2 "prefetchByteArray2#" GenPrimOp
4437+- ByteArray# -> Int# -> State# s -> State# s
4438+- with has_side_effects = True
4440+-primop PrefetchMutableByteArrayOp2 "prefetchMutableByteArray2#" GenPrimOp
4441+- MutableByteArray# s -> Int# -> State# s -> State# s
4442+- with has_side_effects = True
4444+-primop PrefetchAddrOp2 "prefetchAddr2#" GenPrimOp
4445+- Addr# -> Int# -> State# s -> State# s
4446+- with has_side_effects = True
4448+-primop PrefetchValueOp2 "prefetchValue2#" GenPrimOp
4449+- a -> State# s -> State# s
4450+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4451+- has_side_effects = True
4454+-primop PrefetchByteArrayOp1 "prefetchByteArray1#" GenPrimOp
4455+- ByteArray# -> Int# -> State# s -> State# s
4456+- with has_side_effects = True
4458+-primop PrefetchMutableByteArrayOp1 "prefetchMutableByteArray1#" GenPrimOp
4459+- MutableByteArray# s -> Int# -> State# s -> State# s
4460+- with has_side_effects = True
4462+-primop PrefetchAddrOp1 "prefetchAddr1#" GenPrimOp
4463+- Addr# -> Int# -> State# s -> State# s
4464+- with has_side_effects = True
4466+-primop PrefetchValueOp1 "prefetchValue1#" GenPrimOp
4467+- a -> State# s -> State# s
4468+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4469+- has_side_effects = True
4472+-primop PrefetchByteArrayOp0 "prefetchByteArray0#" GenPrimOp
4473+- ByteArray# -> Int# -> State# s -> State# s
4474+- with has_side_effects = True
4476+-primop PrefetchMutableByteArrayOp0 "prefetchMutableByteArray0#" GenPrimOp
4477+- MutableByteArray# s -> Int# -> State# s -> State# s
4478+- with has_side_effects = True
4480+-primop PrefetchAddrOp0 "prefetchAddr0#" GenPrimOp
4481+- Addr# -> Int# -> State# s -> State# s
4482+- with has_side_effects = True
4484+-primop PrefetchValueOp0 "prefetchValue0#" GenPrimOp
4485+- a -> State# s -> State# s
4486+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4487+- has_side_effects = True
4489+-------------------------------------------------------------------------
4491+-------------------------------------------------------------------------
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"
4501+ -- The *host* architecture version:
4502+-#include "../includes/MachDeps.h"
4503++#include "MachDeps.h"
4507+diff --git a/ghc.mk b/ghc.mk
4508+index 38c165d..7cb7913 100644
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
4515+-# ----------------------------------------
4516+-# Special magic for the ghc-prim package
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.
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))
4527+-PRIMOPS_TXT_STAGE1 = compiler/stage1/build/primops.txt
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) >$@
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
4535+ # ----------------------------------------
4536+ # Special magic for the integer package
4538+diff --git a/ghc/ghc.mk b/ghc/ghc.mk
4539+index 20fa142..ad4b7c2 100644
4542+@@ -14,10 +14,6 @@ ghc_USES_CABAL = YES
4543+ ghc_PACKAGE = ghc-bin
4544+ ghc_EXECUTABLE = ghc
4546+-ghc_stage1_CONFIGURE_OPTS += --flags=stage1
4547+-ghc_stage2_CONFIGURE_OPTS += --flags=stage2
4548+-ghc_stage3_CONFIGURE_OPTS += --flags=stage3
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
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)
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
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
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/" && \
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)/"
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
4596+ This package contains the primitive types and operations supplied by GHC.
4599++ Description: Is this stage 1?
4604++ Description: Is this stage 2?
4608+ extra-source-files: changelog.md
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)
4614+ ghc-options: -this-unit-id ghc-prim
4617++ include-dirs: dist-boot
4620++ include-dirs: dist-install
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
4645+ libraries/ghc-prim_PACKAGE = ghc-prim
4646+ libraries/ghc-prim_dist-install_GROUP = libraries
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
4653++# ----------------------------------------
4654++# Special magic for the ghc-prim package
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.
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))
4665++PRIMOPS_TXT_STAGE1 = libraries/ghc-prim/dist-boot/primops.txt
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) >$@
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
4674++# -----------------------------------------------------------------------------
4675++# Create platform includes
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.
4682++PLATFORM_H = ghc_boot_platform.h
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__" >> $@
4690++ @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
4691++ @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
4692++ @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
4694++ @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
4695++ @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
4696++ @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
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)\"" >> $@
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)\"" >> $@
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)\"" >> $@
4720++ @echo "#endif /* __PLATFORM_H__ */" >> $@
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__" >> $@
4732++ @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
4733++ @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
4734++ @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
4736++ @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
4737++ @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
4738++ @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
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)\"" >> $@
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)\"" >> $@
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)\"" >> $@
4762++ @echo "#endif /* __PLATFORM_H__ */" >> $@
4765++# ----------------------------------------------------------------------------
4766++# Generate supporting stuff for prelude/PrimOp.hs
4767++# from prelude/primops.txt
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
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))
4789++compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
4790++compiler_CPP_OPTS += ${GhcCppOpts}
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))
4797++define preprocessCompilerFiles
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' > $$@
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 < $$< > $$@
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 < $$< > $$@
4840++$(eval $(call preprocessCompilerFiles,dist-boot))
4841++$(eval $(call preprocessCompilerFiles,dist-install))
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
4851++++ b/libraries/ghc-prim/primops.txt.pp
4853++-----------------------------------------------------------------------
4855++-- (c) 2010 The University of Glasgow
4857++-- Primitive Operations and Types
4859++-- For more information on PrimOps, see
4860++-- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
4862++-----------------------------------------------------------------------
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.
4868++-- It should first be preprocessed.
4870++-- Information on how PrimOps are implemented and the steps necessary to
4871++-- add a new one can be found in the Commentary:
4873++-- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
4875++-- This file is divided into named sections, each containing or more
4876++-- primop entries. Section headers have the format:
4878++-- section "section-name" {description}
4880++-- This information is used solely when producing documentation; it is
4881++-- otherwise ignored. The description is optional.
4883++-- The format of each primop entry is as follows:
4885++-- primop internal-name "name-in-program-text" type category {description} attributes
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.
4894++-- type refers to the general category of the primop. Valid settings include,
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
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
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
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 }
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.
4933++#include "MachDeps.h"
4935++-- We need platform defines (tests for mingw32 below).
4936++#include "ghc_boot_platform.h"
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.
4951++ GHC also implements a primitive unsigned integer type {\tt
4952++ Word\#} which always has the same number of bits as {\tt
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
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.
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. }
4995++-- Define synonyms for indexing ops.
4997++#if WORD_SIZE_IN_BITS < 32
4998++#define INT32 Int32#
4999++#define WORD32 Word32#
5002++#define WORD32 Word#
5005++#if WORD_SIZE_IN_BITS < 64
5006++#define INT64 Int64#
5007++#define WORD64 Word64#
5010++#define WORD64 Word#
5013++------------------------------------------------------------------------
5015++ {Operations on 31-bit characters.}
5016++------------------------------------------------------------------------
5020++primop CharGtOp "gtChar#" Compare Char# -> Char# -> Int#
5021++primop CharGeOp "geChar#" Compare Char# -> Char# -> Int#
5023++primop CharEqOp "eqChar#" Compare
5024++ Char# -> Char# -> Int#
5025++ with commutable = True
5027++primop CharNeOp "neChar#" Compare
5028++ Char# -> Char# -> Int#
5029++ with commutable = True
5031++primop CharLtOp "ltChar#" Compare Char# -> Char# -> Int#
5032++primop CharLeOp "leChar#" Compare Char# -> Char# -> Int#
5034++primop OrdOp "ord#" GenPrimOp Char# -> Int#
5035++ with code_size = 0
5037++------------------------------------------------------------------------
5039++ {Operations on native-size integers (30+ bits).}
5040++------------------------------------------------------------------------
5044++primop IntAddOp "+#" Dyadic
5045++ Int# -> Int# -> Int#
5046++ with commutable = True
5049++primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
5050++ with fixity = infixl 6
5052++primop IntMulOp "*#"
5053++ Dyadic Int# -> Int# -> Int#
5054++ {Low word of signed integer multiply.}
5055++ with commutable = True
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.
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
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.
5080++ with commutable = True
5082++primop IntQuotOp "quotInt#" Dyadic
5083++ Int# -> Int# -> Int#
5084++ {Rounds towards zero. The behavior is undefined if the second argument is
5087++ with can_fail = True
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.
5094++ with can_fail = True
5096++primop IntQuotRemOp "quotRemInt#" GenPrimOp
5097++ Int# -> Int# -> (# Int#, Int# #)
5098++ {Rounds towards zero.}
5099++ with can_fail = True
5101++primop AndIOp "andI#" Dyadic Int# -> Int# -> Int#
5102++ with commutable = True
5104++primop OrIOp "orI#" Dyadic Int# -> Int# -> Int#
5105++ with commutable = True
5107++primop XorIOp "xorI#" Dyadic Int# -> Int# -> Int#
5108++ with commutable = True
5110++primop NotIOp "notI#" Monadic Int# -> Int#
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
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
5129++primop IntGtOp ">#" Compare Int# -> Int# -> Int#
5130++ with fixity = infix 4
5132++primop IntGeOp ">=#" Compare Int# -> Int# -> Int#
5133++ with fixity = infix 4
5135++primop IntEqOp "==#" Compare
5136++ Int# -> Int# -> Int#
5137++ with commutable = True
5140++primop IntNeOp "/=#" Compare
5141++ Int# -> Int# -> Int#
5142++ with commutable = True
5145++primop IntLtOp "<#" Compare Int# -> Int# -> Int#
5146++ with fixity = infix 4
5148++primop IntLeOp "<=#" Compare Int# -> Int# -> Int#
5149++ with fixity = infix 4
5151++primop ChrOp "chr#" GenPrimOp Int# -> Char#
5152++ with code_size = 0
5154++primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
5155++ with code_size = 0
5157++primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
5158++primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
5160++primop Word2FloatOp "word2Float#" GenPrimOp Word# -> Float#
5161++primop Word2DoubleOp "word2Double#" GenPrimOp Word# -> Double#
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.}
5173++------------------------------------------------------------------------
5175++ {Operations on native-sized unsigned words (30+ bits).}
5176++------------------------------------------------------------------------
5180++primop WordAddOp "plusWord#" Dyadic Word# -> Word# -> Word#
5181++ with commutable = True
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.}
5188++-- Returns (# high, low #) (or equivalently, (# carry, low #))
5189++primop WordAdd2Op "plusWord2#" GenPrimOp
5190++ Word# -> Word# -> (# Word#, Word# #)
5191++ with commutable = True
5193++primop WordSubOp "minusWord#" Dyadic Word# -> Word# -> Word#
5195++primop WordMulOp "timesWord#" Dyadic Word# -> Word# -> Word#
5196++ with commutable = True
5198++-- Returns (# high, low #)
5199++primop WordMul2Op "timesWord2#" GenPrimOp
5200++ Word# -> Word# -> (# Word#, Word# #)
5201++ with commutable = True
5203++primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word#
5204++ with can_fail = True
5206++primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word#
5207++ with can_fail = True
5209++primop WordQuotRemOp "quotRemWord#" GenPrimOp
5210++ Word# -> Word# -> (# Word#, Word# #)
5211++ with can_fail = True
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
5219++primop AndOp "and#" Dyadic Word# -> Word# -> Word#
5220++ with commutable = True
5222++primop OrOp "or#" Dyadic Word# -> Word# -> Word#
5223++ with commutable = True
5225++primop XorOp "xor#" Dyadic Word# -> Word# -> Word#
5226++ with commutable = True
5228++primop NotOp "not#" Monadic Word# -> Word#
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.}
5237++primop Word2IntOp "word2Int#" GenPrimOp Word# -> Int#
5238++ with code_size = 0
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#
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.}
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.}
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.}
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.}
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.}
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.}
5311++------------------------------------------------------------------------
5312++section "Narrowings"
5313++ {Explicit narrowing of native-sized ints or words.}
5314++------------------------------------------------------------------------
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#
5324++#if WORD_SIZE_IN_BITS < 32
5325++------------------------------------------------------------------------
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++------------------------------------------------------------------------
5334++------------------------------------------------------------------------
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++------------------------------------------------------------------------
5346++#if WORD_SIZE_IN_BITS < 64
5347++------------------------------------------------------------------------
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++------------------------------------------------------------------------
5356++------------------------------------------------------------------------
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++------------------------------------------------------------------------
5367++------------------------------------------------------------------------
5369++ {Operations on double-precision (64 bit) floating-point numbers.}
5370++------------------------------------------------------------------------
5374++primop DoubleGtOp ">##" Compare Double# -> Double# -> Int#
5375++ with fixity = infix 4
5377++primop DoubleGeOp ">=##" Compare Double# -> Double# -> Int#
5378++ with fixity = infix 4
5380++primop DoubleEqOp "==##" Compare
5381++ Double# -> Double# -> Int#
5382++ with commutable = True
5385++primop DoubleNeOp "/=##" Compare
5386++ Double# -> Double# -> Int#
5387++ with commutable = True
5390++primop DoubleLtOp "<##" Compare Double# -> Double# -> Int#
5391++ with fixity = infix 4
5393++primop DoubleLeOp "<=##" Compare Double# -> Double# -> Int#
5394++ with fixity = infix 4
5396++primop DoubleAddOp "+##" Dyadic
5397++ Double# -> Double# -> Double#
5398++ with commutable = True
5401++primop DoubleSubOp "-##" Dyadic Double# -> Double# -> Double#
5402++ with fixity = infixl 6
5404++primop DoubleMulOp "*##" Dyadic
5405++ Double# -> Double# -> Double#
5406++ with commutable = True
5409++primop DoubleDivOp "/##" Dyadic
5410++ Double# -> Double# -> Double#
5411++ with can_fail = True
5414++primop DoubleNegOp "negateDouble#" Monadic Double# -> Double#
5416++primop DoubleFabsOp "fabsDouble#" Monadic Double# -> Double#
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#}.}
5423++primop Double2FloatOp "double2Float#" GenPrimOp Double# -> Float#
5425++primop DoubleExpOp "expDouble#" Monadic
5426++ Double# -> Double#
5428++ code_size = { primOpCodeSizeForeignCall }
5430++primop DoubleLogOp "logDouble#" Monadic
5431++ Double# -> Double#
5433++ code_size = { primOpCodeSizeForeignCall }
5436++primop DoubleSqrtOp "sqrtDouble#" Monadic
5437++ Double# -> Double#
5439++ code_size = { primOpCodeSizeForeignCall }
5441++primop DoubleSinOp "sinDouble#" Monadic
5442++ Double# -> Double#
5444++ code_size = { primOpCodeSizeForeignCall }
5446++primop DoubleCosOp "cosDouble#" Monadic
5447++ Double# -> Double#
5449++ code_size = { primOpCodeSizeForeignCall }
5451++primop DoubleTanOp "tanDouble#" Monadic
5452++ Double# -> Double#
5454++ code_size = { primOpCodeSizeForeignCall }
5456++primop DoubleAsinOp "asinDouble#" Monadic
5457++ Double# -> Double#
5459++ code_size = { primOpCodeSizeForeignCall }
5462++primop DoubleAcosOp "acosDouble#" Monadic
5463++ Double# -> Double#
5465++ code_size = { primOpCodeSizeForeignCall }
5468++primop DoubleAtanOp "atanDouble#" Monadic
5469++ Double# -> Double#
5471++ code_size = { primOpCodeSizeForeignCall }
5473++primop DoubleSinhOp "sinhDouble#" Monadic
5474++ Double# -> Double#
5476++ code_size = { primOpCodeSizeForeignCall }
5478++primop DoubleCoshOp "coshDouble#" Monadic
5479++ Double# -> Double#
5481++ code_size = { primOpCodeSizeForeignCall }
5483++primop DoubleTanhOp "tanhDouble#" Monadic
5484++ Double# -> Double#
5486++ code_size = { primOpCodeSizeForeignCall }
5488++primop DoublePowerOp "**##" Dyadic
5489++ Double# -> Double# -> Double#
5492++ code_size = { primOpCodeSizeForeignCall }
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
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
5507++------------------------------------------------------------------------
5509++ {Operations on single-precision (32-bit) floating-point numbers.}
5510++------------------------------------------------------------------------
5514++primop FloatGtOp "gtFloat#" Compare Float# -> Float# -> Int#
5515++primop FloatGeOp "geFloat#" Compare Float# -> Float# -> Int#
5517++primop FloatEqOp "eqFloat#" Compare
5518++ Float# -> Float# -> Int#
5519++ with commutable = True
5521++primop FloatNeOp "neFloat#" Compare
5522++ Float# -> Float# -> Int#
5523++ with commutable = True
5525++primop FloatLtOp "ltFloat#" Compare Float# -> Float# -> Int#
5526++primop FloatLeOp "leFloat#" Compare Float# -> Float# -> Int#
5528++primop FloatAddOp "plusFloat#" Dyadic
5529++ Float# -> Float# -> Float#
5530++ with commutable = True
5532++primop FloatSubOp "minusFloat#" Dyadic Float# -> Float# -> Float#
5534++primop FloatMulOp "timesFloat#" Dyadic
5535++ Float# -> Float# -> Float#
5536++ with commutable = True
5538++primop FloatDivOp "divideFloat#" Dyadic
5539++ Float# -> Float# -> Float#
5540++ with can_fail = True
5542++primop FloatNegOp "negateFloat#" Monadic Float# -> Float#
5544++primop FloatFabsOp "fabsFloat#" Monadic Float# -> Float#
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#}.}
5551++primop FloatExpOp "expFloat#" Monadic
5554++ code_size = { primOpCodeSizeForeignCall }
5556++primop FloatLogOp "logFloat#" Monadic
5559++ code_size = { primOpCodeSizeForeignCall }
5562++primop FloatSqrtOp "sqrtFloat#" Monadic
5565++ code_size = { primOpCodeSizeForeignCall }
5567++primop FloatSinOp "sinFloat#" Monadic
5570++ code_size = { primOpCodeSizeForeignCall }
5572++primop FloatCosOp "cosFloat#" Monadic
5575++ code_size = { primOpCodeSizeForeignCall }
5577++primop FloatTanOp "tanFloat#" Monadic
5580++ code_size = { primOpCodeSizeForeignCall }
5582++primop FloatAsinOp "asinFloat#" Monadic
5585++ code_size = { primOpCodeSizeForeignCall }
5588++primop FloatAcosOp "acosFloat#" Monadic
5591++ code_size = { primOpCodeSizeForeignCall }
5594++primop FloatAtanOp "atanFloat#" Monadic
5597++ code_size = { primOpCodeSizeForeignCall }
5599++primop FloatSinhOp "sinhFloat#" Monadic
5602++ code_size = { primOpCodeSizeForeignCall }
5604++primop FloatCoshOp "coshFloat#" Monadic
5607++ code_size = { primOpCodeSizeForeignCall }
5609++primop FloatTanhOp "tanhFloat#" Monadic
5612++ code_size = { primOpCodeSizeForeignCall }
5614++primop FloatPowerOp "powerFloat#" Dyadic
5615++ Float# -> Float# -> Float#
5617++ code_size = { primOpCodeSizeForeignCall }
5619++primop Float2DoubleOp "float2Double#" GenPrimOp Float# -> Double#
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
5627++------------------------------------------------------------------------
5629++ {Operations on {\tt Array\#}.}
5630++------------------------------------------------------------------------
5634++primtype MutableArray# s a
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.}
5642++ out_of_line = True
5643++ has_side_effects = True
5645++primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
5646++ MutableArray# s a -> MutableArray# s a -> Int#
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.}
5652++ has_side_effects = True
5655++primop WriteArrayOp "writeArray#" GenPrimOp
5656++ MutableArray# s a -> Int# -> a -> State# s -> State# s
5657++ {Write to specified index of mutable array.}
5659++ has_side_effects = True
5661++ code_size = 2 -- card update too
5663++primop SizeofArrayOp "sizeofArray#" GenPrimOp
5665++ {Return the number of elements in the array.}
5667++primop SizeofMutableArrayOp "sizeofMutableArray#" GenPrimOp
5668++ MutableArray# s a -> Int#
5669++ {Return the number of elements in the array.}
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.}
5678++primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
5679++ MutableArray# s a -> State# s -> (# State# s, Array# a #)
5680++ {Make a mutable array immutable, without copying.}
5682++ has_side_effects = True
5684++primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
5685++ Array# a -> State# s -> (# State# s, MutableArray# s a #)
5686++ {Make an immutable array mutable, without copying.}
5688++ out_of_line = True
5689++ has_side_effects = True
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
5701++ out_of_line = True
5702++ has_side_effects = True
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.}
5715++ out_of_line = True
5716++ has_side_effects = True
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.}
5726++ out_of_line = True
5727++ has_side_effects = True
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.}
5737++ out_of_line = True
5738++ has_side_effects = True
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.}
5748++ out_of_line = True
5749++ has_side_effects = True
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.}
5759++ out_of_line = True
5760++ has_side_effects = True
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.}
5767++ out_of_line = True
5768++ has_side_effects = True
5771++------------------------------------------------------------------------
5772++section "Small Arrays"
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\#}.
5792++------------------------------------------------------------------------
5794++primtype SmallArray# a
5796++primtype SmallMutableArray# s a
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.}
5804++ out_of_line = True
5805++ has_side_effects = True
5807++primop SameSmallMutableArrayOp "sameSmallMutableArray#" GenPrimOp
5808++ SmallMutableArray# s a -> SmallMutableArray# s a -> Int#
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.}
5814++ has_side_effects = True
5817++primop WriteSmallArrayOp "writeSmallArray#" GenPrimOp
5818++ SmallMutableArray# s a -> Int# -> a -> State# s -> State# s
5819++ {Write to specified index of mutable array.}
5821++ has_side_effects = True
5824++primop SizeofSmallArrayOp "sizeofSmallArray#" GenPrimOp
5825++ SmallArray# a -> Int#
5826++ {Return the number of elements in the array.}
5828++primop SizeofSmallMutableArrayOp "sizeofSmallMutableArray#" GenPrimOp
5829++ SmallMutableArray# s a -> Int#
5830++ {Return the number of elements in the array.}
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.}
5839++primop UnsafeFreezeSmallArrayOp "unsafeFreezeSmallArray#" GenPrimOp
5840++ SmallMutableArray# s a -> State# s -> (# State# s, SmallArray# a #)
5841++ {Make a mutable array immutable, without copying.}
5843++ has_side_effects = True
5845++primop UnsafeThawSmallArrayOp "unsafeThawSmallArray#" GenPrimOp
5846++ SmallArray# a -> State# s -> (# State# s, SmallMutableArray# s a #)
5847++ {Make an immutable array mutable, without copying.}
5849++ out_of_line = True
5850++ has_side_effects = True
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.
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
5865++ out_of_line = True
5866++ has_side_effects = True
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. }
5880++ out_of_line = True
5881++ has_side_effects = True
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.}
5891++ out_of_line = True
5892++ has_side_effects = True
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.}
5902++ out_of_line = True
5903++ has_side_effects = True
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.}
5913++ out_of_line = True
5914++ has_side_effects = True
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.}
5924++ out_of_line = True
5925++ has_side_effects = True
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.}
5932++ out_of_line = True
5933++ has_side_effects = True
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).
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.}
5948++------------------------------------------------------------------------
5950++primtype ByteArray#
5952++primtype MutableByteArray# s
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
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
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
5973++primop MutableByteArrayIsPinnedOp "isMutableByteArrayPinned#" GenPrimOp
5974++ MutableByteArray# s -> Int#
5975++ {Determine whether a {\tt MutableByteArray\#} is guaranteed not to move
5977++ with out_of_line = True
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
5984++primop ByteArrayContents_Char "byteArrayContents#" GenPrimOp
5985++ ByteArray# -> Addr#
5986++ {Intended for use with pinned arrays; otherwise very unsafe!}
5988++primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
5989++ MutableByteArray# s -> MutableByteArray# s -> Int#
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
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
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
6015++primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
6016++ MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)
6017++ {Make a mutable byte array immutable, without copying.}
6019++ has_side_effects = True
6021++primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
6022++ ByteArray# -> Int#
6023++ {Return the size of the array in bytes.}
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}.}
6031++primop GetSizeofMutableByteArrayOp "getSizeofMutableByteArray#" GenPrimOp
6032++ MutableByteArray# s -> State# s -> (# State# s, Int# #)
6033++ {Return the number of elements in the array.}
6035++primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
6036++ ByteArray# -> Int# -> Char#
6037++ {Read 8-bit character; offset in bytes.}
6038++ with can_fail = True
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
6045++primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
6046++ ByteArray# -> Int# -> Int#
6047++ with can_fail = True
6049++primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
6050++ ByteArray# -> Int# -> Word#
6051++ with can_fail = True
6053++primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
6054++ ByteArray# -> Int# -> Addr#
6055++ with can_fail = True
6057++primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
6058++ ByteArray# -> Int# -> Float#
6059++ with can_fail = True
6061++primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
6062++ ByteArray# -> Int# -> Double#
6063++ with can_fail = True
6065++primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
6066++ ByteArray# -> Int# -> StablePtr# a
6067++ with can_fail = True
6069++primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
6070++ ByteArray# -> Int# -> Int#
6071++ {Read 8-bit integer; offset in bytes.}
6072++ with can_fail = True
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
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
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
6089++primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
6090++ ByteArray# -> Int# -> Word#
6091++ {Read 8-bit word; offset in bytes.}
6092++ with can_fail = True
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
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
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
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
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
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
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
6133++primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
6134++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)
6135++ with has_side_effects = True
6138++primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
6139++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
6140++ with has_side_effects = True
6143++primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
6144++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
6145++ with has_side_effects = True
6148++primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
6149++ MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
6150++ with has_side_effects = True
6153++primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
6154++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
6155++ with has_side_effects = True
6158++primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
6159++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
6160++ with has_side_effects = True
6163++primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
6164++ MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #)
6165++ with has_side_effects = True
6168++primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
6169++ MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #)
6170++ with has_side_effects = True
6173++primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
6174++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
6175++ with has_side_effects = True
6178++primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
6179++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
6180++ with has_side_effects = True
6183++primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
6184++ MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #)
6185++ with has_side_effects = True
6188++primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
6189++ MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #)
6190++ with has_side_effects = True
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
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
6205++primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
6206++ MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6207++ with has_side_effects = True
6210++primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
6211++ MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
6212++ with has_side_effects = True
6215++primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
6216++ MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s
6217++ with has_side_effects = True
6220++primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
6221++ MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
6222++ with has_side_effects = True
6225++primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
6226++ MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
6227++ with has_side_effects = True
6230++primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
6231++ MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s
6232++ with has_side_effects = True
6235++primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
6236++ MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6237++ with has_side_effects = True
6240++primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
6241++ MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6242++ with has_side_effects = True
6245++primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
6246++ MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s
6247++ with has_side_effects = True
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
6255++primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
6256++ MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
6257++ with has_side_effects = True
6260++primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
6261++ MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
6262++ with has_side_effects = True
6265++primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
6266++ MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s
6267++ with has_side_effects = True
6270++primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
6271++ MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s
6272++ with has_side_effects = True
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.}
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
6299++ has_side_effects = True
6300++ code_size = { primOpCodeSizeForeignCall + 4}
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.}
6310++ has_side_effects = True
6311++ code_size = { primOpCodeSizeForeignCall + 4 }
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
6322++ has_side_effects = True
6323++ code_size = { primOpCodeSizeForeignCall + 4}
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.}
6334++ has_side_effects = True
6335++ code_size = { primOpCodeSizeForeignCall + 4}
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.}
6346++ has_side_effects = True
6347++ code_size = { primOpCodeSizeForeignCall + 4}
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}.}
6355++ has_side_effects = True
6356++ code_size = { primOpCodeSizeForeignCall + 4 }
6359++-- Atomic operations
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
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
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
6382++ with has_side_effects = True
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
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
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
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
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
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
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++------------------------------------------------------------------------
6443++primtype ArrayArray#
6445++primtype MutableArrayArray# s
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.}
6453++ out_of_line = True
6454++ has_side_effects = True
6456++primop SameMutableArrayArrayOp "sameMutableArrayArray#" GenPrimOp
6457++ MutableArrayArray# s -> MutableArrayArray# s -> Int#
6459++primop UnsafeFreezeArrayArrayOp "unsafeFreezeArrayArray#" GenPrimOp
6460++ MutableArrayArray# s -> State# s -> (# State# s, ArrayArray# #)
6461++ {Make a mutable array of arrays immutable, without copying.}
6463++ has_side_effects = True
6465++primop SizeofArrayArrayOp "sizeofArrayArray#" GenPrimOp
6466++ ArrayArray# -> Int#
6467++ {Return the number of elements in the array.}
6469++primop SizeofMutableArrayArrayOp "sizeofMutableArrayArray#" GenPrimOp
6470++ MutableArrayArray# s -> Int#
6471++ {Return the number of elements in the array.}
6473++primop IndexArrayArrayOp_ByteArray "indexByteArrayArray#" GenPrimOp
6474++ ArrayArray# -> Int# -> ByteArray#
6475++ with can_fail = True
6477++primop IndexArrayArrayOp_ArrayArray "indexArrayArrayArray#" GenPrimOp
6478++ ArrayArray# -> Int# -> ArrayArray#
6479++ with can_fail = True
6481++primop ReadArrayArrayOp_ByteArray "readByteArrayArray#" GenPrimOp
6482++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, ByteArray# #)
6483++ with has_side_effects = True
6486++primop ReadArrayArrayOp_MutableByteArray "readMutableByteArrayArray#" GenPrimOp
6487++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
6488++ with has_side_effects = True
6491++primop ReadArrayArrayOp_ArrayArray "readArrayArrayArray#" GenPrimOp
6492++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, ArrayArray# #)
6493++ with has_side_effects = True
6496++primop ReadArrayArrayOp_MutableArrayArray "readMutableArrayArrayArray#" GenPrimOp
6497++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableArrayArray# s #)
6498++ with has_side_effects = True
6501++primop WriteArrayArrayOp_ByteArray "writeByteArrayArray#" GenPrimOp
6502++ MutableArrayArray# s -> Int# -> ByteArray# -> State# s -> State# s
6503++ with has_side_effects = True
6506++primop WriteArrayArrayOp_MutableByteArray "writeMutableByteArrayArray#" GenPrimOp
6507++ MutableArrayArray# s -> Int# -> MutableByteArray# s -> State# s -> State# s
6508++ with has_side_effects = True
6511++primop WriteArrayArrayOp_ArrayArray "writeArrayArrayArray#" GenPrimOp
6512++ MutableArrayArray# s -> Int# -> ArrayArray# -> State# s -> State# s
6513++ with has_side_effects = True
6516++primop WriteArrayArrayOp_MutableArrayArray "writeMutableArrayArrayArray#" GenPrimOp
6517++ MutableArrayArray# s -> Int# -> MutableArrayArray# s -> State# s -> State# s
6518++ with has_side_effects = True
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.}
6527++ out_of_line = True
6528++ has_side_effects = True
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.
6540++ out_of_line = True
6541++ has_side_effects = True
6544++------------------------------------------------------------------------
6546++------------------------------------------------------------------------
6549++ { An arbitrary machine address assumed to point outside
6550++ the garbage-collected heap. }
6552++pseudoop "nullAddr#" Addr#
6553++ { The null address. }
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
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#
6578++primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
6579++ Addr# -> Int# -> Char#
6580++ {Reads 8-bit character; offset in bytes.}
6581++ with can_fail = True
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
6588++primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
6589++ Addr# -> Int# -> Int#
6590++ with can_fail = True
6592++primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
6593++ Addr# -> Int# -> Word#
6594++ with can_fail = True
6596++primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
6597++ Addr# -> Int# -> Addr#
6598++ with can_fail = True
6600++primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
6601++ Addr# -> Int# -> Float#
6602++ with can_fail = True
6604++primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
6605++ Addr# -> Int# -> Double#
6606++ with can_fail = True
6608++primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
6609++ Addr# -> Int# -> StablePtr# a
6610++ with can_fail = True
6612++primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
6613++ Addr# -> Int# -> Int#
6614++ with can_fail = True
6616++primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
6617++ Addr# -> Int# -> Int#
6618++ with can_fail = True
6620++primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
6621++ Addr# -> Int# -> INT32
6622++ with can_fail = True
6624++primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
6625++ Addr# -> Int# -> INT64
6626++ with can_fail = True
6628++primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
6629++ Addr# -> Int# -> Word#
6630++ with can_fail = True
6632++primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
6633++ Addr# -> Int# -> Word#
6634++ with can_fail = True
6636++primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
6637++ Addr# -> Int# -> WORD32
6638++ with can_fail = True
6640++primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
6641++ Addr# -> Int# -> WORD64
6642++ with can_fail = True
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
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
6656++primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
6657++ Addr# -> Int# -> State# s -> (# State# s, Int# #)
6658++ with has_side_effects = True
6661++primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
6662++ Addr# -> Int# -> State# s -> (# State# s, Word# #)
6663++ with has_side_effects = True
6666++primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
6667++ Addr# -> Int# -> State# s -> (# State# s, Addr# #)
6668++ with has_side_effects = True
6671++primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
6672++ Addr# -> Int# -> State# s -> (# State# s, Float# #)
6673++ with has_side_effects = True
6676++primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
6677++ Addr# -> Int# -> State# s -> (# State# s, Double# #)
6678++ with has_side_effects = True
6681++primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
6682++ Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
6683++ with has_side_effects = True
6686++primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
6687++ Addr# -> Int# -> State# s -> (# State# s, Int# #)
6688++ with has_side_effects = True
6691++primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
6692++ Addr# -> Int# -> State# s -> (# State# s, Int# #)
6693++ with has_side_effects = True
6696++primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
6697++ Addr# -> Int# -> State# s -> (# State# s, INT32 #)
6698++ with has_side_effects = True
6701++primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
6702++ Addr# -> Int# -> State# s -> (# State# s, INT64 #)
6703++ with has_side_effects = True
6706++primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
6707++ Addr# -> Int# -> State# s -> (# State# s, Word# #)
6708++ with has_side_effects = True
6711++primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
6712++ Addr# -> Int# -> State# s -> (# State# s, Word# #)
6713++ with has_side_effects = True
6716++primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
6717++ Addr# -> Int# -> State# s -> (# State# s, WORD32 #)
6718++ with has_side_effects = True
6721++primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
6722++ Addr# -> Int# -> State# s -> (# State# s, WORD64 #)
6723++ with has_side_effects = True
6726++primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
6727++ Addr# -> Int# -> Char# -> State# s -> State# s
6728++ with has_side_effects = True
6731++primop WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp
6732++ Addr# -> Int# -> Char# -> State# s -> State# s
6733++ with has_side_effects = True
6736++primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
6737++ Addr# -> Int# -> Int# -> State# s -> State# s
6738++ with has_side_effects = True
6741++primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
6742++ Addr# -> Int# -> Word# -> State# s -> State# s
6743++ with has_side_effects = True
6746++primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
6747++ Addr# -> Int# -> Addr# -> State# s -> State# s
6748++ with has_side_effects = True
6751++primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
6752++ Addr# -> Int# -> Float# -> State# s -> State# s
6753++ with has_side_effects = True
6756++primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
6757++ Addr# -> Int# -> Double# -> State# s -> State# s
6758++ with has_side_effects = True
6761++primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
6762++ Addr# -> Int# -> StablePtr# a -> State# s -> State# s
6763++ with has_side_effects = True
6766++primop WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
6767++ Addr# -> Int# -> Int# -> State# s -> State# s
6768++ with has_side_effects = True
6771++primop WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
6772++ Addr# -> Int# -> Int# -> State# s -> State# s
6773++ with has_side_effects = True
6776++primop WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
6777++ Addr# -> Int# -> INT32 -> State# s -> State# s
6778++ with has_side_effects = True
6781++primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
6782++ Addr# -> Int# -> INT64 -> State# s -> State# s
6783++ with has_side_effects = True
6786++primop WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
6787++ Addr# -> Int# -> Word# -> State# s -> State# s
6788++ with has_side_effects = True
6791++primop WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
6792++ Addr# -> Int# -> Word# -> State# s -> State# s
6793++ with has_side_effects = True
6796++primop WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
6797++ Addr# -> Int# -> WORD32 -> State# s -> State# s
6798++ with has_side_effects = True
6801++primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
6802++ Addr# -> Int# -> WORD64 -> State# s -> State# s
6803++ with has_side_effects = True
6806++------------------------------------------------------------------------
6807++section "Mutable variables"
6808++ {Operations on MutVar\#s.}
6809++------------------------------------------------------------------------
6811++primtype MutVar# s a
6812++ {A {\tt MutVar\#} behaves like a single-element mutable array.}
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.}
6818++ out_of_line = True
6819++ has_side_effects = True
6821++-- Note [Why MutVar# ops can't fail]
6822++-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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#
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.}
6839++ -- See Note [Why MutVar# ops can't fail]
6840++ has_side_effects = True
6842++primop WriteMutVarOp "writeMutVar#" GenPrimOp
6843++ MutVar# s a -> a -> State# s -> State# s
6844++ {Write contents of {\tt MutVar\#}.}
6846++ -- See Note [Why MutVar# ops can't fail]
6847++ has_side_effects = True
6848++ code_size = { primOpCodeSizeForeignCall } -- for the write barrier
6850++primop SameMutVarOp "sameMutVar#" GenPrimOp
6851++ MutVar# s a -> MutVar# s a -> Int#
6853++-- Note [Why not an unboxed tuple in atomicModifyMutVar#?]
6854++-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6856++-- Looking at the type of atomicModifyMutVar#, one might wonder why
6857++-- it doesn't return an unboxed tuple. e.g.,
6859++-- MutVar# s a -> (a -> (# a, b #)) -> State# s -> (# State# s, b #)
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.
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. }
6873++ out_of_line = True
6874++ has_side_effects = True
6877++primop CasMutVarOp "casMutVar#" GenPrimOp
6878++ MutVar# s a -> a -> a -> State# s -> (# State# s, Int#, a #)
6880++ out_of_line = True
6881++ has_side_effects = True
6883++------------------------------------------------------------------------
6884++section "Exceptions"
6885++------------------------------------------------------------------------
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
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.
6897++-- For catch, catchSTM, and catchRetry, we must be extra careful; see
6898++-- Note [Exceptions and strictness] in Demand
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 #)
6906++ strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
6908++ , topDmd] topRes }
6909++ -- See Note [Strictness for mask/unmask/catch]
6910++ out_of_line = True
6911++ has_side_effects = True
6913++primop RaiseOp "raise#" GenPrimOp
6915++ -- NB: the type variable "o" is "a", but with OpenKind
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.
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.
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
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).
6943++primop RaiseIOOp "raiseIO#" GenPrimOp
6944++ a -> State# RealWorld -> (# State# RealWorld, b #)
6946++ strictness = { \ _arity -> mkClosedStrictSig [topDmd, topDmd] exnRes }
6947++ out_of_line = True
6948++ has_side_effects = True
6950++primop MaskAsyncExceptionsOp "maskAsyncExceptions#" GenPrimOp
6951++ (State# RealWorld -> (# State# RealWorld, a #))
6952++ -> (State# RealWorld -> (# State# RealWorld, a #))
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
6959++primop MaskUninterruptibleOp "maskUninterruptible#" GenPrimOp
6960++ (State# RealWorld -> (# State# RealWorld, a #))
6961++ -> (State# RealWorld -> (# State# RealWorld, a #))
6963++ strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
6964++ out_of_line = True
6965++ has_side_effects = True
6967++primop UnmaskAsyncExceptionsOp "unmaskAsyncExceptions#" GenPrimOp
6968++ (State# RealWorld -> (# State# RealWorld, a #))
6969++ -> (State# RealWorld -> (# State# RealWorld, a #))
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
6976++primop MaskStatus "getMaskingState#" GenPrimOp
6977++ State# RealWorld -> (# State# RealWorld, Int# #)
6979++ out_of_line = True
6980++ has_side_effects = True
6982++------------------------------------------------------------------------
6983++section "STM-accessible Mutable Variables"
6984++------------------------------------------------------------------------
6988++primop AtomicallyOp "atomically#" GenPrimOp
6989++ (State# RealWorld -> (# State# RealWorld, a #) )
6990++ -> State# RealWorld -> (# State# RealWorld, a #)
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
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.
7001++-- This allows the simplifier to replace things like:
7003++-- (# s2, a #) -> e
7006++-- where 'e' would be unreachable anyway. See Trac #8091.
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 #)
7013++ strictness = { \ _arity -> mkClosedStrictSig [topDmd] exnRes }
7014++ out_of_line = True
7015++ has_side_effects = True
7017++primop CatchRetryOp "catchRetry#" GenPrimOp
7018++ (State# RealWorld -> (# State# RealWorld, a #) )
7019++ -> (State# RealWorld -> (# State# RealWorld, a #) )
7020++ -> (State# RealWorld -> (# State# RealWorld, a #) )
7022++ strictness = { \ _arity -> mkClosedStrictSig [ catchArgDmd
7024++ , topDmd ] topRes }
7025++ -- See Note [Strictness for mask/unmask/catch]
7026++ out_of_line = True
7027++ has_side_effects = True
7029++primop CatchSTMOp "catchSTM#" GenPrimOp
7030++ (State# RealWorld -> (# State# RealWorld, a #) )
7031++ -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
7032++ -> (State# RealWorld -> (# State# RealWorld, a #) )
7034++ strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
7036++ , topDmd ] topRes }
7037++ -- See Note [Strictness for mask/unmask/catch]
7038++ out_of_line = True
7039++ has_side_effects = True
7041++primop Check "check#" GenPrimOp
7042++ (State# RealWorld -> (# State# RealWorld, a #) )
7043++ -> (State# RealWorld -> State# RealWorld)
7045++ out_of_line = True
7046++ has_side_effects = True
7048++primop NewTVarOp "newTVar#" GenPrimOp
7050++ -> State# s -> (# State# s, TVar# s a #)
7051++ {Create a new {\tt TVar\#} holding a specified initial value.}
7053++ out_of_line = True
7054++ has_side_effects = True
7056++primop ReadTVarOp "readTVar#" GenPrimOp
7058++ -> State# s -> (# State# s, a #)
7059++ {Read contents of {\tt TVar\#}. Result is not yet evaluated.}
7061++ out_of_line = True
7062++ has_side_effects = True
7064++primop ReadTVarIOOp "readTVarIO#" GenPrimOp
7066++ -> State# s -> (# State# s, a #)
7067++ {Read contents of {\tt TVar\#} outside an STM transaction}
7069++ out_of_line = True
7070++ has_side_effects = True
7072++primop WriteTVarOp "writeTVar#" GenPrimOp
7075++ -> State# s -> State# s
7076++ {Write contents of {\tt TVar\#}.}
7078++ out_of_line = True
7079++ has_side_effects = True
7081++primop SameTVarOp "sameTVar#" GenPrimOp
7082++ TVar# s a -> TVar# s a -> Int#
7085++------------------------------------------------------------------------
7086++section "Synchronized Mutable Variables"
7087++ {Operations on {\tt MVar\#}s. }
7088++------------------------------------------------------------------------
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))}.) }
7095++primop NewMVarOp "newMVar#" GenPrimOp
7096++ State# s -> (# State# s, MVar# s a #)
7097++ {Create new {\tt MVar\#}; initially empty.}
7099++ out_of_line = True
7100++ has_side_effects = True
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.}
7107++ out_of_line = True
7108++ has_side_effects = True
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.}
7115++ out_of_line = True
7116++ has_side_effects = True
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.}
7123++ out_of_line = True
7124++ has_side_effects = True
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.}
7131++ out_of_line = True
7132++ has_side_effects = True
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.}
7140++ out_of_line = True
7141++ has_side_effects = True
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\#}.}
7148++ out_of_line = True
7149++ has_side_effects = True
7151++primop SameMVarOp "sameMVar#" GenPrimOp
7152++ MVar# s a -> MVar# s a -> Int#
7154++primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
7155++ MVar# s a -> State# s -> (# State# s, Int# #)
7156++ {Return 1 if {\tt MVar\#} is empty; 0 otherwise.}
7158++ out_of_line = True
7159++ has_side_effects = True
7161++------------------------------------------------------------------------
7162++section "Delay/wait operations"
7163++------------------------------------------------------------------------
7165++primop DelayOp "delay#" GenPrimOp
7166++ Int# -> State# s -> State# s
7167++ {Sleep specified number of microseconds.}
7169++ has_side_effects = True
7170++ out_of_line = True
7172++primop WaitReadOp "waitRead#" GenPrimOp
7173++ Int# -> State# s -> State# s
7174++ {Block until input is available on specified file descriptor.}
7176++ has_side_effects = True
7177++ out_of_line = True
7179++primop WaitWriteOp "waitWrite#" GenPrimOp
7180++ Int# -> State# s -> State# s
7181++ {Block until output is possible on specified file descriptor.}
7183++ has_side_effects = True
7184++ out_of_line = True
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.}
7191++ has_side_effects = True
7192++ out_of_line = True
7194++primop AsyncWriteOp "asyncWrite#" GenPrimOp
7195++ Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
7196++ {Asynchronously write bytes from specified file descriptor.}
7198++ has_side_effects = True
7199++ out_of_line = True
7201++primop AsyncDoProcOp "asyncDoProc#" GenPrimOp
7202++ Addr# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
7203++ {Asynchronously perform procedure (first arg), passing it 2nd arg.}
7205++ has_side_effects = True
7206++ out_of_line = True
7210++------------------------------------------------------------------------
7211++section "Concurrency primitives"
7212++------------------------------------------------------------------------
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
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\#}. }
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.)}
7231++primop ForkOp "fork#" GenPrimOp
7232++ a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
7234++ has_side_effects = True
7235++ out_of_line = True
7237++primop ForkOnOp "forkOn#" GenPrimOp
7238++ Int# -> a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
7240++ has_side_effects = True
7241++ out_of_line = True
7243++primop KillThreadOp "killThread#" GenPrimOp
7244++ ThreadId# -> a -> State# RealWorld -> State# RealWorld
7246++ has_side_effects = True
7247++ out_of_line = True
7249++primop YieldOp "yield#" GenPrimOp
7250++ State# RealWorld -> State# RealWorld
7252++ has_side_effects = True
7253++ out_of_line = True
7255++primop MyThreadIdOp "myThreadId#" GenPrimOp
7256++ State# RealWorld -> (# State# RealWorld, ThreadId# #)
7258++ out_of_line = True
7259++ has_side_effects = True
7261++primop LabelThreadOp "labelThread#" GenPrimOp
7262++ ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
7264++ has_side_effects = True
7265++ out_of_line = True
7267++primop IsCurrentThreadBoundOp "isCurrentThreadBound#" GenPrimOp
7268++ State# RealWorld -> (# State# RealWorld, Int# #)
7270++ out_of_line = True
7271++ has_side_effects = True
7273++primop NoDuplicateOp "noDuplicate#" GenPrimOp
7274++ State# s -> State# s
7276++ out_of_line = True
7277++ has_side_effects = True
7279++primop ThreadStatusOp "threadStatus#" GenPrimOp
7280++ ThreadId# -> State# RealWorld -> (# State# RealWorld, Int#, Int#, Int# #)
7282++ out_of_line = True
7283++ has_side_effects = True
7285++------------------------------------------------------------------------
7286++section "Weak pointers"
7287++------------------------------------------------------------------------
7291++-- note that tyvar "o" denotes openAlphaTyVar
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}). }
7302++ has_side_effects = True
7303++ out_of_line = True
7305++primop MkWeakNoFinalizerOp "mkWeakNoFinalizer#" GenPrimOp
7306++ o -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #)
7308++ has_side_effects = True
7309++ out_of_line = True
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. }
7321++ has_side_effects = True
7322++ out_of_line = True
7324++primop DeRefWeakOp "deRefWeak#" GenPrimOp
7325++ Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
7327++ has_side_effects = True
7328++ out_of_line = True
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. }
7339++ has_side_effects = True
7340++ out_of_line = True
7342++primop TouchOp "touch#" GenPrimOp
7343++ o -> State# RealWorld -> State# RealWorld
7346++ has_side_effects = True
7348++------------------------------------------------------------------------
7349++section "Stable pointers and names"
7350++------------------------------------------------------------------------
7352++primtype StablePtr# a
7354++primtype StableName# a
7356++primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
7357++ a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
7359++ has_side_effects = True
7360++ out_of_line = True
7362++primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
7363++ StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
7365++ has_side_effects = True
7366++ out_of_line = True
7368++primop EqStablePtrOp "eqStablePtr#" GenPrimOp
7369++ StablePtr# a -> StablePtr# a -> Int#
7371++ has_side_effects = True
7373++primop MakeStableNameOp "makeStableName#" GenPrimOp
7374++ a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
7376++ has_side_effects = True
7377++ out_of_line = True
7379++primop EqStableNameOp "eqStableName#" GenPrimOp
7380++ StableName# a -> StableName# b -> Int#
7382++primop StableNameToIntOp "stableNameToInt#" GenPrimOp
7383++ StableName# a -> Int#
7385++------------------------------------------------------------------------
7386++section "Compact normal form"
7387++------------------------------------------------------------------------
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. }
7397++ has_side_effects = True
7398++ out_of_line = True
7400++primop CompactResizeOp "compactResize#" GenPrimOp
7401++ Compact# -> Word# -> 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. }
7406++ has_side_effects = True
7407++ out_of_line = True
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. }
7413++ out_of_line = True
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. }
7419++ out_of_line = True
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
7426++ out_of_line = True
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. }
7434++ out_of_line = True
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.
7447++ has_side_effects = True
7448++ out_of_line = True
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. }
7460++ has_side_effects = True
7461++ out_of_line = True
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
7473++ has_side_effects = True
7474++ out_of_line = True
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. }
7481++ has_side_effects = True
7482++ out_of_line = True
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# }
7488++ has_side_effects = True
7489++ out_of_line = True
7491++------------------------------------------------------------------------
7492++section "Unsafe pointer equality"
7493++-- (#1 Bad Guy: Alastair Reid :)
7494++------------------------------------------------------------------------
7496++primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
7498++ { Returns {\texttt 1\#} if the given pointers are equal and {\texttt 0\#} otherwise. }
7500++ can_fail = True -- See Note [reallyUnsafePtrEquality#]
7503++-- Note [reallyUnsafePtrEquality#]
7504++-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
7518++-- \x y . case x of x'
7522++-- let eq = reallyUnsafePtrEquality# x' y'
7525++-- If the let floats out, we'll get
7527++-- \x y . let eq = reallyUnsafePtrEquality# x y
7528++-- in case x of ...
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.
7534++------------------------------------------------------------------------
7535++section "Parallelism"
7536++------------------------------------------------------------------------
7538++primop ParOp "par#" GenPrimOp
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 }
7546++primop SparkOp "spark#" GenPrimOp
7547++ a -> State# s -> (# State# s, a #)
7548++ with has_side_effects = True
7549++ code_size = { primOpCodeSizeForeignCall }
7551++primop SeqOp "seq#" GenPrimOp
7552++ a -> State# s -> (# State# s, a #)
7553++ -- See Note [seq# magic] in PrelRules
7555++primop GetSparkOp "getSpark#" GenPrimOp
7556++ State# s -> (# State# s, Int#, a #)
7558++ has_side_effects = True
7559++ out_of_line = True
7561++primop NumSparks "numSparks#" GenPrimOp
7562++ State# s -> (# State# s, Int# #)
7563++ { Returns the number of sparks in the local spark pool. }
7565++ has_side_effects = True
7566++ out_of_line = True
7568++------------------------------------------------------------------------
7569++section "Tag to enum stuff"
7570++ {Convert back and forth between values of enumerated types
7571++ and small integers.}
7572++------------------------------------------------------------------------
7574++primop DataToTagOp "dataToTag#" GenPrimOp
7575++ a -> Int# -- Zero-indexed; the first constructor has tag zero
7577++ can_fail = True -- See Note [dataToTag#]
7578++ strictness = { \ _arity -> mkClosedStrictSig [evalDmd] topRes }
7579++ -- dataToTag# must have an evaluated argument
7581++primop TagToEnumOp "tagToEnum#" GenPrimOp
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
7592++ \z. case x of y -> let v = dataToTag# y in ...
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 ...
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].)
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.
7608++------------------------------------------------------------------------
7609++section "Bytecode operations"
7610++ {Support for manipulating bytecode objects used by the interpreter and
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++------------------------------------------------------------------------
7618++ { Primitive bytecode type. }
7620++primop AddrToAnyOp "addrToAny#" GenPrimOp
7622++ { Convert an {\tt Addr\#} to a followable Any type. }
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.}
7641++primop MkApUpd0_Op "mkApUpd0#" GenPrimOp
7643++ { Wrap a BCO in a {\tt AP_UPD} thunk which will be updated with the value of
7644++ the BCO when evaluated. }
7646++ out_of_line = True
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
7655++ has_side_effects = True
7656++ out_of_line = True
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
7666++ out_of_line = True
7668++primop GetApStackValOp "getApStackVal#" GenPrimOp
7669++ a -> Int# -> (# Int#, b #)
7671++ out_of_line = True
7673++------------------------------------------------------------------------
7675++ {These aren't nearly as wired in as Etc...}
7676++------------------------------------------------------------------------
7678++primop GetCCSOfOp "getCCSOf#" GenPrimOp
7679++ a -> State# s -> (# State# s, Addr# #)
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
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. }
7695++ out_of_line = True
7697++------------------------------------------------------------------------
7699++ {Miscellaneous built-ins}
7700++------------------------------------------------------------------------
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. }
7711++ { Witness for an unboxed {\tt Proxy#} value, which has no runtime
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.
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. }
7729++pseudoop "unsafeCoerce#"
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.
7737++ The following uses of {\tt unsafeCoerce\#} are supposed to work (i.e. not lead to
7738++ spurious compile-time or run-time crashes):
7740++ * Casting any lifted type to {\tt Any}
7742++ * Casting {\tt Any} back to the real type
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.)
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}.
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.
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) -> ...".
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. }
7779++ has_side_effects = True
7780++ out_of_line = True
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. }
7789++ has_side_effects = True
7790++ out_of_line = True
7792++------------------------------------------------------------------------
7793++section "Safe coercions"
7794++------------------------------------------------------------------------
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
7806++------------------------------------------------------------------------
7807++section "SIMD Vectors"
7808++ {Operations on SIMD vectors.}
7809++------------------------------------------------------------------------
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>]
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>]
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>]
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>]
7844++ with llvm_only = True
7845++ vector = ALL_VECTOR_TYPES
7847++primop VecBroadcastOp "broadcast#" GenPrimOp
7849++ { Broadcast a scalar to all elements of a vector. }
7850++ with llvm_only = True
7851++ vector = ALL_VECTOR_TYPES
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
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
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
7870++ vector = ALL_VECTOR_TYPES
7872++primop VecAddOp "plus#" Dyadic
7873++ VECTOR -> VECTOR -> VECTOR
7874++ { Add two vectors element-wise. }
7875++ with commutable = True
7877++ vector = ALL_VECTOR_TYPES
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
7885++primop VecMulOp "times#" Dyadic
7886++ VECTOR -> VECTOR -> VECTOR
7887++ { Multiply two vectors element-wise. }
7888++ with commutable = True
7890++ vector = ALL_VECTOR_TYPES
7892++primop VecDivOp "divide#" Dyadic
7893++ VECTOR -> VECTOR -> VECTOR
7894++ { Divide two vectors element-wise. }
7895++ with can_fail = True
7897++ vector = FLOAT_VECTOR_TYPES
7899++primop VecQuotOp "quot#" Dyadic
7900++ VECTOR -> VECTOR -> VECTOR
7901++ { Rounds towards zero element-wise. }
7902++ with can_fail = True
7904++ vector = INT_VECTOR_TYPES
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
7911++ vector = INT_VECTOR_TYPES
7913++primop VecNegOp "negate#" Monadic
7915++ { Negate element-wise. }
7916++ with llvm_only = True
7917++ vector = SIGNED_VECTOR_TYPES
7919++primop VecIndexByteArrayOp "indexArray#" GenPrimOp
7920++ ByteArray# -> Int# -> VECTOR
7921++ { Read a vector from specified index of immutable array. }
7922++ with can_fail = True
7924++ vector = ALL_VECTOR_TYPES
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
7932++ vector = ALL_VECTOR_TYPES
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
7940++ vector = ALL_VECTOR_TYPES
7942++primop VecIndexOffAddrOp "indexOffAddr#" GenPrimOp
7943++ Addr# -> Int# -> VECTOR
7944++ { Reads vector; offset in bytes. }
7945++ with can_fail = True
7947++ vector = ALL_VECTOR_TYPES
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
7955++ vector = ALL_VECTOR_TYPES
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
7963++ vector = ALL_VECTOR_TYPES
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
7971++ vector = ALL_VECTOR_TYPES
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
7979++ vector = ALL_VECTOR_TYPES
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
7987++ vector = ALL_VECTOR_TYPES
7989++primop VecIndexScalarOffAddrOp "indexOffAddrAs#" GenPrimOp
7990++ Addr# -> Int# -> VECTOR
7991++ { Reads vector; offset in scalar elements. }
7992++ with can_fail = True
7994++ vector = ALL_VECTOR_TYPES
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
8002++ vector = ALL_VECTOR_TYPES
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
8010++ vector = ALL_VECTOR_TYPES
8012++------------------------------------------------------------------------
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.
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.
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.
8029++ On the Sparc and PPC native backends, prefetch*N is a No-Op.
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.
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.
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.
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 .
8049++ The {\tt prefetch*} family of operations has the order of operations
8050++ determined by passing around the {\tt State#} token.
8052++ To get a "pure" version of these operations, use {\tt inlinePerformIO} which is quite safe in this context.
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.
8066++------------------------------------------------------------------------
8069++--- the Int# argument for prefetch is the byte offset on the byteArray or Addr#
8072++primop PrefetchByteArrayOp3 "prefetchByteArray3#" GenPrimOp
8073++ ByteArray# -> Int# -> State# s -> State# s
8074++ with has_side_effects = True
8076++primop PrefetchMutableByteArrayOp3 "prefetchMutableByteArray3#" GenPrimOp
8077++ MutableByteArray# s -> Int# -> State# s -> State# s
8078++ with has_side_effects = True
8080++primop PrefetchAddrOp3 "prefetchAddr3#" GenPrimOp
8081++ Addr# -> Int# -> State# s -> State# s
8082++ with has_side_effects = True
8084++primop PrefetchValueOp3 "prefetchValue3#" GenPrimOp
8085++ a -> State# s -> State# s
8086++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8087++ has_side_effects = True
8090++primop PrefetchByteArrayOp2 "prefetchByteArray2#" GenPrimOp
8091++ ByteArray# -> Int# -> State# s -> State# s
8092++ with has_side_effects = True
8094++primop PrefetchMutableByteArrayOp2 "prefetchMutableByteArray2#" GenPrimOp
8095++ MutableByteArray# s -> Int# -> State# s -> State# s
8096++ with has_side_effects = True
8098++primop PrefetchAddrOp2 "prefetchAddr2#" GenPrimOp
8099++ Addr# -> Int# -> State# s -> State# s
8100++ with has_side_effects = True
8102++primop PrefetchValueOp2 "prefetchValue2#" GenPrimOp
8103++ a -> State# s -> State# s
8104++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8105++ has_side_effects = True
8108++primop PrefetchByteArrayOp1 "prefetchByteArray1#" GenPrimOp
8109++ ByteArray# -> Int# -> State# s -> State# s
8110++ with has_side_effects = True
8112++primop PrefetchMutableByteArrayOp1 "prefetchMutableByteArray1#" GenPrimOp
8113++ MutableByteArray# s -> Int# -> State# s -> State# s
8114++ with has_side_effects = True
8116++primop PrefetchAddrOp1 "prefetchAddr1#" GenPrimOp
8117++ Addr# -> Int# -> State# s -> State# s
8118++ with has_side_effects = True
8120++primop PrefetchValueOp1 "prefetchValue1#" GenPrimOp
8121++ a -> State# s -> State# s
8122++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8123++ has_side_effects = True
8126++primop PrefetchByteArrayOp0 "prefetchByteArray0#" GenPrimOp
8127++ ByteArray# -> Int# -> State# s -> State# s
8128++ with has_side_effects = True
8130++primop PrefetchMutableByteArrayOp0 "prefetchMutableByteArray0#" GenPrimOp
8131++ MutableByteArray# s -> Int# -> State# s -> State# s
8132++ with has_side_effects = True
8134++primop PrefetchAddrOp0 "prefetchAddr0#" GenPrimOp
8135++ Addr# -> Int# -> State# s -> State# s
8136++ with has_side_effects = True
8138++primop PrefetchValueOp0 "prefetchValue0#" GenPrimOp
8139++ a -> State# s -> State# s
8140++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8141++ has_side_effects = True
8143++------------------------------------------------------------------------
8145++------------------------------------------------------------------------
8148+diff --git a/rts/build/HsVersions.h b/rts/build/HsVersions.h
8149+new file mode 100644
8150+index 0000000..a4ec3e4
8152++++ b/rts/build/HsVersions.h
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!
8161++(This is cpp-dependent, of course)
8165++/* Useful in the headers that we share with the RTS */
8166++#define COMPILING_GHC 1
8168++/* Pull in all the platform defines for this build (foo_TARGET_ARCH etc.) */
8169++#include "ghc_boot_platform.h"
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"
8177++#define GLOBAL_VAR(name,value,ty) \
8178++{-# NOINLINE name #-}; \
8179++name :: IORef (ty); \
8180++name = Util.global (value);
8182++#define GLOBAL_VAR_M(name,value,ty) \
8183++{-# NOINLINE name #-}; \
8184++name :: IORef (ty); \
8185++name = Util.globalM (value);
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));
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));
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)) $
8207++-- Examples: Assuming flagSet :: String -> m Bool
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
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)))
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' >> $@
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' >> $@
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)
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' >> $@
8282++ @echo 'cGhcRtsWithLibdw = False' >> $@
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' >> $@
8296++ @echo 'cLibFFI = False' >> $@
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' >> $@
8306++ @echo 'cGhcThreaded = False' >> $@
8308++ @echo 'cGhcDebugged :: Bool' >> $@
8309++ifeq "$(GhcDebugged)" "YES"
8310++ @echo 'cGhcDebugged = True' >> $@
8312++ @echo 'cGhcDebugged = False' >> $@
8316+ # -----------------------------------------------------------------------------
8317+ # Defining the sources
8319+diff --git a/rts/rts.cabal b/rts/rts.cabal
8320+index f8f1e2e..52c3a4f 100644
8323+@@ -7,7 +7,7 @@ build-type: Simple
8332+@@ -23,7 +23,7 @@ flag libdw
8335+ flag leading-underscore
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
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
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"
8376+ -- Needed for TAG_BITS
8377+-#include "../../includes/MachDeps.h"
8378++#include "MachDeps.h"
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" #-}
8396+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
8400+@@ -960,6 +958,8 @@ parse = run_parser parsex
8404++{-# LINE 19 "<built-in>" #-}
8405++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
8409+@@ -991,8 +991,6 @@ parse = run_parser parsex
8413+-{-# LINE 11 "<command-line>" #-}
8414+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
8418+@@ -1008,8 +1006,6 @@ parse = run_parser parsex
8422+-{-# LINE 11 "<command-line>" #-}
8423+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
8427+@@ -1145,52 +1141,7 @@ parse = run_parser parsex
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
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)
8486+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
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
8494+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
8497+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
8499+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
8509+ infixr 9 `HappyStk`
8510+ data HappyStk a = HappyStk a (HappyStk a)
8511+@@ -1258,7 +1219,7 @@ happyAccept j tk st sts (HappyStk ans _) =
8513+ happyDoAction i tk st
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 -}
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#))))))
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)
8539+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
8541+ -----------------------------------------------------------------------------
8542+@@ -1481,3 +1443,4 @@ happyDontSeq a b = b
8543+ {-# NOINLINE happyFail #-}
8545+ -- end of Happy Template.
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" #-}
8561+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
8565+@@ -429,6 +427,8 @@ happyError e = error $ show (take 10 e)
8569++{-# LINE 19 "<built-in>" #-}
8570++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
8574+@@ -460,8 +460,6 @@ happyError e = error $ show (take 10 e)
8578+-{-# LINE 11 "<command-line>" #-}
8579+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
8583+@@ -477,8 +475,6 @@ happyError e = error $ show (take 10 e)
8587+-{-# LINE 11 "<command-line>" #-}
8588+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
8592+@@ -614,52 +610,7 @@ happyError e = error $ show (take 10 e)
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
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)
8651+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
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
8659+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
8662+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
8664+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
8674+ infixr 9 `HappyStk`
8675+ data HappyStk a = HappyStk a (HappyStk a)
8676+@@ -727,7 +688,7 @@ happyAccept j tk st sts (HappyStk ans _) =
8678+ happyDoAction i tk st
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 -}
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#))))))
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)
8704+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
8706+ -----------------------------------------------------------------------------
8707+@@ -950,3 +912,4 @@ happyDontSeq a b = b
8708+ {-# NOINLINE happyFail #-}
8710+ -- end of Happy Template.