llvm-pretty-0.4.0.1: A pretty printing library inspired by the llvm binding.

Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.LLVM.AST

Synopsis

Documentation

breaks :: (a -> Bool) -> [a] -> [[a]] Source

uncons :: MonadPlus m => [a] -> m (a, [a]) Source

ppMaybe :: (a -> Doc) -> Maybe a -> Doc Source

opt :: Bool -> Doc -> Doc Source

data NamedMd Source

Constructors

NamedMd 

Fields

nmName :: String
 
nmValues :: [Int]
 

Instances

data UnnamedMd Source

Constructors

UnnamedMd 

Fields

umIndex :: !Int
 
umValues :: [Maybe ValMd]
 
umDistinct :: Bool
 

Instances

ppDataLayout :: DataLayout -> Doc Source

Pretty print a data layout specification.

ppLayoutSpec :: LayoutSpec -> Doc Source

Pretty print a single layout specification.

ppLayoutBody :: Int -> Int -> Maybe Int -> Doc Source

Pretty-print the common case for data layout specifications.

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.

ppInlineAsm :: InlineAsm -> Doc Source

Pretty-print the inline assembly block.

data Type' ident Source

Constructors

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 

Instances

Functor Type' 
DefineArgs Type (Typed Value -> BB ()) 
Eq ident => Eq (Type' ident) 
Ord ident => Ord (Type' ident) 
Show ident => Show (Type' ident) 
DefineArgs (Type, Type) (Typed Value -> Typed Value -> BB ()) 
DefineArgs as k => DefineArgs ((:>) Type as) (Typed Value -> k) 
DefineArgs (Type, Type, Type) (Typed Value -> Typed Value -> Typed Value -> BB ()) 

updateAliases :: (a -> Type' b) -> Type' a -> Type' b Source

Traverse a type, updating or removing aliases.

ppArgList :: Bool -> [Doc] -> Doc Source

Build a variable-argument argument list.

data NullResult lab Source

Constructors

HasNull (Value' lab) 
ResolveNull Ident 

elimSequentialType :: MonadPlus m => Type -> m Type Source

Eliminator for array, pointer and vector types.

data TypeDecl Source

Constructors

TypeDecl 

Fields

typeName :: Ident
 
typeValue :: Type
 

Instances

data Declare Source

Constructors

Declare 

Instances

decFunType :: Declare -> Type Source

The function type of this declaration

data FunAttrs Source

Constructors

FunAttrs 

Instances

data BasicBlock' lab Source

Constructors

BasicBlock 

Fields

bbLabel :: Maybe lab
 
bbStmts :: [Stmt' lab]
 

Instances

Show lab => Show (BasicBlock' lab) 

brTargets :: BasicBlock' lab -> [lab] Source

newtype GC Source

Constructors

GC 

Fields

getGC :: String
 

Instances

mapMTyped :: Monad m => (a -> m b) -> Typed a -> m (Typed b) Source

ppTyped :: (a -> Doc) -> Typed a -> Doc Source

data ArithOp Source

Constructors

Add Bool Bool
  • Integral addition.
  • First boolean flag: check for unsigned overflow.
  • Second boolean flag: check for signed overflow.
  • If the checks fail, then the result is poisoned.
FAdd

Floating point addition.

Sub Bool Bool
  • Integral subtraction.
  • First boolean flag: check for unsigned overflow.
  • Second boolean flag: check for signed overflow.
  • If the checks fail, then the result is poisoned.
FSub

Floating point subtraction.

Mul Bool Bool
  • Integral multiplication.
  • First boolean flag: check for unsigned overflow.
  • Second boolean flag: check for signed overflow.
  • If the checks fail, then the result is poisoned.
FMul

Floating point multiplication.

UDiv Bool
  • Integral unsigned division.
  • Boolean flag: check for exact result.
  • If the check fails, then the result is poisoned.
SDiv Bool
  • Integral signed division.
  • Boolean flag: check for exact result.
  • If the check fails, then the result is poisoned.
FDiv

Floating point division.

URem

Integral unsigned reminder resulting from unsigned division. Division by 0 is undefined.

SRem
  • Integral signded reminder resulting from signed division.
  • The sign of the reminder matches the divident (first parameter).
  • Division by 0 is undefined.
FRem
  • Floating point reminder resulting from floating point division.
  • The reminder has the same sign as the divident (first parameter).

Instances

data BitOp Source

Constructors

Shl Bool Bool
  • Shift left.
  • First bool flag: check for unsigned overflow (i.e., shifted out a 1).
  • Second bool flag: check for signed overflow (i.e., shifted out something that does not match the sign bit)

    If a check fails, then the result is poisoned.

    The value of the second parameter must be strictly less than the nubmer of bits in the first parameter, otherwise the result is undefined.

Lshr Bool
  • Logical shift right.
  • The boolean is for exact check: posion the result, if we shift out a 1 bit (i.e., had to round).

    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
  • Arithmetic shift right.
  • The boolean is for exact check: posion the result, if we shift out a 1 bit (i.e., had to round).

    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 

Instances

data Instr' lab Source

Constructors

Ret (Typed (Value' lab))
  • Return from function with the given value.
  • Ends basic block.
RetVoid
  • Return from function.
  • Ends basic block.
Arith ArithOp (Typed (Value' lab)) (Value' lab)
  • Binary arithmetic operation, both operands have the same type.
  • Middle of basic block.
  • The result is the same as parameters.
Bit BitOp (Typed (Value' lab)) (Value' lab)
  • Binary bit-vector operation, both operands have the same type.
  • Middle of basic block.
  • The result is the same as parameters.
Conv ConvOp (Typed (Value' lab)) Type
  • Convert a value from one type to another.
  • Middle of basic block.
  • The result matches the 3rd parameter.
Call Bool Type (Value' lab) [Typed (Value' lab)]
  • Call a function. The boolean is tail-call hint (XXX: needs to be updated)
  • Middle of basic block.
  • The result is as indicated by the provided type.
Alloca Type (Maybe (Typed (Value' lab))) (Maybe Int)
  • Allocated space on the stack: type of elements; how many elements (1 if Nothing); required alignment.
  • Middle of basic block.
  • Returns a pointer to hold the given number of elemets.
Load (Typed (Value' lab)) (Maybe Align)
  • Read a value from the given address: address to read from; assumptions about alignment of the given pointer.
  • Middle of basic block.
  • Returns a value of type matching the pointer.
Store (Typed (Value' lab)) (Typed (Value' lab)) (Maybe Align)
  • Write a value ot memory: value to store; pointer to location where to store; assumptions about the alignment of the given pointer.
  • Middle olf basic block.
  • Effect.
ICmp ICmpOp (Typed (Value' lab)) (Value' lab)
  • Compare two integral values.
  • Middle of basic block.
  • Returns a boolean value.
FCmp FCmpOp (Typed (Value' lab)) (Value' lab)
  • Compare two floating point values.
  • Middle of basic block.
  • Returns a boolean value.
Phi Type [(Value' lab, lab)]
  • Join point for an SSA value: we get one value per predecessor basic block.
  • Middle of basic block.
  • Returns a value of the specified type.
GEP Bool (Typed (Value' lab)) [Typed (Value' lab)]
  • "Get element pointer", compute the address of a field in a structure: inbounds check (value poisoned if this fails); pointer to parent strucutre; path to a sub-component of a strucutre.
  • Middle of basic block.
  • Returns the address of the requiested member.

    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)
  • Local if-then-else; the first argument is boolean, if true pick the 2nd argument, otherwise evaluate to the 3rd.
  • Middle of basic block.
  • Returns either the 2nd or the 3rd argument.
ExtractValue (Typed (Value' lab)) [Int32]
  • Get the value of a member of an aggregate value: the first argument is an aggregate value (not a pointer!), the second is a path of indexes, similar to the one in GEP.
  • Middle of basic block.
  • Returns the given member of the aggregate value.
InsertValue (Typed (Value' lab)) (Typed (Value' lab)) [Int32]
  • Set the value for a member of an aggregate value: the first argument is the value to insert, the second is the aggreagate value to be modified.
  • Middle of basic block.
  • Returns an updated aggregate value.
ExtractElt (Typed (Value' lab)) (Value' lab)
  • Get an element from a vector: the first argument is a vector, the second an index.
  • Middle of basic block.
  • Returns the element at the given positoin.
InsertElt (Typed (Value' lab)) (Typed (Value' lab)) (Value' lab)
  • Modify an element of a vector: the first argument is the vector, the second the value to be inserted, the third is the index where to insert the value.
  • Middle of basic block.
  • Returns an updated vector.
ShuffleVector (Typed (Value' lab)) (Value' lab) (Typed (Value' lab)) 
Jump lab
  • Jump to the given basic block.
  • Ends basic block.
Br (Typed (Value' lab)) lab lab
  • Conditional jump: if the value is true jump to the first basic block, otherwise jump to the second.
  • Ends basic block.
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)]
  • Multi-way branch: the first value determines the direction of the branch, the label is a default direction, if the value does not appear in the jump table, the last argument is the jump table.
  • Ends basic block.
LandingPad Type (Typed (Value' lab)) Bool [Clause' lab] 
Resume (Typed (Value' lab)) 

Instances

data Clause' lab Source

Constructors

Catch (Typed (Value' lab)) 
Filter (Typed (Value' lab)) 

Instances

data ICmpOp Source

Constructors

Ieq 
Ine 
Iugt 
Iuge 
Iult 
Iule 
Isgt 
Isge 
Islt 
Isle 

Instances

data FCmpOp Source

Instances

data ValMd' lab Source

Instances

data DebugLoc' lab Source

Constructors

DebugLoc 

Fields

dlLine :: Int32
 
dlCol :: Int32
 
dlScope :: ValMd' lab
 
dlIA :: Maybe (ValMd' lab)
 

data Stmt' lab Source

Constructors

Result Ident (Instr' lab) [(String, ValMd' lab)] 
Effect (Instr' lab) [(String, ValMd' lab)] 

Instances

extendMetadata :: (String, ValMd' lab) -> Stmt' lab -> Stmt' lab Source

data IndexResult Source

Constructors

Invalid

An invalid use of GEP

HasType Type

A resolved type

Resolve Ident (Type -> IndexResult)

Continue, after resolving an alias

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.