[llvm-commits] [llvm] r75786 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCAsmStreamer.cpp test/MC/AsmParser/directive_dump_and_load.s tools/llvm-mc/AsmParser.cpp tools/llvm-mc/AsmParser.h
Kevin Enderby
enderby at apple.com
Wed Jul 15 08:30:12 PDT 2009
Author: enderby
Date: Wed Jul 15 10:30:11 2009
New Revision: 75786
URL: http://llvm.org/viewvc/llvm-project?rev=75786&view=rev
Log:
Added llvm-mc support for parsing the .dump and .load directives.
Added:
llvm/trunk/test/MC/AsmParser/directive_dump_and_load.s
Modified:
llvm/trunk/include/llvm/MC/MCStreamer.h
llvm/trunk/lib/MC/MCAsmStreamer.cpp
llvm/trunk/tools/llvm-mc/AsmParser.cpp
llvm/trunk/tools/llvm-mc/AsmParser.h
Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=75786&r1=75785&r2=75786&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Wed Jul 15 10:30:11 2009
@@ -166,6 +166,18 @@
/// @param FileName - The file to assemble at this point
virtual void SwitchInputAssemblyFile(const char *FileName) = 0;
+ /// DumpSymbolsandMacros - Dump to the specified file in @param FileName all
+ /// symbols and macros at this point in the assembly.
+ ///
+ /// @param FileName - The file to dump the symbols and macros into.
+ virtual void DumpSymbolsandMacros(const char *FileName) = 0;
+
+ /// LoadSymbolsandMacros - Load from the specified file in @param FileName
+ /// symbols and macros into the assembler at this point in the assembly.
+ ///
+ /// @param FileName - The file to load the symbols and macros from.
+ virtual void LoadSymbolsandMacros(const char *FileName) = 0;
+
/// @}
/// @name Generating Data
/// @{
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=75786&r1=75785&r2=75786&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Wed Jul 15 10:30:11 2009
@@ -59,6 +59,10 @@
virtual void SwitchInputAssemblyFile(const char *FileName);
+ virtual void DumpSymbolsandMacros(const char *FileName);
+
+ virtual void LoadSymbolsandMacros(const char *FileName);
+
virtual void EmitBytes(const char *Data, unsigned Length);
virtual void EmitValue(const MCValue &Value, unsigned Size);
@@ -143,6 +147,14 @@
OS << ".include" << ' ' << FileName << '\n';
}
+void MCAsmStreamer::DumpSymbolsandMacros(const char *FileName) {
+ OS << ".dump" << ' ' << FileName << '\n';
+}
+
+void MCAsmStreamer::LoadSymbolsandMacros(const char *FileName) {
+ OS << ".load" << ' ' << FileName << '\n';
+}
+
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
bool MakeAbsolute) {
assert(!Symbol->getSection() && "Cannot assign to a label!");
Added: llvm/trunk/test/MC/AsmParser/directive_dump_and_load.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_dump_and_load.s?rev=75786&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_dump_and_load.s (added)
+++ llvm/trunk/test/MC/AsmParser/directive_dump_and_load.s Wed Jul 15 10:30:11 2009
@@ -0,0 +1,8 @@
+# RUN: llvm-mc %s | FileCheck %s
+
+# CHECK: TEST0:
+# CHECK: .dump "somefile"
+# CHECK: .load "jack and jill"
+TEST0:
+ .dump "somefile"
+ .load "jack and jill"
Modified: llvm/trunk/tools/llvm-mc/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.cpp?rev=75786&r1=75785&r2=75786&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.cpp Wed Jul 15 10:30:11 2009
@@ -537,6 +537,10 @@
return ParseDirectiveAbort();
if (!strcmp(IDVal, ".include"))
return ParseDirectiveInclude();
+ if (!strcmp(IDVal, ".dump"))
+ return ParseDirectiveDarwinDumpOrLoad(/*IsDump=*/true);
+ if (!strcmp(IDVal, ".load"))
+ return ParseDirectiveDarwinDumpOrLoad(/*IsLoad=*/false);
Warning(IDLoc, "ignoring directive for now");
EatToEndOfStatement();
@@ -1182,3 +1186,28 @@
return false;
}
+
+/// ParseDirectiveDarwinDumpOrLoad
+/// ::= ( .dump | .load ) "filename"
+bool AsmParser::ParseDirectiveDarwinDumpOrLoad(bool IsDump) {
+ const char *Str;
+
+ if (Lexer.isNot(asmtok::String))
+ return TokError("expected string in '.dump' or '.load' directive");
+
+ Str = Lexer.getCurStrVal();
+
+ Lexer.Lex();
+
+ if (Lexer.isNot(asmtok::EndOfStatement))
+ return TokError("unexpected token in '.dump' or '.load' directive");
+
+ Lexer.Lex();
+
+ if (IsDump)
+ Out.DumpSymbolsandMacros(Str);
+ else
+ Out.LoadSymbolsandMacros(Str);
+
+ return false;
+}
Modified: llvm/trunk/tools/llvm-mc/AsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.h?rev=75786&r1=75785&r2=75786&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.h Wed Jul 15 10:30:11 2009
@@ -117,6 +117,8 @@
// Darwin specific ".subsections_via_symbols"
bool ParseDirectiveDarwinSubsectionsViaSymbols();
+ // Darwin specific .dump and .load
+ bool ParseDirectiveDarwinDumpOrLoad(bool IsDump);
bool ParseDirectiveAbort(); // ".abort"
bool ParseDirectiveInclude(); // ".include"
More information about the llvm-commits
mailing list