summaryrefslogtreecommitdiff
path: root/lib/MC/MCParser
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2013-12-18 02:53:03 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2013-12-18 02:53:03 +0000
commit5a445395de7a5481ed8a5d1768aa9e3db83bd18a (patch)
treeaf6fc533654e1afecb6a3a16556a05e522011867 /lib/MC/MCParser
parent2cb3295a536957f0a191660a692e84e4102054a6 (diff)
downloadllvm-5a445395de7a5481ed8a5d1768aa9e3db83bd18a.tar.gz
llvm-5a445395de7a5481ed8a5d1768aa9e3db83bd18a.tar.bz2
llvm-5a445395de7a5481ed8a5d1768aa9e3db83bd18a.tar.xz
AsmParser: add support for .end directive
The .end directive indicates the end of the file. No further instructions are processed after a .end directive is encountered. One potential (glaringly obvious) optimisation that could be pursued here is to extend MCAsmParser with a DiscardRemainder method to avoid processing lexemes to the end of the file. It was unclear at this point if that would be worth adding, and could easily be added in a follow on change. Signed-off-by: Saleem Abdulrasool <compnerd@compnerd.org> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197547 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCParser')
-rw-r--r--lib/MC/MCParser/AsmParser.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index a336cb97c6..35f38a2a87 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/lib/MC/MCParser/AsmParser.cpp
@@ -358,7 +358,8 @@ private:
DK_CFI_RESTORE, DK_CFI_ESCAPE, DK_CFI_SIGNAL_FRAME, DK_CFI_UNDEFINED,
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_SLEB128, DK_ULEB128,
+ DK_END
};
/// \brief Maps directive name --> DirectiveKind enum, for
@@ -464,6 +465,9 @@ private:
// "align"
bool parseDirectiveMSAlign(SMLoc DirectiveLoc, ParseStatementInfo &Info);
+ // "end"
+ bool parseDirectiveEnd(SMLoc DirectiveLoc);
+
void initializeDirectiveKindMap();
};
}
@@ -1508,6 +1512,8 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info) {
return parseDirectiveEndMacro(IDVal);
case DK_PURGEM:
return parseDirectivePurgeMacro(IDLoc);
+ case DK_END:
+ return parseDirectiveEnd(IDLoc);
}
return Error(IDLoc, "unknown directive");
@@ -3743,6 +3749,20 @@ bool AsmParser::parseDirectiveElse(SMLoc DirectiveLoc) {
return false;
}
+/// parseDirectiveEnd
+/// ::= .end
+bool AsmParser::parseDirectiveEnd(SMLoc DirectiveLoc) {
+ if (getLexer().isNot(AsmToken::EndOfStatement))
+ return TokError("unexpected token in '.end' directive");
+
+ Lex();
+
+ while (Lexer.isNot(AsmToken::Eof))
+ Lex();
+
+ return false;
+}
+
/// parseDirectiveEndIf
/// ::= .endif
bool AsmParser::parseDirectiveEndIf(SMLoc DirectiveLoc) {
@@ -3828,6 +3848,7 @@ void AsmParser::initializeDirectiveKindMap() {
DirectiveKindMap[".ifnotdef"] = DK_IFNOTDEF;
DirectiveKindMap[".elseif"] = DK_ELSEIF;
DirectiveKindMap[".else"] = DK_ELSE;
+ DirectiveKindMap[".end"] = DK_END;
DirectiveKindMap[".endif"] = DK_ENDIF;
DirectiveKindMap[".skip"] = DK_SKIP;
DirectiveKindMap[".space"] = DK_SPACE;