package pass
import "github.com/mmcloughlin/avo/pass"
Package pass implements processing passes on avo Files.
Index ¶
- Variables
- func AllocateRegisters(fn *ir.Function) error
- func BindRegisters(fn *ir.Function) error
- func CFG(fn *ir.Function) error
- func EnsureBasePointerCalleeSaved(fn *ir.Function) error
- func IncludeTextFlagHeader(f *ir.File) error
- func LabelTarget(fn *ir.Function) error
- func Liveness(fn *ir.Function) error
- func PruneDanglingLabels(fn *ir.Function) error
- func PruneJumpToFollowingLabel(fn *ir.Function) error
- func PruneSelfMoves(fn *ir.Function) error
- func RequiredISAExtensions(fn *ir.Function) error
- func VerifyAllocation(fn *ir.Function) error
- func VerifyMemOperands(i *ir.Instruction) error
- func ZeroExtend32BitOutputs(i *ir.Instruction) error
- type Allocator
- func NewAllocator(rs []reg.Physical) (*Allocator, error)
- func NewAllocatorForKind(k reg.Kind) (*Allocator, error)
- func (a *Allocator) Add(v reg.ID)
- func (a *Allocator) AddInterference(x, y reg.ID)
- func (a *Allocator) AddInterferenceSet(r reg.Register, s reg.MaskSet)
- func (a *Allocator) Allocate() (reg.Allocation, error)
- func (a *Allocator) SetPriority(id reg.ID, p int)
- type Func
- type FunctionPass
- type InstructionPass
- type Interface
- type Output
Variables ¶
var Compile = Concat( Verify, FunctionPass(PruneJumpToFollowingLabel), FunctionPass(PruneDanglingLabels), FunctionPass(LabelTarget), FunctionPass(CFG), InstructionPass(ZeroExtend32BitOutputs), FunctionPass(Liveness), FunctionPass(AllocateRegisters), FunctionPass(BindRegisters), FunctionPass(VerifyAllocation), FunctionPass(EnsureBasePointerCalleeSaved), Func(IncludeTextFlagHeader), FunctionPass(PruneSelfMoves), FunctionPass(RequiredISAExtensions), )
Compile pass compiles an avo file. Upon successful completion the avo file may be printed to Go assembly.
var Verify = Concat( InstructionPass(VerifyMemOperands), )
Verify pass validates an avo file.
Functions ¶
func AllocateRegisters ¶
AllocateRegisters performs register allocation.
func BindRegisters ¶
BindRegisters applies the result of register allocation, replacing all virtual registers with their assigned physical registers.
func CFG ¶
CFG constructs the call-flow-graph for the function.
func EnsureBasePointerCalleeSaved ¶
EnsureBasePointerCalleeSaved ensures that the base pointer register will be saved and restored if it has been clobbered by the function.
func IncludeTextFlagHeader ¶
IncludeTextFlagHeader includes textflag.h if necessary.
func LabelTarget ¶
LabelTarget populates the LabelTarget of the given function. This maps from label name to the following instruction.
func Liveness ¶
Liveness computes register liveness.
func PruneDanglingLabels ¶
PruneDanglingLabels removes labels that are not referenced by any branches.
func PruneJumpToFollowingLabel ¶
PruneJumpToFollowingLabel removes jump instructions that target an immediately following label.
func PruneSelfMoves ¶
PruneSelfMoves removes move instructions from one register to itself.
func RequiredISAExtensions ¶
RequiredISAExtensions determines ISA extensions required for the given function. Populates the ISA field.
func VerifyAllocation ¶
VerifyAllocation performs sanity checks following register allocation.
func VerifyMemOperands ¶
func VerifyMemOperands(i *ir.Instruction) error
VerifyMemOperands checks the instruction's memory operands.
func ZeroExtend32BitOutputs ¶
func ZeroExtend32BitOutputs(i *ir.Instruction) error
ZeroExtend32BitOutputs applies the rule that "32-bit operands generate a 32-bit result, zero-extended to a 64-bit result in the destination general-purpose register" (Intel Software Developer’s Manual, Volume 1, 3.4.1.1).
Types ¶
type Allocator ¶
type Allocator struct {
// contains filtered or unexported fields
}
Allocator is a graph-coloring register allocator.
func NewAllocator ¶
NewAllocator builds an allocator for the given physical registers.
func NewAllocatorForKind ¶
NewAllocatorForKind builds an allocator for the given kind of registers.
func (*Allocator) Add ¶
Add adds a register to be allocated. Does nothing if the register has already been added.
func (*Allocator) AddInterference ¶
AddInterference records that x and y must be assigned to non-conflicting physical registers.
func (*Allocator) AddInterferenceSet ¶
AddInterferenceSet records that r interferes with every register in s. Convenience wrapper around AddInterference.
func (*Allocator) Allocate ¶
func (a *Allocator) Allocate() (reg.Allocation, error)
Allocate allocates physical registers.
func (*Allocator) SetPriority ¶
SetPriority sets the priority of the given regiser to p. Higher priority registers are preferred in allocations. By default all registers have 0 priority. Priority will only apply to subsequent Add() calls, therefore typically all SetPriority calls should happen at allocator initialization.
type Func ¶
Func adapts a function to the pass Interface.
func (Func) Execute ¶
Execute calls p.
type FunctionPass ¶
FunctionPass is a convenience for implementing a full file pass with a function that operates on each avo Function independently.
func (FunctionPass) Execute ¶
func (p FunctionPass) Execute(f *ir.File) error
Execute calls p on every function in the file. Exits on the first error.
type InstructionPass ¶
type InstructionPass func(*ir.Instruction) error
InstructionPass is a convenience for implementing a full file pass with a function that operates on each Instruction independently.
func (InstructionPass) Execute ¶
func (p InstructionPass) Execute(f *ir.File) error
Execute calls p on every instruction in the file. Exits on the first error.
type Interface ¶
Interface for a processing pass.
func Concat ¶
Concat returns a pass that executes the given passes in order, stopping on the first error.
type Output ¶
type Output struct { Writer io.WriteCloser Printer printer.Printer }
Output pass prints a file.
func (*Output) Execute ¶
Execute prints f with the configured Printer and writes output to Writer.
Source Files ¶
alloc.go cfg.go cleanup.go isa.go pass.go reg.go textflag.go verify.go
- Version
- v0.6.0 (latest)
- Published
- Jan 7, 2024
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- 4 weeks ago –
Tools for package owners.