Croissant Runtime
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
crsn/crsn_arith/src/defs.rs

90 lines
2.6 KiB

use crsn::asm::data::{Rd, Wr};
use crsn::builtin::defs::BitMask;
/// A low level instruction
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ArithOp {
Test { a: Rd },
Compare { a: Rd, b: Rd },
RangeTest { val: Rd, a: Rd, b: Rd },
Rng { dst: Wr, min: Rd, max: Rd },
/// Swap halves
Sw32 { dst: Wr, src: Rd },
/// Swap adjacent half-words
Sw16 { dst: Wr, src: Rd },
/// Swap neighbouring bytes
Sw8 { dst: Wr, src: Rd },
/// Reverse bytes
Rev { dst: Wr, src: Rd },
/// Reverse bits
Rbit { dst: Wr, src: Rd },
/// Count leading zeros in a slice
Clz { dst: Wr, src: Rd, mask: BitMask },
/// Count leading ones in a slice
Clo { dst: Wr, src: Rd, mask: BitMask },
/// Sign extend a slice (zero aligned)
SignExtend { dst: Wr, src: Rd, mask: BitMask },
Add { dst: Wr, a: Rd, b: Rd },
Abs { dst: Wr, a: Rd },
Sub { dst: Wr, a: Rd, b: Rd },
Mul { dst: Wr, a: Rd, b: Rd },
Pow { dst: Wr, a: Rd, pow: Rd },
Div { dst: Wr, rem: Wr, a: Rd, div: Rd },
// "Mod" is functionally equivalent to "Div" with the result discarded,
// but status flags are updated by the remainder
Mod { dst: Wr, a: Rd, div: Rd },
And { dst: Wr, a: Rd, b: Rd },
Or { dst: Wr, a: Rd, b: Rd },
Xor { dst: Wr, a: Rd, b: Rd },
Cpl { dst: Wr, a: Rd },
Rol { dst: Wr, a: Rd, n: Rd },
// Rotate (with wrap-around)
Ror { dst: Wr, a: Rd, n: Rd },
Lsl { dst: Wr, a: Rd, n: Rd },
// Shift
Lsr { dst: Wr, a: Rd, n: Rd },
Asr { dst: Wr, a: Rd, n: Rd },
IntToFloat { dst: Wr, a: Rd },
FloatToInt { dst: Wr, a: Rd, mode: FloatToIntMode },
FloatTest { a: Rd },
FloatCompare { a: Rd, b: Rd },
FloatRangeTest { val: Rd, a: Rd, b: Rd },
FloatRng { dst: Wr, min: Rd, max: Rd },
FloatAdd { dst: Wr, a: Rd, b: Rd },
FloatSub { dst: Wr, a: Rd, b: Rd },
FloatMul { dst: Wr, a: Rd, b: Rd },
FloatPow { dst: Wr, a: Rd, pow: Rd },
FloatRoot { dst: Wr, a: Rd, root: Rd },
FloatHyp { dst: Wr, a: Rd, b: Rd },
FloatDiv { dst: Wr, rem: Wr, a: Rd, div: Rd },
FloatMod { dst: Wr, a: Rd, div: Rd },
FloatAbs { dst: Wr, a: Rd },
FloatSin { dst: Wr, f: Rd },
FloatAsin { dst: Wr, a: Rd },
FloatCos { dst: Wr, f: Rd },
FloatAcos { dst: Wr, a: Rd },
FloatTan { dst: Wr, f: Rd },
FloatAtan { dst: Wr, a: Rd },
FloatAtan2 { dst: Wr, y: Rd, x: Rd },
FloatCot { dst: Wr, f: Rd },
FloatAcot { dst: Wr, a: Rd },
}
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum FloatToIntMode {
Floor,
Ceil,
Round,
}
impl Default for FloatToIntMode {
fn default() -> Self {
Self::Round
}
}