Commit f7e7c32d authored by bjaideep's avatar bjaideep Committed by Commit bot

PPC/s390: [builtins] Introduce proper Float64Cos and Float64Sin.

Port c781e831
Port 4d4eb611

Original commit message:

    Import base::ieee754::cos() and base::ieee754::sin() from fdlibm and
    introduce Float64Cos and Float64Sin TurboFan operator based on that,
    similar to what we do for Float64Log. Rewrite Math.cos() and Math.sin()
    as TurboFan builtins and use those operators to also inline Math.cos()
    and Math.sin() into optimized TurboFan functions.

    Unify Atanh, Cbrt and Expm1 as exports from flibm.

R=bmeurer@chromium.org, mvstanton@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, mbrandy@us.ibm.com

BUG=v8:5086,v8:5118,v8:5103
LOG=N

Review-Url: https://codereview.chromium.org/2078273002
Cr-Commit-Position: refs/heads/master@{#37083}
parent 8e168b06
......@@ -1263,9 +1263,24 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kIeee754Float64Atan2:
ASSEMBLE_IEEE754_BINOP(atan2);
break;
case kIeee754Float64Cbrt:
ASSEMBLE_IEEE754_UNOP(cbrt);
break;
case kIeee754Float64Sin:
ASSEMBLE_IEEE754_UNOP(sin);
break;
case kIeee754Float64Cos:
ASSEMBLE_IEEE754_UNOP(cos);
break;
case kIeee754Float64Exp:
ASSEMBLE_IEEE754_UNOP(exp);
break;
case kIeee754Float64Expm1:
ASSEMBLE_IEEE754_UNOP(expm1);
break;
case kIeee754Float64Atanh:
ASSEMBLE_IEEE754_UNOP(atanh);
break;
case kIeee754Float64Log:
ASSEMBLE_IEEE754_UNOP(log);
break;
......
......@@ -1252,9 +1252,24 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kIeee754Float64Atan2:
ASSEMBLE_IEEE754_BINOP(atan2);
break;
case kIeee754Float64Cbrt:
ASSEMBLE_IEEE754_UNOP(cbrt);
break;
case kIeee754Float64Sin:
ASSEMBLE_IEEE754_UNOP(sin);
break;
case kIeee754Float64Cos:
ASSEMBLE_IEEE754_UNOP(cos);
break;
case kIeee754Float64Exp:
ASSEMBLE_IEEE754_UNOP(exp);
break;
case kIeee754Float64Expm1:
ASSEMBLE_IEEE754_UNOP(expm1);
break;
case kIeee754Float64Atanh:
ASSEMBLE_IEEE754_UNOP(atanh);
break;
case kIeee754Float64Log:
ASSEMBLE_IEEE754_UNOP(log);
break;
......
......@@ -3774,6 +3774,20 @@ void LCodeGen::DoPower(LPower* instr) {
}
}
void LCodeGen::DoMathCos(LMathCos* instr) {
__ PrepareCallCFunction(0, 1, scratch0());
__ MovToFloatParameter(ToDoubleRegister(instr->value()));
__ CallCFunction(ExternalReference::ieee754_cos_function(isolate()), 0, 1);
__ MovFromFloatResult(ToDoubleRegister(instr->result()));
}
void LCodeGen::DoMathSin(LMathSin* instr) {
__ PrepareCallCFunction(0, 1, scratch0());
__ MovToFloatParameter(ToDoubleRegister(instr->value()));
__ CallCFunction(ExternalReference::ieee754_sin_function(isolate()), 0, 1);
__ MovFromFloatResult(ToDoubleRegister(instr->result()));
}
void LCodeGen::DoMathExp(LMathExp* instr) {
__ PrepareCallCFunction(0, 1, scratch0());
__ MovToFloatParameter(ToDoubleRegister(instr->value()));
......
......@@ -1080,6 +1080,10 @@ LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
return DoMathAbs(instr);
case kMathLog:
return DoMathLog(instr);
case kMathCos:
return DoMathCos(instr);
case kMathSin:
return DoMathSin(instr);
case kMathExp:
return DoMathExp(instr);
case kMathSqrt:
......@@ -1157,6 +1161,19 @@ LInstruction* LChunkBuilder::DoMathClz32(HUnaryMathOperation* instr) {
return DefineAsRegister(result);
}
LInstruction* LChunkBuilder::DoMathCos(HUnaryMathOperation* instr) {
DCHECK(instr->representation().IsDouble());
DCHECK(instr->value()->representation().IsDouble());
LOperand* input = UseFixedDouble(instr->value(), d0);
return MarkAsCall(DefineFixedDouble(new (zone()) LMathCos(input), d0), instr);
}
LInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) {
DCHECK(instr->representation().IsDouble());
DCHECK(instr->value()->representation().IsDouble());
LOperand* input = UseFixedDouble(instr->value(), d0);
return MarkAsCall(DefineFixedDouble(new (zone()) LMathSin(input), d0), instr);
}
LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) {
DCHECK(instr->representation().IsDouble());
......
......@@ -98,6 +98,8 @@ class LCodeGen;
V(LoadNamedGeneric) \
V(MathAbs) \
V(MathClz32) \
V(MathCos) \
V(MathSin) \
V(MathExp) \
V(MathFloorD) \
V(MathFloorI) \
......@@ -901,6 +903,25 @@ class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
};
class LMathCos final : public LTemplateInstruction<1, 1, 0> {
public:
explicit LMathCos(LOperand* value) { inputs_[0] = value; }
LOperand* value() { return inputs_[0]; }
DECLARE_CONCRETE_INSTRUCTION(MathCos, "math-cos")
};
class LMathSin final : public LTemplateInstruction<1, 1, 0> {
public:
explicit LMathSin(LOperand* value) { inputs_[0] = value; }
LOperand* value() { return inputs_[0]; }
DECLARE_CONCRETE_INSTRUCTION(MathSin, "math-sin")
};
class LMathExp final : public LTemplateInstruction<1, 1, 0> {
public:
......@@ -2454,6 +2475,8 @@ class LChunkBuilder final : public LChunkBuilderBase {
LInstruction* DoMathFround(HUnaryMathOperation* instr);
LInstruction* DoMathAbs(HUnaryMathOperation* instr);
LInstruction* DoMathLog(HUnaryMathOperation* instr);
LInstruction* DoMathCos(HUnaryMathOperation* instr);
LInstruction* DoMathSin(HUnaryMathOperation* instr);
LInstruction* DoMathExp(HUnaryMathOperation* instr);
LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
......
......@@ -3669,6 +3669,20 @@ void LCodeGen::DoPower(LPower* instr) {
}
}
void LCodeGen::DoMathCos(LMathCos* instr) {
__ PrepareCallCFunction(0, 1, scratch0());
__ MovToFloatParameter(ToDoubleRegister(instr->value()));
__ CallCFunction(ExternalReference::ieee754_cos_function(isolate()), 0, 1);
__ MovFromFloatResult(ToDoubleRegister(instr->result()));
}
void LCodeGen::DoMathSin(LMathSin* instr) {
__ PrepareCallCFunction(0, 1, scratch0());
__ MovToFloatParameter(ToDoubleRegister(instr->value()));
__ CallCFunction(ExternalReference::ieee754_sin_function(isolate()), 0, 1);
__ MovFromFloatResult(ToDoubleRegister(instr->result()));
}
void LCodeGen::DoMathExp(LMathExp* instr) {
__ PrepareCallCFunction(0, 1, scratch0());
__ MovToFloatParameter(ToDoubleRegister(instr->value()));
......
......@@ -985,6 +985,10 @@ LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
return DoMathAbs(instr);
case kMathLog:
return DoMathLog(instr);
case kMathCos:
return DoMathCos(instr);
case kMathSin:
return DoMathSin(instr);
case kMathExp:
return DoMathExp(instr);
case kMathSqrt:
......@@ -1044,6 +1048,20 @@ LInstruction* LChunkBuilder::DoMathClz32(HUnaryMathOperation* instr) {
return DefineAsRegister(result);
}
LInstruction* LChunkBuilder::DoMathCos(HUnaryMathOperation* instr) {
DCHECK(instr->representation().IsDouble());
DCHECK(instr->value()->representation().IsDouble());
LOperand* input = UseFixedDouble(instr->value(), d0);
return MarkAsCall(DefineFixedDouble(new (zone()) LMathCos(input), d0), instr);
}
LInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) {
DCHECK(instr->representation().IsDouble());
DCHECK(instr->value()->representation().IsDouble());
LOperand* input = UseFixedDouble(instr->value(), d0);
return MarkAsCall(DefineFixedDouble(new (zone()) LMathSin(input), d0), instr);
}
LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) {
DCHECK(instr->representation().IsDouble());
DCHECK(instr->value()->representation().IsDouble());
......
......@@ -98,6 +98,8 @@ class LCodeGen;
V(LoadNamedGeneric) \
V(MathAbs) \
V(MathClz32) \
V(MathCos) \
V(MathSin) \
V(MathExp) \
V(MathFloor) \
V(MathFround) \
......@@ -836,6 +838,24 @@ class LMathClz32 final : public LTemplateInstruction<1, 1, 0> {
DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
};
class LMathCos final : public LTemplateInstruction<1, 1, 0> {
public:
explicit LMathCos(LOperand* value) { inputs_[0] = value; }
LOperand* value() { return inputs_[0]; }
DECLARE_CONCRETE_INSTRUCTION(MathCos, "math-cos")
};
class LMathSin final : public LTemplateInstruction<1, 1, 0> {
public:
explicit LMathSin(LOperand* value) { inputs_[0] = value; }
LOperand* value() { return inputs_[0]; }
DECLARE_CONCRETE_INSTRUCTION(MathSin, "math-sin")
};
class LMathExp final : public LTemplateInstruction<1, 1, 0> {
public:
explicit LMathExp(LOperand* value) { inputs_[0] = value; }
......@@ -2293,6 +2313,8 @@ class LChunkBuilder final : public LChunkBuilderBase {
LInstruction* DoMathFround(HUnaryMathOperation* instr);
LInstruction* DoMathAbs(HUnaryMathOperation* instr);
LInstruction* DoMathLog(HUnaryMathOperation* instr);
LInstruction* DoMathCos(HUnaryMathOperation* instr);
LInstruction* DoMathSin(HUnaryMathOperation* instr);
LInstruction* DoMathExp(HUnaryMathOperation* instr);
LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment