| ... |
... |
@@ -939,9 +939,9 @@ getRegister' config plat expr |
|
939
|
939
|
case register of
|
|
940
|
940
|
Any _fmt code ->
|
|
941
|
941
|
pure $ Any (intFormat to) $ \dst -> do
|
|
942
|
|
- code dst `appOL` instrsNonclobberedCode (truncateSubwordReg SNeverClobbers to dst)
|
|
|
942
|
+ code dst `appOL` truncateSubwordRegInplace to dst
|
|
943
|
943
|
Fixed _fmt reg code -> do
|
|
944
|
|
- (trunc_reg, trunc_code) <- instrsWithUnclobberedReg $ truncateSubwordReg SMayClobberSubwordArgReg to reg
|
|
|
944
|
+ (trunc_reg, trunc_code) <- truncateSubwordReg SMayClobberSubwordArgReg to reg
|
|
945
|
945
|
pure $ Fixed (intFormat to) trunc_reg (code `appOL` trunc_code)
|
|
946
|
946
|
CmmMachOp op [e] -> do
|
|
947
|
947
|
(reg, _format, code) <- getSomeReg e
|
| ... |
... |
@@ -1280,8 +1280,9 @@ getRegister' config plat expr |
|
1280
|
1280
|
let w' = opRegWidth w
|
|
1281
|
1281
|
signExt r
|
|
1282
|
1282
|
-- See Note [Signed arithmetic on AArch64] and #27430
|
|
1283
|
|
- | w >= W32 = pure (r, nilOL)
|
|
1284
|
|
- | not is_signed = truncateSubwordReg w r
|
|
|
1283
|
+ | not is_signed = truncateSubwordReg SMayClobberSubwordArgReg w r
|
|
|
1284
|
+ -- TODO(mangoiv) in the signed case if w> W32,
|
|
|
1285
|
+ -- this should be a noop
|
|
1285
|
1286
|
| otherwise = signExtendReg w w' r
|
|
1286
|
1287
|
(reg_x_sx, code_x_sx) <- signExt reg_x
|
|
1287
|
1288
|
(reg_y_sx, code_y_sx) <- signExt reg_y
|
| ... |
... |
@@ -1974,10 +1975,16 @@ pattern WFull <- (\case W32 -> True; W64 -> True; _ -> False -> True) |
|
1974
|
1975
|
pattern WSub :: (Operand -> Operand -> Instr) -> Width
|
|
1975
|
1976
|
pattern WSub {truncInstr} <- (\case W16 -> Just UXTH; W8 -> Just UXTB; _ -> Nothing -> (Just truncInstr))
|
|
1976
|
1977
|
|
|
|
1978
|
+truncateSubwordRegInplace :: Width -> Reg -> OrdList Instr
|
|
|
1979
|
+truncateSubwordRegInplace w_to r = instrsNonclobberedCode (truncateSubwordReg' SNeverClobbers w_to r)
|
|
|
1980
|
+
|
|
|
1981
|
+truncateSubwordReg :: SArgumentClobbering MayClobberArgReg -> Width -> Reg -> NatM (Reg, OrdList Instr)
|
|
|
1982
|
+truncateSubwordReg clobbering w_to r = instrsWithUnclobberedReg (truncateSubwordReg' clobbering w_to r)
|
|
|
1983
|
+
|
|
1977
|
1984
|
-- | Truncate/zero extend the subwords high bits and store the
|
|
1978
|
1985
|
-- result in a new register.
|
|
1979
|
|
-truncateSubwordReg :: SArgumentClobbering a -> Width -> Reg -> SArgumentClobbered a
|
|
1980
|
|
-truncateSubwordReg clobbering w_to r = case clobbering of
|
|
|
1986
|
+truncateSubwordReg' :: SArgumentClobbering a -> Width -> Reg -> SArgumentClobbered a
|
|
|
1987
|
+truncateSubwordReg' clobbering w_to r = case clobbering of
|
|
1981
|
1988
|
SMayClobberSubwordArgReg
|
|
1982
|
1989
|
-- return the input register
|
|
1983
|
1990
|
| WFull <- w_to -> SUnclobbered $ pure (r, nilOL)
|