Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IROpToBytecode ¶
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 ¶
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.
func OpKeywords ¶ added in v1.13.0
func OpKeywords() []string
OpKeywords returns every catalogued op as its kebab-case keyword name, in Op order.
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. infer? stays false: the :call arm (call-dtype/call-core-type) is typeinfer-coupled, not yet reified OpTailCall // tail call ends a block. NOT in typeinfer's terminator-ops set (infers :unknown via default), so infer? is false OpAdd OpSub OpMul OpBitAnd // clojure.core/bit-and — integer bitwise and OpBitOr // clojure.core/bit-or — integer bitwise or OpBitXor // clojure.core/bit-xor — integer bitwise xor OpBitAndNot // clojure.core/bit-and-not — integer bit clear (&^) OpBitShiftLeft // clojure.core/bit-shift-left — integer left shift OpBitShiftRight // clojure.core/bit-shift-right — integer arithmetic right shift OpUnsignedBitShiftRight // clojure.core/unsigned-bit-shift-right — integer logical right shift OpQuot // clojure.core/quot — integer quotient truncated toward zero. int/int lowers to native Go `/` (which truncates identically); any float/ratio/boxed operand lowers via rt.QuotValue (native float `/` does NOT truncate) OpDiv // clojure.core// — true division. float/float lowers to native Go `/`; any other operand mix (int/int -> Ratio, mixed -> Float) lowers via rt.DivValue. Distinguished from Quot by op-kw in lower-go (both render Go `/`) OpUncheckedAdd // clojure.core/unchecked-add — Int+Int wrapping at the platform width; native Go + for int/int, rt.UncheckedAddValue otherwise OpUncheckedSub // clojure.core/unchecked-subtract — Int-Int wrapping at the platform width; native Go - for int/int, rt.UncheckedSubValue otherwise OpUncheckedMul // clojure.core/unchecked-multiply — Int*Int wrapping at the platform width; native Go * for int/int, rt.UncheckedMulValue otherwise OpLt OpLte OpGt OpGte OpEq OpInc OpDec OpBitNot // clojure.core/bit-not — integer bitwise complement 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 OpTry // .Refs[0] = body closure; then optional handler closure (binds the caught value), then optional finally closure; .Aux = {:has-handler bool :has-finally bool}. lower? -> TryOp delegates to try-assign-stmts (registered by ir.lower-go) OpDot // .Refs[0] = obj; .Aux = field symbol; Go struct field selector obj.field (gogen_ir path only) OpDef // .Refs[0] = var (Const aux=*vm.Var), optional .Refs[1] = value; interns + returns the var (2-ref also sets root) OpRecurFn // function-level recur back-edge; .Refs = replacement args (no callee), .Aux = argc int )
func OpByKeyword ¶
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).
The common case — a canonical kebab-case keyword, the exact form ir.build emits — hits the generated opByKeywordExact string switch (op_generated.go): sub-linear and allocation-free. Only a non-canonical spelling falls through to the dash/case-insensitive scan below, which preserves the historical lenient semantics.
func (Op) InferFacet ¶ added in v1.13.0
InferFacet reports whether op's typeinfer facet is reified on an ir.ops op-type.
func (Op) IsTerminator ¶
IsTerminator reports whether op ends a basic block.
func (Op) LocalCarrying ¶ added in v1.13.0
LocalCarrying reports whether lowering materialises op's result into a Go local.
func (Op) LowerFacet ¶ added in v1.13.0
LowerFacet reports whether op's lower-go facet is reified on an ir.ops op-type.