Safe Haskell | None |
---|
This module converts the C form of the LLVM IR into a fully referential Haskell version of the IR. The translation is slightly lossy around integral types in some cases, as Haskell Ints do not have the same range as C ints. In the vast majority of cases this should not really be an issue, but it is possible to lose information. If it is an issue it can be changed.
Note that this uses BasicHashTables as mappings. Switching to LinearHashTable has less space overhead but makes performance tank. Don't be tempted.
- data ParserOptions = ParserOptions {}
- data PositionPrecision
- data TranslationException
- = TooManyReturnValues
- | InvalidBranchInst
- | InvalidSwitchLayout
- | InvalidIndirectBranchOperands
- | KnotTyingFailure ValueTag
- | TypeKnotTyingFailure TypeTag
- | MetaKnotFailure
- | InvalidSelectArgs !Int
- | InvalidExtractElementInst !Int
- | InvalidInsertElementInst !Int
- | InvalidShuffleVectorInst !Int
- | InvalidFunctionInTranslateValue
- | InvalidAliasInTranslateValue
- | InvalidGlobalVarInTranslateValue
- | InvalidBinaryOp !Int
- | InvalidUnaryOp !Int
- | InvalidGEPInst !Int
- | InvalidExtractValueInst !Int
- | InvalidInsertValueInst !Int
- | InvalidTag String ValueTag
- | InvalidBlockAddressFunction Value
- | InvalidBlockAddressBlock Value
- | InvalidUnconditionalBranchTarget Value
- | NonConstantTag ValueTag
- | NonInstructionTag ValueTag
- | InvalidBranchTarget Value
- | InvalidSwitchTarget Value
- | InvalidResumeInst !Int
- | InvalidDataLayout Text String
- | UnparsableBitcode String
- | NoModule
- defaultParserOptions :: ParserOptions
- parseLLVM :: ParserOptions -> ByteString -> IO Module
- hParseLLVM :: ParserOptions -> Handle -> IO Module
- parseLLVMFile :: ParserOptions -> FilePath -> IO Module
Types
data ParserOptions Source
Options controlling how Module
s are constructed.
data PositionPrecision Source
Defines the level of precision of position information in the metadata. LLVM gives very precise information, but tracking all of it can consume excessive amounts of space. This option allows it to be selectively discarded.
PositionPrecise | Preserve all information from LLVM (line and column numbers) |
PositionNone | Discard all position information |
data TranslationException Source
Helpers
defaultParserOptions :: ParserOptionsSource
Reasonable default parsing options
Parser
parseLLVM :: ParserOptions -> ByteString -> IO ModuleSource
Parse the LLVM IR (either assembly or bitcode) from a lazy ByteString
into a Module
.
hParseLLVM :: ParserOptions -> Handle -> IO ModuleSource
Parse LLVM IR from a Handle into a Module
parseLLVMFile :: ParserOptions -> FilePath -> IO ModuleSource
Parse the named LLVM file into the LLVM form of the IR (a
Module
). In the case of an error, a descriptive string will be
returned. The input file can be either LLVM assembly or bitcode.