Skip to content

bloqade.lanes.bytecode.decode.BytecodeDecoder

← Module overview

classBytecodeDecodersource

bloqade.lanes.bytecode.decode.BytecodeDecoder

Turn a bytecode Program into a stack_move ir.Method.

class BytecodeDecoder(frame: StackMachineFrame = StackMachineFrame())

Maintains a virtual stack of SSA values during decoding: each bytecode push emits a stack_move statement whose result is pushed onto the virtual stack, and each pop consumes the top SSA reference. Stack ops (Pop/Dup/Swap) emit corresponding stack_move statements (linear-IR style — see the design doc).

All stack and IR manipulation is delegated to self.frame; the handlers below are thin translators from bytecode opcodes to stack_move statements.

Parameters

NameTypeDefaultDescription
frameStackMachineFrameStackMachineFrame()

Attributes

NameTypeDefaultDescription
frameStackMachineFramefield(default_factory=StackMachineFrame)

methoddecodesource

bloqade.lanes.bytecode.decode.BytecodeDecoder.decode

def decode(program: 'Program', kernel_name: str = 'main') -> ir.Method

Parameters

NameTypeDefaultDescription
program'Program'required
kernel_namestr'main'

Returns

ir.Method

source