ab_riscv_interpreter/rv32/zk/
zbkx.rs1pub mod rv32_zbkx_helpers;
4#[cfg(not(all(miri, target_arch = "aarch64")))]
7#[cfg(test)]
8mod tests;
9
10use crate::{
11 ExecutableInstruction, ExecutableInstructionCsr, ExecutableInstructionOperands, ExecutionError,
12 RegisterFile, Rs1Rs2OperandValues, Rs1Rs2Operands,
13};
14use ab_riscv_macros::instruction_execution;
15use ab_riscv_primitives::prelude::*;
16use core::ops::ControlFlow;
17
18#[instruction_execution]
19impl<Reg> ExecutableInstructionOperands for Rv32ZbkxInstruction<Reg> where Reg: Register<Type = u32> {}
20
21#[instruction_execution]
22impl<Reg, ExtState, CustomError> ExecutableInstructionCsr<ExtState, CustomError>
23 for Rv32ZbkxInstruction<Reg>
24where
25 Reg: Register<Type = u32>,
26{
27}
28
29#[instruction_execution]
30impl<Reg, Regs, ExtState, Memory, PC, InstructionHandler, CustomError>
31 ExecutableInstruction<Regs, ExtState, Memory, PC, InstructionHandler, CustomError>
32 for Rv32ZbkxInstruction<Reg>
33where
34 Reg: Register<Type = u32>,
35 Regs: RegisterFile<Reg>,
36{
37 #[inline(always)]
38 fn execute(
39 self,
40 Rs1Rs2OperandValues {
41 rs1_value,
42 rs2_value,
43 }: Rs1Rs2OperandValues<<Self::Reg as Register>::Type>,
44 _regs: &mut Regs,
45 _ext_state: &mut ExtState,
46 _memory: &mut Memory,
47 _program_counter: &mut PC,
48 _system_instruction_handler: &mut InstructionHandler,
49 ) -> Result<
50 ControlFlow<(), (Self::Reg, <Self::Reg as Register>::Type)>,
51 ExecutionError<Reg::Type, CustomError>,
52 > {
53 match self {
54 Self::Xperm4 { rd, rs1: _, rs2: _ } => Ok(ControlFlow::Continue((
55 rd,
56 rv32_zbkx_helpers::xperm4(rs1_value, rs2_value),
57 ))),
58 Self::Xperm8 { rd, rs1: _, rs2: _ } => Ok(ControlFlow::Continue((
59 rd,
60 rv32_zbkx_helpers::xperm8(rs1_value, rs2_value),
61 ))),
62 }
63 }
64}