Revision: 20160
Author:   [email protected]
Date:     Fri Mar 21 12:16:37 2014 UTC
Log: Add a utility method to the ia32 macro assembler to move a double immediate into an XMM register.

[email protected]
BUG=

Review URL: https://codereview.chromium.org/197233011
http://code.google.com/p/v8/source/detail?r=20160

Modified:
 /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc
 /branches/bleeding_edge/src/ia32/macro-assembler-ia32.h
 /branches/bleeding_edge/test/cctest/test-macro-assembler-ia32.cc

=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Wed Mar 19 07:01:08 2014 UTC +++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Fri Mar 21 12:16:37 2014 UTC
@@ -2854,6 +2854,23 @@
     mov(dst, imm);
   }
 }
+
+
+void MacroAssembler::Move(XMMRegister dst, double val) {
+  // TODO(titzer): recognize double constants with ExternalReferences.
+  CpuFeatureScope scope(this, SSE2);
+  uint64_t int_val = BitCast<uint64_t, double>(val);
+  if (int_val == 0) {
+    xorps(dst, dst);
+  } else {
+    int32_t lower = static_cast<int32_t>(int_val);
+    int32_t upper = static_cast<int32_t>(int_val >> kBitsPerInt);
+    push(Immediate(upper));
+    push(Immediate(lower));
+    movsd(dst, Operand(esp, 0));
+    add(esp, Immediate(kDoubleSize));
+  }
+}


 void MacroAssembler::SetCounter(StatsCounter* counter, int value) {
=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.h Wed Mar 19 07:01:08 2014 UTC +++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.h Fri Mar 21 12:16:37 2014 UTC
@@ -850,6 +850,9 @@
   // Move a constant into a register using the most efficient encoding.
   void Move(Register dst, Immediate imm);

+  // Move an immediate into an XMM register.
+  void Move(XMMRegister dst, double val);
+
   // Push a handle value.
   void Push(Handle<Object> handle) { push(Immediate(handle)); }
   void Push(Smi* smi) { Push(Handle<Smi>(smi, isolate())); }
=======================================
--- /branches/bleeding_edge/test/cctest/test-macro-assembler-ia32.cc Tue Mar 11 08:52:48 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-macro-assembler-ia32.cc Fri Mar 21 12:16:37 2014 UTC
@@ -123,6 +123,23 @@
   __ j(not_equal, &exit);

   // Test 5.
+  if (CpuFeatures::IsSupported(SSE2)) {
+    CpuFeatureScope scope(masm, SSE2);
+    __ mov(eax, Immediate(5));  // Test XMM move immediate.
+    __ Move(xmm0, 0.0);
+    __ Move(xmm1, 0.0);
+    __ ucomisd(xmm0, xmm1);
+    __ j(not_equal, &exit);
+    __ Move(xmm2, 991.01);
+    __ ucomisd(xmm0, xmm2);
+    __ j(equal, &exit);
+    __ Move(xmm0, 991.01);
+    __ ucomisd(xmm0, xmm2);
+    __ j(not_equal, &exit);
+  }
+
+  // Test 6.
+  __ mov(eax, Immediate(6));
   __ Move(edx, Immediate(0));  // Test Move()
   __ cmp(edx, Immediate(0));
   __ j(not_equal, &exit);

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to