X87: [turbofan] Add RoundUint32ToFloat32 operator to Turbofan.

port 187b3f2845 (r33796)

  original commit message:

BUG=

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

Cr-Commit-Position: refs/heads/master@{#33967}
This commit is contained in:
zhengxing.li 2016-02-14 17:30:20 -08:00 committed by Commit bot
parent d8122dc73e
commit d75ddc588e
3 changed files with 47 additions and 2 deletions

View File

@ -1114,6 +1114,49 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
} }
break; 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: { case kX87Int32ToFloat64: {
InstructionOperand* input = instr->InputAt(0); InstructionOperand* input = instr->InputAt(0);
DCHECK(input->IsRegister() || input->IsStackSlot()); DCHECK(input->IsRegister() || input->IsStackSlot());

View File

@ -54,6 +54,7 @@ namespace compiler {
V(X87Float64Min) \ V(X87Float64Min) \
V(X87Float64Abs) \ V(X87Float64Abs) \
V(X87Int32ToFloat32) \ V(X87Int32ToFloat32) \
V(X87Uint32ToFloat32) \
V(X87Int32ToFloat64) \ V(X87Int32ToFloat64) \
V(X87Float32ToFloat64) \ V(X87Float32ToFloat64) \
V(X87Uint32ToFloat64) \ V(X87Uint32ToFloat64) \
@ -86,7 +87,6 @@ namespace compiler {
V(X87Poke) \ V(X87Poke) \
V(X87StackCheck) V(X87StackCheck)
// Addressing modes represent the "shape" of inputs to an instruction. // Addressing modes represent the "shape" of inputs to an instruction.
// Many instructions support multiple addressing modes. Addressing modes // Many instructions support multiple addressing modes. Addressing modes
// are encoded into the InstructionCode of the instruction and tell the // are encoded into the InstructionCode of the instruction and tell the

View File

@ -664,7 +664,9 @@ void InstructionSelector::VisitRoundInt32ToFloat32(Node* node) {
void InstructionSelector::VisitRoundUint32ToFloat32(Node* node) { void InstructionSelector::VisitRoundUint32ToFloat32(Node* node) {
UNIMPLEMENTED(); X87OperandGenerator g(this);
Emit(kX87Uint32ToFloat32, g.DefineAsFixed(node, stX_0),
g.Use(node->InputAt(0)));
} }