summaryrefslogtreecommitdiff
path: root/includes/CodeGen.Platform.hs
diff options
context:
space:
mode:
authorErik de Castro Lopo <erik.decastrolopo@ambiata.com>2017-04-05 05:53:46 +1000
committerBen Gamari <ben@smart-cactus.org>2017-04-28 22:35:04 -0400
commite5b3492f23c2296d0d8221e1787ee585331f726e (patch)
treee1d6797dadc265db7f97615ff71c65c3d83db9c0 /includes/CodeGen.Platform.hs
parent6d14c1485cb570cbd183bcdc0f858d9a6dc1eb31 (diff)
downloadhaskell-e5b3492f23c2296d0d8221e1787ee585331f726e.tar.gz
Enable new warning for fragile/incorrect CPP #if usage
The C code in the RTS now gets built with `-Wundef` and the Haskell code (stages 1 and 2 only) with `-Wcpp-undef`. We now get warnings whereever `#if` is used on undefined identifiers. Test Plan: Validate on Linux and Windows Reviewers: austin, angerman, simonmar, bgamari, Phyx Reviewed By: bgamari Subscribers: thomie, snowleopard Differential Revision: https://phabricator.haskell.org/D3278
Diffstat (limited to 'includes/CodeGen.Platform.hs')
-rw-r--r--includes/CodeGen.Platform.hs52
1 files changed, 28 insertions, 24 deletions
diff --git a/includes/CodeGen.Platform.hs b/includes/CodeGen.Platform.hs
index 3674ea6f95..97628aecdc 100644
--- a/includes/CodeGen.Platform.hs
+++ b/includes/CodeGen.Platform.hs
@@ -1,6 +1,7 @@
import CmmExpr
-#if !(MACHREGS_i386 || MACHREGS_x86_64 || MACHREGS_sparc || MACHREGS_powerpc)
+#if !(defined(MACHREGS_i386) || defined(MACHREGS_x86_64) \
+ || defined(MACHREGS_sparc) || defined(MACHREGS_powerpc))
import Panic
#endif
import Reg
@@ -8,9 +9,9 @@ import Reg
#include "ghcautoconf.h"
#include "stg/MachRegs.h"
-#if MACHREGS_i386 || MACHREGS_x86_64
+#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64)
-# if MACHREGS_i386
+# if defined(MACHREGS_i386)
# define eax 0
# define ebx 1
# define ecx 2
@@ -21,7 +22,7 @@ import Reg
# define esp 7
# endif
-# if MACHREGS_x86_64
+# if defined(MACHREGS_x86_64)
# define rax 0
# define rbx 1
# define rcx 2
@@ -103,7 +104,8 @@ import Reg
-- I'm not sure if these are the correct numberings.
-- Normally, the register names are just stringified as part of the REG() macro
-#elif MACHREGS_powerpc || MACHREGS_arm || MACHREGS_aarch64
+#elif defined(MACHREGS_powerpc) || defined(MACHREGS_arm) \
+ || defined(MACHREGS_aarch64)
# define r0 0
# define r1 1
@@ -140,7 +142,7 @@ import Reg
-- 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 MACHREGS_aarch64 || MACHREGS_arm
+#if defined(MACHREGS_aarch64) || defined(MACHREGS_arm)
# define s0 32
# define s1 33
# define s2 34
@@ -208,7 +210,7 @@ import Reg
# define d31 63
#endif
-# if MACHREGS_darwin
+# if defined(MACHREGS_darwin)
# define f0 32
# define f1 33
# define f2 34
@@ -276,7 +278,7 @@ import Reg
# define fr31 63
# endif
-#elif MACHREGS_sparc
+#elif defined(MACHREGS_sparc)
# define g0 0
# define g1 1
@@ -631,7 +633,9 @@ haveRegBase = False
-- in a real machine register, otherwise returns @'Just' reg@, where
-- reg is the machine register it is stored in.
globalRegMaybe :: GlobalReg -> Maybe RealReg
-#if MACHREGS_i386 || MACHREGS_x86_64 || MACHREGS_sparc || MACHREGS_powerpc || MACHREGS_arm || MACHREGS_aarch64
+#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64) \
+ || defined(MACHREGS_sparc) || defined(MACHREGS_powerpc) \
+ || defined(MACHREGS_arm) || defined(MACHREGS_aarch64)
# ifdef REG_Base
globalRegMaybe BaseReg = Just (RealRegSingle REG_Base)
# endif
@@ -685,7 +689,7 @@ globalRegMaybe (FloatReg 6) = Just (RealRegSingle REG_F6)
# endif
# ifdef REG_D1
globalRegMaybe (DoubleReg 1) =
-# if MACHREGS_sparc
+# if defined(MACHREGS_sparc)
Just (RealRegPair REG_D1 (REG_D1 + 1))
# else
Just (RealRegSingle REG_D1)
@@ -693,7 +697,7 @@ globalRegMaybe (DoubleReg 1) =
# endif
# ifdef REG_D2
globalRegMaybe (DoubleReg 2) =
-# if MACHREGS_sparc
+# if defined(MACHREGS_sparc)
Just (RealRegPair REG_D2 (REG_D2 + 1))
# else
Just (RealRegSingle REG_D2)
@@ -701,7 +705,7 @@ globalRegMaybe (DoubleReg 2) =
# endif
# ifdef REG_D3
globalRegMaybe (DoubleReg 3) =
-# if MACHREGS_sparc
+# if defined(MACHREGS_sparc)
Just (RealRegPair REG_D3 (REG_D3 + 1))
# else
Just (RealRegSingle REG_D3)
@@ -709,7 +713,7 @@ globalRegMaybe (DoubleReg 3) =
# endif
# ifdef REG_D4
globalRegMaybe (DoubleReg 4) =
-# if MACHREGS_sparc
+# if defined(MACHREGS_sparc)
Just (RealRegPair REG_D4 (REG_D4 + 1))
# else
Just (RealRegSingle REG_D4)
@@ -717,7 +721,7 @@ globalRegMaybe (DoubleReg 4) =
# endif
# ifdef REG_D5
globalRegMaybe (DoubleReg 5) =
-# if MACHREGS_sparc
+# if defined(MACHREGS_sparc)
Just (RealRegPair REG_D5 (REG_D5 + 1))
# else
Just (RealRegSingle REG_D5)
@@ -725,7 +729,7 @@ globalRegMaybe (DoubleReg 5) =
# endif
# ifdef REG_D6
globalRegMaybe (DoubleReg 6) =
-# if MACHREGS_sparc
+# if defined(MACHREGS_sparc)
Just (RealRegPair REG_D6 (REG_D6 + 1))
# else
Just (RealRegSingle REG_D6)
@@ -751,7 +755,7 @@ globalRegMaybe (XmmReg 5) = Just (RealRegSingle REG_XMM5)
globalRegMaybe (XmmReg 6) = Just (RealRegSingle REG_XMM6)
# endif
# endif
-# if MAX_REAL_YMM_REG != 0
+# if defined(MAX_REAL_YMM_REG) && MAX_REAL_YMM_REG != 0
# ifdef REG_YMM1
globalRegMaybe (YmmReg 1) = Just (RealRegSingle REG_YMM1)
# endif
@@ -771,7 +775,7 @@ globalRegMaybe (YmmReg 5) = Just (RealRegSingle REG_YMM5)
globalRegMaybe (YmmReg 6) = Just (RealRegSingle REG_YMM6)
# endif
# endif
-# if MAX_REAL_ZMM_REG != 0
+# if defined(MAX_REAL_ZMM_REG) && MAX_REAL_ZMM_REG != 0
# ifdef REG_ZMM1
globalRegMaybe (ZmmReg 1) = Just (RealRegSingle REG_ZMM1)
# endif
@@ -819,7 +823,7 @@ globalRegMaybe CurrentNursery = Just (RealRegSingle REG_CurrentNursery
globalRegMaybe MachSp = Just (RealRegSingle REG_MachSp)
# endif
globalRegMaybe _ = Nothing
-#elif MACHREGS_NO_REGS
+#elif defined(MACHREGS_NO_REGS)
globalRegMaybe _ = Nothing
#else
globalRegMaybe = panic "globalRegMaybe not defined for this platform"
@@ -827,14 +831,14 @@ globalRegMaybe = panic "globalRegMaybe not defined for this platform"
freeReg :: RegNo -> Bool
-#if MACHREGS_i386 || MACHREGS_x86_64
+#if defined(MACHREGS_i386) || defined(MACHREGS_x86_64)
-# if MACHREGS_i386
+# if defined(MACHREGS_i386)
freeReg esp = False -- %esp is the C stack pointer
freeReg esi = False -- Note [esi/edi not allocatable]
freeReg edi = False
# endif
-# if MACHREGS_x86_64
+# if defined(MACHREGS_x86_64)
freeReg rsp = False -- %rsp is the C stack pointer
# endif
@@ -875,14 +879,14 @@ freeRegBase REG_HpLim = False
-- their liveness accurately.
freeRegBase _ = True
-#elif MACHREGS_powerpc
+#elif defined(MACHREGS_powerpc)
freeReg 0 = False -- Used by code setting the back chain pointer
-- in stack reallocations on Linux
-- r0 is not usable in all insns so also reserved
-- on Darwin.
freeReg 1 = False -- The Stack Pointer
-# if !MACHREGS_darwin
+# if !defined(MACHREGS_darwin)
-- most non-darwin powerpc OSes use r2 as a TOC pointer or something like that
freeReg 2 = False
freeReg 13 = False -- reserved for system thread ID on 64 bit
@@ -983,7 +987,7 @@ freeReg REG_HpLim = False
# endif
freeReg _ = True
-#elif MACHREGS_sparc
+#elif defined(MACHREGS_sparc)
-- SPARC regs used by the OS / ABI
-- %g0(r0) is always zero