mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
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> llvm-svn: 197547
This commit is contained in:
parent
a2d4a79272
commit
58e7056c0b
@ -358,7 +358,8 @@ private:
|
|||||||
DK_CFI_RESTORE, DK_CFI_ESCAPE, DK_CFI_SIGNAL_FRAME, DK_CFI_UNDEFINED,
|
DK_CFI_RESTORE, DK_CFI_ESCAPE, DK_CFI_SIGNAL_FRAME, DK_CFI_UNDEFINED,
|
||||||
DK_CFI_REGISTER, DK_CFI_WINDOW_SAVE,
|
DK_CFI_REGISTER, DK_CFI_WINDOW_SAVE,
|
||||||
DK_MACROS_ON, DK_MACROS_OFF, DK_MACRO, DK_ENDM, DK_ENDMACRO, DK_PURGEM,
|
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
|
/// \brief Maps directive name --> DirectiveKind enum, for
|
||||||
@ -464,6 +465,9 @@ private:
|
|||||||
// "align"
|
// "align"
|
||||||
bool parseDirectiveMSAlign(SMLoc DirectiveLoc, ParseStatementInfo &Info);
|
bool parseDirectiveMSAlign(SMLoc DirectiveLoc, ParseStatementInfo &Info);
|
||||||
|
|
||||||
|
// "end"
|
||||||
|
bool parseDirectiveEnd(SMLoc DirectiveLoc);
|
||||||
|
|
||||||
void initializeDirectiveKindMap();
|
void initializeDirectiveKindMap();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1508,6 +1512,8 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info) {
|
|||||||
return parseDirectiveEndMacro(IDVal);
|
return parseDirectiveEndMacro(IDVal);
|
||||||
case DK_PURGEM:
|
case DK_PURGEM:
|
||||||
return parseDirectivePurgeMacro(IDLoc);
|
return parseDirectivePurgeMacro(IDLoc);
|
||||||
|
case DK_END:
|
||||||
|
return parseDirectiveEnd(IDLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Error(IDLoc, "unknown directive");
|
return Error(IDLoc, "unknown directive");
|
||||||
@ -3743,6 +3749,20 @@ bool AsmParser::parseDirectiveElse(SMLoc DirectiveLoc) {
|
|||||||
return false;
|
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
|
/// parseDirectiveEndIf
|
||||||
/// ::= .endif
|
/// ::= .endif
|
||||||
bool AsmParser::parseDirectiveEndIf(SMLoc DirectiveLoc) {
|
bool AsmParser::parseDirectiveEndIf(SMLoc DirectiveLoc) {
|
||||||
@ -3828,6 +3848,7 @@ void AsmParser::initializeDirectiveKindMap() {
|
|||||||
DirectiveKindMap[".ifnotdef"] = DK_IFNOTDEF;
|
DirectiveKindMap[".ifnotdef"] = DK_IFNOTDEF;
|
||||||
DirectiveKindMap[".elseif"] = DK_ELSEIF;
|
DirectiveKindMap[".elseif"] = DK_ELSEIF;
|
||||||
DirectiveKindMap[".else"] = DK_ELSE;
|
DirectiveKindMap[".else"] = DK_ELSE;
|
||||||
|
DirectiveKindMap[".end"] = DK_END;
|
||||||
DirectiveKindMap[".endif"] = DK_ENDIF;
|
DirectiveKindMap[".endif"] = DK_ENDIF;
|
||||||
DirectiveKindMap[".skip"] = DK_SKIP;
|
DirectiveKindMap[".skip"] = DK_SKIP;
|
||||||
DirectiveKindMap[".space"] = DK_SPACE;
|
DirectiveKindMap[".space"] = DK_SPACE;
|
||||||
|
14
test/MC/AsmParser/directive_end-2.s
Normal file
14
test/MC/AsmParser/directive_end-2.s
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# RUN: llvm-mc -triple i386-unknown-unknown %s -I %p -filetype obj -o - \
|
||||||
|
# RUN: | llvm-readobj -t | FileCheck %s
|
||||||
|
|
||||||
|
rock:
|
||||||
|
movl $42, %eax
|
||||||
|
|
||||||
|
.include "directive_end.s"
|
||||||
|
|
||||||
|
hard_place:
|
||||||
|
movl $42, %ebx
|
||||||
|
|
||||||
|
# CHECK: Symbol {
|
||||||
|
# CHECK: Name: rock
|
||||||
|
# CHECK-NOT: Name: hard_place
|
11
test/MC/AsmParser/directive_end.s
Normal file
11
test/MC/AsmParser/directive_end.s
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# RUN: llvm-mc -triple i386-unknown-unknown %s -filetype obj -o - \
|
||||||
|
# RUN: | llvm-readobj -t | FileCheck %s
|
||||||
|
|
||||||
|
.end
|
||||||
|
|
||||||
|
its_a_tarp:
|
||||||
|
int $0x3
|
||||||
|
|
||||||
|
# CHECK: Symbol {
|
||||||
|
# CHECK-NOT: Name: its_a_tarp
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user