ab_riscv_primitives/instructions.rs
1//! This module defines the RISC-V instruction set instructions
2
3pub mod rv32;
4pub mod rv64;
5#[cfg(test)]
6mod test_utils;
7pub mod v;
8pub mod zicsr;
9
10use crate::registers::general_purpose::Register;
11use core::fmt;
12use core::marker::Destruct;
13
14/// Generic instruction
15pub const trait Instruction:
16 fmt::Display + fmt::Debug + [const] Destruct + Copy + Send + Sync + Sized + 'static
17{
18 /// A register type used by the instruction
19 type Reg: Register;
20
21 /// Try to decode a single valid instruction
22 fn try_decode(instruction: u32) -> Option<Self>;
23
24 /// Instruction alignment in bytes
25 fn alignment() -> u8;
26
27 /// Instruction size in bytes
28 fn size(&self) -> u8;
29}