[PATCH] D91460: [AsmParser] make .ascii support spaces as separators

Jian Cai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 20 22:45:04 PST 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe0963ae274be: [AsmParser] make .ascii support spaces as separators (authored by jcai19).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91460/new/

https://reviews.llvm.org/D91460

Files:
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/test/MC/AsmParser/directive_ascii.s


Index: llvm/test/MC/AsmParser/directive_ascii.s
===================================================================
--- llvm/test/MC/AsmParser/directive_ascii.s
+++ llvm/test/MC/AsmParser/directive_ascii.s
@@ -48,3 +48,11 @@
 TEST7:
         .ascii "\x64\Xa6B"
         .ascii "\xface\x0Fe"
+
+# CHECK-LABEL: TEST8:
+# CHECK-NEXT: .byte 65
+# CHECK-NEXT: .byte 66
+# CHECK-NEXT: .byte 67
+# CHECK-NEXT: .byte 68
+TEST8:
+        .ascii "A", "B" "C", "D"
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3008,13 +3008,20 @@
 }
 
 /// parseDirectiveAscii:
-///   ::= ( .ascii | .asciz | .string ) [ "string" ( , "string" )* ]
+//    ::= .ascii [ "string"+ ( , "string"+ )* ]
+///   ::= ( .asciz | .string ) [ "string" ( , "string" )* ]
 bool AsmParser::parseDirectiveAscii(StringRef IDVal, bool ZeroTerminated) {
   auto parseOp = [&]() -> bool {
     std::string Data;
-    if (checkForValidSection() || parseEscapedString(Data))
+    if (checkForValidSection())
       return true;
-    getStreamer().emitBytes(Data);
+    // Only support spaces as separators for .ascii directive for now. See the
+    // discusssion at https://reviews.llvm.org/D91460 for more details
+    do {
+      if (parseEscapedString(Data))
+        return true;
+      getStreamer().emitBytes(Data);
+    } while (!ZeroTerminated && getTok().is(AsmToken::String));
     if (ZeroTerminated)
       getStreamer().emitBytes(StringRef("\0", 1));
     return false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91460.313019.patch
Type: text/x-patch
Size: 1581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201221/faffa962/attachment.bin>


More information about the llvm-commits mailing list