diff options
Diffstat (limited to 'compiler')
26 files changed, 1319 insertions, 39 deletions
diff --git a/compiler/CodeGen.Platform.h b/compiler/CodeGen.Platform.h new file mode 100644 index 0000000000..721648a900 --- /dev/null +++ b/compiler/CodeGen.Platform.h @@ -0,0 +1,1259 @@ + +import GHC.Cmm.Expr +#if !(defined(MACHREGS_i386) || defined(MACHREGS_x86_64) \ + || defined(MACHREGS_sparc) || defined(MACHREGS_powerpc) \ + || defined(MACHREGS_aarch64)) +import GHC.Utils.Panic.Plain +#endif +import GHC.Platform.Reg + +#include "MachRegs.h" + +#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64) + +# if defined(MACHREGS_i386) +# define eax 0 +# define ebx 1 +# define ecx 2 +# define edx 3 +# define esi 4 +# define edi 5 +# define ebp 6 +# define esp 7 +# endif + +# if defined(MACHREGS_x86_64) +# define rax 0 +# define rbx 1 +# define rcx 2 +# define rdx 3 +# define rsi 4 +# define rdi 5 +# define rbp 6 +# define rsp 7 +# define r8 8 +# define r9 9 +# define r10 10 +# define r11 11 +# define r12 12 +# define r13 13 +# define r14 14 +# define r15 15 +# endif + + +-- N.B. XMM, YMM, and ZMM are all aliased to the same hardware registers hence +-- being assigned the same RegNos. +# define xmm0 16 +# define xmm1 17 +# define xmm2 18 +# define xmm3 19 +# define xmm4 20 +# define xmm5 21 +# define xmm6 22 +# define xmm7 23 +# define xmm8 24 +# define xmm9 25 +# define xmm10 26 +# define xmm11 27 +# define xmm12 28 +# define xmm13 29 +# define xmm14 30 +# define xmm15 31 + +# define ymm0 16 +# define ymm1 17 +# define ymm2 18 +# define ymm3 19 +# define ymm4 20 +# define ymm5 21 +# define ymm6 22 +# define ymm7 23 +# define ymm8 24 +# define ymm9 25 +# define ymm10 26 +# define ymm11 27 +# define ymm12 28 +# define ymm13 29 +# define ymm14 30 +# define ymm15 31 + +# define zmm0 16 +# define zmm1 17 +# define zmm2 18 +# define zmm3 19 +# define zmm4 20 +# define zmm5 21 +# define zmm6 22 +# define zmm7 23 +# define zmm8 24 +# define zmm9 25 +# define zmm10 26 +# define zmm11 27 +# define zmm12 28 +# define zmm13 29 +# define zmm14 30 +# define zmm15 31 + +-- Note: these are only needed for ARM/AArch64 because globalRegMaybe is now used in CmmSink.hs. +-- Since it's only used to check 'isJust', the actual values don't matter, thus +-- I'm not sure if these are the correct numberings. +-- Normally, the register names are just stringified as part of the REG() macro + +#elif defined(MACHREGS_powerpc) || defined(MACHREGS_arm) \ + || defined(MACHREGS_aarch64) + +# define r0 0 +# define r1 1 +# define r2 2 +# define r3 3 +# define r4 4 +# define r5 5 +# define r6 6 +# define r7 7 +# define r8 8 +# define r9 9 +# define r10 10 +# define r11 11 +# define r12 12 +# define r13 13 +# define r14 14 +# define r15 15 +# define r16 16 +# define r17 17 +# define r18 18 +# define r19 19 +# define r20 20 +# define r21 21 +# define r22 22 +# define r23 23 +# define r24 24 +# define r25 25 +# define r26 26 +# define r27 27 +# define r28 28 +# define r29 29 +# define r30 30 +# define r31 31 + +-- See note above. These aren't actually used for anything except satisfying the compiler for globalRegMaybe +-- so I'm unsure if they're the correct numberings, should they ever be attempted to be used in the NCG. +#if defined(MACHREGS_aarch64) || defined(MACHREGS_arm) +# define s0 32 +# define s1 33 +# define s2 34 +# define s3 35 +# define s4 36 +# define s5 37 +# define s6 38 +# define s7 39 +# define s8 40 +# define s9 41 +# define s10 42 +# define s11 43 +# define s12 44 +# define s13 45 +# define s14 46 +# define s15 47 +# define s16 48 +# define s17 49 +# define s18 50 +# define s19 51 +# define s20 52 +# define s21 53 +# define s22 54 +# define s23 55 +# define s24 56 +# define s25 57 +# define s26 58 +# define s27 59 +# define s28 60 +# define s29 61 +# define s30 62 +# define s31 63 + +# define d0 32 +# define d1 33 +# define d2 34 +# define d3 35 +# define d4 36 +# define d5 37 +# define d6 38 +# define d7 39 +# define d8 40 +# define d9 41 +# define d10 42 +# define d11 43 +# define d12 44 +# define d13 45 +# define d14 46 +# define d15 47 +# define d16 48 +# define d17 49 +# define d18 50 +# define d19 51 +# define d20 52 +# define d21 53 +# define d22 54 +# define d23 55 +# define d24 56 +# define d25 57 +# define d26 58 +# define d27 59 +# define d28 60 +# define d29 61 +# define d30 62 +# define d31 63 +#endif + +# if defined(MACHREGS_darwin) +# define f0 32 +# define f1 33 +# define f2 34 +# define f3 35 +# define f4 36 +# define f5 37 +# define f6 38 +# define f7 39 +# define f8 40 +# define f9 41 +# define f10 42 +# define f11 43 +# define f12 44 +# define f13 45 +# define f14 46 +# define f15 47 +# define f16 48 +# define f17 49 +# define f18 50 +# define f19 51 +# define f20 52 +# define f21 53 +# define f22 54 +# define f23 55 +# define f24 56 +# define f25 57 +# define f26 58 +# define f27 59 +# define f28 60 +# define f29 61 +# define f30 62 +# define f31 63 +# else +# define fr0 32 +# define fr1 33 +# define fr2 34 +# define fr3 35 +# define fr4 36 +# define fr5 37 +# define fr6 38 +# define fr7 39 +# define fr8 40 +# define fr9 41 +# define fr10 42 +# define fr11 43 +# define fr12 44 +# define fr13 45 +# define fr14 46 +# define fr15 47 +# define fr16 48 +# define fr17 49 +# define fr18 50 +# define fr19 51 +# define fr20 52 +# define fr21 53 +# define fr22 54 +# define fr23 55 +# define fr24 56 +# define fr25 57 +# define fr26 58 +# define fr27 59 +# define fr28 60 +# define fr29 61 +# define fr30 62 +# define fr31 63 +# endif + +#elif defined(MACHREGS_sparc) + +# define g0 0 +# define g1 1 +# define g2 2 +# define g3 3 +# define g4 4 +# define g5 5 +# define g6 6 +# define g7 7 + +# define o0 8 +# define o1 9 +# define o2 10 +# define o3 11 +# define o4 12 +# define o5 13 +# define o6 14 +# define o7 15 + +# define l0 16 +# define l1 17 +# define l2 18 +# define l3 19 +# define l4 20 +# define l5 21 +# define l6 22 +# define l7 23 + +# define i0 24 +# define i1 25 +# define i2 26 +# define i3 27 +# define i4 28 +# define i5 29 +# define i6 30 +# define i7 31 + +# define f0 32 +# define f1 33 +# define f2 34 +# define f3 35 +# define f4 36 +# define f5 37 +# define f6 38 +# define f7 39 +# define f8 40 +# define f9 41 +# define f10 42 +# define f11 43 +# define f12 44 +# define f13 45 +# define f14 46 +# define f15 47 +# define f16 48 +# define f17 49 +# define f18 50 +# define f19 51 +# define f20 52 +# define f21 53 +# define f22 54 +# define f23 55 +# define f24 56 +# define f25 57 +# define f26 58 +# define f27 59 +# define f28 60 +# define f29 61 +# define f30 62 +# define f31 63 + +#elif defined(MACHREGS_s390x) + +# define r0 0 +# define r1 1 +# define r2 2 +# define r3 3 +# define r4 4 +# define r5 5 +# define r6 6 +# define r7 7 +# define r8 8 +# define r9 9 +# define r10 10 +# define r11 11 +# define r12 12 +# define r13 13 +# define r14 14 +# define r15 15 + +# define f0 16 +# define f1 17 +# define f2 18 +# define f3 19 +# define f4 20 +# define f5 21 +# define f6 22 +# define f7 23 +# define f8 24 +# define f9 25 +# define f10 26 +# define f11 27 +# define f12 28 +# define f13 29 +# define f14 30 +# define f15 31 + +#elif defined(MACHREGS_riscv64) + +# define zero 0 +# define ra 1 +# define sp 2 +# define gp 3 +# define tp 4 +# define t0 5 +# define t1 6 +# define t2 7 +# define s0 8 +# define s1 9 +# define a0 10 +# define a1 11 +# define a2 12 +# define a3 13 +# define a4 14 +# define a5 15 +# define a6 16 +# define a7 17 +# define s2 18 +# define s3 19 +# define s4 20 +# define s5 21 +# define s6 22 +# define s7 23 +# define s8 24 +# define s9 25 +# define s10 26 +# define s11 27 +# define t3 28 +# define t4 29 +# define t5 30 +# define t6 31 + +# define ft0 32 +# define ft1 33 +# define ft2 34 +# define ft3 35 +# define ft4 36 +# define ft5 37 +# define ft6 38 +# define ft7 39 +# define fs0 40 +# define fs1 41 +# define fa0 42 +# define fa1 43 +# define fa2 44 +# define fa3 45 +# define fa4 46 +# define fa5 47 +# define fa6 48 +# define fa7 49 +# define fs2 50 +# define fs3 51 +# define fs4 52 +# define fs5 53 +# define fs6 54 +# define fs7 55 +# define fs8 56 +# define fs9 57 +# define fs10 58 +# define fs11 59 +# define ft8 60 +# define ft9 61 +# define ft10 62 +# define ft11 63 + +#endif + +callerSaves :: GlobalReg -> Bool +#if defined(CALLER_SAVES_Base) +callerSaves BaseReg = True +#endif +#if defined(CALLER_SAVES_R1) +callerSaves (VanillaReg 1 _) = True +#endif +#if defined(CALLER_SAVES_R2) +callerSaves (VanillaReg 2 _) = True +#endif +#if defined(CALLER_SAVES_R3) +callerSaves (VanillaReg 3 _) = True +#endif +#if defined(CALLER_SAVES_R4) +callerSaves (VanillaReg 4 _) = True +#endif +#if defined(CALLER_SAVES_R5) +callerSaves (VanillaReg 5 _) = True +#endif +#if defined(CALLER_SAVES_R6) +callerSaves (VanillaReg 6 _) = True +#endif +#if defined(CALLER_SAVES_R7) +callerSaves (VanillaReg 7 _) = True +#endif +#if defined(CALLER_SAVES_R8) +callerSaves (VanillaReg 8 _) = True +#endif +#if defined(CALLER_SAVES_R9) +callerSaves (VanillaReg 9 _) = True +#endif +#if defined(CALLER_SAVES_R10) +callerSaves (VanillaReg 10 _) = True +#endif +#if defined(CALLER_SAVES_F1) +callerSaves (FloatReg 1) = True +#endif +#if defined(CALLER_SAVES_F2) +callerSaves (FloatReg 2) = True +#endif +#if defined(CALLER_SAVES_F3) +callerSaves (FloatReg 3) = True +#endif +#if defined(CALLER_SAVES_F4) +callerSaves (FloatReg 4) = True +#endif +#if defined(CALLER_SAVES_F5) +callerSaves (FloatReg 5) = True +#endif +#if defined(CALLER_SAVES_F6) +callerSaves (FloatReg 6) = True +#endif +#if defined(CALLER_SAVES_D1) +callerSaves (DoubleReg 1) = True +#endif +#if defined(CALLER_SAVES_D2) +callerSaves (DoubleReg 2) = True +#endif +#if defined(CALLER_SAVES_D3) +callerSaves (DoubleReg 3) = True +#endif +#if defined(CALLER_SAVES_D4) +callerSaves (DoubleReg 4) = True +#endif +#if defined(CALLER_SAVES_D5) +callerSaves (DoubleReg 5) = True +#endif +#if defined(CALLER_SAVES_D6) +callerSaves (DoubleReg 6) = True +#endif +#if defined(CALLER_SAVES_L1) +callerSaves (LongReg 1) = True +#endif +#if defined(CALLER_SAVES_Sp) +callerSaves Sp = True +#endif +#if defined(CALLER_SAVES_SpLim) +callerSaves SpLim = True +#endif +#if defined(CALLER_SAVES_Hp) +callerSaves Hp = True +#endif +#if defined(CALLER_SAVES_HpLim) +callerSaves HpLim = True +#endif +#if defined(CALLER_SAVES_CCCS) +callerSaves CCCS = True +#endif +#if defined(CALLER_SAVES_CurrentTSO) +callerSaves CurrentTSO = True +#endif +#if defined(CALLER_SAVES_CurrentNursery) +callerSaves CurrentNursery = True +#endif +callerSaves _ = False + +activeStgRegs :: [GlobalReg] +activeStgRegs = [ +#if defined(REG_Base) + BaseReg +#endif +#if defined(REG_Sp) + ,Sp +#endif +#if defined(REG_Hp) + ,Hp +#endif +#if defined(REG_R1) + ,VanillaReg 1 VGcPtr +#endif +#if defined(REG_R2) + ,VanillaReg 2 VGcPtr +#endif +#if defined(REG_R3) + ,VanillaReg 3 VGcPtr +#endif +#if defined(REG_R4) + ,VanillaReg 4 VGcPtr +#endif +#if defined(REG_R5) + ,VanillaReg 5 VGcPtr +#endif +#if defined(REG_R6) + ,VanillaReg 6 VGcPtr +#endif +#if defined(REG_R7) + ,VanillaReg 7 VGcPtr +#endif +#if defined(REG_R8) + ,VanillaReg 8 VGcPtr +#endif +#if defined(REG_R9) + ,VanillaReg 9 VGcPtr +#endif +#if defined(REG_R10) + ,VanillaReg 10 VGcPtr +#endif +#if defined(REG_SpLim) + ,SpLim +#endif +#if MAX_REAL_XMM_REG != 0 +#if defined(REG_F1) + ,FloatReg 1 +#endif +#if defined(REG_D1) + ,DoubleReg 1 +#endif +#if defined(REG_XMM1) + ,XmmReg 1 +#endif +#if defined(REG_YMM1) + ,YmmReg 1 +#endif +#if defined(REG_ZMM1) + ,ZmmReg 1 +#endif +#if defined(REG_F2) + ,FloatReg 2 +#endif +#if defined(REG_D2) + ,DoubleReg 2 +#endif +#if defined(REG_XMM2) + ,XmmReg 2 +#endif +#if defined(REG_YMM2) + ,YmmReg 2 +#endif +#if defined(REG_ZMM2) + ,ZmmReg 2 +#endif +#if defined(REG_F3) + ,FloatReg 3 +#endif +#if defined(REG_D3) + ,DoubleReg 3 +#endif +#if defined(REG_XMM3) + ,XmmReg 3 +#endif +#if defined(REG_YMM3) + ,YmmReg 3 +#endif +#if defined(REG_ZMM3) + ,ZmmReg 3 +#endif +#if defined(REG_F4) + ,FloatReg 4 +#endif +#if defined(REG_D4) + ,DoubleReg 4 +#endif +#if defined(REG_XMM4) + ,XmmReg 4 +#endif +#if defined(REG_YMM4) + ,YmmReg 4 +#endif +#if defined(REG_ZMM4) + ,ZmmReg 4 +#endif +#if defined(REG_F5) + ,FloatReg 5 +#endif +#if defined(REG_D5) + ,DoubleReg 5 +#endif +#if defined(REG_XMM5) + ,XmmReg 5 +#endif +#if defined(REG_YMM5) + ,YmmReg 5 +#endif +#if defined(REG_ZMM5) + ,ZmmReg 5 +#endif +#if defined(REG_F6) + ,FloatReg 6 +#endif +#if defined(REG_D6) + ,DoubleReg 6 +#endif +#if defined(REG_XMM6) + ,XmmReg 6 +#endif +#if defined(REG_YMM6) + ,YmmReg 6 +#endif +#if defined(REG_ZMM6) + ,ZmmReg 6 +#endif +#else /* MAX_REAL_XMM_REG == 0 */ +#if defined(REG_F1) + ,FloatReg 1 +#endif +#if defined(REG_F2) + ,FloatReg 2 +#endif +#if defined(REG_F3) + ,FloatReg 3 +#endif +#if defined(REG_F4) + ,FloatReg 4 +#endif +#if defined(REG_F5) + ,FloatReg 5 +#endif +#if defined(REG_F6) + ,FloatReg 6 +#endif +#if defined(REG_D1) + ,DoubleReg 1 +#endif +#if defined(REG_D2) + ,DoubleReg 2 +#endif +#if defined(REG_D3) + ,DoubleReg 3 +#endif +#if defined(REG_D4) + ,DoubleReg 4 +#endif +#if defined(REG_D5) + ,DoubleReg 5 +#endif +#if defined(REG_D6) + ,DoubleReg 6 +#endif +#endif /* MAX_REAL_XMM_REG == 0 */ + ] + +haveRegBase :: Bool +#if defined(REG_Base) +haveRegBase = True +#else +haveRegBase = False +#endif + +-- | Returns 'Nothing' if this global register is not stored +-- in a real machine register, otherwise returns @'Just' reg@, where +-- reg is the machine register it is stored in. +globalRegMaybe :: GlobalReg -> Maybe RealReg +#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64) \ + || defined(MACHREGS_sparc) || defined(MACHREGS_powerpc) \ + || defined(MACHREGS_arm) || defined(MACHREGS_aarch64) \ + || defined(MACHREGS_s390x) || defined(MACHREGS_riscv64) +# if defined(REG_Base) +globalRegMaybe BaseReg = Just (RealRegSingle REG_Base) +# endif +# if defined(REG_R1) +globalRegMaybe (VanillaReg 1 _) = Just (RealRegSingle REG_R1) +# endif +# if defined(REG_R2) +globalRegMaybe (VanillaReg 2 _) = Just (RealRegSingle REG_R2) +# endif +# if defined(REG_R3) +globalRegMaybe (VanillaReg 3 _) = Just (RealRegSingle REG_R3) +# endif +# if defined(REG_R4) +globalRegMaybe (VanillaReg 4 _) = Just (RealRegSingle REG_R4) +# endif +# if defined(REG_R5) +globalRegMaybe (VanillaReg 5 _) = Just (RealRegSingle REG_R5) +# endif +# if defined(REG_R6) +globalRegMaybe (VanillaReg 6 _) = Just (RealRegSingle REG_R6) +# endif +# if defined(REG_R7) +globalRegMaybe (VanillaReg 7 _) = Just (RealRegSingle REG_R7) +# endif +# if defined(REG_R8) +globalRegMaybe (VanillaReg 8 _) = Just (RealRegSingle REG_R8) +# endif +# if defined(REG_R9) +globalRegMaybe (VanillaReg 9 _) = Just (RealRegSingle REG_R9) +# endif +# if defined(REG_R10) +globalRegMaybe (VanillaReg 10 _) = Just (RealRegSingle REG_R10) +# endif +# if defined(REG_F1) +globalRegMaybe (FloatReg 1) = Just (RealRegSingle REG_F1) +# endif +# if defined(REG_F2) +globalRegMaybe (FloatReg 2) = Just (RealRegSingle REG_F2) +# endif +# if defined(REG_F3) +globalRegMaybe (FloatReg 3) = Just (RealRegSingle REG_F3) +# endif +# if defined(REG_F4) +globalRegMaybe (FloatReg 4) = Just (RealRegSingle REG_F4) +# endif +# if defined(REG_F5) +globalRegMaybe (FloatReg 5) = Just (RealRegSingle REG_F5) +# endif +# if defined(REG_F6) +globalRegMaybe (FloatReg 6) = Just (RealRegSingle REG_F6) +# endif +# if defined(REG_D1) +globalRegMaybe (DoubleReg 1) = +# if defined(MACHREGS_sparc) + Just (RealRegPair REG_D1 (REG_D1 + 1)) +# else + Just (RealRegSingle REG_D1) +# endif +# endif +# if defined(REG_D2) +globalRegMaybe (DoubleReg 2) = +# if defined(MACHREGS_sparc) + Just (RealRegPair REG_D2 (REG_D2 + 1)) +# else + Just (RealRegSingle REG_D2) +# endif +# endif +# if defined(REG_D3) +globalRegMaybe (DoubleReg 3) = +# if defined(MACHREGS_sparc) + Just (RealRegPair REG_D3 (REG_D3 + 1)) +# else + Just (RealRegSingle REG_D3) +# endif +# endif +# if defined(REG_D4) +globalRegMaybe (DoubleReg 4) = +# if defined(MACHREGS_sparc) + Just (RealRegPair REG_D4 (REG_D4 + 1)) +# else + Just (RealRegSingle REG_D4) +# endif +# endif +# if defined(REG_D5) +globalRegMaybe (DoubleReg 5) = +# if defined(MACHREGS_sparc) + Just (RealRegPair REG_D5 (REG_D5 + 1)) +# else + Just (RealRegSingle REG_D5) +# endif +# endif +# if defined(REG_D6) +globalRegMaybe (DoubleReg 6) = +# if defined(MACHREGS_sparc) + Just (RealRegPair REG_D6 (REG_D6 + 1)) +# else + Just (RealRegSingle REG_D6) +# endif +# endif +# if MAX_REAL_XMM_REG != 0 +# if defined(REG_XMM1) +globalRegMaybe (XmmReg 1) = Just (RealRegSingle REG_XMM1) +# endif +# if defined(REG_XMM2) +globalRegMaybe (XmmReg 2) = Just (RealRegSingle REG_XMM2) +# endif +# if defined(REG_XMM3) +globalRegMaybe (XmmReg 3) = Just (RealRegSingle REG_XMM3) +# endif +# if defined(REG_XMM4) +globalRegMaybe (XmmReg 4) = Just (RealRegSingle REG_XMM4) +# endif +# if defined(REG_XMM5) +globalRegMaybe (XmmReg 5) = Just (RealRegSingle REG_XMM5) +# endif +# if defined(REG_XMM6) +globalRegMaybe (XmmReg 6) = Just (RealRegSingle REG_XMM6) +# endif +# endif +# if defined(MAX_REAL_YMM_REG) && MAX_REAL_YMM_REG != 0 +# if defined(REG_YMM1) +globalRegMaybe (YmmReg 1) = Just (RealRegSingle REG_YMM1) +# endif +# if defined(REG_YMM2) +globalRegMaybe (YmmReg 2) = Just (RealRegSingle REG_YMM2) +# endif +# if defined(REG_YMM3) +globalRegMaybe (YmmReg 3) = Just (RealRegSingle REG_YMM3) +# endif +# if defined(REG_YMM4) +globalRegMaybe (YmmReg 4) = Just (RealRegSingle REG_YMM4) +# endif +# if defined(REG_YMM5) +globalRegMaybe (YmmReg 5) = Just (RealRegSingle REG_YMM5) +# endif +# if defined(REG_YMM6) +globalRegMaybe (YmmReg 6) = Just (RealRegSingle REG_YMM6) +# endif +# endif +# if defined(MAX_REAL_ZMM_REG) && MAX_REAL_ZMM_REG != 0 +# if defined(REG_ZMM1) +globalRegMaybe (ZmmReg 1) = Just (RealRegSingle REG_ZMM1) +# endif +# if defined(REG_ZMM2) +globalRegMaybe (ZmmReg 2) = Just (RealRegSingle REG_ZMM2) +# endif +# if defined(REG_ZMM3) +globalRegMaybe (ZmmReg 3) = Just (RealRegSingle REG_ZMM3) +# endif +# if defined(REG_ZMM4) +globalRegMaybe (ZmmReg 4) = Just (RealRegSingle REG_ZMM4) +# endif +# if defined(REG_ZMM5) +globalRegMaybe (ZmmReg 5) = Just (RealRegSingle REG_ZMM5) +# endif +# if defined(REG_ZMM6) +globalRegMaybe (ZmmReg 6) = Just (RealRegSingle REG_ZMM6) +# endif +# endif +# if defined(REG_Sp) +globalRegMaybe Sp = Just (RealRegSingle REG_Sp) +# endif +# if defined(REG_Lng1) +globalRegMaybe (LongReg 1) = Just (RealRegSingle REG_Lng1) +# endif +# if defined(REG_Lng2) +globalRegMaybe (LongReg 2) = Just (RealRegSingle REG_Lng2) +# endif +# if defined(REG_SpLim) +globalRegMaybe SpLim = Just (RealRegSingle REG_SpLim) +# endif +# if defined(REG_Hp) +globalRegMaybe Hp = Just (RealRegSingle REG_Hp) +# endif +# if defined(REG_HpLim) +globalRegMaybe HpLim = Just (RealRegSingle REG_HpLim) +# endif +# if defined(REG_CurrentTSO) +globalRegMaybe CurrentTSO = Just (RealRegSingle REG_CurrentTSO) +# endif +# if defined(REG_CurrentNursery) +globalRegMaybe CurrentNursery = Just (RealRegSingle REG_CurrentNursery) +# endif +# if defined(REG_MachSp) +globalRegMaybe MachSp = Just (RealRegSingle REG_MachSp) +# endif +globalRegMaybe _ = Nothing +#elif defined(MACHREGS_NO_REGS) +globalRegMaybe _ = Nothing +#else +globalRegMaybe = panic "globalRegMaybe not defined for this platform" +#endif + +freeReg :: RegNo -> Bool + +#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64) + +# if defined(MACHREGS_i386) +freeReg esp = False -- %esp is the C stack pointer +freeReg esi = False -- Note [esi/edi/ebp not allocatable] +freeReg edi = False +freeReg ebp = False +# endif +# if defined(MACHREGS_x86_64) +freeReg rsp = False -- %rsp is the C stack pointer +# endif + +{- +Note [esi/edi/ebp not allocatable] + +%esi is mapped to R1, so %esi would normally be allocatable while it +is not being used for R1. However, %esi has no 8-bit version on x86, +and the linear register allocator is not sophisticated enough to +handle this irregularity (we need more RegClasses). The +graph-colouring allocator also cannot handle this - it was designed +with more flexibility in mind, but the current implementation is +restricted to the same set of classes as the linear allocator. + +Hence, on x86 esi, edi and ebp are treated as not allocatable. +-} + +-- split patterns in two functions to prevent overlaps +freeReg r = freeRegBase r + +freeRegBase :: RegNo -> Bool +# if defined(REG_Base) +freeRegBase REG_Base = False +# endif +# if defined(REG_Sp) +freeRegBase REG_Sp = False +# endif +# if defined(REG_SpLim) +freeRegBase REG_SpLim = False +# endif +# if defined(REG_Hp) +freeRegBase REG_Hp = False +# endif +# if defined(REG_HpLim) +freeRegBase REG_HpLim = False +# endif +-- All other regs are considered to be "free", because we can track +-- their liveness accurately. +freeRegBase _ = True + +#elif defined(MACHREGS_powerpc) + +freeReg 0 = False -- Used by code setting the back chain pointer + -- in stack reallocations on Linux. + -- Moreover r0 is not usable in all insns. +freeReg 1 = False -- The Stack Pointer +-- most ELF PowerPC OSes use r2 as a TOC pointer +freeReg 2 = False +freeReg 13 = False -- reserved for system thread ID on 64 bit +-- at least linux in -fPIC relies on r30 in PLT stubs +freeReg 30 = False +{- TODO: reserve r13 on 64 bit systems only and r30 on 32 bit respectively. + For now we use r30 on 64 bit and r13 on 32 bit as a temporary register + in stack handling code. See compiler/GHC/CmmToAsm/PPC/Instr.hs. + + Later we might want to reserve r13 and r30 only where it is required. + Then use r12 as temporary register, which is also what the C ABI does. +-} + +# if defined(REG_Base) +freeReg REG_Base = False +# endif +# if defined(REG_Sp) +freeReg REG_Sp = False +# endif +# if defined(REG_SpLim) +freeReg REG_SpLim = False +# endif +# if defined(REG_Hp) +freeReg REG_Hp = False +# endif +# if defined(REG_HpLim) +freeReg REG_HpLim = False +# endif +freeReg _ = True + +#elif defined(MACHREGS_aarch64) + +-- stack pointer / zero reg +freeReg 31 = False +-- link register +freeReg 30 = False +-- frame pointer +freeReg 29 = False +-- ip0 -- used for spill offset computations +freeReg 16 = False + +# if defined(REG_Base) +freeReg REG_Base = False +# endif +# if defined(REG_Sp) +freeReg REG_Sp = False +# endif +# if defined(REG_SpLim) +freeReg REG_SpLim = False +# endif +# if defined(REG_Hp) +freeReg REG_Hp = False +# endif +# if defined(REG_HpLim) +freeReg REG_HpLim = False +# endif + +# if defined(REG_R1) +freeReg REG_R1 = False +# endif +# if defined(REG_R2) +freeReg REG_R2 = False +# endif +# if defined(REG_R3) +freeReg REG_R3 = False +# endif +# if defined(REG_R4) +freeReg REG_R4 = False +# endif +# if defined(REG_R5) +freeReg REG_R5 = False +# endif +# if defined(REG_R6) +freeReg REG_R6 = False +# endif +# if defined(REG_R7) +freeReg REG_R7 = False +# endif +# if defined(REG_R8) +freeReg REG_R8 = False +# endif + +# if defined(REG_F1) +freeReg REG_F1 = False +# endif +# if defined(REG_F2) +freeReg REG_F2 = False +# endif +# if defined(REG_F3) +freeReg REG_F3 = False +# endif +# if defined(REG_F4) +freeReg REG_F4 = False +# endif +# if defined(REG_F5) +freeReg REG_F5 = False +# endif +# if defined(REG_F6) +freeReg REG_F6 = False +# endif + +# if defined(REG_D1) +freeReg REG_D1 = False +# endif +# if defined(REG_D2) +freeReg REG_D2 = False +# endif +# if defined(REG_D3) +freeReg REG_D3 = False +# endif +# if defined(REG_D4) +freeReg REG_D4 = False +# endif +# if defined(REG_D5) +freeReg REG_D5 = False +# endif +# if defined(REG_D6) +freeReg REG_D6 = False +# endif + +freeReg _ = True + +#elif defined(MACHREGS_sparc) + +-- SPARC regs used by the OS / ABI +-- %g0(r0) is always zero +freeReg g0 = False + +-- %g5(r5) - %g7(r7) +-- are reserved for the OS +freeReg g5 = False +freeReg g6 = False +freeReg g7 = False + +-- %o6(r14) +-- is the C stack pointer +freeReg o6 = False + +-- %o7(r15) +-- holds the C return address +freeReg o7 = False + +-- %i6(r30) +-- is the C frame pointer +freeReg i6 = False + +-- %i7(r31) +-- is used for C return addresses +freeReg i7 = False + +-- %f0(r32) - %f1(r32) +-- are C floating point return regs +freeReg f0 = False +freeReg f1 = False + +{- +freeReg regNo + -- don't release high half of double regs + | regNo >= f0 + , regNo < NCG_FirstFloatReg + , regNo `mod` 2 /= 0 + = False +-} + +# if defined(REG_Base) +freeReg REG_Base = False +# endif +# if defined(REG_R1) +freeReg REG_R1 = False +# endif +# if defined(REG_R2) +freeReg REG_R2 = False +# endif +# if defined(REG_R3) +freeReg REG_R3 = False +# endif +# if defined(REG_R4) +freeReg REG_R4 = False +# endif +# if defined(REG_R5) +freeReg REG_R5 = False +# endif +# if defined(REG_R6) +freeReg REG_R6 = False +# endif +# if defined(REG_R7) +freeReg REG_R7 = False +# endif +# if defined(REG_R8) +freeReg REG_R8 = False +# endif +# if defined(REG_R9) +freeReg REG_R9 = False +# endif +# if defined(REG_R10) +freeReg REG_R10 = False +# endif +# if defined(REG_F1) +freeReg REG_F1 = False +# endif +# if defined(REG_F2) +freeReg REG_F2 = False +# endif +# if defined(REG_F3) +freeReg REG_F3 = False +# endif +# if defined(REG_F4) +freeReg REG_F4 = False +# endif +# if defined(REG_F5) +freeReg REG_F5 = False +# endif +# if defined(REG_F6) +freeReg REG_F6 = False +# endif +# if defined(REG_D1) +freeReg REG_D1 = False +# endif +# if defined(REG_D1_2) +freeReg REG_D1_2 = False +# endif +# if defined(REG_D2) +freeReg REG_D2 = False +# endif +# if defined(REG_D2_2) +freeReg REG_D2_2 = False +# endif +# if defined(REG_D3) +freeReg REG_D3 = False +# endif +# if defined(REG_D3_2) +freeReg REG_D3_2 = False +# endif +# if defined(REG_D4) +freeReg REG_D4 = False +# endif +# if defined(REG_D4_2) +freeReg REG_D4_2 = False +# endif +# if defined(REG_D5) +freeReg REG_D5 = False +# endif +# if defined(REG_D5_2) +freeReg REG_D5_2 = False +# endif +# if defined(REG_D6) +freeReg REG_D6 = False +# endif +# if defined(REG_D6_2) +freeReg REG_D6_2 = False +# endif +# if defined(REG_Sp) +freeReg REG_Sp = False +# endif +# if defined(REG_SpLim) +freeReg REG_SpLim = False +# endif +# if defined(REG_Hp) +freeReg REG_Hp = False +# endif +# if defined(REG_HpLim) +freeReg REG_HpLim = False +# endif +freeReg _ = True + +#else + +freeReg = panic "freeReg not defined for this platform" + +#endif diff --git a/compiler/GHC/ByteCode/Asm.hs b/compiler/GHC/ByteCode/Asm.hs index 6ef6ef474c..da03d2a903 100644 --- a/compiler/GHC/ByteCode/Asm.hs +++ b/compiler/GHC/ByteCode/Asm.hs @@ -340,7 +340,7 @@ inspectAsm platform long_jumps initial_offset -- count (LargeOp _) = largeArg16s platform -- Bring in all the bci_ bytecode constants. -#include "rts/Bytecodes.h" +#include "Bytecodes.h" largeArgInstr :: Word16 -> Word16 largeArgInstr bci = bci_FLAG_LARGE_ARGS .|. bci diff --git a/compiler/GHC/Cmm/CLabel.hs b/compiler/GHC/Cmm/CLabel.hs index b6ad2b3431..723970e520 100644 --- a/compiler/GHC/Cmm/CLabel.hs +++ b/compiler/GHC/Cmm/CLabel.hs @@ -307,7 +307,7 @@ isTickyLabel _ = False -- label (e.g. "extern StgWordArray(foo)"). The type is fixed to StgWordArray. -- -- Symbols from the RTS don't need "extern" declarations because they are --- exposed via "includes/Stg.h" with the appropriate type. See 'needsCDecl'. +-- exposed via "rts/include/Stg.h" with the appropriate type. See 'needsCDecl'. -- -- The fixed StgWordArray type led to "conflicting types" issues with user -- provided Cmm files (not in the RTS) that declare data of another type (#15467 @@ -659,7 +659,7 @@ mkCmmDataLabel pkg ext str = CmmLabel pkg ext str CmmData mkRtsCmmDataLabel str = CmmLabel rtsUnitId (NeedExternDecl False) str CmmData -- RTS symbols don't need "GHC.CmmToC" to -- generate \"extern\" declaration (they are - -- exposed via includes/Stg.h) + -- exposed via rts/include/Stg.h) mkLocalBlockLabel :: Unique -> CLabel mkLocalBlockLabel u = LocalBlockLabel u @@ -935,7 +935,7 @@ needsCDecl (CmmLabel pkgId (NeedExternDecl external) _ _) | not external = False -- Prototypes for labels defined in the runtime system are imported - -- into HC files via includes/Stg.h. + -- into HC files via rts/include/Stg.h. | pkgId == rtsUnitId = False -- For other labels we inline one into the HC file directly. diff --git a/compiler/GHC/Cmm/Info.hs b/compiler/GHC/Cmm/Info.hs index 1c6dc351b8..d0397c8172 100644 --- a/compiler/GHC/Cmm/Info.hs +++ b/compiler/GHC/Cmm/Info.hs @@ -98,7 +98,7 @@ cmmToRawCmm logger profile cmms -- <normal forward rest of StgInfoTable> -- <forward variable part> -- --- See includes/rts/storage/InfoTables.h +-- See rts/include/rts/storage/InfoTables.h -- -- For return-points these are as follows -- @@ -371,7 +371,7 @@ mkLivenessBits platform liveness lits = mkWordCLit platform (fromIntegral n_bits) : map (mkStgWordCLit platform) bitmap -- The first word is the size. The structure must match - -- StgLargeBitmap in includes/rts/storage/InfoTable.h + -- StgLargeBitmap in rts/include/rts/storage/InfoTable.h ------------------------------------------------------------------------- -- @@ -381,7 +381,7 @@ mkLivenessBits platform liveness -- The standard bits of an info table. This part of the info table -- corresponds to the StgInfoTable type defined in --- includes/rts/storage/InfoTables.h. +-- rts/include/rts/storage/InfoTables.h. -- -- Its shape varies with ticky/profiling/tables next to code etc -- so we can't use constant offsets from Constants diff --git a/compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs b/compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs index 83f581cac4..cd4208bc89 100644 --- a/compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs +++ b/compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs @@ -40,7 +40,7 @@ import GHC.Utils.Panic -- TODO: Is that still true? Could we use allocatableRegsInClass -- without losing performance now? -- --- Look at includes/stg/MachRegs.h to get the numbers. +-- Look at rts/include/stg/MachRegs.h to get the numbers. -- diff --git a/compiler/GHC/CmmToAsm/SPARC/Regs.hs b/compiler/GHC/CmmToAsm/SPARC/Regs.hs index 949701cf2d..0325814c6b 100644 --- a/compiler/GHC/CmmToAsm/SPARC/Regs.hs +++ b/compiler/GHC/CmmToAsm/SPARC/Regs.hs @@ -50,7 +50,7 @@ import GHC.Utils.Panic prepared for any eventuality. The whole fp-register pairing thing on sparcs is a huge nuisance. See - includes/stg/MachRegs.h for a description of what's going on + rts/include/stg/MachRegs.h for a description of what's going on here. -} diff --git a/compiler/GHC/CmmToAsm/X86/Ppr.hs b/compiler/GHC/CmmToAsm/X86/Ppr.hs index 5f030b8d58..e284e618da 100644 --- a/compiler/GHC/CmmToAsm/X86/Ppr.hs +++ b/compiler/GHC/CmmToAsm/X86/Ppr.hs @@ -555,7 +555,7 @@ pprDataItem config lit -- to 32-bit offset fields and modify the RTS -- appropriately -- - -- See Note [x86-64-relative] in includes/rts/storage/InfoTables.h + -- See Note [x86-64-relative] in rts/include/rts/storage/InfoTables.h -- case lit of -- A relative relocation: diff --git a/compiler/GHC/CmmToC.hs b/compiler/GHC/CmmToC.hs index b49fccbd95..3008f01c5c 100644 --- a/compiler/GHC/CmmToC.hs +++ b/compiler/GHC/CmmToC.hs @@ -905,7 +905,7 @@ mkJMP_ i = text "JMP_" <> parens i mkFN_ i = text "FN_" <> parens i -- externally visible function mkIF_ i = text "IF_" <> parens i -- locally visible --- from includes/Stg.h +-- from rts/include/Stg.h -- mkC_,mkW_,mkP_ :: SDoc diff --git a/compiler/GHC/Platform.hs b/compiler/GHC/Platform.hs index 70c8f9b658..b3f5bf830c 100644 --- a/compiler/GHC/Platform.hs +++ b/compiler/GHC/Platform.hs @@ -73,7 +73,7 @@ data Platform = Platform , platformTablesNextToCode :: !Bool -- ^ Determines whether we will be compiling info tables that reside just -- before the entry code, or with an indirection to the entry code. See - -- TABLES_NEXT_TO_CODE in includes/rts/storage/InfoTables.h. + -- TABLES_NEXT_TO_CODE in rts/include/rts/storage/InfoTables.h. , platform_constants :: !(Maybe PlatformConstants) -- ^ Constants such as structure offsets, type sizes, etc. } diff --git a/compiler/GHC/Platform/AArch64.hs b/compiler/GHC/Platform/AArch64.hs index 4e6a6bc230..5d8e044969 100644 --- a/compiler/GHC/Platform/AArch64.hs +++ b/compiler/GHC/Platform/AArch64.hs @@ -6,4 +6,4 @@ import GHC.Prelude #define MACHREGS_NO_REGS 0 #define MACHREGS_aarch64 1 -#include "../../../includes/CodeGen.Platform.hs" +#include "CodeGen.Platform.h" diff --git a/compiler/GHC/Platform/ARM.hs b/compiler/GHC/Platform/ARM.hs index d1e2d9d312..df2210033a 100644 --- a/compiler/GHC/Platform/ARM.hs +++ b/compiler/GHC/Platform/ARM.hs @@ -6,5 +6,5 @@ import GHC.Prelude #define MACHREGS_NO_REGS 0 #define MACHREGS_arm 1 -#include "../../../includes/CodeGen.Platform.hs" +#include "CodeGen.Platform.h" diff --git a/compiler/GHC/Platform/NoRegs.hs b/compiler/GHC/Platform/NoRegs.hs index c00f4cb7ff..27c1ec5b02 100644 --- a/compiler/GHC/Platform/NoRegs.hs +++ b/compiler/GHC/Platform/NoRegs.hs @@ -5,5 +5,5 @@ module GHC.Platform.NoRegs where import GHC.Prelude #define MACHREGS_NO_REGS 1 -#include "../../../includes/CodeGen.Platform.hs" +#include "CodeGen.Platform.h" diff --git a/compiler/GHC/Platform/PPC.hs b/compiler/GHC/Platform/PPC.hs index 5b4f3bfb14..86da0e4b05 100644 --- a/compiler/GHC/Platform/PPC.hs +++ b/compiler/GHC/Platform/PPC.hs @@ -6,5 +6,5 @@ import GHC.Prelude #define MACHREGS_NO_REGS 0 #define MACHREGS_powerpc 1 -#include "../../../includes/CodeGen.Platform.hs" +#include "CodeGen.Platform.h" diff --git a/compiler/GHC/Platform/RISCV64.hs b/compiler/GHC/Platform/RISCV64.hs index 88754d4838..899776921f 100644 --- a/compiler/GHC/Platform/RISCV64.hs +++ b/compiler/GHC/Platform/RISCV64.hs @@ -6,5 +6,5 @@ import GHC.Prelude #define MACHREGS_NO_REGS 0 #define MACHREGS_riscv64 1 -#include "../../../includes/CodeGen.Platform.hs" +#include "CodeGen.Platform.h" diff --git a/compiler/GHC/Platform/S390X.hs b/compiler/GHC/Platform/S390X.hs index 709d2db101..660844216e 100644 --- a/compiler/GHC/Platform/S390X.hs +++ b/compiler/GHC/Platform/S390X.hs @@ -6,5 +6,5 @@ import GHC.Prelude #define MACHREGS_NO_REGS 0 #define MACHREGS_s390x 1 -#include "../../../includes/CodeGen.Platform.hs" +#include "CodeGen.Platform.h" diff --git a/compiler/GHC/Platform/SPARC.hs b/compiler/GHC/Platform/SPARC.hs index b1dad08837..d0ab5fe41a 100644 --- a/compiler/GHC/Platform/SPARC.hs +++ b/compiler/GHC/Platform/SPARC.hs @@ -6,5 +6,5 @@ import GHC.Prelude #define MACHREGS_NO_REGS 0 #define MACHREGS_sparc 1 -#include "../../../includes/CodeGen.Platform.hs" +#include "CodeGen.Platform.h" diff --git a/compiler/GHC/Platform/X86.hs b/compiler/GHC/Platform/X86.hs index e065036f61..24b4ca8ab6 100644 --- a/compiler/GHC/Platform/X86.hs +++ b/compiler/GHC/Platform/X86.hs @@ -6,5 +6,5 @@ import GHC.Prelude #define MACHREGS_NO_REGS 0 #define MACHREGS_i386 1 -#include "../../../includes/CodeGen.Platform.hs" +#include "CodeGen.Platform.h" diff --git a/compiler/GHC/Platform/X86_64.hs b/compiler/GHC/Platform/X86_64.hs index 27c4232975..5911bd37e7 100644 --- a/compiler/GHC/Platform/X86_64.hs +++ b/compiler/GHC/Platform/X86_64.hs @@ -6,5 +6,5 @@ import GHC.Prelude #define MACHREGS_NO_REGS 0 #define MACHREGS_x86_64 1 -#include "../../../includes/CodeGen.Platform.hs" +#include "CodeGen.Platform.h" diff --git a/compiler/GHC/Runtime/Heap/Layout.hs b/compiler/GHC/Runtime/Heap/Layout.hs index 51f209f6b6..1195f83937 100644 --- a/compiler/GHC/Runtime/Heap/Layout.hs +++ b/compiler/GHC/Runtime/Heap/Layout.hs @@ -181,7 +181,7 @@ data SMRep type IsStatic = Bool -- From an SMRep you can get to the closure type defined in --- includes/rts/storage/ClosureTypes.h. Described by the function +-- rts/include/rts/storage/ClosureTypes.h. Described by the function -- rtsClosureType below. data ClosureTypeInfo @@ -404,8 +404,8 @@ cardTableSizeW platform elems = ----------------------------------------------------------------------------- -- deriving the RTS closure type from an SMRep -#include "../includes/rts/storage/ClosureTypes.h" -#include "../includes/rts/storage/FunTypes.h" +#include "ClosureTypes.h" +#include "FunTypes.h" -- Defines CONSTR, CONSTR_1_0 etc -- | Derives the RTS closure type from an 'SMRep' diff --git a/compiler/GHC/StgToCmm/ArgRep.hs b/compiler/GHC/StgToCmm/ArgRep.hs index 2ec0e177e8..cc618a16ed 100644 --- a/compiler/GHC/StgToCmm/ArgRep.hs +++ b/compiler/GHC/StgToCmm/ArgRep.hs @@ -120,11 +120,11 @@ idArgRep platform = toArgRep platform . idPrimRep -- * GHC.StgToCmm.Layout.stdPattern maybe to some degree? -- -- * the RTS_RET(stg_ap_*) and RTS_FUN_DECL(stg_ap_*_fast) --- declarations in includes/stg/MiscClosures.h +-- declarations in rts/include/stg/MiscClosures.h -- --- * the SLOW_CALL_*_ctr declarations in includes/stg/Ticky.h, +-- * the SLOW_CALL_*_ctr declarations in rts/include/stg/Ticky.h, -- --- * the TICK_SLOW_CALL_*() #defines in includes/Cmm.h, +-- * the TICK_SLOW_CALL_*() #defines in rts/include/Cmm.h, -- -- * the PR_CTR(SLOW_CALL_*_ctr) calls in rts/Ticky.c, -- diff --git a/compiler/GHC/StgToCmm/Layout.hs b/compiler/GHC/StgToCmm/Layout.hs index eeae70f747..0a74291ebd 100644 --- a/compiler/GHC/StgToCmm/Layout.hs +++ b/compiler/GHC/StgToCmm/Layout.hs @@ -541,7 +541,7 @@ mkVirtConstrSizes profile field_reps ------------------------------------------------------------------------- -- bring in ARG_P, ARG_N, etc. -#include "../includes/rts/storage/FunTypes.h" +#include "FunTypes.h" mkArgDescr :: Platform -> [Id] -> ArgDescr mkArgDescr platform args diff --git a/compiler/GHC/StgToCmm/Ticky.hs b/compiler/GHC/StgToCmm/Ticky.hs index 76748f2b0d..1317dcbe17 100644 --- a/compiler/GHC/StgToCmm/Ticky.hs +++ b/compiler/GHC/StgToCmm/Ticky.hs @@ -29,12 +29,12 @@ Some of the relevant source files: * GHC.Cmm.Parser expands some macros using generators defined in this module - * includes/stg/Ticky.h declares all of the global counters + * rts/include/stg/Ticky.h declares all of the global counters - * includes/rts/Ticky.h declares the C data type for an + * rts/include/rts/Ticky.h declares the C data type for an STG-declaration's counters - * some macros defined in includes/Cmm.h (and used within the RTS's + * some macros defined in rts/include/Cmm.h (and used within the RTS's CMM code) update the global ticky counters * at the end of execution rts/Ticky.c generates the final report @@ -247,7 +247,7 @@ emitTickyCounter cloType name args ; fun_descr_lit <- newStringCLit $ renderWithContext ctx ppr_for_ticky_name ; arg_descr_lit <- newStringCLit $ map (showTypeCategory . idType . fromNonVoid) args ; emitDataLits ctr_lbl - -- Must match layout of includes/rts/Ticky.h's StgEntCounter + -- Must match layout of rts/include/rts/Ticky.h's StgEntCounter -- -- krc: note that all the fields are I32 now; some were I16 -- before, but the code generator wasn't handling that diff --git a/compiler/GHC/StgToCmm/Utils.hs b/compiler/GHC/StgToCmm/Utils.hs index a1b13e2e8d..4913bbd3ce 100644 --- a/compiler/GHC/StgToCmm/Utils.hs +++ b/compiler/GHC/StgToCmm/Utils.hs @@ -198,7 +198,7 @@ emitRtsCallGen res lbl args safe -- Here we generate the sequence of saves/restores required around a -- foreign call instruction. --- TODO: reconcile with includes/Regs.h +-- TODO: reconcile with rts/include/Regs.h -- * Regs.h claims that BaseReg should be saved last and loaded first -- * This might not have been tickled before since BaseReg is callee save -- * Regs.h saves SparkHd, ParkT1, SparkBase and SparkLim @@ -206,7 +206,7 @@ emitRtsCallGen res lbl args safe -- This code isn't actually used right now, because callerSaves -- only ever returns true in the current universe for registers NOT in -- system_regs (just do a grep for CALLER_SAVES in --- includes/stg/MachRegs.h). It's all one giant no-op, and for +-- rts/include/stg/MachRegs.h). It's all one giant no-op, and for -- good reason: having to save system registers on every foreign call -- would be very expensive, so we avoid assigning them to those -- registers when we add support for an architecture. diff --git a/compiler/GHC/SysTools/BaseDir.hs b/compiler/GHC/SysTools/BaseDir.hs index ad16fac025..03169523c6 100644 --- a/compiler/GHC/SysTools/BaseDir.hs +++ b/compiler/GHC/SysTools/BaseDir.hs @@ -100,7 +100,7 @@ make) set in `aclocal.m4`. This allows the rest of the build system to have access to these and other values determined by configure. - Based on this file, `includes/ghc.mk` when ran will produce the settings file + Based on this file, `rts/include/ghc.mk` when ran will produce the settings file by echoing the values into a the final file. Coincidentally this is also where `ghcplatform.h` and `ghcversion.h` generated which contains information about the build platform and sets CPP for use by the entire build. @@ -118,7 +118,7 @@ hadrian) The last part of this is the `generateSettings` in `src/Rules/Generate.hs` which produces the desired settings file out of Hadrian. This is the - equivalent to `includes/ghc.mk`. + equivalent to `rts/include/ghc.mk`. -- diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in index e9993e7776..2520576498 100644 --- a/compiler/ghc.cabal.in +++ b/compiler/ghc.cabal.in @@ -23,6 +23,19 @@ Category: Development Build-Type: Simple Cabal-Version: >=1.10 +extra-source-files: + Unique.h + CodeGen.Platform.h + -- Shared with rts via hard-link at configure time. This is safer + -- for Windows, where symlinks don't work out of the box, so we + -- can't just commit some in git. + Bytecodes.h + ClosureTypes.h + FunTypes.h + MachRegs.h + -- Target sensative, should not be used. + MachDeps.h + Flag internal-interpreter Description: Build with internal interpreter support. Default: False @@ -56,6 +69,15 @@ Flag dynamic-system-linker Library Default-Language: Haskell2010 Exposed: False + Includes: Unique.h + -- CodeGen.Platform.h -- invalid as C, skip + -- shared with rts via symlink + Bytecodes.h + ClosureTypes.h + FunTypes.h + -- MachRegs.h -- hits #error, skip + -- target sensative, should not be used + MachDeps.h Build-Depends: base >= 4.11 && < 4.17, deepseq >= 1.4 && < 1.5, diff --git a/compiler/ghc.mk b/compiler/ghc.mk index 7766482509..08004b1c5c 100644 --- a/compiler/ghc.mk +++ b/compiler/ghc.mk @@ -93,9 +93,8 @@ compiler/stage$1/build/GHC/Settings/Config.hs : mk/config.mk mk/project.mk | $$$ @echo 'cStage = show ($1 :: Int)' >> $$@ @echo done. -compiler/stage$1/build/GHC/Platform/Constants.hs : $$(includes_GHCCONSTANTS_HASKELL_TYPE) | $$$$(dir $$$$@)/. - $$(call removeFiles,$$@) - "$$(CP)" $$< $$@ +compiler/stage$1/build/GHC/Platform/Constants.hs : $$(deriveConstants_INPLACE) | $$$$(dir $$$$@)/. + $$< --gen-haskell-type -o $$@ endef $(eval $(call compilerConfig,0)) |