Commit d75ddc58 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [turbofan] Add RoundUint32ToFloat32 operator to Turbofan.

  port 187b3f28 (r33796)

  original commit message:

BUG=

Review URL: https://codereview.chromium.org/1700583002

Cr-Commit-Position: refs/heads/master@{#33967}
parent d8122dc7
......@@ -1114,6 +1114,49 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
}
break;
}
case kX87Uint32ToFloat32: {
InstructionOperand* input = instr->InputAt(0);
DCHECK(input->IsRegister() || input->IsStackSlot());
if (FLAG_debug_code && FLAG_enable_slow_asserts) {
__ VerifyX87StackDepth(1);
}
__ fstp(0);
Label msb_set_src;
Label jmp_return;
// Put input integer into eax(tmporarilly)
__ push(eax);
if (input->IsRegister())
__ mov(eax, i.InputRegister(0));
else
__ mov(eax, i.InputOperand(0));
__ test(eax, eax);
__ j(sign, &msb_set_src, Label::kNear);
__ push(eax);
__ fild_s(Operand(esp, 0));
__ pop(eax);
__ jmp(&jmp_return, Label::kNear);
__ bind(&msb_set_src);
// Need another temp reg
__ push(ebx);
__ mov(ebx, eax);
__ shr(eax, 1);
// Recover the least significant bit to avoid rounding errors.
__ and_(ebx, Immediate(1));
__ or_(eax, ebx);
__ push(eax);
__ fild_s(Operand(esp, 0));
__ pop(eax);
__ fld(0);
__ faddp();
// Restore the ebx
__ pop(ebx);
__ bind(&jmp_return);
// Restore the eax
__ pop(eax);
break;
}
case kX87Int32ToFloat64: {
InstructionOperand* input = instr->InputAt(0);
DCHECK(input->IsRegister() || input->IsStackSlot());
......
......@@ -54,6 +54,7 @@ namespace compiler {
V(X87Float64Min) \
V(X87Float64Abs) \
V(X87Int32ToFloat32) \
V(X87Uint32ToFloat32) \
V(X87Int32ToFloat64) \
V(X87Float32ToFloat64) \
V(X87Uint32ToFloat64) \
......@@ -86,7 +87,6 @@ namespace compiler {
V(X87Poke) \
V(X87StackCheck)
// Addressing modes represent the "shape" of inputs to an instruction.
// Many instructions support multiple addressing modes. Addressing modes
// are encoded into the InstructionCode of the instruction and tell the
......
......@@ -664,7 +664,9 @@ void InstructionSelector::VisitRoundInt32ToFloat32(Node* node) {
void InstructionSelector::VisitRoundUint32ToFloat32(Node* node) {
UNIMPLEMENTED();
X87OperandGenerator g(this);
Emit(kX87Uint32ToFloat32, g.DefineAsFixed(node, stX_0),
g.Use(node->InputAt(0)));
}
......
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