Skip to content

Commit

Permalink
rv64: implement intrinsic for float_srt
Browse files Browse the repository at this point in the history
  • Loading branch information
soc committed Oct 28, 2023
1 parent aaad07a commit b89a4c3
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion dora/src/masm/rv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,41 @@ impl MacroAssembler {

pub fn float_cmp_nan(&mut self, mode: MachineMode, dest: Reg, src: FReg) {}

pub fn float_srt(&mut self, _mode: MachineMode, _dest: Reg, _lhs: FReg, _rhs: FReg) {}
pub fn float_srt(&mut self, mode: MachineMode, dest: Reg, lhs: FReg, rhs: FReg) {
match mode {
MachineMode::Float64 => {
self.asm.fmv_x_d(R10.into(), lhs.into());
self.asm.fmv_x_d(R11.into(), rhs.into());
self.asm.srai(R12.into(), R10.into(), 63);
self.asm.srli(R12.into(), R12.into(), 1);
self.asm.xor(R10.into(), R10.into(), R12.into());
self.asm.srai(R12.into(), R11.into(), 63);
self.asm.srli(R12.into(), R12.into(), 1);
self.asm.xor(R11.into(), R11.into(), R12.into());
self.asm.slt(R12.into(), R10.into(), R11.into());
self.asm.xor(R10.into(), R10.into(), R11.into());
self.asm.snez(R10.into(), R10.into());
self.asm.neg(R11.into(), R12.into());
self.asm.or(dest.into(), R10.into(), R11.into())
}
MachineMode::Float32 => {
self.asm.fmv_x_w(R10.into(), lhs.into());
self.asm.fmv_x_w(R11.into(), rhs.into());
self.asm.sraiw(R12.into(), R10.into(), 31);
self.asm.srliw(R12.into(), R12.into(), 1);
self.asm.xor(R10.into(), R10.into(), R12.into());
self.asm.sraiw(R12.into(), R11.into(), 31);
self.asm.srliw(R12.into(), R12.into(), 1);
self.asm.xor(R11.into(), R11.into(), R12.into());
self.asm.slt(R12.into(), R10.into(), R11.into());
self.asm.xor(R10.into(), R10.into(), R11.into());
self.asm.snez(R10.into(), R10.into());
self.asm.neg(R11.into(), R12.into());
self.asm.or(dest.into(), R10.into(), R11.into())
}
_ => unreachable!(),
}
}

pub fn load_float_const(&mut self, mode: MachineMode, dest: FReg, imm: f64) {}

Expand Down

0 comments on commit b89a4c3

Please sign in to comment.