AsmParser/X86: Add temporary hack to allow parsing "sal". Eventually we need
authorDaniel Dunbar <daniel@zuster.org>
Tue, 2 Feb 2010 23:46:47 +0000 (23:46 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 2 Feb 2010 23:46:47 +0000 (23:46 +0000)
some mechanism for specifying alternative syntaxes, but I'm not sure what form
that should take yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95158 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 73e377086bbab6650c2ecdbd24c64289e1b6ed83..3a8f5d556500039e75df2f1de0dce35fde2640f0 100644 (file)
@@ -456,8 +456,14 @@ X86Operand *X86ATTAsmParser::ParseMemOperand() {
 bool X86ATTAsmParser::
 ParseInstruction(const StringRef &Name, SMLoc NameLoc,
                  SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
-
-  Operands.push_back(X86Operand::CreateToken(Name, NameLoc));
+  // FIXME: Hack to recognize "sal..." for now. We need a way to represent
+  // alternative syntaxes in the .td file, without requiring instruction
+  // duplication.
+  if (Name.startswith("sal")) {
+    std::string Tmp = "shl" + Name.substr(3).str();
+    Operands.push_back(X86Operand::CreateToken(Tmp, NameLoc));
+  } else
+    Operands.push_back(X86Operand::CreateToken(Name, NameLoc));
 
   if (getLexer().isNot(AsmToken::EndOfStatement)) {
 
index 314fc1add1e8addf4017884519cf65c8d0d4a3c0..a1b881b31577b0983560e8d0f56eb509cf92f99b 100644 (file)
@@ -64,3 +64,9 @@
 // FIXME: Check that this matches the correct instruction.
 // CHECK: shldl %cl, %eax, %ebx
         shldl %cl, %eax, %ebx
+
+// CHECK: shll $2, %eax
+        shll $2, %eax
+
+// CHECK: shll $2, %eax
+        sall $2, %eax