| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
LLVM.AST
Description
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
Constructors
| Module | |
Fields
| |
Instances
| Eq Module Source # | |
| Data Module Source # | |
Defined in LLVM.AST Methods 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 Modules
data Definition Source #
Any thing which can be at the top level of a Module
Constructors
Instances
Constructors
Instances
globalVariableDefaults :: Global Source #
helper for making GlobalVariables
globalAliasDefaults :: Global Source #
helper for making GlobalAliass
functionDefaults :: Global Source #
helper for making Functions
data UnnamedAddr Source #
Constructors
| LocalAddr | |
| GlobalAddr |
Instances
| Eq UnnamedAddr Source # | |
Defined in LLVM.AST.Global | |
| Data UnnamedAddr Source # | |
Defined in LLVM.AST.Global Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UnnamedAddr -> c UnnamedAddr # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UnnamedAddr # toConstr :: UnnamedAddr -> Constr # dataTypeOf :: UnnamedAddr -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UnnamedAddr) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnnamedAddr) # gmapT :: (forall b. Data b => b -> b) -> UnnamedAddr -> UnnamedAddr # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UnnamedAddr -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UnnamedAddr -> r # gmapQ :: (forall d. Data d => d -> u) -> UnnamedAddr -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UnnamedAddr -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UnnamedAddr -> m UnnamedAddr # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UnnamedAddr -> m UnnamedAddr # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UnnamedAddr -> m UnnamedAddr # | |
| Read UnnamedAddr Source # | |
Defined in LLVM.AST.Global Methods readsPrec :: Int -> ReadS UnnamedAddr # readList :: ReadS [UnnamedAddr] # readPrec :: ReadPrec UnnamedAddr # readListPrec :: ReadPrec [UnnamedAddr] # | |
| Show UnnamedAddr Source # | |
Defined in LLVM.AST.Global Methods showsPrec :: Int -> UnnamedAddr -> ShowS # show :: UnnamedAddr -> String # showList :: [UnnamedAddr] -> ShowS # | |
| Generic UnnamedAddr Source # | |
Defined in LLVM.AST.Global Associated Types type Rep UnnamedAddr :: * -> * # | |
| type Rep UnnamedAddr Source # | |
Constructors
| Parameter Type Name [ParameterAttribute] |
Instances
| Eq Parameter Source # | |
| Data Parameter Source # | |
Defined in LLVM.AST.Global Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Parameter -> c Parameter # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Parameter # toConstr :: Parameter -> Constr # dataTypeOf :: Parameter -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Parameter) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Parameter) # gmapT :: (forall b. Data b => b -> b) -> Parameter -> Parameter # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Parameter -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Parameter -> r # gmapQ :: (forall d. Data d => d -> u) -> Parameter -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Parameter -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Parameter -> m Parameter # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Parameter -> m Parameter # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Parameter -> m Parameter # | |
| Read Parameter Source # | |
| Show Parameter Source # | |
| Generic Parameter Source # | |
| Typed Parameter Source # | |
| type Rep Parameter Source # | |
Defined in LLVM.AST.Global type Rep Parameter = D1 (MetaData "Parameter" "LLVM.AST.Global" "llvm-hs-pure-6.2.1-8ETY0EFB21q8SO4DjmfkXC" False) (C1 (MetaCons "Parameter" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Type) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Name) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [ParameterAttribute])))) | |
data BasicBlock Source #
http://llvm.org/doxygen/classllvm_1_1BasicBlock.html
LLVM code in a function is a sequence of BasicBlocks each with a label,
some instructions, and a terminator.
Constructors
| BasicBlock Name [Named Instruction] (Named Terminator) |
Instances
An Operand is roughly that which is an argument to an Instruction
Constructors
| 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
Constructors
| 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 Methods 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.
Constructors
| MetadataNodeID Word |
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.
Constructors
| MDRef MetadataNodeID | |
| MDInline a |
Instances
| Functor MDRef Source # | |
| Eq a => Eq (MDRef a) Source # | |
| Data a => Data (MDRef a) Source # | |
Defined in LLVM.AST.Operand Methods 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))) | |
Constructors
| MDTuple [Maybe Metadata] | Nothing represents |
| DIExpression DIExpression | |
| DIGlobalVariableExpression DIGlobalVariableExpression | |
| DILocation DILocation | |
| DIMacroNode DIMacroNode | |
| DINode DINode |
Instances
module LLVM.AST.Instruction
module LLVM.AST.Name
Constructors
| VoidType | |
| IntegerType | |
| PointerType | |
Fields | |
| FloatingPointType | |
Fields | |
| FunctionType | |
Fields
| |
| VectorType | |
Fields
| |
| StructureType | |
Fields
| |
| ArrayType | |
Fields
| |
| NamedTypeReference Name | |
| MetadataType | |
| LabelType | |
| TokenType | |
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
Constructors
| 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.