[llvm] r201984 - MCAsmParser: add support for .err directive
Saleem Abdulrasool
compnerd at compnerd.org
Sun Feb 23 07:53:31 PST 2014
Author: compnerd
Date: Sun Feb 23 09:53:30 2014
New Revision: 201984
URL: http://llvm.org/viewvc/llvm-project?rev=201984&view=rev
Log:
MCAsmParser: add support for .err directive
The .err directive produces an error whenever it is assembled. This can be
useful for preventing assembly when an unexpected condition occurs.
Added:
llvm/trunk/test/MC/AsmParser/directive-err.s
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=201984&r1=201983&r2=201984&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Sun Feb 23 09:53:30 2014
@@ -361,6 +361,7 @@ private:
DK_CFI_REGISTER, DK_CFI_WINDOW_SAVE,
DK_MACROS_ON, DK_MACROS_OFF, DK_MACRO, DK_ENDM, DK_ENDMACRO, DK_PURGEM,
DK_SLEB128, DK_ULEB128,
+ DK_ERR,
DK_END
};
@@ -471,6 +472,9 @@ private:
// "end"
bool parseDirectiveEnd(SMLoc DirectiveLoc);
+ // "err"
+ bool parseDirectiveErr(SMLoc DirectiveLoc);
+
void initializeDirectiveKindMap();
};
}
@@ -1526,6 +1530,8 @@ bool AsmParser::parseStatement(ParseStat
return parseDirectivePurgeMacro(IDLoc);
case DK_END:
return parseDirectiveEnd(IDLoc);
+ case DK_ERR:
+ return parseDirectiveErr(IDLoc);
}
return Error(IDLoc, "unknown directive");
@@ -3931,6 +3937,15 @@ bool AsmParser::parseDirectiveEnd(SMLoc
return false;
}
+/// parseDirectiveErr
+/// ::= .err
+bool AsmParser::parseDirectiveErr(SMLoc Loc) {
+ if (!TheCondStack.empty())
+ if (TheCondStack.back().Ignore)
+ return false;
+ return Error(Loc, ".err encountered");
+}
+
/// parseDirectiveEndIf
/// ::= .endif
bool AsmParser::parseDirectiveEndIf(SMLoc DirectiveLoc) {
@@ -4054,6 +4069,7 @@ void AsmParser::initializeDirectiveKindM
DirectiveKindMap[".endm"] = DK_ENDM;
DirectiveKindMap[".endmacro"] = DK_ENDMACRO;
DirectiveKindMap[".purgem"] = DK_PURGEM;
+ DirectiveKindMap[".err"] = DK_ERR;
}
MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) {
Added: llvm/trunk/test/MC/AsmParser/directive-err.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive-err.s?rev=201984&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive-err.s (added)
+++ llvm/trunk/test/MC/AsmParser/directive-err.s Sun Feb 23 09:53:30 2014
@@ -0,0 +1,19 @@
+// RUN: not llvm-mc -triple i386 %s 2>&1 | FileCheck %s
+
+ .err
+// CHECK: error: .err encountered
+// CHECK-NEXT: .err
+// CHECK-NEXT: ^
+
+ .ifc a,a
+ .err
+ .endif
+// CHECK: error: .err encountered
+// CHECK-NEXT: .err
+// CHECK-NEXT: ^
+
+ .ifnc a,a
+ .err
+ .endif
+// CHECK-NOT: error: .err encountered
+
More information about the llvm-commits
mailing list