[Git][ghc/ghc][wip/andreask/arm-ffi] fixup! compiler: refactor truncation to be able to control whether or not registers are alloated
Magnus pushed to branch wip/andreask/arm-ffi at Glasgow Haskell Compiler / GHC Commits: b894fde8 by mangoiv at 2026-08-05T11:57:01+02:00 fixup! compiler: refactor truncation to be able to control whether or not registers are alloated - - - - - 1 changed file: - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs Changes: ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -939,9 +939,9 @@ getRegister' config plat expr case register of Any _fmt code -> pure $ Any (intFormat to) $ \dst -> do - code dst `appOL` instrsNonclobberedCode (truncateSubwordReg SNeverClobbers to dst) + code dst `appOL` truncateSubwordRegInplace to dst Fixed _fmt reg code -> do - (trunc_reg, trunc_code) <- instrsWithUnclobberedReg $ truncateSubwordReg SMayClobberSubwordArgReg to reg + (trunc_reg, trunc_code) <- truncateSubwordReg SMayClobberSubwordArgReg to reg pure $ Fixed (intFormat to) trunc_reg (code `appOL` trunc_code) CmmMachOp op [e] -> do (reg, _format, code) <- getSomeReg e @@ -1280,8 +1280,9 @@ getRegister' config plat expr let w' = opRegWidth w signExt r -- See Note [Signed arithmetic on AArch64] and #27430 - | w >= W32 = pure (r, nilOL) - | not is_signed = truncateSubwordReg w r + | not is_signed = truncateSubwordReg SMayClobberSubwordArgReg w r + -- TODO(mangoiv) in the signed case if w> W32, + -- this should be a noop | otherwise = signExtendReg w w' r (reg_x_sx, code_x_sx) <- signExt reg_x (reg_y_sx, code_y_sx) <- signExt reg_y @@ -1974,10 +1975,16 @@ pattern WFull <- (\case W32 -> True; W64 -> True; _ -> False -> True) pattern WSub :: (Operand -> Operand -> Instr) -> Width pattern WSub {truncInstr} <- (\case W16 -> Just UXTH; W8 -> Just UXTB; _ -> Nothing -> (Just truncInstr)) +truncateSubwordRegInplace :: Width -> Reg -> OrdList Instr +truncateSubwordRegInplace w_to r = instrsNonclobberedCode (truncateSubwordReg' SNeverClobbers w_to r) + +truncateSubwordReg :: SArgumentClobbering MayClobberArgReg -> Width -> Reg -> NatM (Reg, OrdList Instr) +truncateSubwordReg clobbering w_to r = instrsWithUnclobberedReg (truncateSubwordReg' clobbering w_to r) + -- | Truncate/zero extend the subwords high bits and store the -- result in a new register. -truncateSubwordReg :: SArgumentClobbering a -> Width -> Reg -> SArgumentClobbered a -truncateSubwordReg clobbering w_to r = case clobbering of +truncateSubwordReg' :: SArgumentClobbering a -> Width -> Reg -> SArgumentClobbered a +truncateSubwordReg' clobbering w_to r = case clobbering of SMayClobberSubwordArgReg -- return the input register | WFull <- w_to -> SUnclobbered $ pure (r, nilOL) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b894fde8292bdb13d856db43d4b54a8a... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b894fde8292bdb13d856db43d4b54a8a... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Magnus (@MangoIV)