Skip to content

Commit 9dfeec8

Browse files
committed
Reland "[AsmParser] make .ascii support spaces as separators"
This relands commit e0963ae, which was reverted on commit 82c4153 due to a test failure, which turned out to be a false positive.
1 parent 036bc79 commit 9dfeec8

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 10 additions & 3 deletions
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

Lines changed: 8 additions & 0 deletions
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)