Documentation
¶
Index ¶
- Constants
- Variables
- func IrTryIntoCopy(v IrNode) (Reg, Reg, bool)
- type ABILowering
- type BasicBlock
- type BasicBlockIter
- type BlockMerge
- type BranchElim
- type CFG
- type CSE
- type ConstProp
- type Constness
- type CopyElim
- type FuncData
- type FuncLayout
- type Int65
- type IrAlias
- type IrBinaryExpr
- type IrBinaryOp
- type IrBitTestSet
- type IrBranch
- type IrBreakpoint
- type IrCallFunc
- type IrCallMethod
- type IrCallNative
- type IrClobberList
- type IrConstInt
- type IrConstPtr
- type IrDefinitions
- type IrEntry
- type IrImmovable
- type IrImpure
- type IrLEA
- type IrLoad
- type IrLoadArg
- type IrNode
- type IrNop
- type IrPhi
- type IrReturn
- type IrSlotAlive
- type IrSpill
- type IrSpillOp
- type IrSpillSlot
- type IrStore
- type IrSuccessors
- type IrSwitch
- type IrTerminator
- type IrUnaryExpr
- type IrUnaryOp
- type IrUsages
- type IrWriteBarrier
- type Layout
- type Likeliness
- type Pass
- type PassDescriptor
- type PhiElim
- type PhiProp
- type Pos
- type Reduce
- type Reg
- type RegAlloc
- type Rematerialize
- type Reorder
- type ReturnSpread
- type SlotSet
- type SplitCritical
- type StackLiveness
- type TDCE
- type ZeroReg
Constants ¶
const ( K_sys = 0 K_zero = 1 K_temp = 2 K_arch = 3 K_norm = 4 )
const (
N_size = _M_name + 1
)
Variables ¶
var ( MinInt65 = Int65{0, 1} MaxInt65 = Int65{math.MaxUint64, 0} )
var Passes = [...]PassDescriptor{ {Name: "Early Constant Propagation", Pass: new(ConstProp)}, {Name: "Early Reduction", Pass: new(Reduce)}, {Name: "Branch Elimination", Pass: new(BranchElim)}, {Name: "Return Spreading", Pass: new(ReturnSpread)}, {Name: "Value Reordering", Pass: new(Reorder)}, {Name: "Late Constant Propagation", Pass: new(ConstProp)}, {Name: "Late Reduction", Pass: new(Reduce)}, {Name: "Machine Dependent Lowering", Pass: new(Lowering)}, {Name: "Zero Register Substitution", Pass: new(ZeroReg)}, {Name: "Write Barrier Insertion", Pass: new(WriteBarrier)}, {Name: "ABI-Specific Lowering", Pass: new(ABILowering)}, {Name: "Instruction Fusion", Pass: new(Fusion)}, {Name: "Instruction Compaction", Pass: new(Compaction)}, {Name: "Block Merging", Pass: new(BlockMerge)}, {Name: "Critical Edge Splitting", Pass: new(SplitCritical)}, {Name: "Phi Propagation", Pass: new(PhiProp)}, {Name: "Operand Allocation", Pass: new(OperandAlloc)}, {Name: "Constant Rematerialize", Pass: new(Rematerialize)}, {Name: "Pre-allocation TDCE", Pass: new(TDCE)}, {Name: "Register Allocation", Pass: new(RegAlloc)}, {Name: "Stack Liveness Analysis", Pass: new(StackLiveness)}, {Name: "Function Layout", Pass: new(Layout)}, }
var Reductions = []PassDescriptor{ {Name: "Common Sub-expression Elimination", Pass: new(CSE)}, {Name: "Phi Elimination", Pass: new(PhiElim)}, {Name: "Copy Elimination", Pass: new(CopyElim)}, {Name: "Trivial Dead Code Elimination", Pass: new(TDCE)}, }
Functions ¶
Types ¶
type ABILowering ¶ added in v0.1.1
type ABILowering struct{}
ABILowering lowers ABI-specific instructions to machine specific instructions.
func (ABILowering) Apply ¶ added in v0.1.1
func (self ABILowering) Apply(cfg *CFG)
type BasicBlock ¶
type BasicBlock struct { Id int Phi []*IrPhi Ins []IrNode Pred []*BasicBlock Term IrTerminator }
func (*BasicBlock) String ¶ added in v0.1.4
func (self *BasicBlock) String() string
type BasicBlockIter ¶ added in v0.1.2
type BasicBlockIter struct {
// contains filtered or unexported fields
}
func (*BasicBlockIter) Block ¶ added in v0.1.2
func (self *BasicBlockIter) Block() *BasicBlock
func (*BasicBlockIter) ForEach ¶ added in v0.1.2
func (self *BasicBlockIter) ForEach(action func(bb *BasicBlock))
func (*BasicBlockIter) Next ¶ added in v0.1.2
func (self *BasicBlockIter) Next() bool
func (*BasicBlockIter) Reversed ¶ added in v0.1.2
func (self *BasicBlockIter) Reversed() []*BasicBlock
type BlockMerge ¶
type BlockMerge struct{}
BlockMerge merges redundant intermediate blocks (blocks with a single outgoing edge which goes to another block with a single incoming edge).
func (BlockMerge) Apply ¶
func (BlockMerge) Apply(cfg *CFG)
type BranchElim ¶
type BranchElim struct{}
BranchElim removes branches that can be proved unreachable.
func (BranchElim) Apply ¶
func (self BranchElim) Apply(cfg *CFG)
type CFG ¶
type CFG struct { Func FuncData Root *BasicBlock Depth map[int]int Layout *abi.FunctionLayout DominatedBy map[int]*BasicBlock DominatorOf map[int][]*BasicBlock DominanceFrontier map[int][]*BasicBlock // contains filtered or unexported fields }
func (*CFG) CreateBlock ¶ added in v0.1.1
func (self *CFG) CreateBlock() (r *BasicBlock)
func (*CFG) CreateRegister ¶ added in v0.1.1
func (*CFG) CreateUnreachable ¶ added in v0.1.1
func (self *CFG) CreateUnreachable(bb *BasicBlock) (ret *BasicBlock)
func (*CFG) PostOrder ¶
func (self *CFG) PostOrder() *BasicBlockIter
type FuncLayout ¶ added in v0.1.4
type FuncLayout struct { Ins []IrNode Start map[int]int Block map[int]*BasicBlock }
func (*FuncLayout) String ¶ added in v0.1.4
func (self *FuncLayout) String() string
type Int65 ¶
type Int65 struct {
// contains filtered or unexported fields
}
func (Int65) CompareZero ¶
type IrAlias ¶ added in v0.1.2
func (*IrAlias) Definitions ¶ added in v0.1.2
type IrBinaryExpr ¶
type IrBinaryExpr struct { R Reg X Reg Y Reg Op IrBinaryOp }
func (*IrBinaryExpr) Clone ¶ added in v0.1.1
func (self *IrBinaryExpr) Clone() IrNode
func (*IrBinaryExpr) Definitions ¶ added in v0.1.1
func (self *IrBinaryExpr) Definitions() []*Reg
func (*IrBinaryExpr) String ¶
func (self *IrBinaryExpr) String() string
func (*IrBinaryExpr) Usages ¶
func (self *IrBinaryExpr) Usages() []*Reg
type IrBinaryOp ¶
type IrBinaryOp uint8
const ( IrOpAdd IrBinaryOp = iota IrOpSub IrOpMul IrOpAnd IrOpOr IrOpXor IrOpShr IrCmpEq IrCmpNe IrCmpLt IrCmpLtu IrCmpGeu )
func (IrBinaryOp) String ¶
func (self IrBinaryOp) String() string
type IrBitTestSet ¶
func (*IrBitTestSet) Clone ¶ added in v0.1.1
func (self *IrBitTestSet) Clone() IrNode
func (*IrBitTestSet) Definitions ¶ added in v0.1.1
func (self *IrBitTestSet) Definitions() []*Reg
func (*IrBitTestSet) String ¶
func (self *IrBitTestSet) String() string
func (*IrBitTestSet) Usages ¶
func (self *IrBitTestSet) Usages() []*Reg
type IrBranch ¶ added in v0.1.1
type IrBranch struct { To *BasicBlock Likeliness Likeliness }
func IrLikely ¶ added in v0.1.1
func IrLikely(bb *BasicBlock) *IrBranch
func IrUnlikely ¶ added in v0.1.1
func IrUnlikely(bb *BasicBlock) *IrBranch
type IrBreakpoint ¶
type IrBreakpoint struct{}
func (*IrBreakpoint) Clone ¶ added in v0.1.1
func (*IrBreakpoint) Clone() IrNode
func (*IrBreakpoint) String ¶
func (*IrBreakpoint) String() string
type IrCallFunc ¶ added in v0.1.1
type IrCallFunc struct { R Reg In []Reg Out []Reg Func *abi.FunctionLayout }
func (*IrCallFunc) Clone ¶ added in v0.1.1
func (self *IrCallFunc) Clone() IrNode
func (*IrCallFunc) Definitions ¶ added in v0.1.1
func (self *IrCallFunc) Definitions() []*Reg
func (*IrCallFunc) String ¶ added in v0.1.1
func (self *IrCallFunc) String() string
func (*IrCallFunc) Usages ¶ added in v0.1.1
func (self *IrCallFunc) Usages() []*Reg
type IrCallMethod ¶ added in v0.1.1
func (*IrCallMethod) Clone ¶ added in v0.1.1
func (self *IrCallMethod) Clone() IrNode
func (*IrCallMethod) Definitions ¶ added in v0.1.1
func (self *IrCallMethod) Definitions() []*Reg
func (*IrCallMethod) String ¶ added in v0.1.1
func (self *IrCallMethod) String() string
func (*IrCallMethod) Usages ¶ added in v0.1.1
func (self *IrCallMethod) Usages() []*Reg
type IrCallNative ¶ added in v0.1.1
func (*IrCallNative) Clone ¶ added in v0.1.1
func (self *IrCallNative) Clone() IrNode
func (*IrCallNative) Definitions ¶ added in v0.1.1
func (self *IrCallNative) Definitions() []*Reg
func (*IrCallNative) String ¶ added in v0.1.1
func (self *IrCallNative) String() string
func (*IrCallNative) Usages ¶ added in v0.1.1
func (self *IrCallNative) Usages() []*Reg
type IrClobberList ¶ added in v0.1.4
type IrClobberList struct {
R []Reg
}
func IrMarkClobber ¶ added in v0.1.4
func IrMarkClobber(r ...Reg) *IrClobberList
func (*IrClobberList) Clone ¶ added in v0.1.4
func (self *IrClobberList) Clone() IrNode
func (*IrClobberList) String ¶ added in v0.1.4
func (self *IrClobberList) String() string
func (*IrClobberList) Usages ¶ added in v0.1.4
func (self *IrClobberList) Usages() []*Reg
type IrConstInt ¶
func (*IrConstInt) Clone ¶ added in v0.1.1
func (self *IrConstInt) Clone() IrNode
func (*IrConstInt) Definitions ¶ added in v0.1.1
func (self *IrConstInt) Definitions() []*Reg
func (*IrConstInt) String ¶
func (self *IrConstInt) String() string
type IrConstPtr ¶
func (*IrConstPtr) Clone ¶ added in v0.1.1
func (self *IrConstPtr) Clone() IrNode
func (*IrConstPtr) Definitions ¶ added in v0.1.1
func (self *IrConstPtr) Definitions() []*Reg
func (*IrConstPtr) String ¶
func (self *IrConstPtr) String() string
type IrDefinitions ¶ added in v0.1.1
type IrEntry ¶ added in v0.1.1
type IrEntry struct {
R []Reg
}
func (*IrEntry) Definitions ¶ added in v0.1.1
type IrImmovable ¶ added in v0.1.1
type IrImmovable interface { IrNode // contains filtered or unexported methods }
type IrImpure ¶ added in v0.1.1
type IrImpure interface { IrNode // contains filtered or unexported methods }
type IrLEA ¶
func (*IrLEA) Definitions ¶ added in v0.1.1
type IrLoad ¶
func (*IrLoad) Definitions ¶ added in v0.1.1
type IrLoadArg ¶
func (*IrLoadArg) Definitions ¶ added in v0.1.1
type IrNode ¶
func IrCreateSpillEx ¶ added in v0.1.4
func IrSlotGen ¶ added in v0.1.4
func IrSlotGen(s IrSpillSlot) IrNode
type IrPhi ¶
type IrPhi struct { R Reg V map[*BasicBlock]*Reg }
func (*IrPhi) Definitions ¶ added in v0.1.1
type IrReturn ¶
type IrReturn struct {
R []Reg
}
func (*IrReturn) Successors ¶
func (self *IrReturn) Successors() IrSuccessors
type IrSlotAlive ¶ added in v0.1.4
type IrSlotAlive struct {
S []IrSpillSlot
}
func (*IrSlotAlive) Clone ¶ added in v0.1.4
func (self *IrSlotAlive) Clone() IrNode
func (*IrSlotAlive) String ¶ added in v0.1.4
func (self *IrSlotAlive) String() string
type IrSpill ¶ added in v0.1.4
type IrSpill struct { R Reg S IrSpillSlot Op IrSpillOp }
func (*IrSpill) Definitions ¶ added in v0.1.4
type IrSpillSlot ¶ added in v0.1.4
type IrSpillSlot uint64
func (IrSpillSlot) ID ¶ added in v0.1.4
func (self IrSpillSlot) ID() int
func (IrSpillSlot) IsPtr ¶ added in v0.1.4
func (self IrSpillSlot) IsPtr() bool
func (IrSpillSlot) String ¶ added in v0.1.4
func (self IrSpillSlot) String() string
type IrSuccessors ¶
type IrSuccessors interface { Next() bool Block() *BasicBlock Value() (int32, bool) Likeliness() Likeliness UpdateBlock(bb *BasicBlock) }
type IrSwitch ¶
func (*IrSwitch) Successors ¶
func (self *IrSwitch) Successors() IrSuccessors
type IrTerminator ¶
type IrTerminator interface { IrNode Successors() IrSuccessors // contains filtered or unexported methods }
type IrUnaryExpr ¶
func (*IrUnaryExpr) Clone ¶ added in v0.1.1
func (self *IrUnaryExpr) Clone() IrNode
func (*IrUnaryExpr) Definitions ¶ added in v0.1.1
func (self *IrUnaryExpr) Definitions() []*Reg
func (*IrUnaryExpr) String ¶
func (self *IrUnaryExpr) String() string
func (*IrUnaryExpr) Usages ¶
func (self *IrUnaryExpr) Usages() []*Reg
type IrWriteBarrier ¶
func (*IrWriteBarrier) Clone ¶ added in v0.1.1
func (self *IrWriteBarrier) Clone() IrNode
func (*IrWriteBarrier) String ¶
func (self *IrWriteBarrier) String() string
func (*IrWriteBarrier) Usages ¶
func (self *IrWriteBarrier) Usages() []*Reg
type Likeliness ¶ added in v0.1.1
type Likeliness uint8
const ( Likely Likeliness = iota Unlikely )
func (Likeliness) String ¶ added in v0.1.1
func (self Likeliness) String() string
type PassDescriptor ¶
type PhiProp ¶ added in v0.1.2
type PhiProp struct{}
PhiProp propagates Phi nodes into it's source blocks, essentially get rid of them. The CFG is no longer in SSA form after this pass.
type Pos ¶ added in v0.1.4
type Pos struct { B *BasicBlock I int }
type RegAlloc ¶ added in v0.1.1
type RegAlloc struct{}
RegAlloc performs register allocation on CFG.
type Rematerialize ¶ added in v0.1.4
type Rematerialize struct{}
Rematerialize recalculates simple values to reduce register pressure.
func (Rematerialize) Apply ¶ added in v0.1.4
func (Rematerialize) Apply(cfg *CFG)
type Reorder ¶ added in v0.1.1
type Reorder struct{}
Reorder moves value closer to it's usage, which reduces register pressure.
type ReturnSpread ¶ added in v0.1.1
type ReturnSpread struct{}
ReturnSpread spreads the return block to all it's successors, in order to shorten register live ranges.
func (ReturnSpread) Apply ¶ added in v0.1.1
func (ReturnSpread) Apply(cfg *CFG)
type SlotSet ¶ added in v0.1.4
type SlotSet map[IrSpillSlot]struct{}
type SplitCritical ¶ added in v0.1.4
type SplitCritical struct{}
SplitCritical splits critical edges (those that go from a block with more than one outedge to a block with more than one inedge) by inserting an empty block.
PhiProp wants a critical-edge-free CFG so it can safely remove Phi nodes for RegAlloc.
func (SplitCritical) Apply ¶ added in v0.1.4
func (SplitCritical) Apply(cfg *CFG)
type StackLiveness ¶ added in v0.1.4
type StackLiveness struct{}
StackLiveness calculates the liveness of each stack slot.
func (StackLiveness) Apply ¶ added in v0.1.4
func (self StackLiveness) Apply(cfg *CFG)
Source Files
¶
- block.go
- blockiter.go
- builder.go
- cfg.go
- compile.go
- constdata.go
- dominator.go
- funcdata.go
- int65.go
- ir.go
- pass_abispec.go
- pass_blockmerge.go
- pass_branchelim.go
- pass_comsubexpr.go
- pass_constprop.go
- pass_copyelim.go
- pass_layout.go
- pass_phielim.go
- pass_phiprop.go
- pass_reduce.go
- pass_regalloc.go
- pass_rematerialize.go
- pass_reorder.go
- pass_return_spread.go
- pass_splitcritical.go
- pass_stack_liveness.go
- pass_tdce.go
- pass_zeroreg.go
- phi.go
- pos.go
- rename.go
- slotset.go
- utils.go