Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCriticalEdges = errors.New("the CFG has critical edges")
var ErrEntryLiveIns = errors.New("entry block has live in values")
var ErrTooManyRequiredRegisters = errors.New("too many required registers")
Functions ¶
func DumpLivenessChart ¶
func DumpLivenessChart(ra *RegAlloc)
func WriteGraphvizCFG ¶
func WriteGraphvizCFG(ra *RegAlloc)
WriteGraphvizCFG emits a Graphviz dot file of the CFG
func WriteGraphvizInterferenceGraph ¶
func WriteGraphvizInterferenceGraph(ra *RegAlloc)
WriteGraphvizInterferenceGraph emits a Graphviz dot file of the Interference Graph
func WriteGraphvizLivenessGraph ¶
func WriteGraphvizLivenessGraph(ra *RegAlloc)
Types ¶
type RegAlloc ¶
type RegAlloc struct {
// contains filtered or unexported fields
}
func NewRegAlloc ¶
NewRegAlloc returns a new register allocator, ready to have the registers allocated for the given function.
func (*RegAlloc) Allocate ¶
Allocate will run the allocator and assign a physical register or stack slot to each Value that needs one.
This uses a graph colouring algorithm designed for use on SSA code. The SSA code should have copies added for block defs/args such that the allocator is free to choose different registers as it crosses that boundary. Attempts will be made to strongly prefer choosing the same register across a copy and across block args/defs to minimize the number of copies in the resultant code.
A simpler algorithm is chosen rather than a fast algorithm because this can easily be a very complex piece of code and simpler code is easier to ensure is correct. It's extremely important that the register allocator produces correct code or else pretty much anything can happen.
To that end, there is a verifier in the verify sub-package which will double check the work of the allocator. See that code for more information on how it works.
func (*RegAlloc) CheckInput ¶
CheckInput will verify the structure of the input code, which is useful in tests and fuzzing.