зеркало из https://github.com/mozilla/gecko-dev.git
Bug 913282: More Float32 operators: Sqrt; p=dougc,bbouvier, r=jonco,nbp
dougc for the ARM parts, bbouvier for the rest
This commit is contained in:
Родитель
29b722167c
Коммит
10f5a55e22
|
@ -301,6 +301,7 @@ private:
|
|||
OP2_DIVSD_VsdWsd = 0x5E,
|
||||
OP2_MAXSD_VsdWsd = 0x5F,
|
||||
OP2_SQRTSD_VsdWsd = 0x51,
|
||||
OP2_SQRTSS_VssWss = 0x51,
|
||||
OP2_ANDPD_VpdWpd = 0x54,
|
||||
OP2_ORPD_VpdWpd = 0x56,
|
||||
OP2_XORPD_VpdWpd = 0x57,
|
||||
|
@ -2906,6 +2907,14 @@ public:
|
|||
m_formatter.twoByteOp(OP2_SQRTSD_VsdWsd, (RegisterID)dst, (RegisterID)src);
|
||||
}
|
||||
|
||||
void sqrtss_rr(XMMRegisterID src, XMMRegisterID dst)
|
||||
{
|
||||
spew("sqrtss %s, %s",
|
||||
nameFPReg(src), nameFPReg(dst));
|
||||
m_formatter.prefix(PRE_SSE_F3);
|
||||
m_formatter.twoByteOp(OP2_SQRTSS_VssWss, (RegisterID)dst, (RegisterID)src);
|
||||
}
|
||||
|
||||
void roundsd_rr(XMMRegisterID src, XMMRegisterID dst, RoundingMode mode)
|
||||
{
|
||||
spew("roundsd %s, %s, %d",
|
||||
|
|
|
@ -2303,6 +2303,16 @@ class LSqrtD : public LInstructionHelper<1, 1, 0>
|
|||
}
|
||||
};
|
||||
|
||||
// Square root of a float32.
|
||||
class LSqrtF : public LInstructionHelper<1, 1, 0>
|
||||
{
|
||||
public:
|
||||
LIR_HEADER(SqrtF)
|
||||
LSqrtF(const LAllocation &num) {
|
||||
setOperand(0, num);
|
||||
}
|
||||
};
|
||||
|
||||
class LAtan2D : public LCallInstructionHelper<1, 2, 1>
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -102,6 +102,7 @@
|
|||
_(AbsI) \
|
||||
_(AbsD) \
|
||||
_(SqrtD) \
|
||||
_(SqrtF) \
|
||||
_(Atan2D) \
|
||||
_(PowI) \
|
||||
_(PowD) \
|
||||
|
|
|
@ -1185,8 +1185,13 @@ bool
|
|||
LIRGenerator::visitSqrt(MSqrt *ins)
|
||||
{
|
||||
MDefinition *num = ins->num();
|
||||
JS_ASSERT(num->type() == MIRType_Double);
|
||||
LSqrtD *lir = new LSqrtD(useRegisterAtStart(num));
|
||||
JS_ASSERT(IsFloatingPointType(num->type()));
|
||||
if (num->type() == MIRType_Double) {
|
||||
LSqrtD *lir = new LSqrtD(useRegisterAtStart(num));
|
||||
return define(lir, ins);
|
||||
}
|
||||
|
||||
LSqrtF *lir = new LSqrtF(useRegisterAtStart(num));
|
||||
return define(lir, ins);
|
||||
}
|
||||
|
||||
|
|
|
@ -2729,6 +2729,18 @@ MAsmJSCall::New(Callee callee, const Args &args, MIRType resultType, size_t spIn
|
|||
return call;
|
||||
}
|
||||
|
||||
void
|
||||
MSqrt::trySpecializeFloat32() {
|
||||
if (!input()->canProduceFloat32() || !CheckUsesAreFloat32Consumers(this)) {
|
||||
if (input()->type() == MIRType_Float32)
|
||||
ConvertDefinitionToDouble<0>(input(), this);
|
||||
return;
|
||||
}
|
||||
|
||||
setResultType(MIRType_Float32);
|
||||
setPolicyType(MIRType_Float32);
|
||||
}
|
||||
|
||||
bool
|
||||
jit::ElementAccessIsDenseNative(MDefinition *obj, MDefinition *id)
|
||||
{
|
||||
|
|
|
@ -3455,23 +3455,24 @@ class MAbs
|
|||
// Inline implementation of Math.sqrt().
|
||||
class MSqrt
|
||||
: public MUnaryInstruction,
|
||||
public DoublePolicy<0>
|
||||
public FloatingPointPolicy<0>
|
||||
{
|
||||
MSqrt(MDefinition *num)
|
||||
MSqrt(MDefinition *num, MIRType type)
|
||||
: MUnaryInstruction(num)
|
||||
{
|
||||
setResultType(MIRType_Double);
|
||||
setResultType(type);
|
||||
setPolicyType(type);
|
||||
setMovable();
|
||||
}
|
||||
|
||||
public:
|
||||
INSTRUCTION_HEADER(Sqrt)
|
||||
static MSqrt *New(MDefinition *num) {
|
||||
return new MSqrt(num);
|
||||
return new MSqrt(num, MIRType_Double);
|
||||
}
|
||||
static MSqrt *NewAsmJS(MDefinition *num, MIRType type) {
|
||||
JS_ASSERT(type == MIRType_Double);
|
||||
return new MSqrt(num);
|
||||
JS_ASSERT(IsFloatingPointType(type));
|
||||
return new MSqrt(num, type);
|
||||
}
|
||||
MDefinition *num() const {
|
||||
return getOperand(0);
|
||||
|
@ -3487,6 +3488,9 @@ class MSqrt
|
|||
return AliasSet::None();
|
||||
}
|
||||
void computeRange();
|
||||
|
||||
bool isFloat32Commutative() const { return true; }
|
||||
void trySpecializeFloat32();
|
||||
};
|
||||
|
||||
// Inline implementation of atan2 (arctangent of y/x).
|
||||
|
|
|
@ -348,6 +348,15 @@ CodeGeneratorARM::visitSqrtD(LSqrtD *ins)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CodeGeneratorARM::visitSqrtF(LSqrtF *ins)
|
||||
{
|
||||
FloatRegister input = ToFloatRegister(ins->input());
|
||||
FloatRegister output = ToFloatRegister(ins->output());
|
||||
masm.ma_vsqrt_f32(input, output);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CodeGeneratorARM::visitAddI(LAddI *ins)
|
||||
{
|
||||
|
|
|
@ -67,6 +67,7 @@ class CodeGeneratorARM : public CodeGeneratorShared
|
|||
virtual bool visitMinMaxD(LMinMaxD *ins);
|
||||
virtual bool visitAbsD(LAbsD *ins);
|
||||
virtual bool visitSqrtD(LSqrtD *ins);
|
||||
virtual bool visitSqrtF(LSqrtF *ins);
|
||||
virtual bool visitAddI(LAddI *ins);
|
||||
virtual bool visitSubI(LSubI *ins);
|
||||
virtual bool visitBitNotI(LBitNotI *ins);
|
||||
|
|
|
@ -1431,6 +1431,12 @@ MacroAssemblerARM::ma_vsqrt(FloatRegister src, FloatRegister dest, Condition cc)
|
|||
as_vsqrt(dest, src, cc);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssemblerARM::ma_vsqrt_f32(FloatRegister src, FloatRegister dest, Condition cc)
|
||||
{
|
||||
as_vsqrt(VFPRegister(dest).singleOverlay(), VFPRegister(src).singleOverlay(), cc);
|
||||
}
|
||||
|
||||
union DoublePun
|
||||
{
|
||||
struct
|
||||
|
|
|
@ -319,6 +319,7 @@ class MacroAssemblerARM : public Assembler
|
|||
void ma_vabs(FloatRegister src, FloatRegister dest, Condition cc = Always);
|
||||
|
||||
void ma_vsqrt(FloatRegister src, FloatRegister dest, Condition cc = Always);
|
||||
void ma_vsqrt_f32(FloatRegister src, FloatRegister dest, Condition cc = Always);
|
||||
|
||||
void ma_vimm(double value, FloatRegister dest, Condition cc = Always);
|
||||
void ma_vimm_f32(float value, FloatRegister dest, Condition cc = Always);
|
||||
|
|
|
@ -1452,6 +1452,10 @@ class AssemblerX86Shared
|
|||
JS_ASSERT(HasSSE2());
|
||||
masm.sqrtsd_rr(src.code(), dest.code());
|
||||
}
|
||||
void sqrtss(const FloatRegister &src, const FloatRegister &dest) {
|
||||
JS_ASSERT(HasSSE2());
|
||||
masm.sqrtss_rr(src.code(), dest.code());
|
||||
}
|
||||
void roundsd(const FloatRegister &src, const FloatRegister &dest,
|
||||
JSC::X86Assembler::RoundingMode mode)
|
||||
{
|
||||
|
|
|
@ -482,6 +482,15 @@ CodeGeneratorX86Shared::visitSqrtD(LSqrtD *ins)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CodeGeneratorX86Shared::visitSqrtF(LSqrtF *ins)
|
||||
{
|
||||
FloatRegister input = ToFloatRegister(ins->input());
|
||||
FloatRegister output = ToFloatRegister(ins->output());
|
||||
masm.sqrtss(input, output);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CodeGeneratorX86Shared::visitPowHalfD(LPowHalfD *ins)
|
||||
{
|
||||
|
|
|
@ -83,6 +83,7 @@ class CodeGeneratorX86Shared : public CodeGeneratorShared
|
|||
virtual bool visitMinMaxD(LMinMaxD *ins);
|
||||
virtual bool visitAbsD(LAbsD *ins);
|
||||
virtual bool visitSqrtD(LSqrtD *ins);
|
||||
virtual bool visitSqrtF(LSqrtF *ins);
|
||||
virtual bool visitPowHalfD(LPowHalfD *ins);
|
||||
virtual bool visitAddI(LAddI *ins);
|
||||
virtual bool visitSubI(LSubI *ins);
|
||||
|
|
Загрузка…
Ссылка в новой задаче