Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
136 lines (99 sloc) 3.81 KB

LLVM API documentation

LLVM Types

Type

http://llvm.org/docs/LangRef.html#type-system

data Type
  = VoidType
  | IntegerType { typeBits :: Word32 }
  | PointerType { pointerReferent :: Type, pointerAddrSpace :: AddrSpace }
  | FloatingPointType { floatingPointType ::
  | FunctionType { resultType :: Type, argumentTypes :: [Type], isVarArg :: Bool }
  | StructureType { isPacked :: Bool, elementTypes :: [Type] }
  | ArrayType { nArrayElements :: Word64, elementType :: Type }
  ...

Name

Good old variable references

data Name
    = Name ShortByteString -- ^ a string name
    | UnName Word -- ^ a number for a nameless thing

Named

Instances of instructions may be given a name, allowing their results to be referenced as ‘Operand’s. Sometimes instructions - e.g. a call to a function returning void - don’t need names.

data Named a
  = Name := a
  | Do a
  deriving (Eq, Read, Show, Typeable, Data, Generic)

Operand

An ‘Operand’ is roughly that which is an argument to an ‘LLVM.AST.Instruction.Instruction’

data Operand
  -- | %foo
  = LocalReference Type Name
  -- | 'Constant's include 'LLVM.AST.Constant.GlobalReference', for \@foo
  | ConstantOperand Constant
  | MetadataOperand Metadata

Terminator

Data terminators

http://llvm.org/docs/LangRef.html#terminators

data Terminator = Ret | CondBr | Br ...

Instruction

Non Terminator instructions

data Instruction = Add | | FAdd | Sub | FSub | Mul | FMul ...

Constant

data Constant
    = Int { integerBits :: Word32, integerValue :: Integer }
    | Float { floatValue :: F.SomeFloat }
    | Null { constantType :: Type }
    | GlobalReference Type Name

BasicBlock

LLVM code in a function is a sequence of ‘BasicBlock’s each with a label, some instructions, and a terminator.

data BasicBlock = BasicBlock Name [Named Instruction] (Named Terminator)

Global

http://llvm.org/docs/LangRef.html#global-variables

data Global = GlobalVariable | GlobalAlias | Function

Function {
    returnType :: Type,
    name :: Name,
    basicBlocks :: [BasicBlock]
  }

Definition

Any thing which can be at the top level of a ‘Module’

data Definition
  = GlobalDefinition Global
  | TypeDefinition Name (Maybe Type)
  | ...

Module

data Module =
  Module {
    moduleName :: ShortByteString,
    moduleDefinitions :: [Definition]
  }
You can’t perform that action at this time.