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.
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 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 `/`) 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} 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) )
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).
func (Op) IsTerminator ¶
IsTerminator reports whether op ends a basic block.