Reviewers: Michael Starzinger,

Description:
Add a utility method to the ia32 macro assembler to move a double immediate into
an XMM register.

[email protected]
BUG=

Please review this at https://codereview.chromium.org/197233011/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+37, -0 lines):
  M src/ia32/macro-assembler-ia32.h
  M src/ia32/macro-assembler-ia32.cc
  M test/cctest/test-macro-assembler-ia32.cc


Index: src/ia32/macro-assembler-ia32.cc
diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc index 4682b37b16e409c23b9e962f326198fd66d183a8..530c3f5c7c508805a44ce4f8a45991ccf67f03f6 100644
--- a/src/ia32/macro-assembler-ia32.cc
+++ b/src/ia32/macro-assembler-ia32.cc
@@ -2856,6 +2856,23 @@ void MacroAssembler::Move(Register dst, Immediate 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) {
   if (FLAG_native_code_counters && counter->Enabled()) {
mov(Operand::StaticVariable(ExternalReference(counter)), Immediate(value));
Index: src/ia32/macro-assembler-ia32.h
diff --git a/src/ia32/macro-assembler-ia32.h b/src/ia32/macro-assembler-ia32.h index d2c5c7c78ffb4c1fe7cbfae342849e75bd91b69a..bd35743c742637a0bf5d9a7cf0463814f94c067f 100644
--- a/src/ia32/macro-assembler-ia32.h
+++ b/src/ia32/macro-assembler-ia32.h
@@ -850,6 +850,9 @@ class MacroAssembler: public Assembler {
   // 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())); }
Index: test/cctest/test-macro-assembler-ia32.cc
diff --git a/test/cctest/test-macro-assembler-ia32.cc b/test/cctest/test-macro-assembler-ia32.cc index 6a4cfec492a98b031960b67809b2d0b4e81b331c..3ad52712c49a85f1107984a1a02255e43d48dacd 100644
--- a/test/cctest/test-macro-assembler-ia32.cc
+++ b/test/cctest/test-macro-assembler-ia32.cc
@@ -123,6 +123,23 @@ TEST(LoadAndStoreWithRepresentation) {
   __ 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