llvm-general 3.4.4.3 → 3.4.4.4
raw patch · 6 files changed
+44/−24 lines, 6 filesdep ~llvm-generaldep ~llvm-general-pure
Dependency ranges changed: llvm-general, llvm-general-pure
Files
- llvm-general.cabal +3/−3
- src/LLVM/General/Internal/Attribute.hs +6/−4
- src/LLVM/General/Internal/FFI/Function.h +10/−10
- src/LLVM/General/Internal/FFI/LLVMCTypes.hsc +1/−1
- src/LLVM/General/Internal/Type.hs +1/−1
- test/LLVM/General/Test/Module.hs +23/−5
llvm-general.cabal view
@@ -1,5 +1,5 @@ name: llvm-general-version: 3.4.4.3+version: 3.4.4.4 license: BSD3 license-file: LICENSE author: Benjamin S.Scarlet <fgthb0@greynode.net>@@ -38,7 +38,7 @@ type: git location: git://github.com/bscarlet/llvm-general.git branch: llvm-3.4- tag: v3.4.4.3+ tag: v3.4.4.4 flag shared-llvm description: link against llvm shared rather than static library@@ -203,7 +203,7 @@ HUnit >= 1.2.4.2, test-framework-quickcheck2 >= 0.3.0.1, QuickCheck >= 2.5.1.1,- llvm-general == 3.4.4.3,+ llvm-general == 3.4.4.4, llvm-general-pure == 3.4.4.1, containers >= 0.4.2.1, mtl >= 2.1,
src/LLVM/General/Internal/Attribute.hs view
@@ -42,7 +42,9 @@ instanceD (sequence [classP ''Monad [m]]) [t| EncodeM $(m) [$(type')] $(conT ctn) |] [ funD (mkName "encodeM") [ clause [] (normalB [| return . (- let + let+ encodeAlignment a | popCount a == 1 = 1 + popCount (a - 1)+ encodeAlignment _ = error "Cannot encode alignment which is not a power of two" encodeAttribute a = $( caseE [| a |] $ flip map attributeData' $ \(n, b, s, w) -> let bQ = (dataToExpQ (const Nothing) b)@@ -53,7 +55,7 @@ a <- newName "a" match (conP n [varP a])- (normalB [| ($(conE ctcn) (fromIntegral $(varE a) `shiftL` s)) .&. $(bQ) |])+ (normalB [| ($(conE ctcn) (fromIntegral (encodeAlignment $(varE a)) `shiftL` s)) .&. $(bQ) |]) [] ) in@@ -83,7 +85,7 @@ i' <- newName "i'" letE [valD (conP ctcn [varP i']) (normalB [| i |]) []]- [| $(conE n) (fromIntegral $(varE i')) |])+ [| $(conE n) (bit ((fromIntegral $(varE i')) - 1)) |]) | let i = ($(varE bits) .&. $(dataToExpQ (const Nothing) b)) `shiftR` s, i /= $(zero) ]@@ -118,6 +120,7 @@ (FFI.paramAttrSExt, "A.A.SignExt"), (FFI.paramAttrInReg, "A.A.InReg"), (FFI.paramAttrStructRet, "A.A.SRet"),+ (FFI.paramAttrAlignment, "A.A.Alignment"), (FFI.paramAttrNoAlias, "A.A.NoAlias"), (FFI.paramAttrByVal, "A.A.ByVal"), (FFI.paramAttrNoCapture, "A.A.NoCapture"),@@ -134,7 +137,6 @@ (FFI.functionAttrOptimizeForSize, "A.A.OptimizeForSize"), (FFI.functionAttrStackProtect, "A.A.StackProtect"), (FFI.functionAttrStackProtectReq, "A.A.StackProtectReq"),- (FFI.functionAttrAlignment, "A.A.Alignment"), (FFI.functionAttrNoRedZone, "A.A.NoRedZone"), (FFI.functionAttrNoImplicitFloat, "A.A.NoImplicitFloat"), (FFI.functionAttrNaked, "A.A.Naked"),
src/LLVM/General/Internal/FFI/Function.h view
@@ -6,15 +6,16 @@ macro(Fast) \ macro(Cold) \ -#define LLVM_GENERAL_FOR_EACH_PARAM_ATTR(macro) \- macro(ZExt) \- macro(SExt) \- macro(InReg) \- macro(StructRet) \- macro(NoAlias) \- macro(ByVal) \- macro(NoCapture) \- macro(Nest) \+#define LLVM_GENERAL_FOR_EACH_PARAM_ATTR(macro) \+ macro(ZExt,Attribute) \+ macro(SExt,Attribute) \+ macro(InReg,Attribute) \+ macro(StructRet,Attribute) \+ macro(Alignment,) \+ macro(NoAlias,Attribute) \+ macro(ByVal,Attribute) \+ macro(NoCapture,Attribute) \+ macro(Nest,Attribute) #define LLVM_GENERAL_FOR_EACH_FUNCTION_ATTR(macro) \ macro(NoReturn,Attribute) \@@ -26,7 +27,6 @@ macro(OptimizeForSize,Attribute) \ macro(StackProtect,Attribute) \ macro(StackProtectReq,Attribute) \- macro(Alignment,) \ macro(NoRedZone,Attribute) \ macro(NoImplicitFloat,Attribute) \ macro(Naked,Attribute) \
src/LLVM/General/Internal/FFI/LLVMCTypes.hsc view
@@ -193,7 +193,7 @@ newtype ParamAttr = ParamAttr CUInt deriving (Eq, Read, Show, Bits, Typeable, Data, Num)-#define PA_Rec(n) { #n, LLVM ## n ## Attribute },+#define PA_Rec(n,a) { #n, LLVM ## n ## a }, #{inject PARAM_ATTR, ParamAttr, ParamAttr, paramAttr, PA_Rec} newtype FunctionAttr = FunctionAttr CUInt
src/LLVM/General/Internal/Type.hs view
@@ -137,7 +137,7 @@ ifM (decodeM =<< liftIO (FFI.structIsLiteral t)) (getStructure t) (saveNamedType t >> return A.NamedTypeReference `ap` getTypeName t)-+ [typeKindP|Metadata|] -> return A.MetadataType [typeKindP|Array|] -> return A.ArrayType `ap` (decodeM =<< liftIO (FFI.getArrayLength t))
test/LLVM/General/Test/Module.hs view
@@ -9,7 +9,6 @@ import Control.Monad.Trans.Except import Data.Bits import Data.Word-import Data.Functor import qualified Data.Set as Set @@ -50,12 +49,12 @@ \@two = alias i32 addrspace(3)* @three\n\ \\n\ \define i32 @bar() {\n\- \ %1 = call zeroext i32 @foo(i32 inreg 1, i8 signext 4) #0\n\+ \ %1 = call zeroext i32 @foo(i32 inreg align 16 1, i8 signext 4) #0\n\ \ ret i32 %1\n\ \}\n\ \\n\ \; Function Attrs: nounwind readnone uwtable\n\- \define zeroext i32 @foo(i32 inreg %x, i8 signext %y) #0 {\n\+ \define zeroext i32 @foo(i32 inreg align 16 %x, i8 signext %y) #0 {\n\ \ %1 = mul nsw i32 %x, %x\n\ \ br label %here\n\ \\n\@@ -136,7 +135,7 @@ returnAttributes = [A.ZeroExt], function = Right (ConstantOperand (C.GlobalReference (ptr (FunctionType i32 [i32, i8] False)) (Name "foo"))), arguments = [- (ConstantOperand (C.Int 32 1), [A.InReg]),+ (ConstantOperand (C.Int 32 1), [A.InReg, A.Alignment 16]), (ConstantOperand (C.Int 8 4), [A.SignExt]) ], functionAttributes = [A.NoUnwind, A.ReadNone, A.UWTable],@@ -152,7 +151,7 @@ G.returnType = i32, G.name = Name "foo", G.parameters = ([- Parameter i32 (Name "x") [A.InReg],+ Parameter i32 (Name "x") [A.InReg, A.Alignment 16], Parameter i8 (Name "y") [A.SignExt] ], False), G.functionAttributes = [A.NoUnwind, A.ReadNone, A.UWTable],@@ -329,6 +328,25 @@ strCheck ast s s' <- withContext $ \context -> withModuleFromAST' context ast $ runExceptT . verify s' @?= Right (),++ testCase "metadata type" $ withContext $ \context -> do+ let s = "; ModuleID = '<string>'\n\+ \\n\+ \define void @bar(metadata) {\n\+ \ ret void\n\+ \}\n"+ ast = Module "<string>" Nothing Nothing [+ GlobalDefinition $ functionDefaults {+ G.returnType = void,+ G.name = Name "bar",+ G.parameters = ([Parameter MetadataType (UnName 0) []], False),+ G.basicBlocks = [+ BasicBlock (UnName 1) [] (Do $ Ret Nothing [])+ ]+ }+ ]+ strCheck ast s,+ testCase "set flag on constant expr" $ withContext $ \context -> do let ast = Module "<string>" Nothing Nothing [ GlobalDefinition $ functionDefaults {