Skip to main content

Inst

Enum Inst 

Source
pub enum Inst {
Show 200 variants Nop {}, Mov { dst: Reg, src: Reg, }, LoadConst { dst: Reg, k: ConstId, }, DLoadConst { dst: Reg, k: ConstId, }, LoadInt { dst: Reg, val: i32, ty: IntTy, }, DLoadInt { dst: Reg, val: i32, }, LoadBool { dst: Reg, val: bool, }, LoadNil { dst: Reg, }, LoadImport { dst: Reg, import: ImportId, }, GetGlobal { dst: Reg, global: GlobalId, }, SetGlobal { global: GlobalId, src: Reg, }, IAdd { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, ISub { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IMul { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IDiv { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IRem { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IFloorDiv { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IFloorMod { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IAnd { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IOr { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IXor { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IShl { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IShr { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IMin { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IMax { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, INeg { dst: Reg, src: Reg, op: IntOp, }, IBitNot { dst: Reg, src: Reg, op: IntOp, }, IAbs { dst: Reg, src: Reg, op: IntOp, }, IPow { dst: Reg, lhs: Reg, rhs: Reg, op: IntOp, }, IEq { dst: Reg, lhs: Reg, rhs: Reg, ty: IntTy, }, INe { dst: Reg, lhs: Reg, rhs: Reg, ty: IntTy, }, ILt { dst: Reg, lhs: Reg, rhs: Reg, ty: IntTy, }, ILe { dst: Reg, lhs: Reg, rhs: Reg, ty: IntTy, }, IGt { dst: Reg, lhs: Reg, rhs: Reg, ty: IntTy, }, IGe { dst: Reg, lhs: Reg, rhs: Reg, ty: IntTy, }, FAdd { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FSub { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FMul { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FDiv { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FRem { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FIeeeRem { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FMin { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FMax { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FFma { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FNeg { dst: Reg, src: Reg, ty: FloatTy, }, FAbs { dst: Reg, src: Reg, ty: FloatTy, }, FSqrt { dst: Reg, src: Reg, ty: FloatTy, }, FFloor { dst: Reg, src: Reg, ty: FloatTy, }, FCeil { dst: Reg, src: Reg, ty: FloatTy, }, FTrunc { dst: Reg, src: Reg, ty: FloatTy, }, FRound { dst: Reg, src: Reg, ty: FloatTy, }, FRoundEven { dst: Reg, src: Reg, ty: FloatTy, }, FEq { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FNe { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FLt { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FLe { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FGt { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FGe { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FPow { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, FTotalCmp { dst: Reg, lhs: Reg, rhs: Reg, ty: FloatTy, }, BNot { dst: Reg, src: Reg, }, BAnd { dst: Reg, lhs: Reg, rhs: Reg, }, BOr { dst: Reg, lhs: Reg, rhs: Reg, }, BXor { dst: Reg, lhs: Reg, rhs: Reg, }, CEq { dst: Reg, lhs: Reg, rhs: Reg, }, CNe { dst: Reg, lhs: Reg, rhs: Reg, }, CLt { dst: Reg, lhs: Reg, rhs: Reg, }, CLe { dst: Reg, lhs: Reg, rhs: Reg, }, CGt { dst: Reg, lhs: Reg, rhs: Reg, }, CGe { dst: Reg, lhs: Reg, rhs: Reg, }, RefEq { dst: Reg, lhs: Reg, rhs: Reg, }, IntCast { dst: Reg, src: Reg, conv: IntConv, }, Zext { dst: Reg, src: Reg, pair: IntPair, }, Sext { dst: Reg, src: Reg, pair: IntPair, }, Trunc { dst: Reg, src: Reg, pair: IntPair, }, IntToF32 { dst: Reg, src: Reg, ty: IntTy, }, IntToF64 { dst: Reg, src: Reg, ty: IntTy, }, F32ToInt { dst: Reg, src: Reg, conv: FloatConv, }, F64ToInt { dst: Reg, src: Reg, conv: FloatConv, }, F32ToF64 { dst: Reg, src: Reg, }, F64ToF32 { dst: Reg, src: Reg, }, FloatToBits { dst: Reg, src: Reg, ty: IntTy, }, BitsToFloat { dst: Reg, src: Reg, ty: IntTy, }, CharFromU32 { dst: Reg, src: Reg, }, CharToU32 { dst: Reg, src: Reg, }, BoolToInt { dst: Reg, src: Reg, ty: IntTy, }, DAdd { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DSub { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DMul { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DDiv { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DRem { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DFloorDiv { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DFloorMod { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DAnd { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DOr { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DXor { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DShl { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DShr { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DNeg { dst: Reg, src: Reg, pol: Policy, }, DBitNot { dst: Reg, src: Reg, pol: Policy, }, DEq { dst: Reg, lhs: Reg, rhs: Reg, }, DNe { dst: Reg, lhs: Reg, rhs: Reg, }, DLt { dst: Reg, lhs: Reg, rhs: Reg, }, DLe { dst: Reg, lhs: Reg, rhs: Reg, }, DGt { dst: Reg, lhs: Reg, rhs: Reg, }, DGe { dst: Reg, lhs: Reg, rhs: Reg, }, DTruthy { dst: Reg, src: Reg, }, DConcat { dst: Reg, lhs: Reg, rhs: Reg, }, ToDyn { dst: Reg, src: Reg, from: Prim, }, FromDyn { dst: Reg, src: Reg, to: Prim, }, TypeOf { dst: Reg, src: Reg, }, IsKind { dst: Reg, src: Reg, kind: Kind, }, IsType { dst: Reg, src: Reg, ty: TypeRef, }, Cast { dst: Reg, src: Reg, ty: TypeRef, }, DGetIndex { dst: Reg, obj: Reg, key: Reg, }, DSetIndex { obj: Reg, key: Reg, src: Reg, }, GetProp { dst: Reg, obj: Reg, name: NameRef, }, SetProp { obj: Reg, name: NameRef, src: Reg, }, HasProp { dst: Reg, obj: Reg, name: NameRef, }, DCall { dst: Reg, callee: Reg, argc: u8, }, DIterNew { dst: Reg, src: Reg, }, DLen { dst: Reg, src: Reg, }, DNot { dst: Reg, src: Reg, }, DPow { dst: Reg, lhs: Reg, rhs: Reg, pol: Policy, }, DAbs { dst: Reg, src: Reg, pol: Policy, }, DSepIndex { dst: Reg, obj: Reg, key: Reg, }, DSepProp { dst: Reg, obj: Reg, name: NameRef, }, DCallShape { dst: Reg, callee: Reg, shape: ShapeId, }, DParamRef { dst: Reg, callee: Reg, pos: Reg, }, DParamRefNamed { dst: Reg, callee: Reg, name: NameRef, }, ErrPayload { dst: Reg, src: Reg, }, Jmp { target: Target, }, JmpIf { cond: Reg, target: Target, }, JmpIfNot { cond: Reg, target: Target, }, Switch { src: Reg, table: TableId, ty: IntTy, }, Call { dst: Reg, func: FuncId, argc: u8, }, CallIndirect { dst: Reg, callee: Reg, argc: u8, }, CallImport { dst: Reg, import: ImportId, argc: u8, }, TailCall { func: FuncId, args: Reg, argc: u8, }, TailCallIndirect { callee: Reg, args: Reg, argc: u8, }, Ret { src: Reg, }, RetVoid {}, Throw { src: Reg, }, ErrCode { dst: Reg, src: Reg, }, Safepoint {}, Unreachable {}, Raise { src: Reg, kind: ErrorKind, }, MakeClosure { dst: Reg, func: FuncId, }, GetUpval { dst: Reg, idx: UpvalIdx, }, NewCell { dst: Reg, src: Reg, ty: TypeRef, }, CellGet { dst: Reg, cell: Reg, }, CellSet { cell: Reg, src: Reg, }, NewRef { dst: Reg, src: Reg, }, DRefIndex { dst: Reg, obj: Reg, key: Reg, }, DRefProp { dst: Reg, obj: Reg, name: NameRef, }, DBindIndex { obj: Reg, key: Reg, src: Reg, }, DBindProp { obj: Reg, name: NameRef, src: Reg, }, DUnrefIndex { obj: Reg, key: Reg, }, DUnrefProp { obj: Reg, name: NameRef, }, NewStruct { dst: Reg, ty: TypeRef, }, GetField { dst: Reg, obj: Reg, field: FieldIdx, }, SetField { obj: Reg, field: FieldIdx, src: Reg, }, NewArray { dst: Reg, len: Reg, ty: TypeRef, }, ArrayLen { dst: Reg, arr: Reg, }, ArrayGet { dst: Reg, arr: Reg, idx: Reg, }, ArraySet { arr: Reg, idx: Reg, src: Reg, }, ArrayPush { arr: Reg, src: Reg, }, ArrayPop { dst: Reg, arr: Reg, }, NewMap { dst: Reg, ty: TypeRef, }, MapLen { dst: Reg, map: Reg, }, MapGet { dst: Reg, map: Reg, key: Reg, }, MapFind { dst: Reg, map: Reg, key: Reg, }, MapHas { dst: Reg, map: Reg, key: Reg, }, MapSet { map: Reg, key: Reg, src: Reg, }, MapDel { map: Reg, key: Reg, }, MapPush { map: Reg, src: Reg, }, IterNew { dst: Reg, src: Reg, }, IterNext { has: Reg, iter: Reg, val: Reg, }, IterKey { dst: Reg, iter: Reg, }, Dup { dst: Reg, src: Reg, }, StrLen { dst: Reg, s: Reg, }, StrConcat { dst: Reg, lhs: Reg, rhs: Reg, }, StrConcatN { dst: Reg, first: Reg, count: u8, }, StrEq { dst: Reg, lhs: Reg, rhs: Reg, }, StrCmp { dst: Reg, lhs: Reg, rhs: Reg, }, StrSlice { dst: Reg, s: Reg, range: Reg, utf8: bool, }, StrByte { dst: Reg, s: Reg, idx: Reg, }, CoroNew { dst: Reg, func: FuncId, argc: u8, }, CoroNewIndirect { dst: Reg, callee: Reg, argc: u8, }, Yield { dst: Reg, src: Reg, }, Await { dst: Reg, src: Reg, }, Resume { dst: Reg, coro: Reg, src: Reg, }, ResumeThrow { dst: Reg, coro: Reg, src: Reg, }, CoroStatus { dst: Reg, coro: Reg, }, CoroCurrent { dst: Reg, }, YieldKv { dst: Reg, key: Reg, src: Reg, }, CoroClose { dst: Reg, coro: Reg, src: Reg, }, CoroKey { dst: Reg, coro: Reg, }, CoroResult { dst: Reg, coro: Reg, }, Spawn { dst: Reg, callee: Reg, argc: u8, },
}
Expand description

One LSB instruction, decoded.

Every variant is eight bytes and Copy. Field order is display order; Opcode::fields gives each field’s slot in the encoded word. The normative semantics of every instruction, every operand type rule, and every error it can raise are in specs/LSB.md; each variant’s documentation summarizes them.

Window operands. Instructions that need more registers than eight bytes hold read them from consecutive registers: a call’s arguments are dst+1 ..= dst+argc, a closure’s captures follow its destination, str_slice reads its end index from range+1.

The enum is deliberately exhaustive: every execution tier must implement every instruction, and a new one is a format change.

§Examples

use bytecode_lang::{Inst, IntOp, IntTy, Opcode, Reg};

let add = Inst::IAdd { op: IntOp::new(IntTy::I64), dst: Reg(2), lhs: Reg(0), rhs: Reg(1) };
assert_eq!(add.opcode(), Opcode::IAdd);
assert_eq!(add.to_string(), "iadd.i64 r2, r0, r1");
assert_eq!(Inst::from_bytes(add.to_bytes()), Ok(add));
assert_eq!(core::mem::size_of::<Inst>(), 8);

Variants§

§

Nop

Does nothing.

§

Mov

dst = src. Both registers have the same declared type; the 64-bit slot is copied as is.

Fields

§dst: Reg

Destination register.

§src: Reg

Source register.

§

LoadConst

dst = constants[k] in the destination’s typed representation (an int constant into an integer register it fits, a str or bytes constant into a str register, an aggregate into a matching ref).

Fields

§dst: Reg

Destination register.

§k: ConstId

The constant.

§

DLoadConst

dst = constants[k] boxed as a dyn value (integers become dynamic ints and must fit i64; floats become dynamic floats; aggregates become dynamic arrays and maps).

Fields

§dst: Reg

Destination dyn register.

§k: ConstId

The constant.

§

LoadInt

dst = val as an integer of type ty; the immediate is sign-extended and must be representable in ty.

Fields

§dst: Reg

Destination integer register.

§val: i32

The immediate.

§ty: IntTy

The destination’s integer type.

§

DLoadInt

dst = val as a dynamic integer.

Fields

§dst: Reg

Destination dyn register.

§val: i32

The immediate.

§

LoadBool

dst = val.

Fields

§dst: Reg

Destination bool register.

§val: bool

The immediate.

§

LoadNil

dst = nil: the dynamic nil, or the null str/ref.

Fields

§dst: Reg

Destination dyn, str, or ref register.

§

LoadImport

dst = a callable reference to a host function: a first-class value every dynamic call form accepts, bound by the import’s parameter list if it has one.

Fields

§dst: Reg

Destination ref (function type) or dyn register.

§import: ImportId

The import.

§

GetGlobal

dst = globals[global].

Fields

§dst: Reg

Destination register of the global’s type.

§global: GlobalId

The global.

§

SetGlobal

globals[global] = src; the global must be mutable.

Fields

§global: GlobalId

The global.

§src: Reg

Source register of the global’s type.

§

IAdd

dst = lhs + rhs; overflow per op.policy().overflow().

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§op: IntOp

Operand type and policy.

§

ISub

dst = lhs - rhs; overflow per policy.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§op: IntOp

Operand type and policy.

§

IMul

dst = lhs * rhs; overflow per policy.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§op: IntOp

Operand type and policy.

§

IDiv

dst = lhs / rhs, truncating toward zero; rhs == 0 per div_zero, signed MIN / -1 per overflow (wrap gives MIN).

Fields

§dst: Reg

Destination register.

§lhs: Reg

Dividend.

§rhs: Reg

Divisor.

§op: IntOp

Operand type and policy.

§

IRem

dst = lhs rem rhs, the sign following the dividend; rhs == 0 per div_zero; signed MIN rem -1 is 0, never an error.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Dividend.

§rhs: Reg

Divisor.

§op: IntOp

Operand type and policy.

§

IFloorDiv

dst = floor(lhs / rhs) (Python //); zero and overflow rules as idiv.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Dividend.

§rhs: Reg

Divisor.

§op: IntOp

Operand type and policy.

§

IFloorMod

dst = lhs - rhs * floor_div(lhs, rhs), the sign following the divisor; rhs == 0 per div_zero; signed MIN floor_mod -1 is 0.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Dividend.

§rhs: Reg

Divisor.

§op: IntOp

Operand type and policy.

§

IAnd

dst = lhs & rhs.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§op: IntOp

Operand type and policy.

§

IOr

dst = lhs | rhs.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§op: IntOp

Operand type and policy.

§

IXor

dst = lhs ^ rhs.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§op: IntOp

Operand type and policy.

§

IShl

dst = lhs << rhs; bits shifted out are discarded; an amount at least the width (or negative, for a signed type) per shift.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Value to shift.

§rhs: Reg

Shift amount, of the same type.

§op: IntOp

Operand type and policy.

§

IShr

dst = lhs >> rhs, arithmetic for signed types and logical for unsigned; amount rule as ishl.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Value to shift.

§rhs: Reg

Shift amount, of the same type.

§op: IntOp

Operand type and policy.

§

IMin

dst = min(lhs, rhs).

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§op: IntOp

Operand type and policy.

§

IMax

dst = max(lhs, rhs).

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§op: IntOp

Operand type and policy.

§

INeg

dst = 0 - src; neg(MIN) per overflow.

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§op: IntOp

Operand type and policy.

§

IBitNot

dst = !src (bitwise complement; HIR’s bit_not on integers).

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§op: IntOp

Operand type and policy.

§

IAbs

dst = |src|; abs(MIN) per overflow.

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§op: IntOp

Operand type and policy.

§

IPow

dst = lhs ** rhs (OPS v2 pow): the exact power by repeated squaring, 0 ** 0 = 1; a result that does not fit per overflow (wrap keeps the low bits); a negative exponent of a signed type raises NegativeExponent (E0006) under every policy (promote is never valid here). The exponent has the operand type.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Base.

§rhs: Reg

Exponent.

§op: IntOp

Operand type and policy.

§

IEq

dst = lhs == rhs (bool).

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: IntTy

Operand type (signedness decides ordering).

§

INe

dst = lhs != rhs (bool).

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: IntTy

Operand type.

§

ILt

dst = lhs < rhs (bool), signed or unsigned per ty.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: IntTy

Operand type.

§

ILe

dst = lhs <= rhs (bool).

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: IntTy

Operand type.

§

IGt

dst = lhs > rhs (bool).

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: IntTy

Operand type.

§

IGe

dst = lhs >= rhs (bool).

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: IntTy

Operand type.

§

FAdd

dst = lhs + rhs (round to nearest, ties to even).

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

FSub

dst = lhs - rhs.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

FMul

dst = lhs * rhs.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

FDiv

dst = lhs / rhs; division by zero gives ±inf or NaN.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Dividend.

§rhs: Reg

Divisor.

§ty: FloatTy

Operand type.

§

FRem

dst = fmod(lhs, rhs): the truncated remainder, sign of the dividend.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Dividend.

§rhs: Reg

Divisor.

§ty: FloatTy

Operand type.

§

FIeeeRem

dst = remainder(lhs, rhs): IEEE 754 remainder (nearest quotient).

Fields

§dst: Reg

Destination register.

§lhs: Reg

Dividend.

§rhs: Reg

Divisor.

§ty: FloatTy

Operand type.

§

FMin

dst = min(lhs, rhs); NaN if either is NaN; min(-0, +0) = -0.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

FMax

dst = max(lhs, rhs); NaN if either is NaN; max(-0, +0) = +0.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

FFma

dst = fma(lhs, rhs, dst): fused multiply-add, correctly rounded. dst is both the addend and the result.

Fields

§dst: Reg

Addend in, result out.

§lhs: Reg

First factor.

§rhs: Reg

Second factor.

§ty: FloatTy

Operand type.

§

FNeg

dst = -src (sign flip; payload preserved).

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§ty: FloatTy

Operand type.

§

FAbs

dst = |src| (sign clear; payload preserved).

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§ty: FloatTy

Operand type.

§

FSqrt

dst = sqrt(src), correctly rounded.

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§ty: FloatTy

Operand type.

§

FFloor

dst = floor(src).

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§ty: FloatTy

Operand type.

§

FCeil

dst = ceil(src).

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§ty: FloatTy

Operand type.

§

FTrunc

dst = trunc(src) (toward zero).

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§ty: FloatTy

Operand type.

§

FRound

dst = round(src), ties away from zero.

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§ty: FloatTy

Operand type.

§

FRoundEven

dst = round(src), ties to even.

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§ty: FloatTy

Operand type.

§

FEq

dst = lhs == rhs (bool); false if either is NaN.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

FNe

dst = lhs != rhs (bool); true if either is NaN.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

FLt

dst = lhs < rhs (bool); false if either is NaN.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

FLe

dst = lhs <= rhs (bool); false if either is NaN.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

FGt

dst = lhs > rhs (bool); false if either is NaN.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

FGe

dst = lhs >= rhs (bool); false if either is NaN.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

FPow

dst = pow(lhs, rhs) (OPS v2 float pow): C99 Annex F special cases, finite results by the family’s shared ls_pow routine so every tier is bit-identical; f32 computes ls_pow on the operands widened to f64 and rounds once. Never an error.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Base.

§rhs: Reg

Exponent.

§ty: FloatTy

Operand type.

§

FTotalCmp

dst = totalOrder(lhs, rhs) as an i8 of -1, 0, or 1 (IEEE 754 total order: -NaN < -inf < ... < -0 < +0 < ... < +inf < +NaN).

Fields

§dst: Reg

Destination i8 register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§ty: FloatTy

Operand type.

§

BNot

dst = !src (logical).

Fields

§dst: Reg

Destination bool register.

§src: Reg

Operand.

§

BAnd

dst = lhs & rhs (both evaluated; short-circuit is control flow).

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

BOr

dst = lhs | rhs.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

BXor

dst = lhs ^ rhs (also boolean inequality).

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

CEq

dst = lhs == rhs on char scalar values.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

CNe

dst = lhs != rhs on char scalar values.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

CLt

dst = lhs < rhs on char scalar values.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

CLe

dst = lhs <= rhs on char scalar values.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

CGt

dst = lhs > rhs on char scalar values.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

CGe

dst = lhs >= rhs on char scalar values.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

RefEq

dst = lhs and rhs are the same object (or both nil). Operands are str or ref; string contents are not compared.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

IntCast

dst = src converted between integer types: exact if it fits, else per the conversion’s overflow (wrap truncates or sign-extends).

Fields

§dst: Reg

Destination register of type conv.to().

§src: Reg

Source register of type conv.from().

§conv: IntConv

Source type, destination type, overflow policy.

§

Zext

Zero-extends a narrower integer to a wider one; never an error.

Fields

§dst: Reg

Destination register.

§src: Reg

Source register.

§pair: IntPair

Source and destination types (destination at least as wide).

§

Sext

Sign-extends a narrower integer to a wider one; never an error.

Fields

§dst: Reg

Destination register.

§src: Reg

Source register.

§pair: IntPair

Source and destination types (destination at least as wide).

§

Trunc

Keeps the low bits of a wider integer; never an error.

Fields

§dst: Reg

Destination register.

§src: Reg

Source register.

§pair: IntPair

Source and destination types (destination at most as wide).

§

IntToF32

dst = src as f32, rounded to nearest, ties to even.

Fields

§dst: Reg

Destination f32 register.

§src: Reg

Source integer register.

§ty: IntTy

The source’s integer type.

§

IntToF64

dst = src as f64, rounded to nearest, ties to even.

Fields

§dst: Reg

Destination f64 register.

§src: Reg

Source integer register.

§ty: IntTy

The source’s integer type.

§

F32ToInt

dst = src truncated toward zero to the integer type conv.ty(); NaN or out of range per conv.float_to_int().

Fields

§dst: Reg

Destination integer register.

§src: Reg

Source f32 register.

§conv: FloatConv

Destination type and policy.

§

F64ToInt

dst = src truncated toward zero to the integer type conv.ty(); NaN or out of range per conv.float_to_int().

Fields

§dst: Reg

Destination integer register.

§src: Reg

Source f64 register.

§conv: FloatConv

Destination type and policy.

§

F32ToF64

dst = src widened to f64 (exact).

Fields

§dst: Reg

Destination f64 register.

§src: Reg

Source f32 register.

§

F64ToF32

dst = src narrowed to f32, rounded to nearest, ties to even.

Fields

§dst: Reg

Destination f32 register.

§src: Reg

Source f64 register.

§

FloatToBits

dst = the IEEE bits of src as an integer of the same width (ty is a 32- or 64-bit integer type).

Fields

§dst: Reg

Destination integer register.

§src: Reg

Source float register.

§ty: IntTy

The destination’s integer type.

§

BitsToFloat

dst = the float whose IEEE bits are src (ty is a 32- or 64-bit integer type; the float has the same width).

Fields

§dst: Reg

Destination float register.

§src: Reg

Source integer register.

§ty: IntTy

The source’s integer type.

§

CharFromU32

dst = char(src); InvalidChar (E0005) if src (a u32) is not a Unicode scalar value.

Fields

§dst: Reg

Destination char register.

§src: Reg

Source u32 register.

§

CharToU32

dst = src as its u32 scalar value. Total; an LSB addition to OPS.

Fields

§dst: Reg

Destination u32 register.

§src: Reg

Source char register.

§

BoolToInt

dst = 1 if src is true, else 0.

Fields

§dst: Reg

Destination integer register.

§src: Reg

Source bool register.

§ty: IntTy

The destination’s integer type.

§

DAdd

Dynamic +.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§pol: Policy

Policy for the integer path.

§

DSub

Dynamic -.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§pol: Policy

Policy for the integer path.

§

DMul

Dynamic *.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§pol: Policy

Policy for the integer path.

§

DDiv

Dynamic division: truncating for two ints, IEEE otherwise.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Dividend.

§rhs: Reg

Divisor.

§pol: Policy

Policy for the integer path.

§

DRem

Dynamic remainder: irem for two ints, frem otherwise.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Dividend.

§rhs: Reg

Divisor.

§pol: Policy

Policy for the integer path.

§

DFloorDiv

Dynamic floor division (Python //).

Fields

§dst: Reg

Destination register.

§lhs: Reg

Dividend.

§rhs: Reg

Divisor.

§pol: Policy

Policy for the integer path.

§

DFloorMod

Dynamic floor modulo (Python %).

Fields

§dst: Reg

Destination register.

§lhs: Reg

Dividend.

§rhs: Reg

Divisor.

§pol: Policy

Policy for the integer path.

§

DAnd

Dynamic bitwise and (ints only, else hook).

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§pol: Policy

Policy for the integer path.

§

DOr

Dynamic bitwise or.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§pol: Policy

Policy for the integer path.

§

DXor

Dynamic bitwise xor.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§pol: Policy

Policy for the integer path.

§

DShl

Dynamic shift left (64-bit; amount rule per shift, saturate for PHP).

Fields

§dst: Reg

Destination register.

§lhs: Reg

Value to shift.

§rhs: Reg

Shift amount.

§pol: Policy

Policy for the integer path.

§

DShr

Dynamic arithmetic shift right.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Value to shift.

§rhs: Reg

Shift amount.

§pol: Policy

Policy for the integer path.

§

DNeg

Dynamic negation.

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§pol: Policy

Policy for the integer path.

§

DBitNot

Dynamic bitwise complement (PHP/Python ~; HIR’s bit_not): ints only, else the bit_not hook.

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§pol: Policy

Policy for the integer path.

§

DEq

Dynamic equality into a bool register (numbers exactly, strings by content, other kinds through the eq hook or by identity).

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

DNe

Dynamic inequality: the negation of deq.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

DLt

Dynamic < into a bool register (numbers, strings bytewise, chars; else the lt hook or TypeError).

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

DLe

Dynamic <=.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

DGt

Dynamic > (lt with the operands swapped).

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

DGe

Dynamic >= (le with the operands swapped).

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

DTruthy

dst = the truthiness of src as a bool: nil is false, bools are themselves, numbers are true unless zero; other kinds go to the truthy hook, or are true unless an empty string, array, or map.

Fields

§dst: Reg

Destination bool register.

§src: Reg

Operand.

§

DConcat

Dynamic string concatenation (two strings, else the concat hook).

Fields

§dst: Reg

Destination register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

ToDyn

dst = src boxed into a dyn (from names src’s static type; u64 above i64::MAX raises ArithOverflow; str/ref are a no-op).

Fields

§dst: Reg

Destination dyn register.

§src: Reg

Source register.

§from: Prim

The source’s static type.

§

FromDyn

dst = src unboxed to the static type to; TypeError if the kind does not match, ArithOverflow if an int does not fit. (ref targets use cast.)

Fields

§dst: Reg

Destination register.

§src: Reg

Source dyn register.

§to: Prim

The destination’s static type.

§

TypeOf

dst = the Kind code of src, as a u8.

Fields

§dst: Reg

Destination u8 register.

§src: Reg

Source dyn, str, or ref register.

§

IsKind

dst = whether src is of kind kind.

Fields

§dst: Reg

Destination bool register.

§src: Reg

Source dyn, str, or ref register.

§kind: Kind

The kind to test.

§

IsType

dst = whether src is a non-nil instance of struct type ty or of a type that has it as an ancestor.

Fields

§dst: Reg

Destination bool register.

§src: Reg

Source dyn or ref register.

§ty: TypeRef

The struct type.

§

Cast

dst = src as ref ty; TypeError if src is not nil and not an instance of ty (or a descendant).

Fields

§dst: Reg

Destination ref ty register.

§src: Reg

Source dyn or ref register.

§ty: TypeRef

The target type.

§

DGetIndex

Dynamic indexing dst = obj[key]: arrays by int, maps by key, strings by int (the byte); misses and other kinds go to the get_index hook. A reference slot reads as its reference’s value.

Fields

§dst: Reg

Destination dyn register.

§obj: Reg

The indexed value.

§key: Reg

The key.

§

DSetIndex

Dynamic indexed store obj[key] = src; a reference slot is written through, and a reference src stores its value.

Fields

§obj: Reg

The indexed value.

§key: Reg

The key.

§src: Reg

The value to store.

§

GetProp

Dynamic property read dst = obj.name: a struct field or method by name, a map entry with a string key, else the get_prop hook.

Fields

§dst: Reg

Destination dyn register.

§obj: Reg

The object.

§name: NameRef

The property name.

§

SetProp

Dynamic property write obj.name = src.

Fields

§obj: Reg

The object.

§name: NameRef

The property name.

§src: Reg

The value to store.

§

HasProp

dst = whether obj has property name.

Fields

§dst: Reg

Destination bool register.

§obj: Reg

The object.

§name: NameRef

The property name.

§

DCall

Dynamic call: dst = callee(dst+1, ..., dst+argc) with positional dyn arguments, bound to the callee’s parameter list (exactly dcall_shape with an all-positional shape): ArgumentError (E0114) when they do not bind, TypeError when one does not convert to its parameter’s type; non-callables go to the call hook.

Fields

§dst: Reg

Result register (dyn); arguments follow it.

§callee: Reg

The callee.

§argc: u8

The number of arguments.

§

DIterNew

dst = a dynamic iterator over src (array or map; else the iter hook).

Fields

§dst: Reg

Destination dyn register.

§src: Reg

The value to iterate.

§

DLen

dst = the length of src as an i64 (string bytes, array or map entries; else the len hook).

Fields

§dst: Reg

Destination i64 register.

§src: Reg

The value.

§

DNot

Dynamic logical not (PHP !, Python not; HIR’s not): dst = !truthy(src) as a bool, with exactly the truthiness rules of dtruthy (the truthy hook included). dbit_not is the bitwise ~.

Fields

§dst: Reg

Destination bool register.

§src: Reg

Operand.

§

DPow

Dynamic ** (OPS v2 pow): two ints → integer pow at i64 under pol (promote gives the nearest f64 of the exact power, and the f64 power for a negative exponent; other policies raise NegativeExponent for one); numbers with a float → fpow in f64; else the pow hook, else TypeError.

Fields

§dst: Reg

Destination register.

§lhs: Reg

Base.

§rhs: Reg

Exponent.

§pol: Policy

Policy for the integer path.

§

DAbs

Dynamic absolute value: an int → abs at i64 (abs(MIN) per overflow; promote gives 9.223372036854775808e18); a float → fabs; else the abs hook, else TypeError.

Fields

§dst: Reg

Destination register.

§src: Reg

Operand.

§pol: Policy

Policy for the integer path.

§

DSepIndex

Separate an element for a nested write (PHP $a[k][] = v): obj (an array or map) is written, so its own copy-on-write store is made unique first; then if obj[key] is an array or map that another container may share, it is replaced by a copy (O(1), copy-on-write); dst = the element, safe to write in place. A reference slot separates the container inside the reference. An absent key gives nil (nothing is stored); other kinds of obj behave exactly as dget_index.

Fields

§dst: Reg

Destination dyn register.

§obj: Reg

The container.

§key: Reg

The key.

§

DSepProp

dsep_index for a property (PHP $o->items[] = v): a struct field of type dyn or a map entry with that string key; an absent map entry gives nil; other cases behave exactly as get_prop.

Fields

§dst: Reg

Destination dyn register.

§obj: Reg

The object.

§name: NameRef

The property name.

§

DCallShape

Dynamic call with a call shape: dst = callee(...) with the window dst+1 ..= dst+n laid out by shapes[shape] (positional, named, spread, named spread), bound to the callee’s parameter list (ArgumentError E0114 when they do not bind); non-callables go to the call_shape hook, or to call when no argument is named.

Fields

§dst: Reg

Result register (dyn); arguments follow it.

§callee: Reg

The callee.

§shape: ShapeId

The call shape.

§

DParamRef

dst = whether a positional argument at position pos (an i64) would be taken by reference by callee, so a code generator can send a reference or a value (PHP decides per argument at run time). False for non-callables, callees without a parameter list, and negative positions. Never raises.

Fields

§dst: Reg

Destination bool register.

§callee: Reg

The callee.

§pos: Reg

The 0-based position (i64).

§

DParamRefNamed

dst = whether a named argument name would be taken by reference by callee. Never raises.

Fields

§dst: Reg

Destination bool register.

§callee: Reg

The callee.

§name: NameRef

The argument’s name.

§

ErrPayload

dst = the payload of a runtime error value (what raise gave it; nil for errors raised by instructions), or nil for any other value.

Fields

§dst: Reg

Destination dyn register.

§src: Reg

The caught value.

§

Jmp

Continue at target.

Fields

§target: Target

The next instruction.

§

JmpIf

Continue at target if cond is true, else fall through.

Fields

§cond: Reg

A bool register.

§target: Target

Taken when cond is true.

§

JmpIfNot

Continue at target if cond is false, else fall through.

Fields

§cond: Reg

A bool register.

§target: Target

Taken when cond is false.

§

Switch

Continue at tables[table].targets[src] if 0 <= src < len, else at the table’s default.

Fields

§src: Reg

The selector.

§table: TableId

The jump table.

§ty: IntTy

The selector’s integer type.

§

Call

dst = func(dst+1, ..., dst+argc); a call to a function with no result leaves dst untouched.

Fields

§dst: Reg

Result register; arguments follow it.

§func: FuncId

The callee.

§argc: u8

The number of arguments.

§

CallIndirect

dst = callee(dst+1, ..., dst+argc) through a typed function reference (ref of a function type).

Fields

§dst: Reg

Result register; arguments follow it.

§callee: Reg

The function reference.

§argc: u8

The number of arguments.

§

CallImport

dst = import(dst+1, ..., dst+argc): a host call.

Fields

§dst: Reg

Result register; arguments follow it.

§import: ImportId

The host function.

§argc: u8

The number of arguments.

§

TailCall

Replaces the running frame with a call to func(args, ..., args+argc-1); the callee’s results equal the caller’s.

Fields

§func: FuncId

The callee.

§args: Reg

First argument register.

§argc: u8

The number of arguments.

§

TailCallIndirect

Tail call through a typed function reference.

Fields

§callee: Reg

The function reference.

§args: Reg

First argument register.

§argc: u8

The number of arguments.

§

Ret

Return src to the caller.

Fields

§src: Reg

The result register.

§

RetVoid

Return with no result.

§

Throw

Raise src as an error: control moves to the innermost covering handler, in this frame or a caller’s.

Fields

§src: Reg

The error value (dyn or ref).

§

ErrCode

dst = the numeric ErrorKind code of a caught runtime error, or 0 for any other value.

Fields

§dst: Reg

Destination u32 register.

§src: Reg

The caught value.

§

Safepoint

A point where the garbage collector may run and fuel is charged. Calls and allocations are safepoints too; every loop must pass one.

§

Unreachable

Abort the run with Unreachable (E0109).

§

Raise

Raise the runtime error kind (any catchable kind) with src as its payload, at this pc: how a code generator raises HIR’s NoMatch (E0200) with the scrutinee, or an ArgumentError from a prologue.

Fields

§src: Reg

The payload (dyn).

§kind: ErrorKind

The error kind.

§

MakeClosure

dst = a closure of func capturing, by value, the registers dst+1 ..= dst+n (n = the function’s capture count).

Fields

§dst: Reg

Destination register; the captured values follow it.

§func: FuncId

The function.

§

GetUpval

dst = the running closure’s captured value idx.

Fields

§dst: Reg

Destination register of the capture’s type.

§idx: UpvalIdx

The capture.

§

NewCell

dst = a new cell of type ty holding src.

Fields

§dst: Reg

Destination ref register.

§src: Reg

The initial value.

§ty: TypeRef

The cell type.

§

CellGet

dst = the value in cell (a ref to a cell type, or a dyn holding a cell or a reference; TypeError otherwise).

Fields

§dst: Reg

Destination register.

§cell: Reg

The cell.

§

CellSet

Store src into cell (operand rules as cell_get).

Fields

§cell: Reg

The cell.

§src: Reg

The value.

§

NewRef

dst = a new reference holding src (a variable taken by reference, PHP $r = &$x when $x is not yet one). (A)

Fields

§dst: Reg

Destination dyn or ref cell dyn register.

§src: Reg

The initial value (dyn).

§

DRefIndex

dst = a reference to the slot obj[key] (PHP &$a[k]): the slot’s reference if it holds one; else the slot (created with nil if absent in a map) is separated as by dsep_index and replaced by a new reference holding its value. (A)

Fields

§dst: Reg

Destination dyn or ref cell dyn register.

§obj: Reg

The array or map.

§key: Reg

The key.

§

DRefProp

dst = a reference to the property obj.name (PHP &$o->p): a struct field of type dyn, or a map entry with that string key (created with nil if absent). (A)

Fields

§dst: Reg

Destination dyn or ref cell dyn register.

§obj: Reg

The object.

§name: NameRef

The property name.

§

DBindIndex

Make the slot obj[key] the reference src (PHP $a[k] = &$x), replacing what the slot held (a previous reference is unbound, not written through). TypeError if src is not a reference. (A)

Fields

§obj: Reg

The array or map.

§key: Reg

The key.

§src: Reg

The reference.

§

DBindProp

Make the property obj.name the reference src (PHP $o->p = &$x). (A)

Fields

§obj: Reg

The object.

§name: NameRef

The property name.

§src: Reg

The reference.

§

DUnrefIndex

If the slot obj[key] holds a reference, replace it by the reference’s current value (a container value separated as by dup); else nothing. Lets a code generator end a reference’s hold on a slot it can prove no other holder uses (PHP drops such references when it copies the array).

Fields

§obj: Reg

The array or map.

§key: Reg

The key.

§

DUnrefProp

dunref_index for a property.

Fields

§obj: Reg

The object.

§name: NameRef

The property name.

§

NewStruct

dst = a new instance of struct type ty, every field at its type’s default.

Fields

§dst: Reg

Destination ref register.

§ty: TypeRef

The struct type.

§

GetField

dst = obj.field.

Fields

§dst: Reg

Destination register of the field’s type.

§obj: Reg

The instance.

§field: FieldIdx

The field slot.

§

SetField

obj.field = src.

Fields

§obj: Reg

The instance.

§field: FieldIdx

The field slot.

§src: Reg

The value.

§

NewArray

dst = a new array of type ty with len (an i64, at least 0) default elements.

Fields

§dst: Reg

Destination ref register.

§len: Reg

The length.

§ty: TypeRef

The array type.

§

ArrayLen

dst = the array’s length (i64).

Fields

§dst: Reg

Destination i64 register.

§arr: Reg

The array.

§

ArrayGet

dst = arr[idx]; IndexOutOfBounds unless 0 <= idx < len.

Fields

§dst: Reg

Destination register of the element type.

§arr: Reg

The array.

§idx: Reg

The i64 index.

§

ArraySet

arr[idx] = src; IndexOutOfBounds unless 0 <= idx < len.

Fields

§arr: Reg

The array.

§idx: Reg

The i64 index.

§src: Reg

The value.

§

ArrayPush

Append src to the array.

Fields

§arr: Reg

The array.

§src: Reg

The value.

§

ArrayPop

dst = the removed last element; IndexOutOfBounds if empty.

Fields

§dst: Reg

Destination register of the element type.

§arr: Reg

The array.

§

NewMap

dst = a new, empty map of type ty.

Fields

§dst: Reg

Destination ref register.

§ty: TypeRef

The map type.

§

MapLen

dst = the number of entries (i64).

Fields

§dst: Reg

Destination i64 register.

§map: Reg

The map.

§

MapGet

dst = map[key]; KeyNotFound if absent.

Fields

§dst: Reg

Destination register of the value type.

§map: Reg

The map.

§key: Reg

The key.

§

MapFind

dst = map[key], or nil if absent (value type dyn, str, or ref).

Fields

§dst: Reg

Destination register of the value type.

§map: Reg

The map.

§key: Reg

The key.

§

MapHas

dst = whether key is present.

Fields

§dst: Reg

Destination bool register.

§map: Reg

The map.

§key: Reg

The key.

§

MapSet

map[key] = src: a new key goes last; an existing key keeps its position.

Fields

§map: Reg

The map.

§key: Reg

The key.

§src: Reg

The value.

§

MapDel

Remove key if present; the other entries keep their order.

Fields

§map: Reg

The map.

§key: Reg

The key.

§

MapPush

Append src under the next integer key (PHP $a[] = v): one more than the largest integer key ever inserted, or 0.

Fields

§map: Reg

The map.

§src: Reg

The value.

§

IterNew

dst = a typed iterator over the array or map src.

Fields

§dst: Reg

Destination ref (iterator type) register.

§src: Reg

The collection.

§

IterNext

Advance: if another element exists, val = its value and has = true; else has = false and val is untouched.

Fields

§has: Reg

Destination bool register.

§iter: Reg

The iterator.

§val: Reg

Destination register of the value type.

§

IterKey

dst = the key of the element the last iter_next produced.

Fields

§dst: Reg

Destination register of the key type.

§iter: Reg

The iterator.

§

Dup

dst = a shallow copy of src (array, map, struct, or cell; a new identity, so value semantics such as PHP’s array assignment are explicit; O(1), the contents copied on the first write). Reference slots stay shared between the copies. Strings and callables are returned as is; iterators, coroutines, and references raise TypeError.

Fields

§dst: Reg

Destination register.

§src: Reg

Source register.

§

StrLen

dst = the length in bytes (i64).

Fields

§dst: Reg

Destination i64 register.

§s: Reg

The string.

§

StrConcat

dst = lhs ++ rhs.

Fields

§dst: Reg

Destination str register.

§lhs: Reg

First part.

§rhs: Reg

Second part.

§

StrConcatN

dst = the concatenation of the count strings in first .. first+count (the empty string if count is 0).

Fields

§dst: Reg

Destination str register.

§first: Reg

First part.

§count: u8

Number of parts.

§

StrEq

dst = whether the strings have equal bytes.

Fields

§dst: Reg

Destination bool register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

StrCmp

dst = -1, 0, or 1 (i8) by bytewise lexicographic order.

Fields

§dst: Reg

Destination i8 register.

§lhs: Reg

Left operand.

§rhs: Reg

Right operand.

§

StrSlice

dst = s[start..end] by byte offset, start in range and end in range+1 (both i64); IndexOutOfBounds unless 0 <= start <= end <= len; with utf8, InvalidStrIndex if a bound splits a character.

Fields

§dst: Reg

Destination str register.

§s: Reg

The string.

§range: Reg

Start index; the end index is in the next register.

§utf8: bool

Whether bounds must fall on UTF-8 character boundaries.

§

StrByte

dst = the byte at idx (u8); IndexOutOfBounds unless 0 <= idx < len.

Fields

§dst: Reg

Destination u8 register.

§s: Reg

The string.

§idx: Reg

The i64 index.

§

CoroNew

dst = a new coroutine, state created, that will run func(dst+1, ..., dst+argc) when first resumed. The arguments are copied now. (A)

Fields

§dst: Reg

Destination dyn or ref coroutine register; arguments follow it.

§func: FuncId

The body.

§argc: u8

The number of arguments.

§

CoroNewIndirect

dst = a new coroutine running the closure or function reference callee with the arguments dst+1 ..= dst+argc (converted from dyn as dcall does when callee is dyn). (A)

Fields

§dst: Reg

Destination dyn or ref coroutine register; arguments follow it.

§callee: Reg

The callable.

§argc: u8

The number of arguments.

§

Yield

Suspend the running coroutine in state yielded, handing src to its resumer under the next automatic key (PHP’s generator rule: one more than the largest integer key yielded so far, never below 0, so after only yield -5 => x it is 0); when resumed, dst = the value sent. The yield is an unwind point: resume_throw and coro_close raise here. CannotSuspend (E0111) outside a coroutine or across a host frame.

Fields

§dst: Reg

Receives the value sent by the next resume (dyn).

§src: Reg

The value yielded (dyn).

§

Await

Suspend the running coroutine in state awaiting, handing the awaitable src to its resumer (the scheduler); when resumed, dst = the value sent (the awaited result), or the error sent by resume_throw is raised here. CannotSuspend as yield.

Fields

§dst: Reg

Receives the awaited result (dyn).

§src: Reg

The awaitable (dyn).

§

Resume

Resume coro (state created, yielded, or awaiting), sending src; when it next suspends or finishes, dst = the value it yielded, the awaitable it awaits, or its return value (nil for a void body). An error escaping its body marks it failed and is raised here. InvalidCoroState (E0110) for any other state.

Fields

§dst: Reg

Receives the yielded, awaited, or returned value (dyn).

§coro: Reg

The coroutine.

§src: Reg

The value sent (dyn; ignored by a created coroutine).

§

ResumeThrow

Resume coro by raising src at its suspension point (in a created coroutine: before its first instruction, where no handler covers it). Otherwise as resume.

Fields

§dst: Reg

Receives the next yielded, awaited, or returned value (dyn).

§coro: Reg

The coroutine.

§src: Reg

The error value raised inside it (dyn).

§

CoroStatus

dst = the CoroState code of coro, as a u8.

Fields

§dst: Reg

Destination u8 register.

§coro: Reg

The coroutine.

§

CoroCurrent

dst = the running coroutine, or nil on the main stack.

Fields

§dst: Reg

Destination dyn or ref coroutine register.

§

YieldKv

As yield, with an explicit key (PHP yield $k => $v); an integer key larger than any before it moves the automatic-key counter.

Fields

§dst: Reg

Receives the value sent by the next resume (dyn).

§key: Reg

The key (dyn).

§src: Reg

The value yielded (dyn).

§

CoroClose

Close coro (Python close()/aclose(), PHP generator destruction): created → returned without running; returned or failed → nothing. A suspended coroutine is marked closing and src (the close signal, e.g. GeneratorExit) is raised at its suspension point, so its finally blocks run. If the body then returns, or the error escaping it is src itself, the close succeeds (returned; dst = the return value or nil). Another error marks it failed and is raised here. An await while closing suspends normally (dst = the awaitable; drive it with resume); a yield while closing leaves it suspended there and raises CloseIgnored (E0113) here.

Fields

§dst: Reg

Receives the return value, the awaitable, or nil (dyn).

§coro: Reg

The coroutine.

§src: Reg

The close signal raised inside it (dyn).

§

CoroKey

dst = the key of the value coro most recently yielded, or nil before its first yield (PHP Generator::key()).

Fields

§dst: Reg

Destination dyn register.

§coro: Reg

The coroutine.

§

CoroResult

dst = the return value of a returned coroutine (Python’s StopIteration.value, PHP Generator::getReturn()), nil for a void body. InvalidCoroState (E0110) in any other state.

Fields

§dst: Reg

Destination dyn register.

§coro: Reg

The coroutine.

§

Spawn

Start a task: make a coroutine as coro_new_indirect does and pass it to the module’s spawn hook (the host scheduler); dst = the hook’s result (a task handle). NoScheduler (E0112) without the hook. (A)

Fields

§dst: Reg

Receives the task handle (dyn); arguments follow it.

§callee: Reg

The callable.

§argc: u8

The number of arguments.

Implementations§

Source§

impl Inst

Source

pub const fn opcode(&self) -> Opcode

The instruction’s opcode.

§Examples
use bytecode_lang::{Inst, Opcode};

assert_eq!(Inst::RetVoid {}.opcode(), Opcode::RetVoid);
Source

pub fn to_bytes(&self) -> [u8; 8]

The canonical eight-byte encoding.

§Examples
use bytecode_lang::{Inst, Reg};

let mov = Inst::Mov { dst: Reg(1), src: Reg(2) };
assert_eq!(mov.to_bytes(), [0x01, 0, 1, 0, 2, 0, 0, 0]);
Source

pub fn from_bytes(bytes: [u8; 8]) -> Result<Inst, InstError>

Decodes eight bytes. Fails on an unknown opcode, on a modifier value its type does not define, and on non-zero bytes in unused slots, so every instruction has exactly one encoding.

§Errors

InstError says which of the three applies.

§Examples
use bytecode_lang::{Inst, InstError, Opcode};

assert_eq!(Inst::from_bytes([0, 0, 0, 0, 0, 0, 0, 0]), Ok(Inst::Nop {}));
// `load_bool` with 2 in its boolean slot.
assert_eq!(
    Inst::from_bytes([0x06, 2, 0, 0, 0, 0, 0, 0]),
    Err(InstError::InvalidOperand { opcode: Opcode::LoadBool, field: "val" }),
);
Source

pub fn overflow(&self) -> Option<Overflow>

The overflow policy the instruction carries (in an IntOp, Policy, or IntConv modifier), or None for instructions that carry none.

§Examples
use bytecode_lang::{Inst, Overflow, Policy, Reg};

let p = Policy::new().with_overflow(Overflow::Promote);
let add = Inst::DAdd { dst: Reg(0), lhs: Reg(1), rhs: Reg(2), pol: p };
assert_eq!(add.overflow(), Some(Overflow::Promote));
assert_eq!(Inst::Nop {}.overflow(), None);
Source§

impl Inst

Source

pub const fn branch_target(&self) -> Option<Target>

The branch target of jmp, jmp_if, or jmp_if_not, if this is one. (Switch targets live in the function’s jump tables.)

§Examples
use bytecode_lang::{Inst, Reg, Target};

assert_eq!(Inst::Jmp { target: Target(4) }.branch_target(), Some(Target(4)));
assert_eq!(Inst::Mov { dst: Reg(0), src: Reg(1) }.branch_target(), None);
Source

pub const fn mnemonic(&self) -> &'static str

The assembler name of this instruction’s opcode.

§Examples
use bytecode_lang::Inst;

assert_eq!(Inst::Safepoint {}.mnemonic(), "safepoint");

Trait Implementations§

Source§

impl Clone for Inst

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Inst

Source§

impl Debug for Inst

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Inst

mnemonic.modifiers operand, operand, with raw @pc branch targets.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Inst

Source§

impl Hash for Inst

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Inst

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Inst

Auto Trait Implementations§

§

impl Freeze for Inst

§

impl RefUnwindSafe for Inst

§

impl Send for Inst

§

impl Sync for Inst

§

impl Unpin for Inst

§

impl UnsafeUnpin for Inst

§

impl UnwindSafe for Inst

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.