MC/X86: Add custom hack for recognizing "imul $12, %eax" and friends.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 24 Aug 2010 19:24:18 +0000 (19:24 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 24 Aug 2010 19:24:18 +0000 (19:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111947 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmParser/X86AsmParser.cpp
test/MC/AsmParser/X86/x86_instructions.s

index 204ccf77a7580688a4a27ce0dc264dd7b35a0793..3f10b8e2f58f6266a88e0f1e08ca86841a818207 100644 (file)
@@ -826,6 +826,14 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
     Operands.erase(Operands.begin() + 2);
   }
 
+  // FIXME: Hack to handle "imul A, B" which is an alias for "imul A, B, B".
+  if (Name.startswith("imul") && Operands.size() == 3 &&
+      static_cast<X86Operand*>(Operands.back())->isReg()) {
+    X86Operand *Op = static_cast<X86Operand*>(Operands.back());
+    Operands.push_back(X86Operand::CreateReg(Op->getReg(), Op->getStartLoc(),
+                                             Op->getEndLoc()));
+  }
+
   return false;
 }
 
index 8adcc9e0cdf015cd26760c8c65a27d0ce8e448a3..eed69e07d371deab1abe5a5ac3118029639d0cba 100644 (file)
@@ -158,3 +158,6 @@ INT3
 // CHECK: movaps       %xmm3, (%esi)
 // CHECK-STDERR: warning: scale factor without index register is ignored
 movaps %xmm3, (%esi, 2)
+
+// CHECK: imull $12, %eax, %eax
+imul $12, %eax