bloqade.lanes.bytecode.decode.StackMachineFrame
classStackMachineFrame¶source
bloqade.lanes.bytecode.decode.StackMachineFrame
Tracks IR construction state during bytecode decoding.
class StackMachineFrame(stack: list[ir.SSAValue] = list())Mirrors kirin.lowering.Frame’s shape for the bytecode case:
a single basic block wrapped in a Region, plus a virtual stack
of SSA values.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
stack | list[ir.SSAValue] | list() |
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
current_region | ir.Region | field(init=False) | |
current_block | ir.Block | field(init=False) | |
stack | list[ir.SSAValue] | field(default_factory=list) |
methodpush¶source
bloqade.lanes.bytecode.decode.StackMachineFrame.push
def push(stmt: T) -> TAppend a statement to the current block and push its results onto the virtual stack.
Results are pushed in reverse declaration order — the first-declared result (highest on the stack per the dialect convention) ends up on top after pushing. For Swap this means out_top (declared first) sits above out_bot (declared second). For single-result statements there is only one result, so the reversed iteration is a no-op.
Parameters
| Name | Type | Description |
|---|---|---|
stmt | T |
Returns
T
methodpush_value¶source
bloqade.lanes.bytecode.decode.StackMachineFrame.push_value
def push_value(value: ir.SSAValue) -> NonePush an SSA value onto the virtual stack.
Parameters
| Name | Type | Description |
|---|---|---|
value | ir.SSAValue |
methodpop_value¶source
bloqade.lanes.bytecode.decode.StackMachineFrame.pop_value
def pop_value() -> ir.SSAValuePop the top of the virtual stack.
Returns
ir.SSAValue
Raises
| Type | Description |
|---|---|
StackUnderflowError | when the stack is empty. |
methodpop_n¶source
bloqade.lanes.bytecode.decode.StackMachineFrame.pop_n
def pop_n(n: int) -> list[ir.SSAValue]Pop n values from the top of the stack.
Returns them in bottom-to-top order so the caller can pass them as a tuple matching the ‘top-of-stack = last argument’ convention.
Parameters
| Name | Type | Description |
|---|---|---|
n | int |
Returns
list[ir.SSAValue]
Raises
| Type | Description |
|---|---|
StackUnderflowError | when the stack has fewer than ``n`` values. |
methodpeek_value¶source
bloqade.lanes.bytecode.decode.StackMachineFrame.peek_value
def peek_value() -> ir.SSAValueReturn the top-of-stack SSA value without popping.
Returns
ir.SSAValue
Raises
| Type | Description |
|---|---|
StackUnderflowError | when the stack is empty. |
methodswap_values¶source
bloqade.lanes.bytecode.decode.StackMachineFrame.swap_values
def swap_values() -> NoneSwap the top two values on the virtual stack in place.
Raises
| Type | Description |
|---|---|
StackUnderflowError | when the stack has fewer than 2 values. |
methodsnapshot¶source
bloqade.lanes.bytecode.decode.StackMachineFrame.snapshot
def snapshot() -> tuple[ir.SSAValue, ...]Return a tuple snapshot of the stack — used for error reporting.
Returns
tuple[ir.SSAValue, ...]
methoddepth¶source
bloqade.lanes.bytecode.decode.StackMachineFrame.depth