2023-06-20 19:07:48 -05:00
|
|
|
#![no_std]
|
|
|
|
|
2024-05-15 07:36:38 -05:00
|
|
|
pub use crate::ops::*;
|
2023-10-18 05:14:24 -05:00
|
|
|
use core::convert::TryFrom;
|
|
|
|
|
2024-05-15 07:36:38 -05:00
|
|
|
pub mod opcode;
|
|
|
|
mod ops;
|
|
|
|
|
2023-10-01 09:02:06 -05:00
|
|
|
type OpR = u8;
|
2023-07-25 16:43:06 -05:00
|
|
|
|
2023-10-01 09:02:06 -05:00
|
|
|
type OpA = u64;
|
2023-10-22 07:46:45 -05:00
|
|
|
type OpO = i32;
|
|
|
|
type OpP = i16;
|
2023-09-26 16:36:27 -05:00
|
|
|
|
2023-10-01 09:02:06 -05:00
|
|
|
type OpB = u8;
|
|
|
|
type OpH = u16;
|
|
|
|
type OpW = u32;
|
|
|
|
type OpD = u64;
|
2023-06-20 19:07:48 -05:00
|
|
|
|
2023-09-26 16:36:27 -05:00
|
|
|
/// # Safety
|
|
|
|
/// Has to be valid to be decoded from bytecode.
|
|
|
|
pub unsafe trait BytecodeItem {}
|
2023-10-01 09:02:06 -05:00
|
|
|
unsafe impl BytecodeItem for u8 {}
|
2023-08-08 18:24:13 -05:00
|
|
|
|
2023-10-18 05:14:24 -05:00
|
|
|
/// Rounding mode
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
#[repr(u8)]
|
|
|
|
pub enum RoundingMode {
|
|
|
|
NearestEven = 0,
|
|
|
|
Truncate = 1,
|
|
|
|
Up = 2,
|
|
|
|
Down = 3,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TryFrom<u8> for RoundingMode {
|
|
|
|
type Error = ();
|
|
|
|
|
|
|
|
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
2023-11-03 03:43:08 -05:00
|
|
|
(value <= 3)
|
2023-10-18 05:14:24 -05:00
|
|
|
.then(|| unsafe { core::mem::transmute(value) })
|
|
|
|
.ok_or(())
|
|
|
|
}
|
|
|
|
}
|