Skip to main content

Module stack

Module stack 

Source
Expand description

Stack scheduling for EVM code generation.

This module handles the translation from MIR’s SSA values to EVM’s stack-based model. The key abstraction is StackModel, which tracks which MIR values are at which stack depths.

§Submodules

  • model: Core stack model tracking value positions
  • scheduler: Stack scheduler for generating DUP/SWAP sequences
  • shuffler: Optimal stack layout transitions (backward analysis)
  • spill: Spill management for values beyond depth 16

Modules§

shuffler
Stack shuffler for optimal stack layout transitions.

Structs§

BlockStackLayout
Represents a stack layout for a block - the values that should be on the stack when entering or exiting a block, from top to bottom.
LayoutAnalysis
Computes the ideal entry layout for an instruction given the desired exit layout.
ShuffleResult
Result of a shuffle operation.
SpillManager
Manages spill slots for values that cannot fit on the stack.
SpillSlot
A slot in memory where a spilled value is stored.
StackModel
Represents the current state of the EVM stack.
StackScheduler
Stack scheduler that generates stack manipulation operations.
StackShuffler
The stack shuffler transforms a source stack layout to a target layout.

Enums§

ScheduledOp
A scheduled operation to emit.
StackOp
Operations to emit for stack manipulation.
TargetSlot
Represents a slot in the target layout.

Functions§

combine_stack_layouts
Computes a common stack layout for multiple incoming edges at a merge point.
estimate_shuffle_cost
Computes the shuffle cost from a source layout to a target layout. This estimates the number of DUP/SWAP/POP operations needed.
ideal_binary_op_entry
Computes the ideal pre-layout for a binary operation.
ideal_operand_layout
Creates an ideal layout for preparing multiple operands.
ideal_unary_op_entry
Computes the ideal pre-layout for a unary operation.
is_freely_generable
Checks if a value can be freely generated (doesn’t need to be on stack).