1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

Add support for .ifnes psuedo-op.

llvm-svn: 232636
This commit is contained in:
Sid Manning 2015-03-18 14:20:54 +00:00
parent 0cb1767f19
commit 7d4dc00131
3 changed files with 61 additions and 10 deletions

View File

@ -339,8 +339,8 @@ private:
DK_WEAK_DEF_CAN_BE_HIDDEN, DK_COMM, DK_COMMON, DK_LCOMM, DK_ABORT,
DK_INCLUDE, DK_INCBIN, DK_CODE16, DK_CODE16GCC, DK_REPT, DK_IRP, DK_IRPC,
DK_IF, DK_IFEQ, DK_IFGE, DK_IFGT, DK_IFLE, DK_IFLT, DK_IFNE, DK_IFB,
DK_IFNB, DK_IFC, DK_IFEQS, DK_IFNC, DK_IFDEF, DK_IFNDEF, DK_IFNOTDEF,
DK_ELSEIF, DK_ELSE, DK_ENDIF,
DK_IFNB, DK_IFC, DK_IFEQS, DK_IFNC, DK_IFNES, DK_IFDEF, DK_IFNDEF,
DK_IFNOTDEF, DK_ELSEIF, DK_ELSE, DK_ENDIF,
DK_SPACE, DK_SKIP, DK_FILE, DK_LINE, DK_LOC, DK_STABS,
DK_CFI_SECTIONS, DK_CFI_STARTPROC, DK_CFI_ENDPROC, DK_CFI_DEF_CFA,
DK_CFI_DEF_CFA_OFFSET, DK_CFI_ADJUST_CFA_OFFSET, DK_CFI_DEF_CFA_REGISTER,
@ -435,8 +435,8 @@ private:
bool parseDirectiveIfb(SMLoc DirectiveLoc, bool ExpectBlank);
// ".ifc" or ".ifnc", depending on ExpectEqual.
bool parseDirectiveIfc(SMLoc DirectiveLoc, bool ExpectEqual);
// ".ifeqs"
bool parseDirectiveIfeqs(SMLoc DirectiveLoc);
// ".ifeqs" or ".ifnes", depending on ExpectEqual.
bool parseDirectiveIfeqs(SMLoc DirectiveLoc, bool ExpectEqual);
// ".ifdef" or ".ifndef", depending on expect_defined
bool parseDirectiveIfdef(SMLoc DirectiveLoc, bool expect_defined);
bool parseDirectiveElseIf(SMLoc DirectiveLoc); // ".elseif"
@ -1244,9 +1244,11 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
case DK_IFC:
return parseDirectiveIfc(IDLoc, true);
case DK_IFEQS:
return parseDirectiveIfeqs(IDLoc);
return parseDirectiveIfeqs(IDLoc, true);
case DK_IFNC:
return parseDirectiveIfc(IDLoc, false);
case DK_IFNES:
return parseDirectiveIfeqs(IDLoc, false);
case DK_IFDEF:
return parseDirectiveIfdef(IDLoc, true);
case DK_IFNDEF:
@ -3943,9 +3945,12 @@ bool AsmParser::parseDirectiveIfc(SMLoc DirectiveLoc, bool ExpectEqual) {
/// parseDirectiveIfeqs
/// ::= .ifeqs string1, string2
bool AsmParser::parseDirectiveIfeqs(SMLoc DirectiveLoc) {
bool AsmParser::parseDirectiveIfeqs(SMLoc DirectiveLoc, bool ExpectEqual) {
if (Lexer.isNot(AsmToken::String)) {
TokError("expected string parameter for '.ifeqs' directive");
if (ExpectEqual)
TokError("expected string parameter for '.ifeqs' directive");
else
TokError("expected string parameter for '.ifnes' directive");
eatToEndOfStatement();
return true;
}
@ -3954,7 +3959,10 @@ bool AsmParser::parseDirectiveIfeqs(SMLoc DirectiveLoc) {
Lex();
if (Lexer.isNot(AsmToken::Comma)) {
TokError("expected comma after first string for '.ifeqs' directive");
if (ExpectEqual)
TokError("expected comma after first string for '.ifeqs' directive");
else
TokError("expected comma after first string for '.ifnes' directive");
eatToEndOfStatement();
return true;
}
@ -3962,7 +3970,10 @@ bool AsmParser::parseDirectiveIfeqs(SMLoc DirectiveLoc) {
Lex();
if (Lexer.isNot(AsmToken::String)) {
TokError("expected string parameter for '.ifeqs' directive");
if (ExpectEqual)
TokError("expected string parameter for '.ifeqs' directive");
else
TokError("expected string parameter for '.ifnes' directive");
eatToEndOfStatement();
return true;
}
@ -3972,7 +3983,7 @@ bool AsmParser::parseDirectiveIfeqs(SMLoc DirectiveLoc) {
TheCondStack.push_back(TheCondState);
TheCondState.TheCond = AsmCond::IfCond;
TheCondState.CondMet = String1 == String2;
TheCondState.CondMet = ExpectEqual == (String1 == String2);
TheCondState.Ignore = !TheCondState.CondMet;
return false;
@ -4219,6 +4230,7 @@ void AsmParser::initializeDirectiveKindMap() {
DirectiveKindMap[".ifc"] = DK_IFC;
DirectiveKindMap[".ifeqs"] = DK_IFEQS;
DirectiveKindMap[".ifnc"] = DK_IFNC;
DirectiveKindMap[".ifnes"] = DK_IFNES;
DirectiveKindMap[".ifdef"] = DK_IFDEF;
DirectiveKindMap[".ifndef"] = DK_IFNDEF;
DirectiveKindMap[".ifnotdef"] = DK_IFNOTDEF;

View File

@ -20,3 +20,20 @@
// CHECK-NOT: error: unmatched .ifs or .elses
.ifnes
// CHECK: error: expected string parameter for '.ifnes' directive
// CHECK: .ifnes
// CHECK: ^
.ifnes "string1"
// CHECK: error: expected comma after first string for '.ifnes' directive
// CHECK: .ifnes "string1"
// CHECK: ^
.ifnes "string1",
// CHECK: error: expected string parameter for '.ifnes' directive
// CHECK: .ifnes "string1",
// CHECK: ^

22
test/MC/AsmParser/ifnes.s Normal file
View File

@ -0,0 +1,22 @@
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
# CHECK-NOT: .byte 0
# CHECK: .byte 1
.ifnes "foo space", "foo space"
.byte 0
.else
.byte 1
.endif
# CHECK-NOT: .byte 0
# CHECK: .byte 1
.ifnes "unequal", "unEqual"
.byte 1
.else
.byte 0
.endif
# CHECK-NOT: .byte 0
# CHECK: .byte 1
.ifnes "equal", "equal" ; .byte 0 ; .else ; .byte 1 ; .endif