aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2009-07-15 15:30:11 +0000
committerKevin Enderby <enderby@apple.com>2009-07-15 15:30:11 +0000
commit6e68cd96b2c76c80bfff07e8121ba19691ec1276 (patch)
treef97a4cf04c01009e2b0378c123bd462b80912091
parenta4b048668418f74dfb2399421dc54db1d999c9cd (diff)
downloadexternal_llvm-6e68cd96b2c76c80bfff07e8121ba19691ec1276.zip
external_llvm-6e68cd96b2c76c80bfff07e8121ba19691ec1276.tar.gz
external_llvm-6e68cd96b2c76c80bfff07e8121ba19691ec1276.tar.bz2
Added llvm-mc support for parsing the .dump and .load directives.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75786 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/MC/MCStreamer.h12
-rw-r--r--lib/MC/MCAsmStreamer.cpp12
-rw-r--r--test/MC/AsmParser/directive_dump_and_load.s8
-rw-r--r--tools/llvm-mc/AsmParser.cpp29
-rw-r--r--tools/llvm-mc/AsmParser.h2
5 files changed, 63 insertions, 0 deletions
diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h
index 1327b26..8daa246 100644
--- a/include/llvm/MC/MCStreamer.h
+++ b/include/llvm/MC/MCStreamer.h
@@ -166,6 +166,18 @@ namespace llvm {
/// @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
/// @{
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp
index 2a15783..8ce3325 100644
--- a/lib/MC/MCAsmStreamer.cpp
+++ b/lib/MC/MCAsmStreamer.cpp
@@ -59,6 +59,10 @@ namespace {
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 @@ void MCAsmStreamer::SwitchInputAssemblyFile(const char *FileName) {
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!");
diff --git a/test/MC/AsmParser/directive_dump_and_load.s b/test/MC/AsmParser/directive_dump_and_load.s
new file mode 100644
index 0000000..74c300d
--- /dev/null
+++ b/test/MC/AsmParser/directive_dump_and_load.s
@@ -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"
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index 1550c69..cb21a93 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/tools/llvm-mc/AsmParser.cpp
@@ -537,6 +537,10 @@ bool AsmParser::ParseStatement() {
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 @@ bool AsmParser::ParseDirectiveInclude() {
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;
+}
diff --git a/tools/llvm-mc/AsmParser.h b/tools/llvm-mc/AsmParser.h
index 1bb7ca2..62aa4ef 100644
--- a/tools/llvm-mc/AsmParser.h
+++ b/tools/llvm-mc/AsmParser.h
@@ -117,6 +117,8 @@ private:
// Darwin specific ".subsections_via_symbols"
bool ParseDirectiveDarwinSubsectionsViaSymbols();
+ // Darwin specific .dump and .load
+ bool ParseDirectiveDarwinDumpOrLoad(bool IsDump);
bool ParseDirectiveAbort(); // ".abort"
bool ParseDirectiveInclude(); // ".include"