Last active
August 29, 2015 13:55
-
-
Save cartazio/8748569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Module {moduleName = "<string>", moduleDataLayout = Just (DataLayout {endianness = Just LittleEndian, stackAlignment = Just 128, pointerLayouts = fromList [(AddrSpace 0,(64,AlignmentInfo {abiAlignment = 64, preferredAlignment = Just 64}))], typeLayouts = fromList [((IntegerAlign,1),AlignmentInfo {abiAlignment = 8, preferredAlignment = Just 8}),((IntegerAlign,8),AlignmentInfo {abiAlignment = 8, preferredAlignment = Just 8}),((IntegerAlign,16),AlignmentInfo {abiAlignment = 16, preferredAlignment = Just 16}),((IntegerAlign,32),AlignmentInfo {abiAlignment = 32, preferredAlignment = Just 32}),((IntegerAlign,64),AlignmentInfo {abiAlignment = 64, preferredAlignment = Just 64}),((VectorAlign,64),AlignmentInfo {abiAlignment = 64, preferredAlignment = Just 64}),((VectorAlign,128),AlignmentInfo {abiAlignment = 128, preferredAlignment = Just 128}),((FloatAlign,32),AlignmentInfo {abiAlignment = 32, preferredAlignment = Just 32}),((FloatAlign,64),AlignmentInfo {abiAlignment = 64, preferredAlignment = Just 64}),((FloatAlign,80),AlignmentInfo {abiAlignment = 128, preferredAlignment = Just 128}),((AggregateAlign,0),AlignmentInfo {abiAlignment = 0, preferredAlignment = Just 64}),((StackAlign,0),AlignmentInfo {abiAlignment = 64, preferredAlignment = Just 64})], nativeSizes = Just (fromList [8,16,32,64])}), moduleTargetTriple = Just "x86_64-apple-macosx10.9.0", moduleDefinitions = [GlobalDefinition (Function {linkage = External, visibility = Default, callingConvention = C, returnAttributes = [], returnType = IntegerType {typeBits = 32}, name = Name "plus", parameters = ([Parameter (IntegerType {typeBits = 32}) (Name "a") [],Parameter (IntegerType {typeBits = 32}) (Name "b") []],False), functionAttributes = [NoUnwind,StackProtect,UWTable], section = Nothing, alignment = 0, garbageCollectorName = Nothing, basicBlocks = [BasicBlock (UnName 0) [UnName 1 := Alloca {allocatedType = IntegerType {typeBits = 32}, numElements = Nothing, alignment = 4, metadata = []},UnName 2 := Alloca {allocatedType = IntegerType {typeBits = 32}, numElements = Nothing, alignment = 4, metadata = []},Do (Store {volatile = False, address = LocalReference (UnName 1), value = LocalReference (Name "a"), maybeAtomicity = Nothing, alignment = 4, metadata = []}),Do (Store {volatile = False, address = LocalReference (UnName 2), value = LocalReference (Name "b"), maybeAtomicity = Nothing, alignment = 4, metadata = []}),UnName 3 := Load {volatile = False, address = LocalReference (UnName 1), maybeAtomicity = Nothing, alignment = 4, metadata = []},UnName 4 := Load {volatile = False, address = LocalReference (UnName 2), maybeAtomicity = Nothing, alignment = 4, metadata = []},UnName 5 := Add {nsw = True, nuw = False, operand0 = LocalReference (UnName 3), operand1 = LocalReference (UnName 4), metadata = []}] (Do (Ret {returnOperand = Just (LocalReference (UnName 5)), metadata' = []}))]})]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"; ModuleID = 'test.c'\ntarget datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.9.0\"\n\ndefine i32 @plus(i32 %a, i32 %b) nounwind ssp uwtable {\n %1 = alloca i32, align 4\n %2 = alloca i32, align 4\n store i32 %a, i32* %1, align 4\n store i32 %b, i32* %2, align 4\n %3 = load i32* %1, align 4\n %4 = load i32* %2, align 4\n %5 = add nsw i32 %3, %4\n ret i32 %5\n}\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int plus(int a, int b) ; | |
int plus(int a, int b){ | |
return a + b ; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import LLVM.General | |
import LLVM.General.Context | |
import Control.Monad.Error | |
parseStringLLVM str = do | |
res <- withContext (\x -> do | |
(Right modAST) <- runErrorT $ withModuleFromString x str moduleAST | |
return modAST | |
) | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment