summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2022-05-24 14:00:01 +0200
committerAndreas Klebinger <klebinger.andreas@gmx.at>2022-05-24 14:59:21 +0200
commiteb3e47c3df63eea34b6acb27e83aedab974b80ca (patch)
treec792ae66082b0b4d8fbbdba438ede53609560cee
parente2520df3fffa0cf22fb19c5fb872832d11c07d35 (diff)
downloadhaskell-wip/andreask/cmm_lint.tar.gz
Fix #21563 by using Word64 for 64bit shift code.wip/andreask/cmm_lint
We use the 64bit shifts only on 64bit platforms. But we compile the code always so compiling it on 32bit caused a lint error. So use Word64 instead.
-rw-r--r--compiler/GHC/ByteCode/Asm.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/GHC/ByteCode/Asm.hs b/compiler/GHC/ByteCode/Asm.hs
index 427549b6fd..9163aeacd4 100644
--- a/compiler/GHC/ByteCode/Asm.hs
+++ b/compiler/GHC/ByteCode/Asm.hs
@@ -302,7 +302,7 @@ runAsm platform long_jumps e = go
words = concatMap expand ops
expand (SmallOp w) = [w]
expand (LabelOp w) = expand (Op (e w))
- expand (Op w) = if largeOps then largeArg platform w else [fromIntegral w]
+ expand (Op w) = if largeOps then largeArg platform (fromIntegral w) else [fromIntegral w]
-- expand (LargeOp w) = largeArg platform w
state $ \(st_i0,st_l0,st_p0) ->
let st_i1 = addListToSS st_i0 (opcode : words)
@@ -345,13 +345,14 @@ inspectAsm platform long_jumps initial_offset
largeArgInstr :: Word16 -> Word16
largeArgInstr bci = bci_FLAG_LARGE_ARGS .|. bci
-largeArg :: Platform -> Word -> [Word16]
+largeArg :: Platform -> Word64 -> [Word16]
largeArg platform w = case platformWordSize platform of
PW8 -> [fromIntegral (w `shiftR` 48),
fromIntegral (w `shiftR` 32),
fromIntegral (w `shiftR` 16),
fromIntegral w]
- PW4 -> [fromIntegral (w `shiftR` 16),
+ PW4 -> assert (w < fromIntegral (maxBound :: Word32)) $
+ [fromIntegral (w `shiftR` 16),
fromIntegral w]
largeArg16s :: Platform -> Word