Reviewers: Benedikt Meurer,

Message:
ptal

Description:
fix imul(reg, op, imm) emission on x64

R=bmeu...@chromium.org

BUG=

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

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

Affected files (+20, -12 lines):
  M src/x64/assembler-x64.cc
  M src/x64/disasm-x64.cc
  M test/cctest/test-disasm-x64.cc


Index: src/x64/assembler-x64.cc
diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc
index 8cc53953e7a116d3b86ab67a1db47e257db35e0b..01103b234f961eddd5f02dde8bef3ac66addc12b 100644
--- a/src/x64/assembler-x64.cc
+++ b/src/x64/assembler-x64.cc
@@ -974,11 +974,13 @@ void Assembler::emit_imul(Register dst, const Operand& src, Immediate imm,
   emit_rex(dst, src, size);
   if (is_int8(imm.value_)) {
     emit(0x6B);
+    emit_operand(dst, src);
+    emit(imm.value_);
   } else {
     emit(0x69);
+    emit_operand(dst, src);
+    emitl(imm.value_);
   }
-  emit_operand(dst, src);
-  emit(imm.value_);
 }


Index: src/x64/disasm-x64.cc
diff --git a/src/x64/disasm-x64.cc b/src/x64/disasm-x64.cc
index 9b558839780186abdd55081c41fcd731bb466eb8..dcbba9fc81af7c96060c77bc4c294adbfe1ed960 100644
--- a/src/x64/disasm-x64.cc
+++ b/src/x64/disasm-x64.cc
@@ -1486,15 +1486,15 @@ int DisassemblerX64::InstructionDecode(v8::internal::Vector<char> out_buffer,

       case 0x69:  // fall through
       case 0x6B: {
-        int mod, regop, rm;
-        get_modrm(*(data + 1), &mod, &regop, &rm);
-        int32_t imm = *data == 0x6B ? *(data + 2)
-            : *reinterpret_cast<int32_t*>(data + 2);
-        AppendToBuffer("imul%c %s,%s,0x%x",
-                       operand_size_code(),
-                       NameOfCPURegister(regop),
-                       NameOfCPURegister(rm), imm);
-        data += 2 + (*data == 0x6B ? 1 : 4);
+        int count = 1;
+        count += PrintOperands("imul", REG_OPER_OP_ORDER, data + count);
+        AppendToBuffer(",0x");
+        if (*data == 0x69) {
+          count += PrintImmediate(data + count, operand_size());
+        } else {
+          count += PrintImmediate(data + count, OPERAND_BYTE_SIZE);
+        }
+        data += count;
         break;
       }

Index: test/cctest/test-disasm-x64.cc
diff --git a/test/cctest/test-disasm-x64.cc b/test/cctest/test-disasm-x64.cc
index 3fd3ef184b489364fb8a4da848a2590e7f462abd..0a4882e32d4b09aa69ddffa34e1ce3b4b3e42c72 100644
--- a/test/cctest/test-disasm-x64.cc
+++ b/test/cctest/test-disasm-x64.cc
@@ -184,10 +184,16 @@ TEST(DisasmX64) {
   __ notq(rdx);
   __ testq(Operand(rbx, rcx, times_4, 10000), rdx);

-  __ imulq(rdx, Operand(rbx, rcx, times_4, 10000));
   __ imulq(rdx, rcx, Immediate(12));
   __ imulq(rdx, rcx, Immediate(1000));
+  __ imulq(rdx, Operand(rbx, rcx, times_4, 10000));
+  __ imulq(rdx, Operand(rbx, rcx, times_4, 10000), Immediate(12));
   __ imulq(rdx, Operand(rbx, rcx, times_4, 10000), Immediate(1000));
+  __ imull(r15, rcx, Immediate(12));
+  __ imull(r15, rcx, Immediate(1000));
+  __ imull(r15, Operand(rbx, rcx, times_4, 10000));
+  __ imull(r15, Operand(rbx, rcx, times_4, 10000), Immediate(12));
+  __ imull(r15, Operand(rbx, rcx, times_4, 10000), Immediate(1000));

   __ incq(rdx);
   __ incq(Operand(rbx, rcx, times_4, 10000));


--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to