diff --git a/js/src/ion/shared/Lowering-x86-shared.cpp b/js/src/ion/shared/Lowering-x86-shared.cpp index 5a3a3dde8f9..46a71d4c503 100644 --- a/js/src/ion/shared/Lowering-x86-shared.cpp +++ b/js/src/ion/shared/Lowering-x86-shared.cpp @@ -70,6 +70,39 @@ LIRGeneratorX86Shared::visitPowHalf(MPowHalf *ins) return defineReuseInput(lir, ins, 0); } +bool +LIRGeneratorX86Shared::lowerForShift(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, + MDefinition *lhs, MDefinition *rhs) +{ + ins->setOperand(0, useRegisterAtStart(lhs)); + + // shift operator should be constant or in register ecx + // x86 can't shift a non-ecx register + if (rhs->isConstant()) + ins->setOperand(1, useOrConstant(rhs)); + else + ins->setOperand(1, useFixed(rhs, ecx)); + + return defineReuseInput(ins, mir, 0); +} + +bool +LIRGeneratorX86Shared::lowerForALU(LInstructionHelper<1, 1, 0> *ins, MDefinition *mir, + MDefinition *input) +{ + ins->setOperand(0, useRegisterAtStart(input)); + return defineReuseInput(ins, mir, 0); +} + +bool +LIRGeneratorX86Shared::lowerForALU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, + MDefinition *lhs, MDefinition *rhs) +{ + ins->setOperand(0, useRegisterAtStart(lhs)); + ins->setOperand(1, useOrConstant(rhs)); + return defineReuseInput(ins, mir, 0); +} + bool LIRGeneratorX86Shared::lowerMulI(MMul *mul, MDefinition *lhs, MDefinition *rhs) { @@ -198,3 +231,12 @@ LIRGeneratorX86Shared::visitConstant(MConstant *ins) return LIRGeneratorShared::visitConstant(ins); } +bool +LIRGeneratorX86Shared::lowerTruncateDToInt32(MTruncateToInt32 *ins) +{ + MDefinition *opd = ins->input(); + JS_ASSERT(opd->type() == MIRType_Double); + + LDefinition maybeTemp = Assembler::HasSSE3() ? LDefinition::BogusTemp() : tempFloat(); + return define(new LTruncateDToInt32(useRegister(opd), maybeTemp), ins); +} diff --git a/js/src/ion/shared/Lowering-x86-shared.h b/js/src/ion/shared/Lowering-x86-shared.h index 7a299269937..d7c450bdd14 100644 --- a/js/src/ion/shared/Lowering-x86-shared.h +++ b/js/src/ion/shared/Lowering-x86-shared.h @@ -27,6 +27,11 @@ class LIRGeneratorX86Shared : public LIRGeneratorShared bool visitGuardShape(MGuardShape *ins); bool visitGuardObjectType(MGuardObjectType *ins); bool visitPowHalf(MPowHalf *ins); + bool lowerForShift(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, + MDefinition *rhs); + bool lowerForALU(LInstructionHelper<1, 1, 0> *ins, MDefinition *mir, MDefinition *input); + bool lowerForALU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, + MDefinition *rhs); bool visitConstant(MConstant *ins); bool visitAsmJSNeg(MAsmJSNeg *ins); bool visitAsmJSUDiv(MAsmJSUDiv *ins); @@ -36,6 +41,7 @@ class LIRGeneratorX86Shared : public LIRGeneratorShared bool lowerModI(MMod *mod); bool lowerUrshD(MUrsh *mir); bool lowerConstantDouble(double d, MInstruction *ins); + bool lowerTruncateDToInt32(MTruncateToInt32 *ins); }; } // namespace ion diff --git a/js/src/ion/x64/Lowering-x64.cpp b/js/src/ion/x64/Lowering-x64.cpp index 99086a0edc1..e3ea4adb0a8 100644 --- a/js/src/ion/x64/Lowering-x64.cpp +++ b/js/src/ion/x64/Lowering-x64.cpp @@ -4,8 +4,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "ion/MIR.h" #include "Lowering-x64.h" + +#include "ion/MIR.h" #include "Assembler-x64.h" #include "ion/shared/Lowering-shared-inl.h" @@ -78,36 +79,6 @@ LIRGeneratorX64::visitReturn(MReturn *ret) return add(ins); } -bool -LIRGeneratorX64::lowerForShift(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, MDefinition *rhs) -{ - ins->setOperand(0, useRegisterAtStart(lhs)); - - // shift operator should be constant or in register rcx - // x86 can't shift a non-ecx register - if (rhs->isConstant()) - ins->setOperand(1, useOrConstant(rhs)); - else - ins->setOperand(1, useFixed(rhs, rcx)); - - return defineReuseInput(ins, mir, 0); -} - -bool -LIRGeneratorX64::lowerForALU(LInstructionHelper<1, 1, 0> *ins, MDefinition *mir, MDefinition *input) -{ - ins->setOperand(0, useRegisterAtStart(input)); - return defineReuseInput(ins, mir, 0); -} - -bool -LIRGeneratorX64::lowerForALU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, MDefinition *rhs) -{ - ins->setOperand(0, useRegisterAtStart(lhs)); - ins->setOperand(1, useOrConstant(rhs)); - return defineReuseInput(ins, mir, 0); -} - bool LIRGeneratorX64::lowerForFPU(LMathD *ins, MDefinition *mir, MDefinition *lhs, MDefinition *rhs) { @@ -206,15 +177,6 @@ LIRGeneratorX64::newLGetPropertyCacheT(MGetPropertyCache *ins) return new LGetPropertyCacheT(useRegister(ins->object()), LDefinition::BogusTemp()); } -bool -LIRGeneratorX64::lowerTruncateDToInt32(MTruncateToInt32 *ins) -{ - MDefinition *opd = ins->input(); - JS_ASSERT(opd->type() == MIRType_Double); - - return define(new LTruncateDToInt32(useRegister(opd), LDefinition::BogusTemp()), ins); -} - bool LIRGeneratorX64::visitStoreTypedArrayElementStatic(MStoreTypedArrayElementStatic *ins) { diff --git a/js/src/ion/x64/Lowering-x64.h b/js/src/ion/x64/Lowering-x64.h index 3e781088020..6d49b121878 100644 --- a/js/src/ion/x64/Lowering-x64.h +++ b/js/src/ion/x64/Lowering-x64.h @@ -28,16 +28,8 @@ class LIRGeneratorX64 : public LIRGeneratorX86Shared LUse::Policy policy = LUse::REGISTER, bool useAtStart = false); bool useBoxFixed(LInstruction *lir, size_t n, MDefinition *mir, Register reg1, Register); - bool lowerForShift(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, - MDefinition *rhs); - - bool lowerForALU(LInstructionHelper<1, 1, 0> *ins, MDefinition *mir, MDefinition *input); - bool lowerForALU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, - MDefinition *rhs); bool lowerForFPU(LMathD *ins, MDefinition *mir, MDefinition *lhs, MDefinition *rhs); - bool lowerTruncateDToInt32(MTruncateToInt32 *ins); - LGetPropertyCacheT *newLGetPropertyCacheT(MGetPropertyCache *ins); public: diff --git a/js/src/ion/x86/Lowering-x86.cpp b/js/src/ion/x86/Lowering-x86.cpp index c477b1a549e..b540435083d 100644 --- a/js/src/ion/x86/Lowering-x86.cpp +++ b/js/src/ion/x86/Lowering-x86.cpp @@ -4,8 +4,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "Lowering-x86.h" + #include "ion/MIR.h" -#include "ion/Lowering.h" #include "Assembler-x86.h" #include "ion/shared/Lowering-shared-inl.h" @@ -124,36 +125,6 @@ LIRGeneratorX86::visitReturn(MReturn *ret) return fillBoxUses(ins, 0, opd) && add(ins); } -bool -LIRGeneratorX86::lowerForShift(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, MDefinition *rhs) -{ - ins->setOperand(0, useRegisterAtStart(lhs)); - - // shift operator should be constant or in register ecx - // x86 can't shift a non-ecx register - if (rhs->isConstant()) - ins->setOperand(1, useOrConstant(rhs)); - else - ins->setOperand(1, useFixed(rhs, ecx)); - - return defineReuseInput(ins, mir, 0); -} - -bool -LIRGeneratorX86::lowerForALU(LInstructionHelper<1, 1, 0> *ins, MDefinition *mir, MDefinition *input) -{ - ins->setOperand(0, useRegisterAtStart(input)); - return defineReuseInput(ins, mir, 0); -} - -bool -LIRGeneratorX86::lowerForALU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, MDefinition *rhs) -{ - ins->setOperand(0, useRegisterAtStart(lhs)); - ins->setOperand(1, useOrConstant(rhs)); - return defineReuseInput(ins, mir, 0); -} - bool LIRGeneratorX86::lowerForFPU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, MDefinition *rhs) { @@ -323,13 +294,3 @@ LIRGeneratorX86::newLGetPropertyCacheT(MGetPropertyCache *ins) scratch = LDefinition::BogusTemp(); return new LGetPropertyCacheT(useRegister(ins->object()), scratch); } - -bool -LIRGeneratorX86::lowerTruncateDToInt32(MTruncateToInt32 *ins) -{ - MDefinition *opd = ins->input(); - JS_ASSERT(opd->type() == MIRType_Double); - - LDefinition maybeTemp = Assembler::HasSSE3() ? LDefinition::BogusTemp() : tempFloat(); - return define(new LTruncateDToInt32(useRegister(opd), maybeTemp), ins); -} diff --git a/js/src/ion/x86/Lowering-x86.h b/js/src/ion/x86/Lowering-x86.h index d870ea6784c..29560ca21af 100644 --- a/js/src/ion/x86/Lowering-x86.h +++ b/js/src/ion/x86/Lowering-x86.h @@ -29,17 +29,9 @@ class LIRGeneratorX86 : public LIRGeneratorX86Shared void lowerUntypedPhiInput(MPhi *phi, uint32_t inputPosition, LBlock *block, size_t lirIndex); bool defineUntypedPhi(MPhi *phi, size_t lirIndex); - bool lowerForShift(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, - MDefinition *rhs); - - bool lowerForALU(LInstructionHelper<1, 1, 0> *ins, MDefinition *mir, MDefinition *input); - bool lowerForALU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, - MDefinition *rhs); bool lowerForFPU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, MDefinition *rhs); - bool lowerTruncateDToInt32(MTruncateToInt32 *ins); - LGetPropertyCacheT *newLGetPropertyCacheT(MGetPropertyCache *ins); public: