pub trait ComputeInstructions: Sized {
Show 30 methods
// Required methods
fn add(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn sub(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn xor(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn or(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn and(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn sll(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn srl(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn sra(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn slt(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn sltu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn mul(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn mulh(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn mulhu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn mulhsu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn div(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn divu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn rem(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn remu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn addw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn subw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn sllw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn srlw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn sraw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn mulw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn divw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn divuw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn remw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn remuw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand);
fn auipc(&mut self, rd: RiscRegister, imm: u64);
fn lui(&mut self, rd: RiscRegister, imm: u64);
}Expand description
An ALU instruction backend for a specific target architecture.
This trait is implemented for each target architecture supported by the JIT transpiler.
Required Methods§
Sourcefn add(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn add(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Add the values of two registers together, using 64bit arithmetic.
add: rd = rs1 + rs2
Sourcefn sub(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn sub(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Subtract the values of two registers from each other, using 64bit arithmetic.
sub: rd = rs1 - rs2
Sourcefn xor(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn xor(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Bitwise XOR the values of two registers together.
xor: rd = rs1 ^ rs2
Sourcefn or(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn or(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Bitwise OR the values of two registers together.
or: rd = rs1 | rs2
Sourcefn and(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn and(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Bitwise AND the values of two registers together.
and: rd = rs1 & rs2
Sourcefn sll(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn sll(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Shift the values of two registers left by the amount specified by the second register.
sll: rd = rs1 << rs2
Sourcefn srl(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn srl(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Shift the values of two registers right by the amount specified by the second register.
srl: rd = rs1 >> rs2
Sourcefn sra(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn sra(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Shift the values of two registers right by the amount specified by the second register, using arithmetic right shift.
sra: rd = rs1 >> rs2
Sourcefn slt(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn slt(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Set if less than (signed comparison).
slt: rd = (rs1 < rs2) ? 1 : 0
Sourcefn sltu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn sltu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Set if less than (unsigned comparison).
sltu: rd = (rs1 < rs2) ? 1 : 0
Sourcefn mul(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn mul(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Multiply the values of two registers together, using 64bit arithmetic.
mul: rd = rs1 * rs2
Sourcefn mulh(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn mulh(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Multiply the values of two registers together and return the high 64 bits (signed).
mulh: rd = (rs1 * rs2) >> 64 (signed)
Sourcefn mulhu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn mulhu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Multiply the values of two registers together and return the high 64 bits (unsigned).
mulhu: rd = (rs1 * rs2) >> 64 (unsigned)
Sourcefn mulhsu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn mulhsu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Multiply signed rs1 by unsigned rs2 and return the high 64 bits.
mulhsu: rd = (rs1 * rs2) >> 64 (signed * unsigned)
Sourcefn div(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn div(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Divide the values of two registers (signed).
div: rd = rs2 == 0 ? 0 : rs1 / rs2
Sourcefn divu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn divu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Divide the values of two registers (unsigned).
divu: rd = rs2 == 0 ? 0 : rs1 / rs2
Sourcefn rem(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn rem(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Remainder of two registers (signed).
rem: rd = rs2 == 0 ? 0 : rs1 % rs2
Sourcefn remu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn remu(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Remainder of two registers (unsigned).
remu: rd = rs2 == 0 ? 0 : rs1 % rs2
Sourcefn addw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn addw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Add the values of two registers together, using 64bit arithmetic, but only keeping lower 32 bits.
addw: rd = (rs1 + rs2) & 0xFFFFFFFF (sign-extended to 64-bit)
Sourcefn subw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn subw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Subtract the values of two registers, using 64bit arithmetic, but only keeping lower 32 bits.
subw: rd = (rs1 - rs2) & 0xFFFFFFFF (sign-extended to 64-bit)
Sourcefn sllw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn sllw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Shift the values of two registers left by the amount specified by the second register (32-bit).
sllw: rd = (rs1 << (rs2 & 0x1F)) & 0xFFFFFFFF (sign-extended to 64-bit)
Sourcefn srlw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn srlw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Shift the values of two registers right by the amount specified by the second register (32-bit logical).
srlw: rd = ((rs1 & 0xFFFFFFFF) >> (rs2 & 0x1F)) (sign-extended to 64-bit)
Sourcefn sraw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn sraw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Shift the values of two registers right by the amount specified by the second register (32-bit arithmetic).
sraw: rd = ((rs1 as i32) >> (rs2 & 0x1F)) (sign-extended to 64-bit)
Sourcefn mulw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn mulw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Multiply the values of two registers together, using 32bit arithmetic (sign-extended to 64-bit).
mulw: rd = (rs1 * rs2) & 0xFFFFFFFF (sign-extended to 64-bit)
Sourcefn divw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn divw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Divide the values of two registers together, using 32bit arithmetic (sign-extended to 64-bit).
divw: rd = rs2 == 0 ? 0xFFFFFFFF : (rs1 as i32) / (rs2 as i32) (sign-extended to 64-bit)
Sourcefn divuw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn divuw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Divide the values of two registers, unsigned 32bit (sign-extended to 64-bit).
divuw: rd = rs2 == 0 ? 0xFFFFFFFF : (rs1 as u32) / (rs2 as u32) (sign-extended to 64-bit)
Sourcefn remw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn remw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Remainder the values of two registers together, using 32bit arithmetic (sign-extended to 64-bit).
remw: rd = rs2 == 0 ? rs1 : (rs1 as i32) % (rs2 as i32) (sign-extended to 64-bit)
Sourcefn remuw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
fn remuw(&mut self, rd: RiscRegister, rs1: RiscOperand, rs2: RiscOperand)
Remainder the values of two registers, unsigned 32bit (sign-extended to 64-bit).
remuw: rd = rs2 == 0 ? rs1 : (rs1 as u32) % (rs2 as u32) (sign-extended to 64-bit)
Sourcefn auipc(&mut self, rd: RiscRegister, imm: u64)
fn auipc(&mut self, rd: RiscRegister, imm: u64)
Advance to the next pc, storing the current (pc + imm) in a register.
auipc: rd = pc + imm, pc = pc + 4
Sourcefn lui(&mut self, rd: RiscRegister, imm: u64)
fn lui(&mut self, rd: RiscRegister, imm: u64)
Load upper immediate into a register.
lui: rd = imm << 12
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".