diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2019-08-05 20:44:33 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-08-06 20:26:32 -0400 |
commit | 6f116005a144b3f09381e0a5967a364eb57a5aa5 (patch) | |
tree | e6fa10c5f1f37790d15dff2b9dce7c700b26366a /compiler/prelude/PrelRules.hs | |
parent | c83e39bf91cfeb17a54ccfd5d01bfdfa1b4a72c9 (diff) | |
download | haskell-6f116005a144b3f09381e0a5967a364eb57a5aa5.tar.gz |
Introduce a type for "platform word size", use it instead of Int
We introduce a PlatformWordSize type and use it in platformWordSize
field.
This removes to panic/error calls called when platform word size is not
32 or 64. We now check for this when reading the platform config.
Diffstat (limited to 'compiler/prelude/PrelRules.hs')
-rw-r--r-- | compiler/prelude/PrelRules.hs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/prelude/PrelRules.hs b/compiler/prelude/PrelRules.hs index 8a1876506d..83313a3ca9 100644 --- a/compiler/prelude/PrelRules.hs +++ b/compiler/prelude/PrelRules.hs @@ -433,10 +433,10 @@ shiftRightLogical :: DynFlags -> Integer -> Int -> Integer -- Shift right, putting zeros in rather than sign-propagating as Bits.shiftR would do -- Do this by converting to Word and back. Obviously this won't work for big -- values, but its ok as we use it here -shiftRightLogical dflags x n - | wordSizeInBits dflags == 32 = fromIntegral (fromInteger x `shiftR` n :: Word32) - | wordSizeInBits dflags == 64 = fromIntegral (fromInteger x `shiftR` n :: Word64) - | otherwise = panic "shiftRightLogical: unsupported word size" +shiftRightLogical dflags x n = + case platformWordSize (targetPlatform dflags) of + PW4 -> fromIntegral (fromInteger x `shiftR` n :: Word32) + PW8 -> fromIntegral (fromInteger x `shiftR` n :: Word64) -------------------------- retLit :: (DynFlags -> Literal) -> RuleM CoreExpr @@ -489,7 +489,7 @@ shiftRule shift_op _ -> mzero } wordSizeInBits :: DynFlags -> Integer -wordSizeInBits dflags = toInteger (platformWordSize (targetPlatform dflags) `shiftL` 3) +wordSizeInBits dflags = toInteger (platformWordSizeInBits (targetPlatform dflags)) -------------------------- floatOp2 :: (Rational -> Rational -> Rational) @@ -802,11 +802,12 @@ liftLitDynFlags f = do removeOp32 :: RuleM CoreExpr removeOp32 = do dflags <- getDynFlags - if wordSizeInBits dflags == 32 - then do - [e] <- getArgs - return e - else mzero + case platformWordSize (targetPlatform dflags) of + PW4 -> do + [e] <- getArgs + return e + PW8 -> + mzero getArgs :: RuleM [CoreExpr] getArgs = RuleM $ \_ _ args -> Just args |