Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: src/compiler/x87/code-generator-x87.cc

Issue 1700583002: X87: [turbofan] Add RoundUint32ToFloat32 operator to Turbofan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/compiler/x87/instruction-codes-x87.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/x87/code-generator-x87.cc
diff --git a/src/compiler/x87/code-generator-x87.cc b/src/compiler/x87/code-generator-x87.cc
index a2dacd3ebc328c725be36a6c0ac70717faf8a065..30da40b1739beeee5f31ccbfae77e541e603c6da 100644
--- a/src/compiler/x87/code-generator-x87.cc
+++ b/src/compiler/x87/code-generator-x87.cc
@@ -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());
« no previous file with comments | « no previous file | src/compiler/x87/instruction-codes-x87.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698