Bug 870149 - Move common x86/x64 lowering code to x86-shared. r=h4writer

This commit is contained in:
Sean Stangl 2013-05-08 16:00:03 -07:00
parent 93abe3a25f
commit 213d85c004
6 changed files with 52 additions and 97 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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)
{

View File

@ -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:

View File

@ -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);
}

View File

@ -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: