package ir
import "github.com/mmcloughlin/avo/ir"
Package ir provides the intermediate representation of avo programs.
Index ¶
- type Comment
- type Datum
- func NewDatum(offset int, v operand.Constant) Datum
- func (d Datum) Interval() (int, int)
- func (d Datum) Overlaps(other Datum) bool
- type File
- type Function
- func NewFunction(name string) *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
- func NewGlobal(sym operand.Symbol) *Global
- func NewStaticGlobal(name string) *Global
- func (g *Global) AddDatum(d Datum) error
- func (g *Global) Append(v operand.Constant)
- func (g *Global) Base() operand.Mem
- func (g *Global) Grow(size int)
- type Instruction
- func (i Instruction) InputRegisters() []reg.Register
- func (i Instruction) IsUnconditionalBranch() bool
- func (i *Instruction) OpcodeWithSuffixes() string
- func (i Instruction) OutputRegisters() []reg.Register
- func (i Instruction) Registers() []reg.Register
- func (i Instruction) TargetLabel() *Label
- type Label
- type Node
- type Pragma
- type Section
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.
func NewDatum ¶
NewDatum builds a Datum from the given constant.
func (Datum) Interval ¶
Interval returns the range of bytes this datum will occupy within its section.
func (Datum) Overlaps ¶
Overlaps returns whether d overlaps with other.
type File ¶
type File struct { Constraints buildtags.Constraints Includes []string Sections []Section }
File represents an assembly file.
func NewFile ¶
func NewFile() *File
NewFile initializes an empty file.
func (*File) AddSection ¶
AddSection appends a Section to the file.
func (*File) Functions ¶
Functions returns all functions in 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) AddLabel ¶
AddLabel appends a label to f.
func (*Function) AddNode ¶
AddNode appends a Node to f.
func (*Function) AddPragma ¶
AddPragma adds a pragma to this function.
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) Labels ¶
Labels returns just the list of label nodes.
func (*Function) SetSignature ¶
SetSignature sets the function signature.
func (*Function) Stub ¶
Stub returns the Go function declaration.
type Global ¶
Global represents a DATA section.
func NewGlobal ¶
NewGlobal constructs an empty 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.
func (*Global) Append ¶
Append the constant to the end of the data section.
func (*Global) Base ¶
Base returns a pointer to the start of the data section.
func (*Global) Grow ¶
Grow ensures that the data section has at least the given size.
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 Label ¶
type Label string
Label within a function.
type Node ¶
type Node interface {
// contains filtered or unexported methods
}
Node is a part of a Function.
type Pragma ¶
Pragma represents a function compiler directive.
type Section ¶
type Section interface {
// contains filtered or unexported methods
}
Section is a part of a file.
Source Files ¶
- Version
- v0.6.0 (latest)
- Published
- Jan 7, 2024
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 4 weeks ago –
Tools for package owners.