Skip to content

Commit e0963ae

Browse files
committed
[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: ClangBuiltLinux/linux#1196 Reviewed By: nickdesaulniers, jrtc27 Differential Revision: https://reviews.llvm.org/D91460
1 parent 26d378b commit e0963ae

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

llvm/lib/MC/MCParser/AsmParser.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -3008,13 +3008,20 @@ bool AsmParser::parseAngleBracketString(std::string &Data) {
30083008
}
30093009

30103010
/// parseDirectiveAscii:
3011-
/// ::= ( .ascii | .asciz | .string ) [ "string" ( , "string" )* ]
3011+
// ::= .ascii [ "string"+ ( , "string"+ )* ]
3012+
/// ::= ( .asciz | .string ) [ "string" ( , "string" )* ]
30123013
bool AsmParser::parseDirectiveAscii(StringRef IDVal, bool ZeroTerminated) {
30133014
auto parseOp = [&]() -> bool {
30143015
std::string Data;
3015-
if (checkForValidSection() || parseEscapedString(Data))
3016+
if (checkForValidSection())
30163017
return true;
3017-
getStreamer().emitBytes(Data);
3018+
// Only support spaces as separators for .ascii directive for now. See the
3019+
// discusssion at https://reviews.llvm.org/D91460 for more details
3020+
do {
3021+
if (parseEscapedString(Data))
3022+
return true;
3023+
getStreamer().emitBytes(Data);
3024+
} while (!ZeroTerminated && getTok().is(AsmToken::String));
30183025
if (ZeroTerminated)
30193026
getStreamer().emitBytes(StringRef("\0", 1));
30203027
return false;

llvm/test/MC/AsmParser/directive_ascii.s

+8
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,11 @@ TEST6:
4848
TEST7:
4949
.ascii "\x64\Xa6B"
5050
.ascii "\xface\x0Fe"
51+
52+
# CHECK-LABEL: TEST8:
53+
# CHECK-NEXT: .byte 65
54+
# CHECK-NEXT: .byte 66
55+
# CHECK-NEXT: .byte 67
56+
# CHECK-NEXT: .byte 68
57+
TEST8:
58+
.ascii "A", "B" "C", "D"

0 commit comments

Comments
 (0)