fix rdar://8431880 - rcl/rcr with no shift amount not recognized
authorChris Lattner <sabre@nondot.org>
Wed, 15 Sep 2010 04:33:27 +0000 (04:33 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 15 Sep 2010 04:33:27 +0000 (04:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113936 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 7098c58cde933afdd7face3ab0a1c010834df66b..4856cc9283c92d2f9b9adbfb766dfad679890032 100644 (file)
@@ -813,7 +813,7 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
   if (getLexer().is(AsmToken::EndOfStatement))
     Parser.Lex(); // Consume the EndOfStatement
 
-  // FIXME: Hack to handle recognize s{hr,ar,hl} <op>, $1.  Canonicalize to
+  // FIXME: Hack to handle recognize s{hr,ar,hl} $1, <op>.  Canonicalize to
   // "shift <op>".
   if ((Name.startswith("shr") || Name.startswith("sar") ||
        Name.startswith("shl")) &&
@@ -825,6 +825,14 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
       Operands.erase(Operands.begin() + 1);
     }
   }
+  
+  // FIXME: Hack to handle recognize "rc[lr] <op>" -> "rcl $1, <op>".
+  if ((Name.startswith("rcl") || Name.startswith("rcr")) &&
+      Operands.size() == 2) {
+    const MCExpr *One = MCConstantExpr::Create(1, getParser().getContext());
+    Operands.push_back(X86Operand::CreateImm(One, NameLoc, NameLoc));
+    std::swap(Operands[1], Operands[2]);
+  }
 
   // FIXME: Hack to handle recognize "in[bwl] <op>".  Canonicalize it to
   // "inb <op>, %al".
index 4faf2e55fe1f395afda1492d2225d4afec5ccd1e..3bd2a30504459b566ae2f09b628ce30fbb6892f2 100644 (file)
@@ -257,3 +257,14 @@ fnstsw
 fnstsw %ax
 fnstsw %eax
 fnstsw %al
+
+// rdar://8431880
+// CHECK: rclb $1, %bl
+// CHECK: rcll $1, 3735928559(%ebx,%ecx,8)
+// CHECK: rcrl $1, %ecx
+// CHECK: rcrl $1, 305419896
+
+rcl    %bl
+rcll   0xdeadbeef(%ebx,%ecx,8)
+rcr    %ecx
+rcrl   0x12345678