Commit 4953b17c authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [builtins] Introduce proper Float64Atan and Float64Atan2 operators.

  port 89d8c57b (r36916)

  original commit message:
  Import base::ieee754::atan() and base::ieee754::atan2() from fdlibm and
  introduce Float64Atan and Float64Atan2 TurboFan operators based on those,
  similar to what we already did for Float64Log and Float64Log1p. Rewrite
  Math.atan() and Math.atan2() as TurboFan builtin and use the operators
  to also inline Math.atan() and Math.atan2() into optimized TurboFan functions.

BUG=

Review-Url: https://codereview.chromium.org/2093423003
Cr-Commit-Position: refs/heads/master@{#37262}
parent 8ac5a457
......@@ -370,6 +370,30 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
} \
} while (0)
#define ASSEMBLE_IEEE754_BINOP(name) \
do { \
/* Saves the esp into ebx */ \
__ push(ebx); \
__ mov(ebx, esp); \
/* Pass one double as argument on the stack. */ \
__ PrepareCallCFunction(4, eax); \
__ fstp(0); \
/* Load first operand from original stack */ \
__ fld_d(MemOperand(ebx, 4 + kDoubleSize)); \
/* Put first operand into stack for function call */ \
__ fstp_d(Operand(esp, 0 * kDoubleSize)); \
/* Load second operand from original stack */ \
__ fld_d(MemOperand(ebx, 4)); \
/* Put second operand into stack for function call */ \
__ fstp_d(Operand(esp, 1 * kDoubleSize)); \
__ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \
4); \
/* Restore the ebx */ \
__ pop(ebx); \
/* Return value is in st(0) on x87. */ \
__ lea(esp, Operand(esp, 2 * kDoubleSize)); \
} while (false)
#define ASSEMBLE_IEEE754_UNOP(name) \
do { \
/* Saves the esp into ebx */ \
......@@ -723,6 +747,12 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ lea(i.OutputRegister(), Operand(base, offset.offset()));
break;
}
case kIeee754Float64Atan:
ASSEMBLE_IEEE754_UNOP(atan);
break;
case kIeee754Float64Atan2:
ASSEMBLE_IEEE754_BINOP(atan2);
break;
case kIeee754Float64Log:
ASSEMBLE_IEEE754_UNOP(log);
break;
......
......@@ -1087,6 +1087,14 @@ void InstructionSelector::VisitFloat32Neg(Node* node) { UNREACHABLE(); }
void InstructionSelector::VisitFloat64Neg(Node* node) { UNREACHABLE(); }
void InstructionSelector::VisitFloat64Ieee754Binop(Node* node,
InstructionCode opcode) {
X87OperandGenerator g(this);
Emit(kX87PushFloat64, g.NoOutput(), g.Use(node->InputAt(0)));
Emit(kX87PushFloat64, g.NoOutput(), g.Use(node->InputAt(1)));
Emit(opcode, g.DefineAsFixed(node, stX_0), 0, nullptr)->MarkAsCall();
}
void InstructionSelector::VisitFloat64Ieee754Unop(Node* node,
InstructionCode opcode) {
X87OperandGenerator g(this);
......
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