diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index ba3e6669ed1e..6f34a77f099f 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -780,9 +780,9 @@ class MacroAssembler : public MacroAssemblerSpecific inline void subPtr(ImmWord imm, Register dest) DEFINED_ON(x64); inline void subPtr(const Address& addr, Register dest) DEFINED_ON(mips_shared, arm, arm64, x86, x64); - inline void sub64(Register64 src, Register64 dest) DEFINED_ON(x86, x64, arm); - inline void sub64(Imm64 imm, Register64 dest) DEFINED_ON(x86, x64, arm); - inline void sub64(const Operand& src, Register64 dest) DEFINED_ON(x64); + inline void sub64(Register64 src, Register64 dest) DEFINED_ON(x86, x64, arm, mips64); + inline void sub64(Imm64 imm, Register64 dest) DEFINED_ON(x86, x64, arm, mips64); + inline void sub64(const Operand& src, Register64 dest) DEFINED_ON(x64, mips64); inline void subFloat32(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; diff --git a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp index 9731b528ccca..60d877e35ba9 100644 --- a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp +++ b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp @@ -375,6 +375,22 @@ CodeGeneratorMIPSShared::visitSubI(LSubI* ins) bailoutFrom(&overflow, ins->snapshot()); } +void +CodeGeneratorMIPSShared::visitSubI64(LSubI64* lir) +{ + const LInt64Allocation lhs = lir->getInt64Operand(LSubI64::Lhs); + const LInt64Allocation rhs = lir->getInt64Operand(LSubI64::Rhs); + + MOZ_ASSERT(ToOutRegister64(lir) == ToRegister64(lhs)); + + if (IsConstant(rhs)) { + masm.sub64(Imm64(ToInt64(rhs)), ToRegister64(lhs)); + return; + } + + masm.sub64(ToOperandOrRegister64(rhs), ToRegister64(lhs)); +} + void CodeGeneratorMIPSShared::visitMulI(LMulI* ins) { diff --git a/js/src/jit/mips-shared/CodeGenerator-mips-shared.h b/js/src/jit/mips-shared/CodeGenerator-mips-shared.h index 974b34aad2a0..e987d2d6c376 100644 --- a/js/src/jit/mips-shared/CodeGenerator-mips-shared.h +++ b/js/src/jit/mips-shared/CodeGenerator-mips-shared.h @@ -130,6 +130,7 @@ class CodeGeneratorMIPSShared : public CodeGeneratorShared virtual void visitAddI(LAddI* ins); virtual void visitAddI64(LAddI64* ins); virtual void visitSubI(LSubI* ins); + virtual void visitSubI64(LSubI64* ins); virtual void visitBitNotI(LBitNotI* ins); virtual void visitBitOpI(LBitOpI* ins); virtual void visitBitOpI64(LBitOpI64* ins); diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index e2d9746d6010..e7d4ba6cce1e 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -212,6 +212,33 @@ MacroAssembler::subPtr(Imm32 imm, Register dest) ma_dsubu(dest, dest, imm); } +void +MacroAssembler::sub64(Register64 src, Register64 dest) +{ + as_dsubu(dest.reg, dest.reg, src.reg); +} + +void +MacroAssembler::sub64(const Operand& src, Register64 dest) +{ + if (src.getTag() == Operand::MEM) { + Register64 scratch(ScratchRegister); + + load64(src.toAddress(), scratch); + sub64(scratch, dest); + } else { + sub64(Register64(src.toReg()), dest); + } +} + +void +MacroAssembler::sub64(Imm64 imm, Register64 dest) +{ + MOZ_ASSERT(dest.reg != ScratchRegister); + mov(ImmWord(imm.value), ScratchRegister); + as_dsubu(dest.reg, dest.reg, ScratchRegister); +} + void MacroAssembler::mul64(Imm64 imm, const Register64& dest) {