Skip to main content

instruction_execution

Attribute Macro instruction_execution 

Source
#[instruction_execution]
Expand description

Processes #[instruction_execution] attribute on enum execution implementation.

It must be applied to implementation of traits ExecutableInstructionOperands, ExecutableInstructionCsr and ExecutableInstruction, whose definition is already annotated with #[instruction] macro.

Similarly to that macro, this macro will process the contents of trait implementations.

ExecutableInstructionOperands::get_rs1_rs2_operands() method will be generated from scratch.

ExecutableInstruction::execute(), ExecutableInstructionCsr::prepare_csr_read() and ExecutableInstructionCsr::prepare_csr_write() methods will end up containing both inherited and own execution logic according to the ordering set in #[instruction].

There are constraints on the ExecutableInstruction::execute() method body, it must have one or both (but nothing else) of the following:

  • matching in the following style: match self { Self::Variant { .. } }
    • note that Self must be used instead of the explicit type name, such that it works when inherited
  • Ok(ControlFlow::Continue(Default::default())) expression.

Also requires process_instruction_macros() in build.rs to function, see #[instruction] macro documentation.

ExecutableInstructionCsr::prepare_csr_read() and ExecutableInstructionCsr::prepare_csr_write() methods can’t contain return in them, similarly to instruction decoding implementation processed by #[instruction] macro.