diff --git a/winch/codegen/src/isa/aarch64/masm.rs b/winch/codegen/src/isa/aarch64/masm.rs index e8788fe71d70..f092378cdf9a 100644 --- a/winch/codegen/src/isa/aarch64/masm.rs +++ b/winch/codegen/src/isa/aarch64/masm.rs @@ -204,14 +204,7 @@ impl Masm for MacroAssembler { Address::offset(reg, offset as i64) } - fn cmp_with_set( - &mut self, - _dst: RegImm, - _lhs: RegImm, - _rhs: RegImm, - _kind: CmpKind, - _size: OperandSize, - ) { + fn cmp_with_set(&mut self, _src: RegImm, _dst: RegImm, _kind: CmpKind, _size: OperandSize) { todo!() } } diff --git a/winch/codegen/src/isa/x64/masm.rs b/winch/codegen/src/isa/x64/masm.rs index 0586a93ea8db..dfb40ae2067e 100644 --- a/winch/codegen/src/isa/x64/masm.rs +++ b/winch/codegen/src/isa/x64/masm.rs @@ -256,24 +256,9 @@ impl Masm for MacroAssembler { Address::offset(reg, offset) } - fn cmp_with_set( - &mut self, - dst: RegImm, - lhs: RegImm, - rhs: RegImm, - kind: CmpKind, - size: OperandSize, - ) { - let (src, dst): (Operand, Operand) = if dst == lhs { - (rhs.into(), dst.into()) - } else { - panic!( - "the destination and first source argument must be the same, dst={:?}, lhs={:?}", - dst, lhs - ); - }; - - self.asm.cmp(src, dst, size); + fn cmp_with_set(&mut self, src: RegImm, dst: RegImm, kind: CmpKind, size: OperandSize) { + let dst = dst.into(); + self.asm.cmp(src.into(), dst, size); self.asm.setcc(kind, dst); } } diff --git a/winch/codegen/src/masm.rs b/winch/codegen/src/masm.rs index c2461b79624c..f5fa618b6788 100644 --- a/winch/codegen/src/masm.rs +++ b/winch/codegen/src/masm.rs @@ -192,16 +192,9 @@ pub(crate) trait MacroAssembler { /// Calculate remainder. fn rem(&mut self, context: &mut CodeGenContext, kind: RemKind, size: OperandSize); - /// Compare two operands and put the result in dst. + /// Compare src and dst and put the result in dst. /// This function will potentially emit a series of instructions. - fn cmp_with_set( - &mut self, - dst: RegImm, - lhs: RegImm, - rhs: RegImm, - kind: CmpKind, - size: OperandSize, - ); + fn cmp_with_set(&mut self, src: RegImm, dst: RegImm, kind: CmpKind, size: OperandSize); /// Push the register to the stack, returning the offset. fn push(&mut self, src: Reg) -> u32; diff --git a/winch/codegen/src/visitor.rs b/winch/codegen/src/visitor.rs index eaa1a7ec19be..d58b1ba38ebf 100644 --- a/winch/codegen/src/visitor.rs +++ b/winch/codegen/src/visitor.rs @@ -274,7 +274,7 @@ where use OperandSize::*; self.context.unop(self.masm, S32, &mut |masm, reg, size| { - masm.cmp_with_set(reg, reg, RegImm::imm(0), CmpKind::Eq, size); + masm.cmp_with_set(RegImm::imm(0), reg, CmpKind::Eq, size); }); } @@ -282,7 +282,7 @@ where use OperandSize::*; self.context.unop(self.masm, S64, &mut |masm, reg, size| { - masm.cmp_with_set(reg, reg, RegImm::imm(0), CmpKind::Eq, size); + masm.cmp_with_set(RegImm::imm(0), reg, CmpKind::Eq, size); }); } @@ -330,14 +330,14 @@ where fn cmp_i32s(&mut self, kind: CmpKind) { self.context .i32_binop(self.masm, &mut |masm, dst, src, size| { - masm.cmp_with_set(dst, dst, src, kind, size); + masm.cmp_with_set(src, dst, kind, size); }); } fn cmp_i64s(&mut self, kind: CmpKind) { self.context .i64_binop(self.masm, &mut move |masm, dst, src, size| { - masm.cmp_with_set(dst, dst, src, kind, size); + masm.cmp_with_set(src, dst, kind, size); }); } }