diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/CodeGen.Platform.hs | 39 | ||||
-rw-r--r-- | includes/Rts.h | 6 | ||||
-rw-r--r-- | includes/rts/EventLogFormat.h | 2 | ||||
-rw-r--r-- | includes/stg/MachRegs.h | 72 | ||||
-rw-r--r-- | includes/stg/MachRegsForHost.h | 4 | ||||
-rw-r--r-- | includes/stg/SMP.h | 6 | ||||
-rw-r--r-- | includes/stg/Types.h | 9 |
7 files changed, 136 insertions, 2 deletions
diff --git a/includes/CodeGen.Platform.hs b/includes/CodeGen.Platform.hs index 99d774b02c..b108a61c0a 100644 --- a/includes/CodeGen.Platform.hs +++ b/includes/CodeGen.Platform.hs @@ -344,6 +344,42 @@ import Reg # 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 + #endif callerSaves :: GlobalReg -> Bool @@ -630,7 +666,8 @@ haveRegBase = False 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_arm) || defined(MACHREGS_aarch64) \ + || defined(MACHREGS_s390x) # if defined(REG_Base) globalRegMaybe BaseReg = Just (RealRegSingle REG_Base) # endif diff --git a/includes/Rts.h b/includes/Rts.h index 7ad6988f3b..d0f5371007 100644 --- a/includes/Rts.h +++ b/includes/Rts.h @@ -16,6 +16,12 @@ extern "C" { #endif +/* get types from GHC's runtime system */ +#include "ghcconfig.h" +/* We have to include Types.h before everything else as this defines some + macros that will change the behaviour of system headers. */ +#include "stg/Types.h" + /* We include windows.h very early, as on Win64 the CONTEXT type has fields "R8", "R9" and "R10", which goes bad if we've already #define'd those names for our own purposes (in stg/Regs.h) */ diff --git a/includes/rts/EventLogFormat.h b/includes/rts/EventLogFormat.h index 0ffa77a2df..d5ed01a864 100644 --- a/includes/rts/EventLogFormat.h +++ b/includes/rts/EventLogFormat.h @@ -180,6 +180,8 @@ #define EVENT_HEAP_PROF_SAMPLE_STRING 164 #define EVENT_HEAP_PROF_SAMPLE_END 165 #define EVENT_HEAP_BIO_PROF_SAMPLE_BEGIN 166 +#define EVENT_PROF_SAMPLE_COST_CENTRE 167 +#define EVENT_PROF_BEGIN 168 #define EVENT_USER_BINARY_MSG 181 diff --git a/includes/stg/MachRegs.h b/includes/stg/MachRegs.h index 0afc88152e..ea1125bbf8 100644 --- a/includes/stg/MachRegs.h +++ b/includes/stg/MachRegs.h @@ -589,6 +589,78 @@ the stack. See Note [Overlapping global registers] for implications. #define REG_D3 d14 #define REG_D4 d15 +/* ----------------------------------------------------------------------------- + The s390x register mapping + + Register | Role(s) | Call effect + ------------+-------------------------------------+----------------- + r0,r1 | - | caller-saved + r2 | Argument / return value | caller-saved + r3,r4,r5 | Arguments | caller-saved + r6 | Argument | callee-saved + r7...r11 | - | callee-saved + r12 | (Commonly used as GOT pointer) | callee-saved + r13 | (Commonly used as literal pool pointer) | callee-saved + r14 | Return address | caller-saved + r15 | Stack pointer | callee-saved + f0 | Argument / return value | caller-saved + f2,f4,f6 | Arguments | caller-saved + f1,f3,f5,f7 | - | caller-saved + f8...f15 | - | callee-saved + v0...v31 | - | caller-saved + + Each general purpose register r0 through r15 as well as each floating-point + register f0 through f15 is 64 bits wide. Each vector register v0 through v31 + is 128 bits wide. + + Note, the vector registers v0 through v15 overlap with the floating-point + registers f0 through f15. + + -------------------------------------------------------------------------- */ + +#elif defined(MACHREGS_s390x) + +#define REG(x) __asm__("%" #x) + +#define REG_Base r7 +#define REG_Sp r8 +#define REG_Hp r10 +#define REG_R1 r11 +#define REG_R2 r12 +#define REG_R3 r13 +#define REG_R4 r6 +#define REG_R5 r2 +#define REG_R6 r3 +#define REG_R7 r4 +#define REG_R8 r5 +#define REG_SpLim r9 +#define REG_MachSp r15 + +#define REG_F1 f8 +#define REG_F2 f9 +#define REG_F3 f10 +#define REG_F4 f11 +#define REG_F5 f0 +#define REG_F6 f1 + +#define REG_D1 f12 +#define REG_D2 f13 +#define REG_D3 f14 +#define REG_D4 f15 +#define REG_D5 f2 +#define REG_D6 f3 + +#define CALLER_SAVES_R5 +#define CALLER_SAVES_R6 +#define CALLER_SAVES_R7 +#define CALLER_SAVES_R8 + +#define CALLER_SAVES_F5 +#define CALLER_SAVES_F6 + +#define CALLER_SAVES_D5 +#define CALLER_SAVES_D6 + #else #error Cannot find platform to give register info for diff --git a/includes/stg/MachRegsForHost.h b/includes/stg/MachRegsForHost.h index 135c7974bd..3597b2be90 100644 --- a/includes/stg/MachRegsForHost.h +++ b/includes/stg/MachRegsForHost.h @@ -67,6 +67,10 @@ #define MACHREGS_darwin 1 #endif +#if defined(s390x_HOST_ARCH) +#define MACHREGS_s390x 1 +#endif + #endif #include "MachRegs.h" diff --git a/includes/stg/SMP.h b/includes/stg/SMP.h index 260a916d40..60f084be9a 100644 --- a/includes/stg/SMP.h +++ b/includes/stg/SMP.h @@ -343,6 +343,8 @@ write_barrier(void) { #elif defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) \ || defined(powerpc64le_HOST_ARCH) __asm__ __volatile__ ("lwsync" : : : "memory"); +#elif defined(s390x_HOST_ARCH) + __asm__ __volatile__ ("" : : : "memory"); #elif defined(sparc_HOST_ARCH) /* Sparc in TSO mode does not require store/store barriers. */ __asm__ __volatile__ ("" : : : "memory"); @@ -364,6 +366,8 @@ store_load_barrier(void) { #elif defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) \ || defined(powerpc64le_HOST_ARCH) __asm__ __volatile__ ("sync" : : : "memory"); +#elif defined(s390x_HOST_ARCH) + __asm__ __volatile__ ("bcr 14,0" : : : "memory"); #elif defined(sparc_HOST_ARCH) __asm__ __volatile__ ("membar #StoreLoad" : : : "memory"); #elif defined(arm_HOST_ARCH) @@ -386,6 +390,8 @@ load_load_barrier(void) { #elif defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) \ || defined(powerpc64le_HOST_ARCH) __asm__ __volatile__ ("lwsync" : : : "memory"); +#elif defined(s390x_HOST_ARCH) + __asm__ __volatile__ ("" : : : "memory"); #elif defined(sparc_HOST_ARCH) /* Sparc in TSO mode does not require load/load barriers. */ __asm__ __volatile__ ("" : : : "memory"); diff --git a/includes/stg/Types.h b/includes/stg/Types.h index 7558d1f420..8ce9e3c156 100644 --- a/includes/stg/Types.h +++ b/includes/stg/Types.h @@ -21,8 +21,15 @@ #pragma once #if defined(mingw32_HOST_OS) +# if defined(__USE_MINGW_ANSI_STDIO) +# if __USE_MINGW_ANSI_STDIO != 1 +# warning "Mismatch between __USE_MINGW_ANSI_STDIO definitions. \ +If using Rts.h make sure it is the first header included." +# endif +# else /* Inform mingw we want the ISO rather than Windows printf format specifiers. */ -#define __USE_MINGW_ANSI_STDIO 1 +# define __USE_MINGW_ANSI_STDIO 1 +#endif #endif /* ISO C 99 says: |