Skip to main content

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 utils;
8pub mod v;
9pub mod zicond;
10pub mod zicsr;
11pub mod zvbb;
12pub mod zvbc;
13
14use crate::registers::general_purpose::Register;
15use core::fmt;
16use core::marker::Destruct;
17
18/// Generic instruction
19pub const trait Instruction:
20    fmt::Display + fmt::Debug + [const] Destruct + Copy + Send + Sync + Sized
21{
22    /// A register type used by the instruction
23    type Reg: Register;
24
25    /// Try to decode a single valid instruction
26    fn try_decode(instruction: u32) -> Option<Self>;
27
28    /// Instruction alignment in bytes
29    fn alignment() -> u8;
30
31    /// Instruction size in bytes
32    fn size(&self) -> u8;
33}