llvm-data-interop-0.3.0: A low-level data interoperability binding for LLVM

Safe HaskellNone

LLVM.Parse

Contents

Description

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.

Synopsis

Types

data ParserOptions Source

Options controlling how Modules 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.

Constructors

PositionPrecise

Preserve all information from LLVM (line and column numbers)

PositionNone

Discard all position information

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.