Skip to content

Commit 147f843

Browse files
author
git apple-llvm automerger
committed
Merge commit '7ada6f111f13' from llvm.org/main into next
2 parents c61a572 + 7ada6f1 commit 147f843

File tree

3 files changed

+51
-24
lines changed

3 files changed

+51
-24
lines changed

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5224,37 +5224,43 @@ bool AsmParser::parseDirectiveIfc(SMLoc DirectiveLoc, bool ExpectEqual) {
52245224
/// parseDirectiveIfeqs
52255225
/// ::= .ifeqs string1, string2
52265226
bool AsmParser::parseDirectiveIfeqs(SMLoc DirectiveLoc, bool ExpectEqual) {
5227-
if (Lexer.isNot(AsmToken::String)) {
5228-
if (ExpectEqual)
5229-
return TokError("expected string parameter for '.ifeqs' directive");
5230-
return TokError("expected string parameter for '.ifnes' directive");
5231-
}
5227+
TheCondStack.push_back(TheCondState);
5228+
TheCondState.TheCond = AsmCond::IfCond;
52325229

5233-
StringRef String1 = getTok().getStringContents();
5234-
Lex();
5230+
if (TheCondState.Ignore) {
5231+
eatToEndOfStatement();
5232+
} else {
5233+
if (Lexer.isNot(AsmToken::String)) {
5234+
if (ExpectEqual)
5235+
return TokError("expected string parameter for '.ifeqs' directive");
5236+
return TokError("expected string parameter for '.ifnes' directive");
5237+
}
52355238

5236-
if (Lexer.isNot(AsmToken::Comma)) {
5237-
if (ExpectEqual)
5239+
StringRef String1 = getTok().getStringContents();
5240+
Lex();
5241+
5242+
if (Lexer.isNot(AsmToken::Comma)) {
5243+
if (ExpectEqual)
5244+
return TokError(
5245+
"expected comma after first string for '.ifeqs' directive");
52385246
return TokError(
5239-
"expected comma after first string for '.ifeqs' directive");
5240-
return TokError("expected comma after first string for '.ifnes' directive");
5241-
}
5247+
"expected comma after first string for '.ifnes' directive");
5248+
}
52425249

5243-
Lex();
5250+
Lex();
52445251

5245-
if (Lexer.isNot(AsmToken::String)) {
5246-
if (ExpectEqual)
5247-
return TokError("expected string parameter for '.ifeqs' directive");
5248-
return TokError("expected string parameter for '.ifnes' directive");
5249-
}
5252+
if (Lexer.isNot(AsmToken::String)) {
5253+
if (ExpectEqual)
5254+
return TokError("expected string parameter for '.ifeqs' directive");
5255+
return TokError("expected string parameter for '.ifnes' directive");
5256+
}
52505257

5251-
StringRef String2 = getTok().getStringContents();
5252-
Lex();
5258+
StringRef String2 = getTok().getStringContents();
5259+
Lex();
52535260

5254-
TheCondStack.push_back(TheCondState);
5255-
TheCondState.TheCond = AsmCond::IfCond;
5256-
TheCondState.CondMet = ExpectEqual == (String1 == String2);
5257-
TheCondState.Ignore = !TheCondState.CondMet;
5261+
TheCondState.CondMet = ExpectEqual == (String1 == String2);
5262+
TheCondState.Ignore = !TheCondState.CondMet;
5263+
}
52585264

52595265
return false;
52605266
}

llvm/test/MC/AsmParser/ifeqs.s

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,14 @@
1818
// CHECK-NOT: .byte 0
1919
// CHECK: .byte 1
2020

21+
22+
.if 0
23+
.ifeqs "alpha", "alpha"
24+
.byte 2
25+
.else
26+
.byte 3
27+
.endif
28+
.endif
29+
30+
// CHECK-NOT: .byte 2
31+
// CHECK-NOT: .byte 3

llvm/test/MC/AsmParser/ifnes.s

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,13 @@
2020
# CHECK: .byte 1
2121
.ifnes "equal", "equal" ; .byte 0 ; .else ; .byte 1 ; .endif
2222

23+
.if 0
24+
.ifnes "alpha", "alpha"
25+
.byte 2
26+
.else
27+
.byte 3
28+
.endif
29+
.endif
30+
31+
// CHECK-NOT: .byte 2
32+
// CHECK-NOT: .byte 3

0 commit comments

Comments
 (0)