mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Added llvm-mc support for parsing the .include directive.
llvm-svn: 75711
This commit is contained in:
parent
0d3021c94c
commit
3e47cf1dda
@ -160,6 +160,12 @@ namespace llvm {
|
||||
/// @param AbortReason - The reason assembly is terminated, if non-NULL.
|
||||
virtual void AbortAssembly(const char *AbortReason) = 0;
|
||||
|
||||
/// SwitchInputAssemblyFile - Assemble the contents of the specified file in
|
||||
/// @param FileName at this point in the assembly.
|
||||
///
|
||||
/// @param FileName - The file to assemble at this point
|
||||
virtual void SwitchInputAssemblyFile(const char *FileName) = 0;
|
||||
|
||||
/// @}
|
||||
/// @name Generating Data
|
||||
/// @{
|
||||
|
@ -57,6 +57,8 @@ namespace {
|
||||
|
||||
virtual void AbortAssembly(const char *AbortReason = NULL);
|
||||
|
||||
virtual void SwitchInputAssemblyFile(const char *FileName);
|
||||
|
||||
virtual void EmitBytes(const char *Data, unsigned Length);
|
||||
|
||||
virtual void EmitValue(const MCValue &Value, unsigned Size);
|
||||
@ -137,6 +139,10 @@ void MCAsmStreamer::AbortAssembly(const char *AbortReason) {
|
||||
|
||||
}
|
||||
|
||||
void MCAsmStreamer::SwitchInputAssemblyFile(const char *FileName) {
|
||||
OS << ".include" << ' ' << FileName << '\n';
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
|
||||
bool MakeAbsolute) {
|
||||
assert(!Symbol->getSection() && "Cannot assign to a label!");
|
||||
|
8
test/MC/AsmParser/directive_include.s
Normal file
8
test/MC/AsmParser/directive_include.s
Normal file
@ -0,0 +1,8 @@
|
||||
# RUN: llvm-mc %s | FileCheck %s
|
||||
|
||||
# CHECK: TEST0:
|
||||
# CHECK: .include "some/include/file"
|
||||
# CHECK: .include "mary had a little lamb"
|
||||
TEST0:
|
||||
.include "some/include/file"
|
||||
.include "mary had a little lamb"
|
@ -535,6 +535,8 @@ bool AsmParser::ParseStatement() {
|
||||
return ParseDirectiveDarwinSubsectionsViaSymbols();
|
||||
if (!strcmp(IDVal, ".abort"))
|
||||
return ParseDirectiveAbort();
|
||||
if (!strcmp(IDVal, ".include"))
|
||||
return ParseDirectiveInclude();
|
||||
|
||||
Warning(IDLoc, "ignoring directive for now");
|
||||
EatToEndOfStatement();
|
||||
@ -1158,3 +1160,25 @@ bool AsmParser::ParseDirectiveDarwinLsym() {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// ParseDirectiveInclude
|
||||
/// ::= .include "filename"
|
||||
bool AsmParser::ParseDirectiveInclude() {
|
||||
const char *Str;
|
||||
|
||||
if (Lexer.isNot(asmtok::String))
|
||||
return TokError("expected string in '.include' directive");
|
||||
|
||||
Str = Lexer.getCurStrVal();
|
||||
|
||||
Lexer.Lex();
|
||||
|
||||
if (Lexer.isNot(asmtok::EndOfStatement))
|
||||
return TokError("unexpected token in '.include' directive");
|
||||
|
||||
Lexer.Lex();
|
||||
|
||||
Out.SwitchInputAssemblyFile(Str);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -119,6 +119,7 @@ private:
|
||||
bool ParseDirectiveDarwinSubsectionsViaSymbols();
|
||||
|
||||
bool ParseDirectiveAbort(); // ".abort"
|
||||
bool ParseDirectiveInclude(); // ".include"
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
Loading…
Reference in New Issue
Block a user