/// @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
/// @{
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);
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!");
--- /dev/null
+# RUN: llvm-mc %s | FileCheck %s
+
+# CHECK: TEST0:
+# CHECK: .dump "somefile"
+# CHECK: .load "jack and jill"
+TEST0:
+ .dump "somefile"
+ .load "jack and jill"
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();
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;
+}
// Darwin specific ".subsections_via_symbols"
bool ParseDirectiveDarwinSubsectionsViaSymbols();
+ // Darwin specific .dump and .load
+ bool ParseDirectiveDarwinDumpOrLoad(bool IsDump);
bool ParseDirectiveAbort(); // ".abort"
bool ParseDirectiveInclude(); // ".include"