From 768cac50b8194f887435424669fd3454f6c7a3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Fri, 31 Jan 2025 08:57:27 +0000 Subject: [PATCH] Bug 1944011 - Part 44: Generate boilerplate for LModI. r=iain Needs a temp register on non-ARM targets, except for that difference the definition can be shared. Differential Revision: https://phabricator.services.mozilla.com/D235857 --- js/src/jit/LIROps.yaml | 10 +++++++++- js/src/jit/arm/LIR-arm.h | 13 ------------- js/src/jit/arm64/LIR-arm64.h | 13 ------------- js/src/jit/loong64/LIR-loong64.h | 16 ---------------- .../mips-shared/CodeGenerator-mips-shared.cpp | 2 +- js/src/jit/mips-shared/LIR-mips-shared.h | 16 ---------------- js/src/jit/none/LIR-none.h | 10 ---------- js/src/jit/riscv64/CodeGenerator-riscv64.cpp | 2 +- js/src/jit/riscv64/LIR-riscv64.h | 16 ---------------- js/src/jit/shared/LIR-shared.h | 4 ++++ js/src/jit/wasm32/LIR-wasm32.h | 10 ---------- .../x86-shared/CodeGenerator-x86-shared.cpp | 4 ++-- js/src/jit/x86-shared/LIR-x86-shared.h | 19 ------------------- 13 files changed, 17 insertions(+), 118 deletions(-) diff --git a/js/src/jit/LIROps.yaml b/js/src/jit/LIROps.yaml index be40d32a167c1..a8b5356d3fded 100644 --- a/js/src/jit/LIROps.yaml +++ b/js/src/jit/LIROps.yaml @@ -4895,7 +4895,15 @@ extra_name: true - name: ModI - gen_boilerplate: false + result_type: WordSized + operands: + lhs: WordSized + rhs: WordSized +#if !defined(JS_CODEGEN_ARM) && !defined(JS_CODEGEN_ARM64) + num_temps: 1 +#endif + mir_op: Mod + extra_name: true - name: DivPowTwoI gen_boilerplate: false diff --git a/js/src/jit/arm/LIR-arm.h b/js/src/jit/arm/LIR-arm.h index 76ae986f4b531..7b222de98f284 100644 --- a/js/src/jit/arm/LIR-arm.h +++ b/js/src/jit/arm/LIR-arm.h @@ -132,19 +132,6 @@ class LDivPowTwoI : public LInstructionHelper<1, 1, 0> { MDiv* mir() const { return mir_->toDiv(); } }; -class LModI : public LBinaryMath<0> { - public: - LIR_HEADER(ModI); - - LModI(const LAllocation& lhs, const LAllocation& rhs) - : LBinaryMath(classOpcode) { - setOperand(0, lhs); - setOperand(1, rhs); - } - - MMod* mir() const { return mir_->toMod(); } -}; - class LMulI : public LBinaryMath<0> { public: LIR_HEADER(MulI); diff --git a/js/src/jit/arm64/LIR-arm64.h b/js/src/jit/arm64/LIR-arm64.h index 20a0ba6e57397..4f814888c5dac 100644 --- a/js/src/jit/arm64/LIR-arm64.h +++ b/js/src/jit/arm64/LIR-arm64.h @@ -48,19 +48,6 @@ class LDivPowTwoI : public LInstructionHelper<1, 1, 0> { MDiv* mir() const { return mir_->toDiv(); } }; -class LModI : public LBinaryMath<0> { - public: - LIR_HEADER(ModI); - - LModI(const LAllocation& lhs, const LAllocation& rhs) - : LBinaryMath(classOpcode) { - setOperand(0, lhs); - setOperand(1, rhs); - } - - MMod* mir() const { return mir_->toMod(); } -}; - class LMulI : public LBinaryMath<0> { public: LIR_HEADER(MulI); diff --git a/js/src/jit/loong64/LIR-loong64.h b/js/src/jit/loong64/LIR-loong64.h index eb5796db428e8..09f472e7b434d 100644 --- a/js/src/jit/loong64/LIR-loong64.h +++ b/js/src/jit/loong64/LIR-loong64.h @@ -43,22 +43,6 @@ class LDivPowTwoI : public LInstructionHelper<1, 1, 1> { MDiv* mir() const { return mir_->toDiv(); } }; -class LModI : public LBinaryMath<1> { - public: - LIR_HEADER(ModI); - - LModI(const LAllocation& lhs, const LAllocation& rhs, - const LDefinition& callTemp) - : LBinaryMath(classOpcode) { - setOperand(0, lhs); - setOperand(1, rhs); - setTemp(0, callTemp); - } - - const LDefinition* callTemp() { return getTemp(0); } - MMod* mir() const { return mir_->toMod(); } -}; - class LMulI : public LBinaryMath<0> { public: LIR_HEADER(MulI); diff --git a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp index e14953eb46662..f439e0f5032be 100644 --- a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp +++ b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp @@ -555,7 +555,7 @@ void CodeGenerator::visitModI(LModI* ins) { Register lhs = ToRegister(ins->lhs()); Register rhs = ToRegister(ins->rhs()); Register dest = ToRegister(ins->output()); - Register callTemp = ToRegister(ins->callTemp()); + Register callTemp = ToRegister(ins->temp0()); MMod* mir = ins->mir(); Label done; diff --git a/js/src/jit/mips-shared/LIR-mips-shared.h b/js/src/jit/mips-shared/LIR-mips-shared.h index ca98e953685e2..87408a7ff93a7 100644 --- a/js/src/jit/mips-shared/LIR-mips-shared.h +++ b/js/src/jit/mips-shared/LIR-mips-shared.h @@ -27,22 +27,6 @@ class LDivPowTwoI : public LInstructionHelper<1, 1, 1> { MDiv* mir() const { return mir_->toDiv(); } }; -class LModI : public LBinaryMath<1> { - public: - LIR_HEADER(ModI); - - LModI(const LAllocation& lhs, const LAllocation& rhs, - const LDefinition& callTemp) - : LBinaryMath(classOpcode) { - setOperand(0, lhs); - setOperand(1, rhs); - setTemp(0, callTemp); - } - - const LDefinition* callTemp() { return getTemp(0); } - MMod* mir() const { return mir_->toMod(); } -}; - class LMulI : public LBinaryMath<0> { public: LIR_HEADER(MulI); diff --git a/js/src/jit/none/LIR-none.h b/js/src/jit/none/LIR-none.h index ce24d1babf97b..8d8f032867d7a 100644 --- a/js/src/jit/none/LIR-none.h +++ b/js/src/jit/none/LIR-none.h @@ -27,16 +27,6 @@ class LDivPowTwoI : public LInstructionHelper<1, 1, 0> { int32_t shift() { MOZ_CRASH(); } MDiv* mir() const { MOZ_CRASH(); } }; -class LModI : public LBinaryMath<1> { - public: - LModI(const LAllocation&, const LAllocation&, const LDefinition&) - : LBinaryMath(Opcode::Invalid) { - MOZ_CRASH(); - } - - const LDefinition* callTemp() { MOZ_CRASH(); } - MMod* mir() const { MOZ_CRASH(); } -}; class LMulI : public LInstruction {}; diff --git a/js/src/jit/riscv64/CodeGenerator-riscv64.cpp b/js/src/jit/riscv64/CodeGenerator-riscv64.cpp index 933fa24efe23f..42de2bc5da216 100644 --- a/js/src/jit/riscv64/CodeGenerator-riscv64.cpp +++ b/js/src/jit/riscv64/CodeGenerator-riscv64.cpp @@ -1059,7 +1059,7 @@ void CodeGenerator::visitModI(LModI* ins) { Register lhs = ToRegister(ins->lhs()); Register rhs = ToRegister(ins->rhs()); Register dest = ToRegister(ins->output()); - Register callTemp = ToRegister(ins->callTemp()); + Register callTemp = ToRegister(ins->temp0()); MMod* mir = ins->mir(); Label done, prevent; diff --git a/js/src/jit/riscv64/LIR-riscv64.h b/js/src/jit/riscv64/LIR-riscv64.h index fc1df8637076a..f1864499a98b2 100644 --- a/js/src/jit/riscv64/LIR-riscv64.h +++ b/js/src/jit/riscv64/LIR-riscv64.h @@ -43,22 +43,6 @@ class LDivPowTwoI : public LInstructionHelper<1, 1, 1> { MDiv* mir() const { return mir_->toDiv(); } }; -class LModI : public LBinaryMath<1> { - public: - LIR_HEADER(ModI); - - LModI(const LAllocation& lhs, const LAllocation& rhs, - const LDefinition& callTemp) - : LBinaryMath(classOpcode) { - setOperand(0, lhs); - setOperand(1, rhs); - setTemp(0, callTemp); - } - - const LDefinition* callTemp() { return getTemp(0); } - MMod* mir() const { return mir_->toMod(); } -}; - class LMulI : public LBinaryMath<0> { public: LIR_HEADER(MulI); diff --git a/js/src/jit/shared/LIR-shared.h b/js/src/jit/shared/LIR-shared.h index 56117effcda9b..cc6ec631aef34 100644 --- a/js/src/jit/shared/LIR-shared.h +++ b/js/src/jit/shared/LIR-shared.h @@ -2209,6 +2209,10 @@ const char* LDivI::extraName() const { } return mir()->canBeNegativeOverflow() ? "NegativeOverflow" : nullptr; } + +const char* LModI::extraName() const { + return mir()->isTruncated() ? "Truncated" : nullptr; +} #endif } // namespace jit diff --git a/js/src/jit/wasm32/LIR-wasm32.h b/js/src/jit/wasm32/LIR-wasm32.h index 8fe75ab13a335..3e034855526d9 100644 --- a/js/src/jit/wasm32/LIR-wasm32.h +++ b/js/src/jit/wasm32/LIR-wasm32.h @@ -26,16 +26,6 @@ class LDivPowTwoI : public LInstructionHelper<1, 1, 0> { int32_t shift() { MOZ_CRASH(); } MDiv* mir() const { MOZ_CRASH(); } }; -class LModI : public LBinaryMath<1> { - public: - LModI(const LAllocation&, const LAllocation&, const LDefinition&) - : LBinaryMath(Opcode::Invalid) { - MOZ_CRASH(); - } - - const LDefinition* callTemp() { MOZ_CRASH(); } - MMod* mir() const { MOZ_CRASH(); } -}; class LMulI : public LInstruction {}; diff --git a/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp b/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp index 7580f055fc65b..c006ccc4b621e 100644 --- a/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp +++ b/js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp @@ -1365,7 +1365,7 @@ void CodeGeneratorX86Shared::visitModOverflowCheck(ModOverflowCheck* ool) { } void CodeGenerator::visitModI(LModI* ins) { - Register remainder = ToRegister(ins->remainder()); + Register remainder = ToRegister(ins->output()); Register lhs = ToRegister(ins->lhs()); Register rhs = ToRegister(ins->rhs()); @@ -1373,7 +1373,7 @@ void CodeGenerator::visitModI(LModI* ins) { MOZ_ASSERT_IF(lhs != rhs, rhs != eax); MOZ_ASSERT(rhs != edx); MOZ_ASSERT(remainder == edx); - MOZ_ASSERT(ToRegister(ins->getTemp(0)) == eax); + MOZ_ASSERT(ToRegister(ins->temp0()) == eax); Label done; ReturnZero* ool = nullptr; diff --git a/js/src/jit/x86-shared/LIR-x86-shared.h b/js/src/jit/x86-shared/LIR-x86-shared.h index 855532d9897ab..e20d0ccd9e1d9 100644 --- a/js/src/jit/x86-shared/LIR-x86-shared.h +++ b/js/src/jit/x86-shared/LIR-x86-shared.h @@ -61,25 +61,6 @@ class LDivOrModConstantI : public LInstructionHelper<1, 1, 1> { } }; -class LModI : public LBinaryMath<1> { - public: - LIR_HEADER(ModI) - - LModI(const LAllocation& lhs, const LAllocation& rhs, const LDefinition& temp) - : LBinaryMath(classOpcode) { - setOperand(0, lhs); - setOperand(1, rhs); - setTemp(0, temp); - } - - const char* extraName() const { - return mir()->isTruncated() ? "Truncated" : nullptr; - } - - const LDefinition* remainder() { return getDef(0); } - MMod* mir() const { return mir_->toMod(); } -}; - // This class performs a simple x86 'div', yielding either a quotient or // remainder depending on whether this instruction is defined to output eax // (quotient) or edx (remainder).