[PATCH] D91460: [AsmParser] make .ascii support spaces as separators
Jian Cai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 30 15:42:24 PST 2020
jcai19 updated this revision to Diff 308492.
jcai19 edited the summary of this revision.
jcai19 added a comment.
Address comments.
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/AArch64/directive-parse-err.s
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/test/MC/AsmParser/AArch64/directive-parse-err.s
===================================================================
--- llvm/test/MC/AsmParser/AArch64/directive-parse-err.s
+++ llvm/test/MC/AsmParser/AArch64/directive-parse-err.s
@@ -13,7 +13,7 @@
.set ident3, 0 $
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
.set ident3, 0 // EOL COMMENT
- // CHECK: [[@LINE+1]]:20: error: unexpected token in '.ascii' directive
+ // CHECK: [[@LINE+1]]:20: error: expected string in '.ascii' directive
.ascii "string1" $
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
.ascii "string1" // EOL COMMENT
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3002,7 +3002,8 @@
}
/// 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;
@@ -3014,7 +3015,24 @@
return false;
};
- if (parseMany(parseOp))
+ auto parseManyWithOptionalComma = [&]() -> bool {
+ if (parseOptionalToken(AsmToken::EndOfStatement))
+ return false;
+ while (true) {
+ if (parseOp())
+ return true;
+ if (parseOptionalToken(AsmToken::EndOfStatement))
+ return false;
+ if (parseOptionalToken(AsmToken::Comma) &&
+ check(getTok().isNot(AsmToken::String), "expected string"))
+ return true;
+ }
+ return false;
+ };
+
+ // Support space as separtors for .ascii directive. See the discussion in
+ // https://reviews.llvm.org/D91460 for more details
+ if (ZeroTerminated ? parseMany(parseOp) : parseManyWithOptionalComma())
return addErrorSuffix(" in '" + Twine(IDVal) + "' directive");
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91460.308492.patch
Type: text/x-patch
Size: 2396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201130/f9814e69/attachment.bin>
More information about the llvm-commits
mailing list