ir

package
v0.0.0-...-99d40e0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 6 Imported by: 10

Documentation

Overview

Package ir implements Nebula IR instructions and stack.

Nebula IR is an intermediate language between Whitespace and LLVM IR.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessHandler

type AccessHandler func(n uint, pos token.Pos)

AccessHandler watches accesses of values under stack frame.

type AccessStackStmt

type AccessStackStmt struct {
	StackSize uint
	PosBase
}

AccessStackStmt is a statement that asserts the stack length.

func NewAccessStackStmt

func NewAccessStackStmt(stackSize uint, pos token.Pos) *AccessStackStmt

NewAccessStackStmt constructs a AccessStackStmt.

func (*AccessStackStmt) OpString

func (*AccessStackStmt) OpString() string

OpString pretty prints the op kind.

type BasicBlock

type BasicBlock struct {
	ID         int           // Unique block ID for printing
	LabelName  string        // Name derived from label
	Labels     []Label       // Labels for this block in source
	Nodes      []Inst        // Non-branching non-stack instructions
	Terminator TermInst      // Terminator control flow instruction
	Entries    []*BasicBlock // Entry blocks; blocks immediately preceding this block in flow
	Callers    []*BasicBlock // Calling blocks; blocks calling this block or its parents
	Returns    []*BasicBlock // Returning blocks; blocks returning to this block
	Prev       *BasicBlock   // Predecessor block in source
	Next       *BasicBlock   // Successor block in source
}

BasicBlock is a list of consecutive non-branching instructions in a program followed by a branch.

func (*BasicBlock) AppendInst

func (block *BasicBlock) AppendInst(inst Inst)

AppendInst appends an instruction to the block.

func (*BasicBlock) Disconnect

func (block *BasicBlock) Disconnect()

Disconnect removes incoming edges to a basic block. The block is not removed from the program block slice and callers are not updated.

func (*BasicBlock) Name

func (block *BasicBlock) Name() string

Name returns the name of the basic block from either the first label or the block address.

func (*BasicBlock) SetTerminator

func (block *BasicBlock) SetTerminator(term TermInst)

SetTerminator sets the terminator instruction of the block.

func (*BasicBlock) String

func (block *BasicBlock) String() string

func (*BasicBlock) Succs

func (block *BasicBlock) Succs() []*BasicBlock

Succs returns all outgoing edges of the block.

type BinaryExpr

type BinaryExpr struct {
	Op BinaryOp
	ValueBase
	UserBase
	PosBase
}

BinaryExpr is an arithmetic expression with two operands.

func NewBinaryExpr

func NewBinaryExpr(op BinaryOp, lhs, rhs Value, pos token.Pos) *BinaryExpr

NewBinaryExpr constructs a BinaryExpr.

func (*BinaryExpr) OpString

func (bin *BinaryExpr) OpString() string

OpString pretty prints the op kind.

type BinaryOp

type BinaryOp uint8

BinaryOp is the operator kind of a binary expression.

const (
	Add BinaryOp = iota + 1
	Sub
	Mul
	Div
	Mod
	Shl
	LShr
	AShr
	And
	Or
	Xor
)

Binary operations.

func (BinaryOp) String

func (op BinaryOp) String() string

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder assists in IR construction.

func NewBuilder

func NewBuilder(file *token.File) *Builder

NewBuilder constructs a builder with a given number of basic blocks.

func (*Builder) Block

func (b *Builder) Block(n int) *BasicBlock

Block returns the nth block.

func (*Builder) Blocks

func (b *Builder) Blocks() []*BasicBlock

Blocks returns all blocks.

func (*Builder) CreateAccessStackStmt

func (b *Builder) CreateAccessStackStmt(stackSize uint, pos token.Pos) *AccessStackStmt

CreateAccessStackStmt constructs a AccessStackStmt and appends it to the current block.

func (*Builder) CreateBinaryExpr

func (b *Builder) CreateBinaryExpr(op BinaryOp, lhs, rhs Value, pos token.Pos) *BinaryExpr

CreateBinaryExpr constructs a BinaryExpr and appends it to the current block.

func (*Builder) CreateBlock

func (b *Builder) CreateBlock() *BasicBlock

CreateBlock creates a block.

func (*Builder) CreateCallTerm

func (b *Builder) CreateCallTerm(callee, next *BasicBlock, pos token.Pos) *CallTerm

CreateCallTerm constructs a CallTerm and appends it to the current block.

func (*Builder) CreateExitTerm

func (b *Builder) CreateExitTerm(pos token.Pos) *ExitTerm

CreateExitTerm constructs a ExitTerm and appends it to the current block.

func (*Builder) CreateFlushStmt

func (b *Builder) CreateFlushStmt(pos token.Pos) *FlushStmt

CreateFlushStmt constructs a FlushStmt and appends it to the current block.

func (*Builder) CreateJmpCondTerm

func (b *Builder) CreateJmpCondTerm(op JmpCondOp, val Value, trueBlock, falseBlock *BasicBlock, pos token.Pos) *JmpCondTerm

CreateJmpCondTerm constructs a JmpCondTerm and appends it to the current block.

func (*Builder) CreateJmpTerm

func (b *Builder) CreateJmpTerm(op JmpOp, jumpee *BasicBlock, pos token.Pos) *JmpTerm

CreateJmpTerm constructs a JmpTerm and appends it to the current block.

func (*Builder) CreateLoadHeapExpr

func (b *Builder) CreateLoadHeapExpr(addr Value, pos token.Pos) *LoadHeapExpr

CreateLoadHeapExpr constructs a LoadHeapExpr and appends it to the current block.

func (*Builder) CreateLoadStackExpr

func (b *Builder) CreateLoadStackExpr(stackPos uint, pos token.Pos) *LoadStackExpr

CreateLoadStackExpr constructs a LoadStackExpr and appends it to the current block.

func (*Builder) CreateOffsetStackStmt

func (b *Builder) CreateOffsetStackStmt(offset int, pos token.Pos) *OffsetStackStmt

CreateOffsetStackStmt constructs a OffsetStackStmt and appends it to the current block.

func (*Builder) CreatePrintStmt

func (b *Builder) CreatePrintStmt(op PrintOp, val Value, pos token.Pos) *PrintStmt

CreatePrintStmt constructs a PrintStmt and appends it to the current block.

func (*Builder) CreateReadExpr

func (b *Builder) CreateReadExpr(op ReadOp, pos token.Pos) *ReadExpr

CreateReadExpr constructs a ReadExpr and appends it to the current block.

func (*Builder) CreateRetTerm

func (b *Builder) CreateRetTerm(pos token.Pos) *RetTerm

CreateRetTerm constructs a RetTerm and appends it to the current block.

func (*Builder) CreateStoreHeapStmt

func (b *Builder) CreateStoreHeapStmt(addr, val Value, pos token.Pos) *StoreHeapStmt

CreateStoreHeapStmt constructs a StoreHeapStmt and appends it to the current block.

func (*Builder) CreateStoreStackStmt

func (b *Builder) CreateStoreStackStmt(stackPos uint, val Value, pos token.Pos) *StoreStackStmt

CreateStoreStackStmt constructs a StoreStackStmt and appends it to the current block.

func (*Builder) CreateUnaryExpr

func (b *Builder) CreateUnaryExpr(op UnaryOp, val Value, pos token.Pos) *UnaryExpr

CreateUnaryExpr constructs a UnaryExpr and appends it to the current block.

func (*Builder) CurrentBlock

func (b *Builder) CurrentBlock() *BasicBlock

CurrentBlock returns the currently selected block.

func (*Builder) InitBlocks

func (b *Builder) InitBlocks(n int)

InitBlocks creates n empty blocks and sets the first to be the current block.

func (*Builder) Program

func (b *Builder) Program() (*Program, error)

Program completes IR construction and returns a program.

func (*Builder) SetCurrentBlock

func (b *Builder) SetCurrentBlock(block *BasicBlock)

SetCurrentBlock sets the currently selected block.

type CallTerm

type CallTerm struct {
	TermBase
	PosBase
	// contains filtered or unexported fields
}

CallTerm is terminator that pushes the current location to the call stack, then jumps to the callee.

func NewCallTerm

func NewCallTerm(callee, next *BasicBlock, pos token.Pos) *CallTerm

NewCallTerm constructs a CallTerm.

func (*CallTerm) OpString

func (*CallTerm) OpString() string

OpString pretty prints the op kind.

type ExitTerm

type ExitTerm struct {
	TermBase
	PosBase
}

ExitTerm is a terminator that exits the program.

func NewExitTerm

func NewExitTerm(pos token.Pos) *ExitTerm

NewExitTerm constructs a FlushStmt.

func (*ExitTerm) OpString

func (*ExitTerm) OpString() string

OpString pretty prints the op kind.

type FlushStmt

type FlushStmt struct {
	PosBase
}

FlushStmt is a statement that flushes stdout.

func NewFlushStmt

func NewFlushStmt(pos token.Pos) *FlushStmt

NewFlushStmt constructs a FlushStmt.

func (*FlushStmt) OpString

func (*FlushStmt) OpString() string

OpString pretty prints the op kind.

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

Formatter pretty prints Nebula IR.

func NewFormatter

func NewFormatter() *Formatter

NewFormatter constructs a Formatter.

func (*Formatter) FormatBlock

func (f *Formatter) FormatBlock(block *BasicBlock) string

FormatBlock pretty prints a BasicBlock.

func (*Formatter) FormatInst

func (f *Formatter) FormatInst(inst Inst) string

FormatInst pretty prints an Inst.

func (*Formatter) FormatProgram

func (f *Formatter) FormatProgram(p *Program) string

FormatProgram pretty prints a Program.

func (*Formatter) FormatStack

func (f *Formatter) FormatStack(s *Stack) string

FormatStack pretty prints a stack.

func (*Formatter) FormatValue

func (f *Formatter) FormatValue(val Value) string

FormatValue pretty prints a value.

type Inst

type Inst interface {
	OpString() string
	Pos() token.Pos
}

Inst is an instruction with a source location.

type IntConst

type IntConst struct {
	ValueBase
	PosBase
	// contains filtered or unexported fields
}

IntConst is a constant integer value. The contained ints can be compared for pointer equality.

func NewIntConst

func NewIntConst(val *big.Int, pos token.Pos) *IntConst

NewIntConst constructs an IntConst.

func (*IntConst) Int

func (ic *IntConst) Int() *big.Int

Int returns the constant integer.

type JmpCondOp

type JmpCondOp uint8

JmpCondOp is the kind of operator for a conditional jump terminator.

const (
	Jz JmpCondOp = iota + 1
	Jnz
	Jn
)

Conditional jump operations.

func (JmpCondOp) String

func (op JmpCondOp) String() string

type JmpCondTerm

type JmpCondTerm struct {
	Op JmpCondOp

	UserBase
	TermBase
	PosBase
	// contains filtered or unexported fields
}

JmpCondTerm is a terminator that conditionally jumps to one of two blocks.

func NewJmpCondTerm

func NewJmpCondTerm(op JmpCondOp, val Value, trueBlock, falseBlock *BasicBlock, pos token.Pos) *JmpCondTerm

NewJmpCondTerm constructs a JmpCondTerm.

func (*JmpCondTerm) OpString

func (jc *JmpCondTerm) OpString() string

OpString pretty prints the op kind.

type JmpOp

type JmpOp uint8

JmpOp is the operator kind of a jump terminator.

const (
	Jmp JmpOp = iota + 1
	Fallthrough
)

Jump operations.

func (JmpOp) String

func (op JmpOp) String() string

type JmpTerm

type JmpTerm struct {
	Op JmpOp

	TermBase
	PosBase
	// contains filtered or unexported fields
}

JmpTerm is a terminator that unconditionally jumps to a block.

func NewJmpTerm

func NewJmpTerm(op JmpOp, jumpee *BasicBlock, pos token.Pos) *JmpTerm

NewJmpTerm constructs a JmpTerm.

func (*JmpTerm) OpString

func (jmp *JmpTerm) OpString() string

OpString pretty prints the op kind.

type Label

type Label struct {
	ID   *big.Int
	Name string
}

Label is a label with an optional name.

func (*Label) String

func (l *Label) String() string

type LoadHandler

type LoadHandler func(n uint, pos token.Pos) (load Value)

LoadHandler watches loads of values under stack frame.

type LoadHeapExpr

type LoadHeapExpr struct {
	ValueBase
	UserBase
	PosBase
}

LoadHeapExpr is an expression that loads a value at an address from the heap.

func NewLoadHeapExpr

func NewLoadHeapExpr(addr Value, pos token.Pos) *LoadHeapExpr

NewLoadHeapExpr constructs a LoadHeapExpr.

func (*LoadHeapExpr) OpString

func (*LoadHeapExpr) OpString() string

OpString pretty prints the op kind.

type LoadStackExpr

type LoadStackExpr struct {
	StackPos uint
	ValueBase
	PosBase
}

LoadStackExpr is an expression that loads a value from under the current stack frame. A position of 1 is the top of the stack.

func NewLoadStackExpr

func NewLoadStackExpr(stackPos uint, pos token.Pos) *LoadStackExpr

NewLoadStackExpr constructs a LoadStackExpr.

func (*LoadStackExpr) OpString

func (*LoadStackExpr) OpString() string

OpString pretty prints the op kind.

type OffsetStackStmt

type OffsetStackStmt struct {
	Offset int
	PosBase
}

OffsetStackStmt is a statement that changes the stack length relatively.

func NewOffsetStackStmt

func NewOffsetStackStmt(offset int, pos token.Pos) *OffsetStackStmt

NewOffsetStackStmt constructs a OffsetStackStmt.

func (*OffsetStackStmt) OpString

func (*OffsetStackStmt) OpString() string

OpString pretty prints the op kind.

type PhiExpr

type PhiExpr struct {
	ValueBase
	PosBase
	// contains filtered or unexported fields
}

PhiExpr is an SSA Φ function with pairs of values and predecessor blocks.

func (*PhiExpr) AddIncoming

func (phi *PhiExpr) AddIncoming(val Value, block *BasicBlock)

AddIncoming adds a val for an incoming edge to the phi expression.

func (*PhiExpr) OpString

func (phi *PhiExpr) OpString() string

OpString pretty prints the op kind.

func (*PhiExpr) Values

func (phi *PhiExpr) Values() []PhiValue

Values returns pairs of values and predecessor blocks.

type PhiValue

type PhiValue struct {
	Value Value
	Block *BasicBlock
}

PhiValue is a value and predecessor block.

type PosBase

type PosBase struct {
	// contains filtered or unexported fields
}

PosBase stores source position information.

func (*PosBase) Pos

func (pb *PosBase) Pos() token.Pos

Pos returns the source location of this node.

type PrintOp

type PrintOp uint8

PrintOp is operator kind of a print statement.

const (
	PrintByte PrintOp = iota + 1
	PrintInt
)

Print operations.

func (PrintOp) String

func (op PrintOp) String() string

type PrintStmt

type PrintStmt struct {
	Op PrintOp
	UserBase
	PosBase
}

PrintStmt is an expression that prints a value to stdout.

func NewPrintStmt

func NewPrintStmt(op PrintOp, val Value, pos token.Pos) *PrintStmt

NewPrintStmt constructs a PrintStmt.

func (*PrintStmt) OpString

func (print *PrintStmt) OpString() string

OpString pretty prints the op kind.

type Program

type Program struct {
	Name        string
	Blocks      []*BasicBlock
	Entry       *BasicBlock
	NextBlockID int
	File        *token.File
}

Program is a set of interconnected basic blocks.

func (*Program) Digraph

func (p *Program) Digraph() digraph.Digraph

Digraph constructs a digraph representing control flow.

func (*Program) DotDigraph

func (p *Program) DotDigraph() string

DotDigraph creates a control flow graph in the Graphviz DOT format.

func (*Program) RenumberBlockIDs

func (p *Program) RenumberBlockIDs()

RenumberBlockIDs cleans up block IDs to match the block index.

func (*Program) String

func (p *Program) String() string

func (*Program) TrimUnreachable

func (p *Program) TrimUnreachable()

TrimUnreachable removes uncalled blocks.

type ReadExpr

type ReadExpr struct {
	Op ReadOp
	ValueBase
	PosBase
}

ReadExpr is an expression that reads a value from stdin.

func NewReadExpr

func NewReadExpr(op ReadOp, pos token.Pos) *ReadExpr

NewReadExpr constructs a ReadExpr.

func (*ReadExpr) OpString

func (read *ReadExpr) OpString() string

OpString pretty prints the op kind.

type ReadOp

type ReadOp uint8

ReadOp is the operator kind of a read expression.

const (
	ReadByte ReadOp = iota + 1
	ReadInt
)

Read operations.

func (ReadOp) String

func (op ReadOp) String() string

type RetTerm

type RetTerm struct {
	TermBase
	PosBase
}

RetTerm is a terminator that returns to the caller.

func NewRetTerm

func NewRetTerm(pos token.Pos) *RetTerm

NewRetTerm constructs a RetTerm.

func (*RetTerm) OpString

func (*RetTerm) OpString() string

OpString pretty prints the op kind.

type RetUnderflowError

type RetUnderflowError struct {
	Traces [][]*BasicBlock
}

RetUnderflowError is an error given when ret is executed without a caller.

func (*RetUnderflowError) Error

func (err *RetUnderflowError) Error() string

type Stack

type Stack struct {
	HandleAccess AccessHandler // Executed on access
	HandleLoad   LoadHandler   // Executed on load
	// contains filtered or unexported fields
}

Stack models a stack frame for converting Whitespace stack-oriented operations to SSA form. When accessing a position under the stack frame, the load handler is invoked to provide that value.

func (*Stack) Access

func (s *Stack) Access(n uint, pos token.Pos)

Access accesses the nth position under the stack frame.

func (*Stack) Accesses

func (s *Stack) Accesses() uint

Accesses returns the lowest position accessed under stack frame.

func (*Stack) At

func (s *Stack) At(n uint, pos token.Pos) (nth Value)

At accesses and returns the nth value on the stack.

func (*Stack) Clear

func (s *Stack) Clear()

Clear resets the stack.

func (*Stack) Copy

func (s *Stack) Copy(n uint, pos token.Pos) (nth Value)

Copy copies the nth value and pushes it to the stack.

func (*Stack) Drop

func (s *Stack) Drop(pos token.Pos)

Drop discards the top value on the stack without accessing it.

func (*Stack) DropN

func (s *Stack) DropN(n uint, pos token.Pos)

DropN discards the top n values on the stack without accessing them.

func (*Stack) Dup

func (s *Stack) Dup(pos token.Pos) (top Value)

Dup copies the top value and pushes it to the stack.

func (*Stack) Get

func (s *Stack) Get(n uint) (nth Value, ok bool)

Get returns the nth value on the stack, if it has already been accessed.

func (*Stack) Len

func (s *Stack) Len() uint

Len returns the number of values on the stack.

func (*Stack) Pop

func (s *Stack) Pop(pos token.Pos) (top Value)

Pop pops the top value from the stack and returns the removed value.

func (*Stack) Pop2

func (s *Stack) Pop2(pos token.Pos) (val1, val0 Value)

Pop2 pops the top two values form the stack and returns the removed values.

func (*Stack) Pops

func (s *Stack) Pops() uint

Pops returns the numbers of values popped under stack frame.

func (*Stack) Push

func (s *Stack) Push(val Value)

Push pushes a value to the top of the stack.

func (*Stack) Slide

func (s *Stack) Slide(n uint, pos token.Pos)

Slide discards n values on the stack, leaving the top value.

func (*Stack) String

func (s *Stack) String() string

func (*Stack) Swap

func (s *Stack) Swap(pos token.Pos)

Swap swaps the top two values on the stack.

func (*Stack) Top

func (s *Stack) Top(pos token.Pos) (top Value)

Top accesses and returns the top value on the stack.

func (*Stack) Values

func (s *Stack) Values() []Value

Values returns all values in the stack frame.

type StoreHeapStmt

type StoreHeapStmt struct {
	UserBase
	PosBase
}

StoreHeapStmt is a statement that stores a value at an address in the heap.

func NewStoreHeapStmt

func NewStoreHeapStmt(addr, val Value, pos token.Pos) *StoreHeapStmt

NewStoreHeapStmt constructs a StoreHeapStmt.

func (*StoreHeapStmt) OpString

func (*StoreHeapStmt) OpString() string

OpString pretty prints the op kind.

type StoreStackStmt

type StoreStackStmt struct {
	StackPos uint
	UserBase
	PosBase
}

StoreStackStmt is a statement that stores a value at a position in the stack.

func NewStoreStackStmt

func NewStoreStackStmt(stackPos uint, val Value, pos token.Pos) *StoreStackStmt

NewStoreStackStmt constructs a StoreStackStmt.

func (*StoreStackStmt) OpString

func (*StoreStackStmt) OpString() string

OpString pretty prints the op kind.

type TermBase

type TermBase struct {
	PosBase
	// contains filtered or unexported fields
}

TermBase implements the TermInst interface.

func (*TermBase) NSuccs

func (term *TermBase) NSuccs() int

NSuccs returns the number of successor blocks.

func (*TermBase) SetSucc

func (term *TermBase) SetSucc(n int, block *BasicBlock)

SetSucc sets the specified successor block to a given block.

func (*TermBase) Succ

func (term *TermBase) Succ(n int) *BasicBlock

Succ returns the specified successor block.

func (*TermBase) Succs

func (term *TermBase) Succs() []*BasicBlock

Succs returns the terminator's successor blocks.

type TermInst

type TermInst interface {
	Succs() []*BasicBlock
	NSuccs() int
	Succ(n int) *BasicBlock
	SetSucc(n int, block *BasicBlock)
	Inst
}

TermInst is a branching instruction that terminates a basic block.

type UnaryExpr

type UnaryExpr struct {
	Op UnaryOp
	ValueBase
	UserBase
	PosBase
}

UnaryExpr is an arithmetic expression with one operand.

func NewUnaryExpr

func NewUnaryExpr(op UnaryOp, val Value, pos token.Pos) *UnaryExpr

NewUnaryExpr constructs a UnaryExpr.

func (*UnaryExpr) OpString

func (un *UnaryExpr) OpString() string

OpString pretty prints the op kind.

type UnaryOp

type UnaryOp uint8

UnaryOp is the operator kind of a unary expression.

const (
	Neg UnaryOp = iota + 1
)

Unary operations.

func (UnaryOp) String

func (op UnaryOp) String() string

type User

type User interface {
	Operands() []*ValueUse
	NOperands() int
	Operand(n int) *ValueUse
	SetOperand(n int, val Value)
	ClearOperands()
	UsesValue(val Value) bool
	Inst
}

User is an instruction that uses values.

type UserBase

type UserBase struct {
	PosBase
	// contains filtered or unexported fields
}

UserBase implements the User interface.

func (*UserBase) ClearOperands

func (user *UserBase) ClearOperands()

ClearOperands clears all operands and removes the uses.

func (*UserBase) NOperands

func (user *UserBase) NOperands() int

NOperands returns the number of operands.

func (*UserBase) Operand

func (user *UserBase) Operand(n int) *ValueUse

Operand returns the specified operand.

func (*UserBase) Operands

func (user *UserBase) Operands() []*ValueUse

Operands returns the user's operands.

func (*UserBase) SetOperand

func (user *UserBase) SetOperand(n int, val Value)

SetOperand sets the specified operand to a value and updates the use lists.

func (*UserBase) UsesValue

func (user *UserBase) UsesValue(val Value) bool

UsesValue returns whether an operand uses the value.

type Value

type Value interface {
	Uses() []*ValueUse
	NUses() int
	AddUse(use *ValueUse)
	RemoveUse(use *ValueUse) bool
	ReplaceUsesWith(other Value)
	Pos() token.Pos
}

Value is an expression or constant with a set of uses.

type ValueBase

type ValueBase struct {
	// contains filtered or unexported fields
}

ValueBase implements the Value interface.

func (*ValueBase) AddUse

func (val *ValueBase) AddUse(use *ValueUse)

AddUse adds a use edge to the value and user.

func (*ValueBase) NUses

func (val *ValueBase) NUses() int

NUses returns the number of uses.

func (*ValueBase) RemoveUse

func (val *ValueBase) RemoveUse(use *ValueUse) bool

RemoveUse removes a use from the use list.

func (*ValueBase) ReplaceUsesWith

func (val *ValueBase) ReplaceUsesWith(other Value)

ReplaceUsesWith replaces all uses of def with newDef.

func (*ValueBase) Uses

func (val *ValueBase) Uses() []*ValueUse

Uses returns the set of instructions referring this value.

type ValueUse

type ValueUse struct {
	// contains filtered or unexported fields
}

ValueUse is an edge between a value definition and referrer.

func (*ValueUse) Def

func (use *ValueUse) Def() Value

Def returns the value definition.

func (*ValueUse) SetDef

func (use *ValueUse) SetDef(def Value)

SetDef replaces the value definition and updates uses.

func (*ValueUse) User

func (use *ValueUse) User() (User, int)

User returns the user and user's operand.

Directories

Path Synopsis
Package codegen lowers Nebula IR to LLVM IR.
Package codegen lowers Nebula IR to LLVM IR.
Package optimize analyzes and optimizes Nebula IR.
Package optimize analyzes and optimizes Nebula IR.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL