diff options
author | David Terei <davidterei@gmail.com> | 2010-07-02 16:05:11 +0000 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2010-07-02 16:05:11 +0000 |
commit | 77e899c398432fbf7cf9a98737430c21ad8d7c94 (patch) | |
tree | 25ba02951dccc7cc3a4394ad1eb2e02a4c6234d3 /compiler/llvmGen/Llvm | |
parent | 12ec40c5c2b51e826477c557922297f105a41fdb (diff) | |
download | haskell-77e899c398432fbf7cf9a98737430c21ad8d7c94.tar.gz |
LLVM: Use the inbounds keyword for getelementptr instructions.
Diffstat (limited to 'compiler/llvmGen/Llvm')
-rw-r--r-- | compiler/llvmGen/Llvm/AbsSyn.hs | 3 | ||||
-rw-r--r-- | compiler/llvmGen/Llvm/PpLlvm.hs | 9 |
2 files changed, 7 insertions, 5 deletions
diff --git a/compiler/llvmGen/Llvm/AbsSyn.hs b/compiler/llvmGen/Llvm/AbsSyn.hs index 1fed3a88dd..7a5b70048f 100644 --- a/compiler/llvmGen/Llvm/AbsSyn.hs +++ b/compiler/llvmGen/Llvm/AbsSyn.hs @@ -171,12 +171,13 @@ data LlvmExpression {- | Navigate in an structure, selecting elements + * inbound: Is the pointer inbounds? (computed pointer doesn't overflow) * ptr: Location of the structure * indexes: A list of indexes to select the correct value. For example the first element of the third element of the structure ptr is selected with [3,1] (zero indexed) -} - | GetElemPtr LlvmVar [Int] + | GetElemPtr Bool LlvmVar [Int] {- | Cast the variable from to the to type. This is an abstraction of three diff --git a/compiler/llvmGen/Llvm/PpLlvm.hs b/compiler/llvmGen/Llvm/PpLlvm.hs index 2227fb6094..4391fc58a2 100644 --- a/compiler/llvmGen/Llvm/PpLlvm.hs +++ b/compiler/llvmGen/Llvm/PpLlvm.hs @@ -177,7 +177,7 @@ ppLlvmExpression expr Call tp fp args attrs -> ppCall tp fp args attrs Cast op from to -> ppCast op from to Compare op left right -> ppCmpOp op left right - GetElemPtr ptr indexes -> ppGetElementPtr ptr indexes + GetElemPtr inb ptr indexes -> ppGetElementPtr inb ptr indexes Load ptr -> ppLoad ptr Malloc tp amount -> ppMalloc tp amount Phi tp precessors -> ppPhi tp precessors @@ -268,10 +268,11 @@ ppAlloca tp amount = in text "alloca" <+> texts tp <> comma <+> texts amount' -ppGetElementPtr :: LlvmVar -> [Int] -> Doc -ppGetElementPtr ptr idx = +ppGetElementPtr :: Bool -> LlvmVar -> [Int] -> Doc +ppGetElementPtr inb ptr idx = let indexes = hcat $ map ((comma <+> texts i32 <+>) . texts) idx - in text "getelementptr" <+> texts ptr <> indexes + inbound = if inb then text "inbounds" else empty + in text "getelementptr" <+> inbound <+> texts ptr <> indexes ppReturn :: Maybe LlvmVar -> Doc |