mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-03 01:12:59 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201984 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
da6ffb33d2
commit
a0d16299c9
@ -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(ParseStatementInfo &Info) {
|
||||
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 DirectiveLoc) {
|
||||
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::initializeDirectiveKindMap() {
|
||||
DirectiveKindMap[".endm"] = DK_ENDM;
|
||||
DirectiveKindMap[".endmacro"] = DK_ENDMACRO;
|
||||
DirectiveKindMap[".purgem"] = DK_PURGEM;
|
||||
DirectiveKindMap[".err"] = DK_ERR;
|
||||
}
|
||||
|
||||
MCAsmMacro *AsmParser::parseMacroLikeBody(SMLoc DirectiveLoc) {
|
||||
|
19
test/MC/AsmParser/directive-err.s
Normal file
19
test/MC/AsmParser/directive-err.s
Normal file
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user