Author: Jian Cai Date: 2020-12-20T22:41:00-08:00 New Revision: e0963ae274be5b071d1e1b00f5e4e019483c09e9
URL: https://github.com/llvm/llvm-project/commit/e0963ae274be5b071d1e1b00f5e4e019483c09e9 DIFF: https://github.com/llvm/llvm-project/commit/e0963ae274be5b071d1e1b00f5e4e019483c09e9.diff LOG: [AsmParser] make .ascii support spaces as separators Currently the integrated assembler only allows commas as the separator between string arguments in .ascii. This patch adds support to using space as separators and make IAS consistent with GNU assembler. Link: https://github.com/ClangBuiltLinux/linux/issues/1196 Reviewed By: nickdesaulniers, jrtc27 Differential Revision: https://reviews.llvm.org/D91460 Added: Modified: llvm/lib/MC/MCParser/AsmParser.cpp llvm/test/MC/AsmParser/directive_ascii.s Removed: ################################################################################ diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 55b0003e9909..5b9039d9a783 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -3008,13 +3008,20 @@ bool AsmParser::parseAngleBracketString(std::string &Data) { } /// 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; diff --git a/llvm/test/MC/AsmParser/directive_ascii.s b/llvm/test/MC/AsmParser/directive_ascii.s index ea988879819b..e34aa7a8a561 100644 --- a/llvm/test/MC/AsmParser/directive_ascii.s +++ b/llvm/test/MC/AsmParser/directive_ascii.s @@ -48,3 +48,11 @@ TEST6: 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" _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits