Documentation
¶
Overview ¶
Package ir provides the intermediate representation of avo programs.
Index ¶
- type Comment
- type Datum
- type File
- type Function
- func (f *Function) AddComment(lines ...string)
- func (f *Function) AddInstruction(i *Instruction)
- func (f *Function) AddLabel(l Label)
- func (f *Function) AddNode(n Node)
- func (f *Function) AddPragma(directive string, args ...string)
- func (f *Function) AllocLocal(size int) operand.Mem
- func (f *Function) ArgumentBytes() int
- func (f *Function) FrameBytes() int
- func (f *Function) Instructions() []*Instruction
- func (f *Function) Labels() []Label
- func (f *Function) SetSignature(s *gotypes.Signature)
- func (f *Function) Stub() string
- type Global
- type Instruction
- type Label
- type Node
- type Pragma
- type Section
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comment ¶
type Comment struct {
Lines []string
}
Comment represents a multi-line comment.
func NewComment ¶
NewComment builds a Comment consisting of the provided lines.
type Datum ¶
Datum represents a data element at a particular offset of a data section.
type File ¶
type File struct {
Constraints buildtags.Constraints
Includes []string
Sections []Section
}
File represents an assembly file.
func (*File) AddSection ¶
AddSection appends a Section to the file.
type Function ¶
type Function struct {
Name string
Attributes attr.Attribute
Pragmas []Pragma
Doc []string
Signature *gotypes.Signature
LocalSize int
Nodes []Node
// LabelTarget maps from label name to the following instruction.
LabelTarget map[Label]*Instruction
// Register allocation.
Allocation reg.Allocation
// ISA is the list of required instruction set extensions.
ISA []string
}
Function represents an assembly function.
func NewFunction ¶
NewFunction builds an empty function of the given name.
func (*Function) AddComment ¶
AddComment adds comment lines to f.
func (*Function) AddInstruction ¶
func (f *Function) AddInstruction(i *Instruction)
AddInstruction appends an instruction to f.
func (*Function) AllocLocal ¶
AllocLocal allocates size bytes in this function's stack. Returns a reference to the base pointer for the newly allocated region.
func (*Function) ArgumentBytes ¶
ArgumentBytes returns the size of the arguments in bytes.
func (*Function) FrameBytes ¶
FrameBytes returns the size of the stack frame in bytes.
func (*Function) Instructions ¶
func (f *Function) Instructions() []*Instruction
Instructions returns just the list of instruction nodes.
func (*Function) SetSignature ¶
SetSignature sets the function signature.
type Global ¶
Global represents a DATA section.
func NewStaticGlobal ¶
NewStaticGlobal is a convenience for building a static DATA section.
func (*Global) AddDatum ¶
AddDatum adds d to this data section, growing it if necessary. Errors if the datum overlaps with existing data.
type Instruction ¶
type Instruction struct {
Opcode string
Suffixes []string
Operands []operand.Op
Inputs []operand.Op
Outputs []operand.Op
IsTerminal bool
IsBranch bool
IsConditional bool
CancellingInputs bool
// ISA is the list of required instruction set extensions.
ISA []string
// CFG.
Pred []*Instruction
Succ []*Instruction
// LiveIn/LiveOut are sets of live register IDs pre/post execution.
LiveIn reg.MaskSet
LiveOut reg.MaskSet
}
Instruction is a single instruction in a function.
func (Instruction) InputRegisters ¶
func (i Instruction) InputRegisters() []reg.Register
InputRegisters returns all registers read by this instruction.
func (Instruction) IsUnconditionalBranch ¶
func (i Instruction) IsUnconditionalBranch() bool
IsUnconditionalBranch reports whether i is an unconditional branch.
func (*Instruction) OpcodeWithSuffixes ¶
func (i *Instruction) OpcodeWithSuffixes() string
OpcodeWithSuffixes returns the full opcode, including dot-separated suffixes.
func (Instruction) OutputRegisters ¶
func (i Instruction) OutputRegisters() []reg.Register
OutputRegisters returns all registers written by this instruction.
func (Instruction) Registers ¶
func (i Instruction) Registers() []reg.Register
Registers returns all registers involved in the instruction.
func (Instruction) TargetLabel ¶
func (i Instruction) TargetLabel() *Label
TargetLabel returns the label referenced by this instruction. Returns nil if no label is referenced.
type Node ¶
type Node interface {
// contains filtered or unexported methods
}
Node is a part of a Function.