ab_riscv_primitives/
instructions.rs1pub mod rv32;
4pub mod rv64;
5#[cfg(test)]
6mod test_utils;
7pub mod utils;
8pub mod v;
9pub mod zawrs;
10pub mod zicond;
11pub mod zicsr;
12pub mod zkr;
13pub mod zvbb;
14pub mod zvbc;
15
16use crate::registers::general_purpose::Register;
17use core::any::TypeId;
18use core::fmt;
19use core::marker::Destruct;
20
21pub const trait Instruction:
23 fmt::Display + fmt::Debug + [const] Destruct + Copy + Send + Sync + Sized + 'static
24{
25 const IMPLEMENTED_EXTENSIONS: &'static [TypeId];
30
31 type Reg: [const] Register;
33
34 fn try_decode(instruction: u32) -> Option<Self>;
36
37 fn alignment() -> u8;
39
40 fn size(&self) -> u8;
42
43 #[inline(always)]
45 fn implements_extension<E>() -> bool
46 where
47 E: Instruction<Reg = Self::Reg>,
48 {
49 const {
50 let mut result = false;
51 let mut index = 0;
54 while index < Self::IMPLEMENTED_EXTENSIONS.len() {
55 if Self::IMPLEMENTED_EXTENSIONS[index] == TypeId::of::<E>() {
56 result = true;
57 }
58 index += 1;
59 }
60
61 result
62 }
63 }
64}