summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-09-18 17:43:15 +0100
committerIan Lynagh <ian@well-typed.com>2012-09-18 17:43:15 +0100
commitb44db6f1fac8e5c166104d6158eeaccbe9eb223d (patch)
tree77e560d4578d43d4d9e44549005f908bd2bdbf5f
parent98903b9626ab332eeac9d4baeb6854dd47272e8c (diff)
downloadhaskell-b44db6f1fac8e5c166104d6158eeaccbe9eb223d.tar.gz
Remove some uses of the WORDS_BIGENDIAN CPP symbol
-rw-r--r--compiler/cmm/CmmUtils.hs12
-rw-r--r--compiler/cmm/PprC.hs12
-rw-r--r--includes/mkDerivedConstants.c29
3 files changed, 39 insertions, 14 deletions
diff --git a/compiler/cmm/CmmUtils.hs b/compiler/cmm/CmmUtils.hs
index e4d1c9efb5..8cbe46360c 100644
--- a/compiler/cmm/CmmUtils.hs
+++ b/compiler/cmm/CmmUtils.hs
@@ -165,13 +165,11 @@ packHalfWordsCLit :: DynFlags -> StgHalfWord -> StgHalfWord -> CmmLit
-- ToDo: consider using half-word lits instead
-- but be careful: that's vulnerable when reversed
packHalfWordsCLit dflags lower_half_word upper_half_word
-#ifdef WORDS_BIGENDIAN
- = mkWordCLit dflags ((fromIntegral lower_half_word `shiftL` hALF_WORD_SIZE_IN_BITS)
- .|. fromIntegral upper_half_word)
-#else
- = mkWordCLit dflags ((fromIntegral lower_half_word)
- .|. (fromIntegral upper_half_word `shiftL` hALF_WORD_SIZE_IN_BITS))
-#endif
+ = if wORDS_BIGENDIAN dflags
+ then mkWordCLit dflags ((l `shiftL` hALF_WORD_SIZE_IN_BITS) .|. u)
+ else mkWordCLit dflags (l .|. (u `shiftL` hALF_WORD_SIZE_IN_BITS))
+ where l = fromIntegral lower_half_word
+ u = fromIntegral upper_half_word
---------------------------------------------------
--
diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs
index bb2f189e14..1a3eb0d716 100644
--- a/compiler/cmm/PprC.hs
+++ b/compiler/cmm/PprC.hs
@@ -492,13 +492,11 @@ pprStatics dflags (CmmStaticLit (CmmFloat f W64) : rest)
= map pprLit1 (doubleToWords dflags f) ++ pprStatics dflags rest
pprStatics dflags (CmmStaticLit (CmmInt i W64) : rest)
| wordWidth dflags == W32
-#ifdef WORDS_BIGENDIAN
- = pprStatics dflags (CmmStaticLit (CmmInt q W32) :
- CmmStaticLit (CmmInt r W32) : rest)
-#else
- = pprStatics dflags (CmmStaticLit (CmmInt r W32) :
- CmmStaticLit (CmmInt q W32) : rest)
-#endif
+ = if wORDS_BIGENDIAN dflags
+ then pprStatics dflags (CmmStaticLit (CmmInt q W32) :
+ CmmStaticLit (CmmInt r W32) : rest)
+ else pprStatics dflags (CmmStaticLit (CmmInt r W32) :
+ CmmStaticLit (CmmInt q W32) : rest)
where r = i .&. 0xffffffff
q = i `shiftR` 32
pprStatics dflags (CmmStaticLit (CmmInt _ w) : _)
diff --git a/includes/mkDerivedConstants.c b/includes/mkDerivedConstants.c
index 558d709f94..c73233288a 100644
--- a/includes/mkDerivedConstants.c
+++ b/includes/mkDerivedConstants.c
@@ -293,6 +293,27 @@ enum Mode { Gen_Haskell_Type, Gen_Haskell_Value, Gen_Haskell_Wrappers, Gen_Haske
#define FUN_OFFSET(sym) (OFFSET(Capability,f.sym) - OFFSET(Capability,r))
+void constantBool(char *haskellName, int val) {
+ switch (mode) {
+ case Gen_Haskell_Type:
+ printf(" , pc_%s :: Bool\n", haskellName);
+ break;
+ case Gen_Haskell_Value:
+ printf(" , pc_%s = %s\n", haskellName, val ? "True" : "False");
+ break;
+ case Gen_Haskell_Wrappers:
+ printf("%s :: DynFlags -> Bool\n", haskellName);
+ printf("%s dflags = pc_%s (sPlatformConstants (settings dflags))\n",
+ haskellName, haskellName);
+ break;
+ case Gen_Haskell_Exports:
+ printf(" %s,\n", haskellName);
+ break;
+ case Gen_Header:
+ break;
+ }
+}
+
void constantIntC(char *cName, char *haskellName, intptr_t val) {
/* If the value is larger than 2^28 or smaller than -2^28, then fail.
This test is a bit conservative, but if any constants are roughly
@@ -700,6 +721,14 @@ main(int argc, char *argv[])
// Amount of pointer bits used for semi-tagging constructor closures
constantInt("tAG_BITS", TAG_BITS);
+ constantBool("wORDS_BIGENDIAN",
+#ifdef WORDS_BIGENDIAN
+ 1
+#else
+ 0
+#endif
+ );
+
switch (mode) {
case Gen_Haskell_Type:
printf(" } deriving (Read, Show)\n");