Skip to content

Move to stack

MoveToStackMove dataclass

MoveToStackMove(arch_spec: ArchSpec)

Lower a move-dialect kernel to a canonicalized stack_move kernel.

emit runs the full move → stack_move lowering pipeline, producing an ir.Method that is stack-consistent and ready for bytecode emission:

  1. RewriteMoveToStackMove — in-place move → stack_move rewrite (strips Load/Store state threading, materialises address attributes as Const* SSA values, rebuilds Measure/AwaitMeasure/GetItem).
  2. DCE + CSE to a fixpoint — the cleanup the encoder pipeline expects before stackification (see stackify's docstring).
  3. stackify — normalise into stack-consistent form (single block, each SSA value used at most once, defining statements in stack order).

RewriteMoveToStackMove only lowers the subset of move statements the bytecode path supports. When no_raise is False, emit runs raise_if_statements_outside_dialect_group right after dropping move from the group — before stackify, so an unlowered statement is reported precisely instead of garbled by a later stage. Kirin's verify() does not check dialect-group membership, so such a statement would otherwise slip through and fail lazily inside dump_program.

emit_bytecode runs emit and encodes the result to a bytecode Program via dump_program.