Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- data Module = Module {
- modDataLayout :: DataLayout
- modTypes :: [TypeDecl]
- modNamedMd :: [NamedMd]
- modUnnamedMd :: [UnnamedMd]
- modGlobals :: [Global]
- modDeclares :: [Declare]
- modDefines :: [Define]
- modInlineAsm :: InlineAsm
- modAliases :: [GlobalAlias]
- emptyModule :: Module
- data NamedMd = NamedMd {}
- data UnnamedMd = UnnamedMd {}
- data GlobalAlias = GlobalAlias {}
- type DataLayout = [LayoutSpec]
- data LayoutSpec
- = BigEndian
- | LittleEndian
- | PointerSize !Int !Int (Maybe Int)
- | IntegerSize !Int !Int (Maybe Int)
- | VectorSize !Int !Int (Maybe Int)
- | FloatSize !Int !Int (Maybe Int)
- | AggregateSize !Int !Int (Maybe Int)
- | StackObjSize !Int !Int (Maybe Int)
- | NativeIntSize [Int]
- | StackAlign !Int
- | Mangling Mangling
- data Mangling
- parseDataLayout :: MonadPlus m => String -> m DataLayout
- parseLayoutSpec :: MonadPlus m => String -> m LayoutSpec
- type InlineAsm = [String]
- newtype Ident = Ident String
- newtype Symbol = Symbol String
- data PrimType
- data FloatType
- type Type = Type' Ident
- data Type' ident
- updateAliases :: (a -> Type' b) -> Type' a -> Type' b
- isFloatingPoint :: PrimType -> Bool
- isAlias :: Type -> Bool
- isPrimTypeOf :: (PrimType -> Bool) -> Type -> Bool
- isLabel :: PrimType -> Bool
- isInteger :: PrimType -> Bool
- isVector :: Type -> Bool
- isVectorOf :: (Type -> Bool) -> Type -> Bool
- isArray :: Type -> Bool
- isPointer :: Type -> Bool
- data NullResult lab
- = HasNull (Value' lab)
- | ResolveNull Ident
- primTypeNull :: PrimType -> Value' lab
- floatTypeNull :: FloatType -> Value' lab
- typeNull :: Type -> NullResult lab
- elimFunTy :: MonadPlus m => Type -> m (Type, [Type], Bool)
- elimAlias :: MonadPlus m => Type -> m Ident
- elimPtrTo :: MonadPlus m => Type -> m Type
- elimVector :: MonadPlus m => Type -> m (Int32, Type)
- elimArray :: MonadPlus m => Type -> m (Int32, Type)
- elimFunPtr :: MonadPlus m => Type -> m (Type, [Type], Bool)
- elimPrimType :: MonadPlus m => Type -> m PrimType
- elimFloatType :: MonadPlus m => PrimType -> m FloatType
- elimSequentialType :: MonadPlus m => Type -> m Type
- data TypeDecl = TypeDecl {}
- data Global = Global {}
- addGlobal :: Global -> Module -> Module
- data GlobalAttrs = GlobalAttrs {
- gaLinkage :: Maybe Linkage
- gaConstant :: Bool
- emptyGlobalAttrs :: GlobalAttrs
- data Declare = Declare {
- decRetType :: Type
- decName :: Symbol
- decArgs :: [Type]
- decVarArgs :: Bool
- decFunType :: Declare -> Type
- data Define = Define {
- defAttrs :: FunAttrs
- defRetType :: Type
- defName :: Symbol
- defArgs :: [Typed Ident]
- defVarArgs :: Bool
- defSection :: Maybe String
- defBody :: [BasicBlock]
- defFunType :: Define -> Type
- addDefine :: Define -> Module -> Module
- data FunAttrs = FunAttrs {}
- emptyFunAttrs :: FunAttrs
- data BlockLabel
- data BasicBlock' lab = BasicBlock {}
- type BasicBlock = BasicBlock' BlockLabel
- brTargets :: BasicBlock' lab -> [lab]
- data Linkage
- newtype GC = GC {}
- data Typed a = Typed {
- typedType :: Type
- typedValue :: a
- mapMTyped :: Monad m => (a -> m b) -> Typed a -> m (Typed b)
- data ArithOp
- isIArith :: ArithOp -> Bool
- isFArith :: ArithOp -> Bool
- data BitOp
- data ConvOp
- type Align = Int
- data Instr' lab
- = Ret (Typed (Value' lab))
- | RetVoid
- | Arith ArithOp (Typed (Value' lab)) (Value' lab)
- | Bit BitOp (Typed (Value' lab)) (Value' lab)
- | Conv ConvOp (Typed (Value' lab)) Type
- | Call Bool Type (Value' lab) [Typed (Value' lab)]
- | Alloca Type (Maybe (Typed (Value' lab))) (Maybe Int)
- | Load (Typed (Value' lab)) (Maybe Align)
- | Store (Typed (Value' lab)) (Typed (Value' lab)) (Maybe Align)
- | ICmp ICmpOp (Typed (Value' lab)) (Value' lab)
- | FCmp FCmpOp (Typed (Value' lab)) (Value' lab)
- | Phi Type [(Value' lab, lab)]
- | GEP Bool (Typed (Value' lab)) [Typed (Value' lab)]
- | Select (Typed (Value' lab)) (Typed (Value' lab)) (Value' lab)
- | ExtractValue (Typed (Value' lab)) [Int32]
- | InsertValue (Typed (Value' lab)) (Typed (Value' lab)) [Int32]
- | ExtractElt (Typed (Value' lab)) (Value' lab)
- | InsertElt (Typed (Value' lab)) (Typed (Value' lab)) (Value' lab)
- | ShuffleVector (Typed (Value' lab)) (Value' lab) (Typed (Value' lab))
- | Jump lab
- | Br (Typed (Value' lab)) lab lab
- | Invoke Type (Value' lab) [Typed (Value' lab)] lab lab
- | Comment String
- | Unreachable
- | Unwind
- | VaArg (Typed (Value' lab)) Type
- | IndirectBr (Typed (Value' lab)) [lab]
- | Switch (Typed (Value' lab)) lab [(Integer, lab)]
- | LandingPad Type (Typed (Value' lab)) Bool [Clause' lab]
- | Resume (Typed (Value' lab))
- type Instr = Instr' BlockLabel
- data Clause' lab
- type Clause = Clause' BlockLabel
- isTerminator :: Instr' lab -> Bool
- isComment :: Instr' lab -> Bool
- isPhi :: Instr' lab -> Bool
- data ICmpOp
- data FCmpOp
- data Value' lab
- = ValInteger Integer
- | ValBool Bool
- | ValFloat Float
- | ValDouble Double
- | ValIdent Ident
- | ValSymbol Symbol
- | ValNull
- | ValArray Type [Value' lab]
- | ValVector Type [Value' lab]
- | ValStruct [Typed (Value' lab)]
- | ValPackedStruct [Typed (Value' lab)]
- | ValString String
- | ValConstExpr (ConstExpr' lab)
- | ValUndef
- | ValLabel lab
- | ValZeroInit
- | ValAsm Bool Bool String String
- | ValMd (ValMd' lab)
- type Value = Value' BlockLabel
- data ValMd' lab
- type ValMd = ValMd' BlockLabel
- data DebugLoc' lab = DebugLoc {}
- type DebugLoc = DebugLoc' BlockLabel
- isConst :: Value' lab -> Bool
- elimValSymbol :: MonadPlus m => Value' lab -> m Symbol
- elimValInteger :: MonadPlus m => Value' lab -> m Integer
- data Stmt' lab
- type Stmt = Stmt' BlockLabel
- stmtInstr :: Stmt' lab -> Instr' lab
- stmtMetadata :: Stmt' lab -> [(String, ValMd' lab)]
- extendMetadata :: (String, ValMd' lab) -> Stmt' lab -> Stmt' lab
- data ConstExpr' lab
- type ConstExpr = ConstExpr' BlockLabel
- data IndexResult
- isInvalid :: IndexResult -> Bool
- resolveGepFull :: (Ident -> Maybe Type) -> Type -> [Typed (Value' lab)] -> Maybe Type
- resolveGep :: Type -> [Typed (Value' lab)] -> IndexResult
- resolveGepBody :: Type -> [Typed (Value' lab)] -> IndexResult
- isGepIndex :: Typed (Value' lab) -> Bool
- isGepStructIndex :: Typed (Value' lab) -> Maybe Integer
- resolveValueIndex :: Type -> [Int32] -> IndexResult
Documentation
Module | |
|
emptyModule :: Module Source #
type DataLayout = [LayoutSpec] Source #
data LayoutSpec Source #
BigEndian | |
LittleEndian | |
PointerSize !Int !Int (Maybe Int) | |
IntegerSize !Int !Int (Maybe Int) | |
VectorSize !Int !Int (Maybe Int) | |
FloatSize !Int !Int (Maybe Int) | |
AggregateSize !Int !Int (Maybe Int) | |
StackObjSize !Int !Int (Maybe Int) | |
NativeIntSize [Int] | |
StackAlign !Int | |
Mangling Mangling |
parseDataLayout :: MonadPlus m => String -> m DataLayout Source #
Parse the data layout string.
parseLayoutSpec :: MonadPlus m => String -> m LayoutSpec Source #
Parse a single layout specification from a string.
Eq Ident Source # | |
Ord Ident Source # | |
Show Ident Source # | |
IsString Ident Source # | |
IsValue Ident Source # | |
DefineArgs Type (Typed Value -> BB ()) Source # | |
DefineArgs (Type, Type) (Typed Value -> Typed Value -> BB ()) Source # | |
DefineArgs as k => DefineArgs ((:>) Type as) (Typed Value -> k) Source # | |
DefineArgs (Type, Type, Type) (Typed Value -> Typed Value -> Typed Value -> BB ()) Source # | |
PrimType PrimType | |
Alias ident | |
Array Int32 (Type' ident) | |
FunTy (Type' ident) [Type' ident] Bool | |
PtrTo (Type' ident) | |
Struct [Type' ident] | |
PackedStruct [Type' ident] | |
Vector Int32 (Type' ident) | |
Opaque |
Functor Type' Source # | |
DefineArgs Type (Typed Value -> BB ()) Source # | |
Eq ident => Eq (Type' ident) Source # | |
Ord ident => Ord (Type' ident) Source # | |
Show ident => Show (Type' ident) Source # | |
DefineArgs (Type, Type) (Typed Value -> Typed Value -> BB ()) Source # | |
DefineArgs as k => DefineArgs ((:>) Type as) (Typed Value -> k) Source # | |
DefineArgs (Type, Type, Type) (Typed Value -> Typed Value -> Typed Value -> BB ()) Source # | |
updateAliases :: (a -> Type' b) -> Type' a -> Type' b Source #
Traverse a type, updating or removing aliases.
isFloatingPoint :: PrimType -> Bool Source #
data NullResult lab Source #
HasNull (Value' lab) | |
ResolveNull Ident |
primTypeNull :: PrimType -> Value' lab Source #
floatTypeNull :: FloatType -> Value' lab Source #
typeNull :: Type -> NullResult lab Source #
elimSequentialType :: MonadPlus m => Type -> m Type Source #
Eliminator for array, pointer and vector types.
Global | |
|
data GlobalAttrs Source #
Declare | |
|
decFunType :: Declare -> Type Source #
The function type of this declaration
Define | |
|
defFunType :: Define -> Type Source #
data BlockLabel Source #
Eq BlockLabel Source # | |
Ord BlockLabel Source # | |
Show BlockLabel Source # | |
IsString BlockLabel Source # | |
IsValue Value Source # | |
DefineArgs Type (Typed Value -> BB ()) Source # | |
DefineArgs (Type, Type) (Typed Value -> Typed Value -> BB ()) Source # | |
DefineArgs as k => DefineArgs ((:>) Type as) (Typed Value -> k) Source # | |
DefineArgs (Type, Type, Type) (Typed Value -> Typed Value -> Typed Value -> BB ()) Source # | |
type BasicBlock = BasicBlock' BlockLabel Source #
brTargets :: BasicBlock' lab -> [lab] Source #
Symbol Linkage
Typed | |
|
Functor Typed Source # | |
Foldable Typed Source # | |
Traversable Typed Source # | |
DefineArgs Type (Typed Value -> BB ()) Source # | |
Show a => Show (Typed a) Source # | |
IsValue a => IsValue (Typed a) Source # | |
DefineArgs (Type, Type) (Typed Value -> Typed Value -> BB ()) Source # | |
DefineArgs as k => DefineArgs ((:>) Type as) (Typed Value -> k) Source # | |
DefineArgs (Type, Type, Type) (Typed Value -> Typed Value -> Typed Value -> BB ()) Source # | |
Add Bool Bool |
|
FAdd | Floating point addition. |
Sub Bool Bool |
|
FSub | Floating point subtraction. |
Mul Bool Bool |
|
FMul | Floating point multiplication. |
UDiv Bool |
|
SDiv Bool |
|
FDiv | Floating point division. |
URem | Integral unsigned reminder resulting from unsigned division. Division by 0 is undefined. |
SRem |
|
FRem |
|
Shl Bool Bool |
|
Lshr Bool |
The value of the second parameter must be strictly less than the nubmer of bits in the first parameter, otherwise the result is undefined. |
Ashr Bool |
The value of the second parameter must be strictly less than the nubmer of bits in the first parameter, otherwise the result is undefined. |
And | |
Or | |
Xor |
Ret (Typed (Value' lab)) |
|
RetVoid |
|
Arith ArithOp (Typed (Value' lab)) (Value' lab) |
|
Bit BitOp (Typed (Value' lab)) (Value' lab) |
|
Conv ConvOp (Typed (Value' lab)) Type |
|
Call Bool Type (Value' lab) [Typed (Value' lab)] |
|
Alloca Type (Maybe (Typed (Value' lab))) (Maybe Int) |
|
Load (Typed (Value' lab)) (Maybe Align) |
|
Store (Typed (Value' lab)) (Typed (Value' lab)) (Maybe Align) |
|
ICmp ICmpOp (Typed (Value' lab)) (Value' lab) |
|
FCmp FCmpOp (Typed (Value' lab)) (Value' lab) |
|
Phi Type [(Value' lab, lab)] |
|
GEP Bool (Typed (Value' lab)) [Typed (Value' lab)] |
The types in path are the types of the index, not the fields. The indexes are in units of a fields (i.e., the first element in a struct is field 0, the next one is 1, etc., regardless of the size of the fields in bytes). |
Select (Typed (Value' lab)) (Typed (Value' lab)) (Value' lab) |
|
ExtractValue (Typed (Value' lab)) [Int32] |
|
InsertValue (Typed (Value' lab)) (Typed (Value' lab)) [Int32] |
|
ExtractElt (Typed (Value' lab)) (Value' lab) |
|
InsertElt (Typed (Value' lab)) (Typed (Value' lab)) (Value' lab) |
|
ShuffleVector (Typed (Value' lab)) (Value' lab) (Typed (Value' lab)) | |
Jump lab |
|
Br (Typed (Value' lab)) lab lab |
|
Invoke Type (Value' lab) [Typed (Value' lab)] lab lab | |
Comment String | Comment |
Unreachable | No defined sematics, we should not get to here. |
Unwind | |
VaArg (Typed (Value' lab)) Type | |
IndirectBr (Typed (Value' lab)) [lab] | |
Switch (Typed (Value' lab)) lab [(Integer, lab)] |
|
LandingPad Type (Typed (Value' lab)) Bool [Clause' lab] | |
Resume (Typed (Value' lab)) |
type Instr = Instr' BlockLabel Source #
type Clause = Clause' BlockLabel Source #
isTerminator :: Instr' lab -> Bool Source #
ValInteger Integer | |
ValBool Bool | |
ValFloat Float | |
ValDouble Double | |
ValIdent Ident | |
ValSymbol Symbol | |
ValNull | |
ValArray Type [Value' lab] | |
ValVector Type [Value' lab] | |
ValStruct [Typed (Value' lab)] | |
ValPackedStruct [Typed (Value' lab)] | |
ValString String | |
ValConstExpr (ConstExpr' lab) | |
ValUndef | |
ValLabel lab | |
ValZeroInit | |
ValAsm Bool Bool String String | |
ValMd (ValMd' lab) |
Functor Value' Source # | |
HasLabel Value' Source # | |
IsValue Value Source # | |
DefineArgs Type (Typed Value -> BB ()) Source # | |
Show lab => Show (Value' lab) Source # | |
DefineArgs (Type, Type) (Typed Value -> Typed Value -> BB ()) Source # | |
DefineArgs as k => DefineArgs ((:>) Type as) (Typed Value -> k) Source # | |
DefineArgs (Type, Type, Type) (Typed Value -> Typed Value -> Typed Value -> BB ()) Source # | |
type Value = Value' BlockLabel Source #
type ValMd = ValMd' BlockLabel Source #
type DebugLoc = DebugLoc' BlockLabel Source #
type Stmt = Stmt' BlockLabel Source #
data ConstExpr' lab Source #
ConstGEP Bool [Typed (Value' lab)] | |
ConstConv ConvOp (Typed (Value' lab)) Type | |
ConstSelect (Typed (Value' lab)) (Typed (Value' lab)) (Typed (Value' lab)) | |
ConstBlockAddr Symbol lab |
Functor ConstExpr' Source # | |
HasLabel ConstExpr' Source # | |
Show lab => Show (ConstExpr' lab) Source # | |
type ConstExpr = ConstExpr' BlockLabel Source #
data IndexResult Source #
isInvalid :: IndexResult -> Bool Source #
:: (Ident -> Maybe Type) | Type alias resolution |
-> Type | Pointer type |
-> [Typed (Value' lab)] | Path |
-> Maybe Type | Type of result |
Resolves the type of a GEP instruction. Type aliases are resolved
using the given function. An invalid use of GEP or one relying
on unknown type aliases will return Nothing
resolveGep :: Type -> [Typed (Value' lab)] -> IndexResult Source #
Resolve the type of a GEP instruction. Note that the type produced is the type of the result, not necessarily a pointer.
resolveGepBody :: Type -> [Typed (Value' lab)] -> IndexResult Source #
Resolve the type of a GEP instruction. This assumes that the input has already been processed as a pointer.
resolveValueIndex :: Type -> [Int32] -> IndexResult Source #