[llvm-commits] [llvm] r113348 - in /llvm/trunk: lib/Target/X86/AsmParser/X86AsmParser.cpp test/MC/AsmParser/X86/x86_64-new-encoder.s

Chris Lattner sabre at nondot.org
Tue Sep 7 22:17:37 PDT 2010


Author: lattner
Date: Wed Sep  8 00:17:37 2010
New Revision: 113348

URL: http://llvm.org/viewvc/llvm-project?rev=113348&view=rev
Log:
add support for instruction prefixes on the same line as the instruction,
implementing rdar://8033482 and PR7254.

Modified:
    llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
    llvm/trunk/test/MC/AsmParser/X86/x86_64-new-encoder.s

Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=113348&r1=113347&r2=113348&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Wed Sep  8 00:17:37 2010
@@ -758,10 +758,19 @@
 
   if (ExtraImmOp)
     Operands.push_back(X86Operand::CreateImm(ExtraImmOp, NameLoc, NameLoc));
-
   
-  // This does the actual operand parsing.
-  if (getLexer().isNot(AsmToken::EndOfStatement)) {
+  
+  // Determine whether this is an instruction prefix.
+  bool isPrefix =
+    PatchedName == "lock" || PatchedName == "rep" || 
+    PatchedName == "repne";
+  
+  
+  // This does the actual operand parsing.  Don't parse any more if we have a
+  // prefix juxtaposed with an operation like "lock incl 4(%rax)", because we
+  // just want to parse the "lock" as the first instruction and the "incl" as
+  // the next one.
+  if (getLexer().isNot(AsmToken::EndOfStatement) && !isPrefix) {
 
     // Parse '*' modifier.
     if (getLexer().is(AsmToken::Star)) {
@@ -785,11 +794,13 @@
       else
         return true;
     }
+    
+    if (getLexer().isNot(AsmToken::EndOfStatement))
+      return TokError("unexpected token in argument list");
   }
   
-  if (getLexer().isNot(AsmToken::EndOfStatement))
-    return TokError("unexpected token in argument list");
-  Parser.Lex(); // Consume the EndOfStatement
+  if (getLexer().is(AsmToken::EndOfStatement))
+    Parser.Lex(); // Consume the EndOfStatement
 
   // FIXME: Hack to handle recognizing s{hr,ar,hl}? $1.
   if ((Name.startswith("shr") || Name.startswith("sar") ||

Modified: llvm/trunk/test/MC/AsmParser/X86/x86_64-new-encoder.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/X86/x86_64-new-encoder.s?rev=113348&r1=113347&r2=113348&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/X86/x86_64-new-encoder.s (original)
+++ llvm/trunk/test/MC/AsmParser/X86/x86_64-new-encoder.s Wed Sep  8 00:17:37 2010
@@ -173,3 +173,15 @@
 // CHECK: xchgl	%ecx, 368(%rax)
 xchgl   %ecx, 368(%rax)
 // CHECK: xchgl	%ecx, 368(%rax)
+
+// PR7254
+lock  incl 1(%rsp)
+// CHECK: lock
+// CHECK: incl 1(%rsp)
+
+// rdar://8033482
+rep movsl
+// CHECK: rep
+// CHECK: encoding: [0xf3]
+// CHECK: movsl
+// CHECK: encoding: [0xa5]





More information about the llvm-commits mailing list