[llvm] r232636 - Add support for .ifnes psuedo-op.
Sid Manning
sidneym at codeaurora.org
Wed Mar 18 07:20:54 PDT 2015
Author: sidneym
Date: Wed Mar 18 09:20:54 2015
New Revision: 232636
URL: http://llvm.org/viewvc/llvm-project?rev=232636&view=rev
Log:
Add support for .ifnes psuedo-op.
Added:
llvm/trunk/test/MC/AsmParser/ifnes.s
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/test/MC/AsmParser/ifeqs-diagnostics.s
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=232636&r1=232635&r2=232636&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Wed Mar 18 09:20:54 2015
@@ -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(ParseStat
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
/// 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(SMLo
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(SMLo
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(SMLo
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::initializeDirectiveKindM
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;
Modified: llvm/trunk/test/MC/AsmParser/ifeqs-diagnostics.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/ifeqs-diagnostics.s?rev=232636&r1=232635&r2=232636&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/ifeqs-diagnostics.s (original)
+++ llvm/trunk/test/MC/AsmParser/ifeqs-diagnostics.s Wed Mar 18 09:20:54 2015
@@ -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: ^
Added: llvm/trunk/test/MC/AsmParser/ifnes.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/ifnes.s?rev=232636&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/ifnes.s (added)
+++ llvm/trunk/test/MC/AsmParser/ifnes.s Wed Mar 18 09:20:54 2015
@@ -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
+
More information about the llvm-commits
mailing list