Andreas Klebinger pushed to branch wip/andreask/arm-ffi at Glasgow Haskell Compiler / GHC Commits: e3e35453 by Andreas Klebinger at 2026-07-29T20:13:25+00:00 cmm: Expand size annotations to more operators with -dppr-debug - - - - - 32f219c8 by Andreas Klebinger at 2026-07-29T22:20:46+00:00 arm ncg: Fix bitmask immediates being too large. We now use the appropriate bitmask width for the *operation* rather than the one of literal operand. - - - - - 2 changed files: - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs Changes: ===================================== compiler/GHC/Cmm/Expr.hs ===================================== @@ -552,11 +552,11 @@ genMachOp platform mop args infixMachOp :: MachOp -> Maybe SDoc infixMachOp mop = case mop of - MO_And _ -> Just $ char '&' - MO_Or _ -> Just $ char '|' - MO_Xor _ -> Just $ char '^' - MO_Not _ -> Just $ char '~' - MO_S_Neg _ -> Just $ char '-' -- there is no unsigned neg :) + MO_And w -> Just $ withDebugWidth w $ char '&' + MO_Or w -> Just $ withDebugWidth w $ char '|' + MO_Xor w -> Just $ withDebugWidth w $ char '^' + MO_Not w -> Just $ withDebugWidth w $ char '~' + MO_S_Neg w -> Just $ withDebugWidth w $ char '-' -- there is no unsigned neg :) _ -> Nothing -- -------------------------------------------------------------------------- ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -1184,14 +1184,14 @@ getRegister' config plat expr return $ Any (intFormat w) (\dst -> code_x `snocOL` annExpr expr (LSR (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))) -- 3. Logic &&, || - CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> - return $ Any fmt (\d -> unitOL $ annExpr expr (AND fmt (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) + CmmMachOp (MO_And w) [(CmmReg reg), CmmLit (CmmInt n _)] | Just op_bitmask <- getBitmaskImm n (opRegWidth w) -> + return $ Any fmt (\d -> unitOL $ annExpr expr (AND fmt (OpReg w d) (OpReg w' r') op_bitmask)) where fmt = intFormat w w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg - CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | isAArch64Bitmask (opRegWidth w') (fromIntegral n) -> - return $ Any fmt (\d -> unitOL $ annExpr expr (ORR fmt (OpReg w d) (OpReg w' r') (OpImm (ImmInteger n)))) + CmmMachOp (MO_Or w) [(CmmReg reg), CmmLit (CmmInt n _)] | Just op_bitmask <- getBitmaskImm n (opRegWidth w) -> + return $ Any fmt (\d -> unitOL $ annExpr expr (ORR fmt (OpReg w d) (OpReg w' r') op_bitmask)) where fmt = intFormat w w' = formatToWidth (cmmTypeFormat (cmmRegType reg)) r' = getRegisterReg plat reg View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a96d43048cde2fc2236b06d06b39c8... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a96d43048cde2fc2236b06d06b39c8... 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