summaryrefslogtreecommitdiff
path: root/compiler/GHC/Llvm
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-01-27 13:28:32 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-02-04 16:14:47 -0500
commit7217156c40240c0aed5ffd83ead0fe4ba0484c75 (patch)
tree1cd6f31d82ba304695189c52939a64a5d9c9f150 /compiler/GHC/Llvm
parent58d7faacafc975d522cbc9f56a7db1e46b37d4a1 (diff)
downloadhaskell-7217156c40240c0aed5ffd83ead0fe4ba0484c75.tar.gz
Introduce alignment in CmmLoad
Diffstat (limited to 'compiler/GHC/Llvm')
-rw-r--r--compiler/GHC/Llvm/Ppr.hs20
-rw-r--r--compiler/GHC/Llvm/Syntax.hs2
2 files changed, 9 insertions, 13 deletions
diff --git a/compiler/GHC/Llvm/Ppr.hs b/compiler/GHC/Llvm/Ppr.hs
index 8ec3f58db2..405296f79f 100644
--- a/compiler/GHC/Llvm/Ppr.hs
+++ b/compiler/GHC/Llvm/Ppr.hs
@@ -242,7 +242,7 @@ ppLlvmExpression opts expr
ExtractV struct idx -> ppExtractV opts struct idx
Insert vec elt idx -> ppInsert opts vec elt idx
GetElemPtr inb ptr indexes -> ppGetElementPtr opts inb ptr indexes
- Load ptr -> ppLoad opts ptr
+ Load ptr align -> ppLoad opts ptr align
ALoad ord st ptr -> ppALoad opts ord st ptr
Malloc tp amount -> ppMalloc opts tp amount
AtomicRMW aop tgt src ordering -> ppAtomicRMW opts aop tgt src ordering
@@ -365,20 +365,16 @@ ppCmpXChg opts addr old new s_ord f_ord =
text "cmpxchg" <+> ppVar opts addr <> comma <+> ppVar opts old <> comma <+> ppVar opts new
<+> ppSyncOrdering s_ord <+> ppSyncOrdering f_ord
--- XXX: On x86, vector types need to be 16-byte aligned for aligned access, but
--- we have no way of guaranteeing that this is true with GHC (we would need to
--- modify the layout of the stack and closures, change the storage manager,
--- etc.). So, we blindly tell LLVM that *any* vector store or load could be
--- unaligned. In the future we may be able to guarantee that certain vector
--- access patterns are aligned, in which case we will need a more granular way
--- of specifying alignment.
-ppLoad :: LlvmCgConfig -> LlvmVar -> SDoc
-ppLoad opts var = text "load" <+> ppr derefType <> comma <+> ppVar opts var <> align
+ppLoad :: LlvmCgConfig -> LlvmVar -> LMAlign -> SDoc
+ppLoad opts var alignment =
+ text "load" <+> ppr derefType <> comma <+> ppVar opts var <> align
where
derefType = pLower $ getVarType var
- align | isVector . pLower . getVarType $ var = text ", align 1"
- | otherwise = empty
+ align =
+ case alignment of
+ Just n -> text ", align" <+> ppr n
+ Nothing -> empty
ppALoad :: LlvmCgConfig -> LlvmSyncOrdering -> SingleThreaded -> LlvmVar -> SDoc
ppALoad opts ord st var =
diff --git a/compiler/GHC/Llvm/Syntax.hs b/compiler/GHC/Llvm/Syntax.hs
index 12e0073c7a..befac77734 100644
--- a/compiler/GHC/Llvm/Syntax.hs
+++ b/compiler/GHC/Llvm/Syntax.hs
@@ -252,7 +252,7 @@ data LlvmExpression
{- |
Load the value at location ptr
-}
- | Load LlvmVar
+ | Load LlvmVar LMAlign
{- |
Atomic load of the value at location ptr