Documentation
¶
Index ¶
- Variables
- func NextTemp() string
- type Argument
- type ArrayType
- type Assign
- type BasicBlock
- func (b *BasicBlock) AddInstr(i Stmt)
- func (b *BasicBlock) Empty() bool
- func (b *BasicBlock) HasName() bool
- func (b *BasicBlock) InsertInstrBegin(inst Stmt)
- func (b *BasicBlock) Instr() *list.List
- func (b *BasicBlock) LastInst() Stmt
- func (b *BasicBlock) LastInstIsCondBr() bool
- func (b *BasicBlock) Name() string
- func (b *BasicBlock) Parent() *Function
- func (b *BasicBlock) RemoveInstr(rem *list.Element)
- func (b *BasicBlock) SetName(name string)
- func (b *BasicBlock) String() string
- func (b *BasicBlock) Type() Type
- type BinaryOp
- type BitVector
- type Builder
- func (b *Builder) CreateAdd(lhs, rhs Expr) *BinaryOp
- func (b *Builder) CreateAssign(Val, Dst Expr) *Assign
- func (b *Builder) CreateCmp(pred Opcode, lhs, rhs Expr) Expr
- func (b *Builder) CreateCondBr(cond Expr, ifTrue, ifFalse *BasicBlock) *CondBr
- func (b *Builder) CreateFuncCall(callee Expr, args []Expr) *FuncCall
- func (b *Builder) CreateJmp(dst *BasicBlock) *Jump
- func (b *Builder) CreateLoad(addr Expr) *Load
- func (b *Builder) CreateNeg(v Expr) Expr
- func (b *Builder) CreateNot(v Expr) Expr
- func (b *Builder) CreateProcCall(callee Expr, args []Expr) *ProcCallInstr
- func (b *Builder) CreateRet(v Expr) *Return
- func (b *Builder) CreateSub(lhs, rhs Expr) Expr
- func (b *Builder) CreateXOR(lhs, rhs Expr) Expr
- func (b *Builder) GetInsertBlock() *BasicBlock
- func (b *Builder) SetInsertPoint(BB *BasicBlock)
- type Cmp
- type CondBr
- type ConstantBool
- func (c ConstantBool) BaseName() string
- func (c ConstantBool) HasName() bool
- func (c ConstantBool) Name() string
- func (c ConstantBool) NumOperands() int
- func (c ConstantBool) Operand(i int) Expr
- func (c ConstantBool) SetName(string)
- func (c ConstantBool) String() string
- func (c ConstantBool) Type() Type
- type ConstantInt
- type ControlFlowGraph
- func (cfg *ControlFlowGraph) AddPred(BlkName string, Predecessors ...*BasicBlock)
- func (cfg *ControlFlowGraph) AddSucc(BlkName string, Successors ...*BasicBlock)
- func (cfg *ControlFlowGraph) DeleteBlocks(blocks ...*BasicBlock)
- func (cfg *ControlFlowGraph) IsBrNode(blk string) bool
- func (cfg *ControlFlowGraph) IsJoinNode(blk string) bool
- func (cfg *ControlFlowGraph) PostOrder() []*BasicBlock
- func (cfg *ControlFlowGraph) Reverse() *ControlFlowGraph
- func (cfg *ControlFlowGraph) ReversePostOrder() []*BasicBlock
- func (cfg *ControlFlowGraph) String() string
- type Expr
- type FuncCall
- type Function
- func (f *Function) CFG() *ControlFlowGraph
- func (f *Function) HasExternalLinkage() bool
- func (f *Function) HasInternalLinkage() bool
- func (f *Function) HasName() bool
- func (f *Function) Name() string
- func (f *Function) NumUses() int
- func (f *Function) OrigName() string
- func (f *Function) Parent() *Module
- func (f *Function) SetName(name string)
- func (f *Function) String() string
- func (f *Function) SymbolTable()
- func (f *Function) Type() Type
- type FunctionType
- func (f FunctionType) ArgType(i uint) Type
- func (FunctionType) IsArrayTy() bool
- func (FunctionType) IsFuncTy() bool
- func (FunctionType) IsIntegerTy() bool
- func (FunctionType) IsPtrTy() bool
- func (f FunctionType) IsVarArg() bool
- func (FunctionType) IsVoidTy() bool
- func (f FunctionType) NumArgs() int
- func (f FunctionType) ReturnType() Type
- func (f FunctionType) String() string
- type Int1
- type Int16
- type Int32
- type Int64
- type Int8
- type IntegerType
- type Jump
- type LabelType
- type LinkageKind
- type Load
- type Module
- type ObjKind
- type Object
- type Opcode
- type PHINode
- func (phi *PHINode) AddIncoming(v Expr, blk *BasicBlock)
- func (phi *PHINode) BaseName() string
- func (phi *PHINode) HasName() bool
- func (phi *PHINode) Name() string
- func (phi *PHINode) NumOperands() int
- func (phi *PHINode) Operand(int) Expr
- func (phi *PHINode) SetName(string)
- func (phi *PHINode) String() string
- func (phi *PHINode) Type() Type
- type PHINodeIncoming
- type PointerType
- type ProcCallInstr
- type Program
- type PtrTy
- type Return
- type Scope
- type Stmt
- type Store
- type SymbolTable
- type Temp
- type Type
- type ValueSymbolTable
- type Variable
- type Void
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type Argument ¶
type Argument struct {
// contains filtered or unexported fields
}
Argument ... ---------------------
func CreateArgument ¶
func CreateArgument(ty *FunctionType, parent *Function, name string) *Argument
type ArrayType ¶
type ArrayType struct {
// contains filtered or unexported fields
}
ArrayType -----------------------------------------
func CreateArrayType ¶
func (ArrayType) IsIntegerTy ¶
type Assign ¶
Assign --------------------------------
func CreateAssign ¶
func (*Assign) Parent ¶
func (a *Assign) Parent() *BasicBlock
func (*Assign) SetParent ¶
func (a *Assign) SetParent(parent *BasicBlock)
type BasicBlock ¶
BasicBlock ... -------------------------
func CreateBasicBlock ¶
func CreateBasicBlock(name string, parent *Function) *BasicBlock
func NewBasicBlock ¶
func NewBasicBlock(name string) *BasicBlock
func (*BasicBlock) AddInstr ¶
func (b *BasicBlock) AddInstr(i Stmt)
func (*BasicBlock) Empty ¶
func (b *BasicBlock) Empty() bool
func (*BasicBlock) HasName ¶
func (b *BasicBlock) HasName() bool
func (*BasicBlock) InsertInstrBegin ¶
func (b *BasicBlock) InsertInstrBegin(inst Stmt)
func (*BasicBlock) Instr ¶
func (b *BasicBlock) Instr() *list.List
func (*BasicBlock) LastInst ¶
func (b *BasicBlock) LastInst() Stmt
func (*BasicBlock) LastInstIsCondBr ¶
func (b *BasicBlock) LastInstIsCondBr() bool
func (*BasicBlock) Name ¶
func (b *BasicBlock) Name() string
func (*BasicBlock) Parent ¶
func (b *BasicBlock) Parent() *Function
func (*BasicBlock) RemoveInstr ¶
func (b *BasicBlock) RemoveInstr(rem *list.Element)
func (*BasicBlock) SetName ¶
func (b *BasicBlock) SetName(name string)
func (*BasicBlock) String ¶
func (b *BasicBlock) String() string
func (*BasicBlock) Type ¶
func (b *BasicBlock) Type() Type
type Builder ¶
type Builder struct { BB *BasicBlock // the current BasicBlock where instructions are inserted CFG *ControlFlowGraph // A graph modelling control-flow for the current function }
func NewBuilder ¶
func NewBuilder() *Builder
func (*Builder) CreateAssign ¶
func (*Builder) CreateCondBr ¶
func (b *Builder) CreateCondBr(cond Expr, ifTrue, ifFalse *BasicBlock) *CondBr
func (*Builder) CreateFuncCall ¶
func (*Builder) CreateJmp ¶
func (b *Builder) CreateJmp(dst *BasicBlock) *Jump
func (*Builder) CreateLoad ¶
func (*Builder) CreateProcCall ¶
func (b *Builder) CreateProcCall(callee Expr, args []Expr) *ProcCallInstr
func (*Builder) GetInsertBlock ¶
func (b *Builder) GetInsertBlock() *BasicBlock
GetInsertBlock returns the current BasicBlock where instructions are inserted
func (*Builder) SetInsertPoint ¶
func (b *Builder) SetInsertPoint(BB *BasicBlock)
SetInsertPoint updates the current BasicBlock to BB
type CondBr ¶
type CondBr struct { Op Opcode Cond Expr IfTrue *BasicBlock IfFalse *BasicBlock // contains filtered or unexported fields }
CondBr ----------
func CreateCondBr ¶
func CreateCondBr(cond Expr, ifThen, ifElse *BasicBlock) *CondBr
func (*CondBr) Parent ¶
func (c *CondBr) Parent() *BasicBlock
func (*CondBr) SetParent ¶
func (c *CondBr) SetParent(parent *BasicBlock)
type ConstantBool ¶
ConstantBool ... --------------------
func NewConstBool ¶
func NewConstBool(value int) *ConstantBool
func (ConstantBool) BaseName ¶
func (c ConstantBool) BaseName() string
func (ConstantBool) HasName ¶
func (c ConstantBool) HasName() bool
func (ConstantBool) Name ¶
func (c ConstantBool) Name() string
func (ConstantBool) NumOperands ¶
func (c ConstantBool) NumOperands() int
func (ConstantBool) Operand ¶
func (c ConstantBool) Operand(i int) Expr
func (ConstantBool) SetName ¶
func (c ConstantBool) SetName(string)
func (ConstantBool) String ¶
func (c ConstantBool) String() string
func (ConstantBool) Type ¶
func (c ConstantBool) Type() Type
type ConstantInt ¶
ConstantInt ... --------------------
func NewConstantInt ¶
func NewConstantInt(ty Type, value uint64, signed bool) *ConstantInt
func (ConstantInt) BaseName ¶
func (c ConstantInt) BaseName() string
func (ConstantInt) HasName ¶
func (c ConstantInt) HasName() bool
func (ConstantInt) Name ¶
func (c ConstantInt) Name() string
func (ConstantInt) NumOperands ¶
func (c ConstantInt) NumOperands() int
func (ConstantInt) Operand ¶
func (c ConstantInt) Operand(i int) Expr
func (ConstantInt) SetName ¶
func (c ConstantInt) SetName(string)
func (ConstantInt) String ¶
func (c ConstantInt) String() string
func (ConstantInt) Type ¶
func (c ConstantInt) Type() Type
type ControlFlowGraph ¶
type ControlFlowGraph struct {
Entry, Exit *BasicBlock
Nodes adt.Set[*BasicBlock]
Succ map[string]*adt.HashSet[*BasicBlock]
Pred map[string]*adt.HashSet[*BasicBlock]
Defs map[string]Stmt
Uses map[string]adt.Set[Stmt]
}
ControlFlowGraph ----------------------------------------------------------------
func NewCFG ¶
func NewCFG() *ControlFlowGraph
func (*ControlFlowGraph) AddPred ¶
func (cfg *ControlFlowGraph) AddPred(BlkName string, Predecessors ...*BasicBlock)
func (*ControlFlowGraph) AddSucc ¶
func (cfg *ControlFlowGraph) AddSucc(BlkName string, Successors ...*BasicBlock)
func (*ControlFlowGraph) DeleteBlocks ¶
func (cfg *ControlFlowGraph) DeleteBlocks(blocks ...*BasicBlock)
func (*ControlFlowGraph) IsBrNode ¶
func (cfg *ControlFlowGraph) IsBrNode(blk string) bool
func (*ControlFlowGraph) IsJoinNode ¶
func (cfg *ControlFlowGraph) IsJoinNode(blk string) bool
func (*ControlFlowGraph) PostOrder ¶
func (cfg *ControlFlowGraph) PostOrder() []*BasicBlock
func (*ControlFlowGraph) Reverse ¶
func (cfg *ControlFlowGraph) Reverse() *ControlFlowGraph
func (*ControlFlowGraph) ReversePostOrder ¶
func (cfg *ControlFlowGraph) ReversePostOrder() []*BasicBlock
func (*ControlFlowGraph) String ¶
func (cfg *ControlFlowGraph) String() string
type Expr ¶
type Expr interface { Name() string BaseName() string SetName(string) HasName() bool Operand(int) Expr NumOperands() int Type() Type fmt.Stringer // contains filtered or unexported methods }
func GetAllOnesValue ¶
func GetNullValue ¶
type FuncCall ¶
type FuncCall struct { Op Opcode Callee Expr Args []Expr // contains filtered or unexported fields }
FuncCall ... --------------------
func CreateFuncCall ¶
func (FuncCall) NumOperands ¶
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
Function ... -----------------------------
func CreateFunction ¶
func CreateFunction(ty *FunctionType, link LinkageKind, name string, module *Module) *Function
func CreatePreDeclaredFunction ¶
func CreatePreDeclaredFunction(ty *FunctionType, link LinkageKind, name string, module *Module) *Function
func (*Function) CFG ¶
func (f *Function) CFG() *ControlFlowGraph
func (*Function) HasExternalLinkage ¶
func (*Function) HasInternalLinkage ¶
func (*Function) SymbolTable ¶
func (f *Function) SymbolTable()
type FunctionType ¶
type FunctionType struct {
// contains filtered or unexported fields
}
FunctionType ... ---------------------
func CreateFunctionType ¶
func CreateFunctionType(args []Type, retTy Type, varArgs bool) *FunctionType
func (FunctionType) ArgType ¶
func (f FunctionType) ArgType(i uint) Type
func (FunctionType) IsArrayTy ¶
func (FunctionType) IsArrayTy() bool
func (FunctionType) IsFuncTy ¶
func (FunctionType) IsFuncTy() bool
func (FunctionType) IsIntegerTy ¶
func (FunctionType) IsIntegerTy() bool
func (FunctionType) IsPtrTy ¶
func (FunctionType) IsPtrTy() bool
func (FunctionType) IsVarArg ¶
func (f FunctionType) IsVarArg() bool
func (FunctionType) IsVoidTy ¶
func (FunctionType) IsVoidTy() bool
func (FunctionType) NumArgs ¶
func (f FunctionType) NumArgs() int
func (FunctionType) ReturnType ¶
func (f FunctionType) ReturnType() Type
func (FunctionType) String ¶
func (f FunctionType) String() string
type Int1 ¶
type Int1 struct {
// contains filtered or unexported fields
}
Int1 ... ----------------------
func (Int1) IsIntegerTy ¶
type Int16 ¶
type Int16 struct {
// contains filtered or unexported fields
}
Int16 ... ----------------------
func (Int16) IsIntegerTy ¶
type Int32 ¶
type Int32 struct {
// contains filtered or unexported fields
}
Int32 ... ----------------------
func (Int32) IsIntegerTy ¶
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 ... ----------------------
func (Int64) IsIntegerTy ¶
type Int8 ¶
type Int8 struct {
// contains filtered or unexported fields
}
Int8 ... ----------------------
func (Int8) IsIntegerTy ¶
type IntegerType ¶
IntegerType ... ----------------------
func GetIntegerType ¶
func GetIntegerType(numBits uint) IntegerType
type Jump ¶
type Jump struct { Op Opcode Dst *BasicBlock // contains filtered or unexported fields }
Jump --------------------------------
func CreateJmp ¶
func CreateJmp(dst *BasicBlock) *Jump
func (*Jump) Parent ¶
func (j *Jump) Parent() *BasicBlock
func (*Jump) SetParent ¶
func (j *Jump) SetParent(parent *BasicBlock)
type LabelType ¶
type LabelType struct {
// contains filtered or unexported fields
}
LabelType ... ---------------------
func (LabelType) IsIntegerTy ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) GetFunction ¶
func (*Module) GetFunctionList ¶
func (*Module) GetOrInsertFunction ¶
func (m *Module) GetOrInsertFunction(name string, ty *FunctionType, link LinkageKind) *Function
type PHINode ¶
type PHINode struct { Op Opcode Incoming []PHINodeIncoming // contains filtered or unexported fields }
PHINode --------------------------
func CreateEmptyPHINode ¶
func CreateEmptyPHINode() *PHINode
func CreatePHINode ¶
func (*PHINode) AddIncoming ¶
func (phi *PHINode) AddIncoming(v Expr, blk *BasicBlock)
func (*PHINode) NumOperands ¶
type PHINodeIncoming ¶
type PHINodeIncoming struct { V Expr Blk *BasicBlock }
func (PHINodeIncoming) String ¶
func (p PHINodeIncoming) String() string
type PointerType ¶
type PointerType struct {
// contains filtered or unexported fields
}
PointerType ... --------------------
func CreatePointerType ¶
func CreatePointerType(ty Type) *PointerType
func (PointerType) ElemType ¶
func (p PointerType) ElemType() Type
func (PointerType) IsArrayTy ¶
func (PointerType) IsArrayTy() bool
func (PointerType) IsFuncTy ¶
func (PointerType) IsFuncTy() bool
func (PointerType) IsIntegerTy ¶
func (PointerType) IsIntegerTy() bool
func (PointerType) IsPtrTy ¶
func (PointerType) IsPtrTy() bool
func (PointerType) IsVoidTy ¶
func (PointerType) IsVoidTy() bool
func (PointerType) String ¶
func (PointerType) String() string
type ProcCallInstr ¶
type ProcCallInstr struct { Op Opcode Callee Expr Args []Expr // contains filtered or unexported fields }
ProcCallInstr ... --------------------
func CreateProcCall ¶
func CreateProcCall(callee Expr, args []Expr) *ProcCallInstr
func (*ProcCallInstr) Parent ¶
func (c *ProcCallInstr) Parent() *BasicBlock
func (*ProcCallInstr) SetParent ¶
func (c *ProcCallInstr) SetParent(parent *BasicBlock)
func (*ProcCallInstr) String ¶
func (c *ProcCallInstr) String() string
type PtrTy ¶
type PtrTy struct {
To Type
}
PtrTy -------------------------------------------
func (PtrTy) IsIntegerTy ¶
type Return ¶
Return -----------------------------
func (*Return) Parent ¶
func (r *Return) Parent() *BasicBlock
func (*Return) SetParent ¶
func (r *Return) SetParent(parent *BasicBlock)
type Stmt ¶
type Stmt interface { Parent() *BasicBlock SetParent(*BasicBlock) fmt.Stringer // contains filtered or unexported methods }
type Store ¶
Store -----------------------
func CreateStore ¶
func (*Store) Parent ¶
func (s *Store) Parent() *BasicBlock
func (*Store) SetParent ¶
func (s *Store) SetParent(parent *BasicBlock)
type SymbolTable ¶
type SymbolTable struct {
// contains filtered or unexported fields
}
func NewScope ¶
func NewScope(parent Scope, name string) *SymbolTable
func (*SymbolTable) Elems ¶
func (s *SymbolTable) Elems() map[string]Object
func (*SymbolTable) Insert ¶
func (s *SymbolTable) Insert(obj Object) Object
func (*SymbolTable) Lookup ¶
func (s *SymbolTable) Lookup(name string) Object
Lookup checks the current and (possibly) parent (and ancestor) scopes for the object with the given name if no such object exists, return nil.
func (*SymbolTable) Parent ¶
func (s *SymbolTable) Parent() Scope
Parent returns the scope's containing (parent) scope.
func (*SymbolTable) Size ¶
func (s *SymbolTable) Size() int
Size returns the number of symbols in the scope.
type Temp ¶
type Temp struct {
// contains filtered or unexported fields
}
Temp --------------------------------------
func (*Temp) NumOperands ¶
type ValueSymbolTable ¶
type Variable ¶
type Variable struct {
// contains filtered or unexported fields
}
Variable ----------------