[PATCH] D91460: [AsmParser] make .ascii support spaces as separators
Jian Cai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 4 15:19:48 PST 2020
jcai19 updated this revision to Diff 309678.
jcai19 added a comment.
Update the syntax in the comment.
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,10 @@
TEST7:
.ascii "\x64\Xa6B"
.ascii "\xface\x0Fe"
+
+# CHECK: TEST8:
+# CHECK: .byte 65
+# CHECK: .byte 66
+# CHECK: .byte 67
+TEST8:
+ .ascii "A", "B" "C"
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3002,13 +3002,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.309678.patch
Type: text/x-patch
Size: 1531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201204/f59a2c6c/attachment.bin>
More information about the llvm-commits
mailing list