Expand description
Single-pass predecode for PVM2 (RV+C+custom-0) byte streams.
Walks the code from PC=0, decoding every instruction and recording:
- Decoded instruction array (
Vec<RvPreDecodedInst>): one entry per static instruction, with PC + next-PC pre-computed so the codegen loop doesn’t redo decoding. - Gas-block-start markers: PC=0 plus every PC immediately
following a terminator. The strict post-terminator set is sound
because runtime
jalrtargets are validated to be block starts (the linker injects aFallthroughterminator before any branch target that isn’t naturally post-terminator).
Per-block gas costs are computed by running the pipeline simulator
in crate::gas_cost::rv_gas_cost_for_block once per basic block;
the results are stored in Predecode::block_costs.
Structs§
- Predecode
- Output of the predecode pass over an RV+C+custom-0 code section.
- RvGas
Meta - Pre-resolved metadata used by the per-block gas accountant. The
fields are computed once at decode time so the gas hot path does
not have to re-match the
Instvariant on each invocation. - RvPre
Decoded Inst - One decoded instruction with its PC, next-PC, block-start flag, and pre-resolved gas metadata.
Functions§
- is_
ecall_ block ecall.jar/ecalli— the instructions that form their own (singleton) gas block, charged dynamically at dispatch rather than by a static block preamble. Acost == 0block start marks one.- is_
terminator - Block-terminating instructions: anything that can leave the fall-through path. Used to mark the next instruction as a gas-block start.
- predecode
- Predecode an entire RV+C+custom-0 code section.
- predecode_
rv_ with_ mem_ cycles - Like
predecodebut takes an explicitmem_cyclesparameter. Used by callers that want to override the default L2-hit latency (e.g. for tier-specific gas modeling).