ir

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IROpToBytecode

func IROpToBytecode(op Op) int32

IROpToBytecode returns the bytecode OP_* constant corresponding to the given IR op. Returns vm.OP_NOOP for ops without a direct bytecode counterpart.

func IsCheapMaterializeOp

func IsCheapMaterializeOp(op Op) bool

IsCheapMaterializeOp reports whether op is one of the cheap-to- re-emit loads (Const, LoadArg, LoadVar, LoadClosed). Used by the lowerer's body-emit policy and use-site materialization fallback.

Types

type Op

type Op uint16

Op is the kind of an IR node.

const (
	OpInvalid    Op = iota
	OpConst         // .Aux = vm.Value (the constant; lowered as OP_LOAD_CONST with interned index)
	OpLoadArg       // .Aux = int (arg index)
	OpLoadVar       // .Aux = *vm.Var; var roots are mutable
	OpLoadClosed    // .Aux = int (closed-over index)
	OpBlockArg      // block parameter
	OpSetVar        // .Refs[0] = var (Const aux=*vm.Var), .Refs[1] = value; pushes var back
	OpCall          // .Refs[0] = fn, .Refs[1:] = args; .Aux = arity int
	OpTailCall      // tail call ends a block
	OpAdd
	OpSub
	OpMul
	OpLt
	OpLte
	OpGt
	OpGte
	OpEq
	OpInc
	OpDec
	OpPop         // discard top stack value; no result (OP_POP)
	OpReturn      // .Refs[0] = value
	OpBranch      // unconditional; .Aux = *BranchTarget
	OpBranchIf    // .Refs[0] = cond; .Aux = struct{True,False *BranchTarget}
	OpMakeClosure // .Refs[0] = *Func value (the func to wrap as a closure)
	OpPushClosed  // .Refs[0] = closure, .Refs[1] = value to attach
)

func OpByKeyword

func OpByKeyword(name string) (Op, bool)

OpByKeyword looks up an Op by its keyword name. The match is case-insensitive AND dash-insensitive, so "load-arg", "loadarg", and "LoadArg" all match opTable entry "LoadArg".

Used by Lisp-side IR construction primitives, where ops are passed as kebab-case keywords (the Clojure idiom).

func (Op) IsPure

func (op Op) IsPure() bool

IsPure reports whether op has no observable side effects.

func (Op) IsTerminator

func (op Op) IsTerminator() bool

IsTerminator reports whether op ends a basic block.

func (Op) StackOut

func (op Op) StackOut() int

StackOut returns the number of values op pushes (0 or 1).

func (Op) String

func (op Op) String() string

String returns the op's display name (or "Op?" for an unknown op).

Jump to

Keyboard shortcuts

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