X87: [turbofan] Add support for reinterpreting integers as floating point and vice...
authorchunyang.dai <chunyang.dai@intel.com>
Thu, 24 Sep 2015 03:43:42 +0000 (20:43 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 24 Sep 2015 03:43:56 +0000 (03:43 +0000)
port c610a22231212b12055c294f55b8f3942127580b (r30849).

original commit message:

BUG=

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

Cr-Commit-Position: refs/heads/master@{#30898}

src/compiler/x87/code-generator-x87.cc
src/compiler/x87/instruction-codes-x87.h
src/compiler/x87/instruction-selector-x87.cc

index 4f90a80..9ca9a30 100644 (file)
@@ -1069,6 +1069,28 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
       }
       break;
     }
+    case kX87BitcastFI: {
+      __ fstp(0);
+      __ mov(i.OutputRegister(), MemOperand(esp, 0));
+      __ lea(esp, Operand(esp, kFloatSize));
+      break;
+    }
+    case kX87BitcastIF: {
+      if (instr->InputAt(0)->IsRegister()) {
+        __ lea(esp, Operand(esp, -kFloatSize));
+        __ mov(MemOperand(esp, 0), i.InputRegister(0));
+        __ fstp(0);
+        __ fld_s(MemOperand(esp, 0));
+        __ lea(esp, Operand(esp, kFloatSize));
+      } else {
+        __ lea(esp, Operand(esp, -kDoubleSize));
+        __ mov(MemOperand(esp, 0), i.InputRegister(0));
+        __ fstp(0);
+        __ fld_d(MemOperand(esp, 0));
+        __ lea(esp, Operand(esp, kDoubleSize));
+      }
+      break;
+    }
     case kX87Lea: {
       AddressingMode mode = AddressingModeField::decode(instr->opcode());
       // Shorten "leal" to "addl", "subl" or "shll" if the register allocation
index d1b759b..9408e41 100644 (file)
@@ -74,6 +74,8 @@ namespace compiler {
   V(X87Movss)                      \
   V(X87Movsd)                      \
   V(X87Lea)                        \
+  V(X87BitcastFI)                  \
+  V(X87BitcastIF)                  \
   V(X87Push)                       \
   V(X87PushFloat64)                \
   V(X87PushFloat32)                \
index 2051b14..ac868fb 100644 (file)
@@ -665,12 +665,15 @@ void InstructionSelector::VisitTruncateFloat64ToInt32(Node* node) {
 
 
 void InstructionSelector::VisitBitcastFloat32ToInt32(Node* node) {
-  UNIMPLEMENTED();
+  X87OperandGenerator g(this);
+  Emit(kX87PushFloat32, g.NoOutput(), g.Use(node->InputAt(0)));
+  Emit(kX87BitcastFI, g.DefineAsRegister(node), 0, NULL);
 }
 
 
 void InstructionSelector::VisitBitcastInt32ToFloat32(Node* node) {
-  UNIMPLEMENTED();
+  X87OperandGenerator g(this);
+  Emit(kX87BitcastIF, g.DefineAsFixed(node, stX_0), g.Use(node->InputAt(0)));
 }