[PATCH] D44359: MC intel asm parser: Allow @ at the start of function names.

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 10 18:59:36 PST 2018


thakis created this revision.
thakis added reviewers: hans, rnk.

Ports parts of r193000 to the intel parser. Fixes part of PR36676.


https://reviews.llvm.org/D44359

Files:
  lib/Target/X86/AsmParser/X86AsmParser.cpp
  test/MC/COFF/tricky-names.ll


Index: test/MC/COFF/tricky-names.ll
===================================================================
--- test/MC/COFF/tricky-names.ll
+++ test/MC/COFF/tricky-names.ll
@@ -1,8 +1,11 @@
 ; Check how tricky symbols are printed in the asm output.
 ; RUN: llc -mtriple=i686-pc-win32 %s -o - | FileCheck %s --check-prefix=ASM
+; RUN: llc -mtriple=i686-pc-win32 %s -x86-asm-syntax=intel -o - | FileCheck %s --check-prefix=ASM
 
-; Check that we can roundtrip these names through our assembler.
+; Check that we can roundtrip these names through our assembler,
+; in both at&t and intel syntax.
 ; RUN: llc -mtriple=i686-pc-win32 %s -o - | llvm-mc -triple i686-pc-win32 -filetype=obj | llvm-readobj -t | FileCheck %s --check-prefix=READOBJ
+; RUN: llc -mtriple=i686-pc-win32 -x86-asm-syntax=intel %s -o - | llvm-mc -triple i686-pc-win32 -filetype=obj | llvm-readobj -t | FileCheck %s --check-prefix=READOBJ
 
 
 @"\01??__E_Generic_object@?$_Error_objects at H@std@@YAXXZ" = global i32 0
Index: lib/Target/X86/AsmParser/X86AsmParser.cpp
===================================================================
--- lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1383,14 +1383,15 @@
       if (ParseIntelDotOperator(SM, End))
         return true;
       break;
+    case AsmToken::At:
     case AsmToken::String:
     case AsmToken::Identifier: {
       SMLoc IdentLoc = Tok.getLoc();
       StringRef Identifier = Tok.getString();
       UpdateLocLex = false;
       // Register
       unsigned Reg;
-      if (Tok.isNot(AsmToken::String) && !ParseRegister(Reg, IdentLoc, End)) {
+      if (Tok.is(AsmToken::Identifier) && !ParseRegister(Reg, IdentLoc, End)) {
         if (SM.onRegister(Reg, ErrMsg))
           return Error(Tok.getLoc(), ErrMsg);
         break;
@@ -1428,6 +1429,9 @@
         break;
       }
       // MS InlineAsm identifier
+      // Call parseIdentifier() to combine @ with the identifier behind it.
+      if (TK == AsmToken::At && Parser.parseIdentifier(Identifier))
+        return Error(IdentLoc, "expected identifier");
       if (ParseIntelInlineAsmIdentifier(Val, Identifier, Info, false, End))
         return true;
       else if (SM.onIdentifierExpr(Val, Identifier, Info, true, ErrMsg))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44359.137935.patch
Type: text/x-patch
Size: 2252 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180311/963f22a5/attachment.bin>


More information about the llvm-commits mailing list