[PATCH] D91460: [AsmParser] make .ascii/.asciz/.string support spaces as separators
Jian Cai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 30 14:52:30 PST 2020
jcai19 updated this revision to Diff 308486.
jcai19 edited the summary of this revision.
jcai19 added a comment.
Since GNU assembler changed how it interpreted using space as separators in .asciz and .string in https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=3d955acb36f483c05724181da5ffba46b1303c43, limit this patch to .ascii only as matching the new GAS behavior in the two directives may cause subtle issues when building existing code that assumes the old behavior with LLVM's integrated assembler.
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
@@ -3014,7 +3014,25 @@
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 && parseManyWithOptionalComma()) ||
+ (ZeroTerminated && parseMany(parseOp)))
return addErrorSuffix(" in '" + Twine(IDVal) + "' directive");
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91460.308486.patch
Type: text/x-patch
Size: 2059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201130/dd9b3645/attachment.bin>
More information about the llvm-commits
mailing list