Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module and descendants define AST data types to represent LLVM code. Note that these types are designed for fidelity rather than convenience - if the truth of what LLVM supports is less than pretty, so be it.
Synopsis
- data Module = Module {}
- defaultModule :: Module
- data Definition
- data Global
- = GlobalVariable Name Linkage Visibility (Maybe StorageClass) (Maybe Model) (Maybe UnnamedAddr) Bool Type AddrSpace (Maybe Constant) (Maybe ShortByteString) (Maybe ShortByteString) Word32 [(ShortByteString, MDRef MDNode)]
- | GlobalAlias Name Linkage Visibility (Maybe StorageClass) (Maybe Model) (Maybe UnnamedAddr) Type AddrSpace Constant
- | Function Linkage Visibility (Maybe StorageClass) CallingConvention [ParameterAttribute] Type Name ([Parameter], Bool) [Either GroupID FunctionAttribute] (Maybe ShortByteString) (Maybe ShortByteString) Word32 (Maybe ShortByteString) (Maybe Constant) [BasicBlock] (Maybe Constant) [(ShortByteString, MDRef MDNode)]
- globalVariableDefaults :: Global
- globalAliasDefaults :: Global
- functionDefaults :: Global
- data UnnamedAddr
- data Parameter = Parameter Type Name [ParameterAttribute]
- data BasicBlock = BasicBlock Name [Named Instruction] (Named Terminator)
- data Operand
- type CallableOperand = Either InlineAssembly Operand
- data Metadata
- newtype MetadataNodeID = MetadataNodeID Word
- data MDRef a
- = MDRef MetadataNodeID
- | MDInline a
- data MDNode
- module LLVM.AST.Instruction
- module LLVM.AST.Name
- data Type
- = VoidType
- | IntegerType { }
- | PointerType { }
- | FloatingPointType { }
- | FunctionType {
- resultType :: Type
- argumentTypes :: [Type]
- isVarArg :: Bool
- | VectorType { }
- | StructureType {
- isPacked :: Bool
- elementTypes :: [Type]
- | ArrayType { }
- | NamedTypeReference Name
- | MetadataType
- | LabelType
- | TokenType
- data FloatingPointType
Documentation
Module | |
|
Instances
Eq Module Source # | |
Data Module Source # | |
Defined in LLVM.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Module -> c Module # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Module # toConstr :: Module -> Constr # dataTypeOf :: Module -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Module) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Module) # gmapT :: (forall b. Data b => b -> b) -> Module -> Module # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Module -> r # gmapQ :: (forall d. Data d => d -> u) -> Module -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Module -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Module -> m Module # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Module -> m Module # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Module -> m Module # | |
Read Module Source # | |
Show Module Source # | |
Generic Module Source # | |
type Rep Module Source # | |
Defined in LLVM.AST type Rep Module = D1 (MetaData "Module" "LLVM.AST" "llvm-hs-pure-6.2.1-8ETY0EFB21q8SO4DjmfkXC" False) (C1 (MetaCons "Module" PrefixI True) ((S1 (MetaSel (Just "moduleName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ShortByteString) :*: S1 (MetaSel (Just "moduleSourceFileName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ShortByteString)) :*: (S1 (MetaSel (Just "moduleDataLayout") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe DataLayout)) :*: (S1 (MetaSel (Just "moduleTargetTriple") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe ShortByteString)) :*: S1 (MetaSel (Just "moduleDefinitions") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Definition]))))) |
defaultModule :: Module Source #
helper for making Module
s
data Definition Source #
Any thing which can be at the top level of a Module
Instances
Instances
globalVariableDefaults :: Global Source #
helper for making GlobalVariable
s
globalAliasDefaults :: Global Source #
helper for making GlobalAlias
s
functionDefaults :: Global Source #
helper for making Function
s
data UnnamedAddr Source #
Instances
Instances
data BasicBlock Source #
http://llvm.org/doxygen/classllvm_1_1BasicBlock.html
LLVM code in a function is a sequence of BasicBlock
s each with a label,
some instructions, and a terminator.
Instances
An Operand
is roughly that which is an argument to an Instruction
LocalReference Type Name | %foo |
ConstantOperand Constant |
|
MetadataOperand Metadata |
Instances
type CallableOperand = Either InlineAssembly Operand Source #
The Call
instruction is special: the callee can be inline assembly
MDString ShortByteString | |
MDNode (MDRef MDNode) | |
MDValue Operand | http://llvm.org/docs/doxygen/html/classllvm_1_1ValueAsMetadata.html |
Instances
Eq Metadata Source # | |
Data Metadata Source # | |
Defined in LLVM.AST.Operand gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Metadata -> c Metadata # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Metadata # toConstr :: Metadata -> Constr # dataTypeOf :: Metadata -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Metadata) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Metadata) # gmapT :: (forall b. Data b => b -> b) -> Metadata -> Metadata # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Metadata -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Metadata -> r # gmapQ :: (forall d. Data d => d -> u) -> Metadata -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Metadata -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Metadata -> m Metadata # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Metadata -> m Metadata # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Metadata -> m Metadata # | |
Ord Metadata Source # | |
Defined in LLVM.AST.Operand | |
Read Metadata Source # | |
Show Metadata Source # | |
Generic Metadata Source # | |
type Rep Metadata Source # | |
Defined in LLVM.AST.Operand type Rep Metadata = D1 (MetaData "Metadata" "LLVM.AST.Operand" "llvm-hs-pure-6.2.1-8ETY0EFB21q8SO4DjmfkXC" False) (C1 (MetaCons "MDString" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ShortByteString)) :+: (C1 (MetaCons "MDNode" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (MDRef MDNode))) :+: C1 (MetaCons "MDValue" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Operand)))) |
newtype MetadataNodeID Source #
A MetadataNodeID
is a number for identifying a metadata node.
Note this is different from "named metadata", which are represented with
NamedMetadataDefinition
.
Instances
MDRef
can either represent a reference to some piece of
metadata or the metadata itself.
This is mainly useful for encoding cyclic metadata. Note that LLVM represents inline and non-inline nodes identically, so roundtripping the Haskell AST does not preserve whether a node was inline or not.
Instances
Functor MDRef Source # | |
Eq a => Eq (MDRef a) Source # | |
Data a => Data (MDRef a) Source # | |
Defined in LLVM.AST.Operand gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MDRef a -> c (MDRef a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (MDRef a) # toConstr :: MDRef a -> Constr # dataTypeOf :: MDRef a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (MDRef a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (MDRef a)) # gmapT :: (forall b. Data b => b -> b) -> MDRef a -> MDRef a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MDRef a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MDRef a -> r # gmapQ :: (forall d. Data d => d -> u) -> MDRef a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MDRef a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MDRef a -> m (MDRef a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MDRef a -> m (MDRef a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MDRef a -> m (MDRef a) # | |
Ord a => Ord (MDRef a) Source # | |
Read a => Read (MDRef a) Source # | |
Show a => Show (MDRef a) Source # | |
Generic (MDRef a) Source # | |
type Rep (MDRef a) Source # | |
Defined in LLVM.AST.Operand type Rep (MDRef a) = D1 (MetaData "MDRef" "LLVM.AST.Operand" "llvm-hs-pure-6.2.1-8ETY0EFB21q8SO4DjmfkXC" False) (C1 (MetaCons "MDRef" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 MetadataNodeID)) :+: C1 (MetaCons "MDInline" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))) |
MDTuple [Maybe Metadata] | Nothing represents |
DIExpression DIExpression | |
DIGlobalVariableExpression DIGlobalVariableExpression | |
DILocation DILocation | |
DIMacroNode DIMacroNode | |
DINode DINode |
Instances
module LLVM.AST.Instruction
module LLVM.AST.Name
Instances
data FloatingPointType Source #
LLVM supports some special formats floating point format. This type is to distinguish those format. Also see http://llvm.org/docs/LangRef.html#floating-point-types
HalfFP | 16-bit floating point value |
FloatFP | 32-bit floating point value |
DoubleFP | 64-bit floating point value |
FP128FP | 128-bit floating point value (112-bit mantissa) |
X86_FP80FP | 80-bit floating point value (X87) |
PPC_FP128FP | 128-bit floating point value (two 64-bits) |
Instances
Overview
llvm-hs-pure
defines the Haskell AST for representing an LLVM
Module
. For interacting with the LLVM C/C++ libraries and an
overview of the various libraries in the llvm-hs
ecosystem, take a
look at the docs in the LLVM
module in llvm-hs
.
In addition to constructing the LLVM AST manually, there is also a
monadic IRBuilder interface in IRBuilder
. The IRBuilder will
take care of generating fresh names automatically and generally
reduces the verbosity of using the AST directly. Using
RecursiveDo/mdo
, it is also capable of handling forward references
automatically.