implement aliases for shld/shrd, part of rdar://8418316
authorChris Lattner <sabre@nondot.org>
Wed, 15 Sep 2010 04:37:18 +0000 (04:37 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 15 Sep 2010 04:37:18 +0000 (04:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113937 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 4856cc9283c92d2f9b9adbfb766dfad679890032..7afa7e66d5e1a4bf5bbfd6a94665e7920cd97fc3 100644 (file)
@@ -833,6 +833,15 @@ ParseInstruction(StringRef Name, SMLoc NameLoc,
     Operands.push_back(X86Operand::CreateImm(One, NameLoc, NameLoc));
     std::swap(Operands[1], Operands[2]);
   }
+  
+  // FIXME: Hack to handle recognize "sh[lr]d op,op" -> "shld $1, op,op".
+  if ((Name.startswith("shld") || Name.startswith("shrd")) &&
+      Operands.size() == 3) {
+    const MCExpr *One = MCConstantExpr::Create(1, getParser().getContext());
+    Operands.insert(Operands.begin()+1,
+                    X86Operand::CreateImm(One, NameLoc, NameLoc));
+  }
+  
 
   // FIXME: Hack to handle recognize "in[bwl] <op>".  Canonicalize it to
   // "inb <op>, %al".
index 3bd2a30504459b566ae2f09b628ce30fbb6892f2..0f0c1ed76a320699d415ffee5dd9580058ff0b4b 100644 (file)
@@ -268,3 +268,14 @@ rcl        %bl
 rcll   0xdeadbeef(%ebx,%ecx,8)
 rcr    %ecx
 rcrl   0x12345678
+
+// rdar://8418316
+// CHECK: shldw        $1, %bx, %bx
+// CHECK: shldw        $1, %bx, %bx
+// CHECK: shrdw        $1, %bx, %bx
+// CHECK: shrdw        $1, %bx, %bx
+
+shld   %bx,%bx
+shld   $1, %bx,%bx
+shrd   %bx,%bx
+shrd   $1, %bx,%bx