[PATCH] D91460: [AsmParser] make .ascii/.asciz/.string support multiple strings
Jian Cai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 13 13:42:13 PST 2020
jcai19 created this revision.
Herald added subscribers: llvm-commits, atanasyan, jrtc27, hiraditya, sdardis.
Herald added a project: LLVM.
jcai19 requested review of this revision.
Currently the integrated assembler only allows one string in
.ascii/.asciz/.string directive. This patch adds support to multiple
multiple strings to be consistent with GNU assembler, and fixes an issue
while buiding Linux kernel with the integrated assmebler.
Links:
https://github.com/ClangBuiltLinux/linux/issues/1196
https://sourceware.org/binutils/docs/as/Ascii.html#Ascii
https://sourceware.org/binutils/docs/as/Asciz.html#Asciz
https://sourceware.org/binutils/docs/as/String.html#String
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D91460
Files:
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/test/MC/AsmParser/AArch64/directive-parse-err.s
llvm/test/MC/Mips/asciiz-directive-bad.s
Index: llvm/test/MC/Mips/asciiz-directive-bad.s
===================================================================
--- llvm/test/MC/Mips/asciiz-directive-bad.s
+++ llvm/test/MC/Mips/asciiz-directive-bad.s
@@ -3,6 +3,6 @@
.asciiz 12
# CHECK: :[[@LINE-1]]:11: error: expected string in '.asciiz' directive
.asciiz "a"3
-# CHECK: :[[@LINE-1]]:14: error: unexpected token in '.asciiz' directive
+# CHECK: :[[@LINE-1]]:14: error: expected string in '.asciiz' directive
.asciiz "a",
# CHECK: :[[@LINE-1]]:15: error: expected string in '.asciiz' directive
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,15 +13,15 @@
.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
- // CHECK: [[@LINE+1]]:20: error: unexpected token in '.asciz' directive
+ // CHECK: [[@LINE+1]]:20: error: expected string in '.asciz' directive
.asciz "string2" $
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
.asciz "string2" // EOL COMMENT
- // CHECK: [[@LINE+1]]:20: error: unexpected token in '.string' directive
+ // CHECK: [[@LINE+1]]:20: error: expected string in '.string' directive
.string "string3" $
// CHECK-NOT: [[@LINE+1]]:{{[0-9]+}}: error:
.string "string3" // EOL COMMENT
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3014,8 +3014,15 @@
return false;
};
- if (parseMany(parseOp))
- return addErrorSuffix(" in '" + Twine(IDVal) + "' directive");
+ while (true) {
+ if (parseOptionalToken(AsmToken::EndOfStatement)) // return true on success
+ break;
+ if (parseOp()) // return false on success
+ return addErrorSuffix(" in '" + Twine(IDVal) + "' directive");
+ if (parseOptionalToken(AsmToken::Comma) &&
+ check(getTok().isNot(AsmToken::String), "expected string"))
+ return addErrorSuffix(" in '" + Twine(IDVal) + "' directive");
+ }
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91460.305254.patch
Type: text/x-patch
Size: 2459 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201113/61049eb9/attachment.bin>
More information about the llvm-commits
mailing list