diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-01-27 13:28:32 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-02-04 16:14:47 -0500 |
commit | 7217156c40240c0aed5ffd83ead0fe4ba0484c75 (patch) | |
tree | 1cd6f31d82ba304695189c52939a64a5d9c9f150 /compiler/GHC/CmmToC.hs | |
parent | 58d7faacafc975d522cbc9f56a7db1e46b37d4a1 (diff) | |
download | haskell-7217156c40240c0aed5ffd83ead0fe4ba0484c75.tar.gz |
Introduce alignment in CmmLoad
Diffstat (limited to 'compiler/GHC/CmmToC.hs')
-rw-r--r-- | compiler/GHC/CmmToC.hs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/compiler/GHC/CmmToC.hs b/compiler/GHC/CmmToC.hs index a6a036c290..65077dcc0b 100644 --- a/compiler/GHC/CmmToC.hs +++ b/compiler/GHC/CmmToC.hs @@ -221,7 +221,8 @@ pprStmt platform stmt = parens (mkP_ <> pprExpr1 platform dest <> comma <> pprExpr platform src) <> semi | otherwise - -> hsep [ pprExpr platform (CmmLoad dest rep), equals, pprExpr platform src <> semi ] + -> hsep [ pprExpr platform (CmmLoad dest rep NaturallyAligned), equals, pprExpr platform src <> semi ] + -- TODO: Is this right? where rep = cmmExprType platform src @@ -376,10 +377,10 @@ pprSwitch platform e ids pprExpr :: Platform -> CmmExpr -> SDoc pprExpr platform e = case e of - CmmLit lit -> pprLit platform lit - CmmLoad e ty -> pprLoad platform e ty - CmmReg reg -> pprCastReg reg - CmmRegOff reg 0 -> pprCastReg reg + CmmLit lit -> pprLit platform lit + CmmLoad e ty align -> pprLoad platform e ty align + CmmReg reg -> pprCastReg reg + CmmRegOff reg 0 -> pprCastReg reg -- CmmRegOff is an alias of MO_Add CmmRegOff reg i -> pprCastReg reg <> char '+' <> @@ -390,13 +391,14 @@ pprExpr platform e = case e of CmmStackSlot _ _ -> panic "pprExpr: CmmStackSlot not supported!" -pprLoad :: Platform -> CmmExpr -> CmmType -> SDoc -pprLoad platform e ty +pprLoad :: Platform -> CmmExpr -> CmmType -> AlignmentSpec -> SDoc +pprLoad platform e ty _align | width == W64, wordWidth platform /= W64 = (if isFloatType ty then text "PK_DBL" else text "PK_Word64") <> parens (mkP_ <> pprExpr1 platform e) + -- TODO: exploit natural-alignment where possible | otherwise = case e of CmmReg r | isPtrReg r && width == wordWidth platform && not (isFloatType ty) @@ -1285,7 +1287,7 @@ te_Target (PrimTarget{}) = return () te_Expr :: CmmExpr -> TE () te_Expr (CmmLit lit) = te_Lit lit -te_Expr (CmmLoad e _) = te_Expr e +te_Expr (CmmLoad e _ _) = te_Expr e te_Expr (CmmReg r) = te_Reg r te_Expr (CmmMachOp _ es) = mapM_ te_Expr es te_Expr (CmmRegOff r _) = te_Reg r |