[llvm-commits] [llvm] r108174 - in /llvm/trunk: include/llvm/MC/MCParser/AsmParser.h lib/MC/MCParser/AsmParser.cpp test/MC/AsmParser/directive_subsections_via_symbols.s test/MC/AsmParser/hello.s
Daniel Dunbar
daniel at zuster.org
Mon Jul 12 11:49:22 PDT 2010
Author: ddunbar
Date: Mon Jul 12 13:49:22 2010
New Revision: 108174
URL: http://llvm.org/viewvc/llvm-project?rev=108174&view=rev
Log:
MC/AsmParser: Move some misc. Darwin directive handling to DarwinAsmParser.
Modified:
llvm/trunk/include/llvm/MC/MCParser/AsmParser.h
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/test/MC/AsmParser/directive_subsections_via_symbols.s
llvm/trunk/test/MC/AsmParser/hello.s
Modified: llvm/trunk/include/llvm/MC/MCParser/AsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/AsmParser.h?rev=108174&r1=108173&r2=108174&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/AsmParser.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/AsmParser.h Mon Jul 12 13:49:22 2010
@@ -144,15 +144,6 @@
bool ParseDirectiveDarwinZerofill(); // Darwin specific ".zerofill"
bool ParseDirectiveDarwinTBSS(); // Darwin specific ".tbss"
- // Darwin specific ".subsections_via_symbols"
- bool ParseDirectiveDarwinSubsectionsViaSymbols();
- // Darwin specific .dump and .load
- bool ParseDirectiveDarwinDumpOrLoad(SMLoc IDLoc, bool IsDump);
- // Darwin specific .secure_log_unique
- bool ParseDirectiveDarwinSecureLogUnique(SMLoc IDLoc);
- // Darwin specific .secure_log_reset
- bool ParseDirectiveDarwinSecureLogReset(SMLoc IDLoc);
-
bool ParseDirectiveAbort(); // ".abort"
bool ParseDirectiveInclude(); // ".include"
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=108174&r1=108173&r2=108174&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Mon Jul 12 13:49:22 2010
@@ -65,7 +65,26 @@
virtual void Initialize(MCAsmParser &Parser) {
// Call the base implementation.
this->MCAsmParserExtension::Initialize(Parser);
- }
+
+ Parser.AddDirectiveHandler(this, ".subsections_via_symbols",
+ MCAsmParser::DirectiveHandler(
+ &DarwinAsmParser::ParseDirectiveSubsectionsViaSymbols));
+ Parser.AddDirectiveHandler(this, ".dump", MCAsmParser::DirectiveHandler(
+ &DarwinAsmParser::ParseDirectiveDumpOrLoad));
+ Parser.AddDirectiveHandler(this, ".load", MCAsmParser::DirectiveHandler(
+ &DarwinAsmParser::ParseDirectiveDumpOrLoad));
+ Parser.AddDirectiveHandler(this, ".secure_log_unique",
+ MCAsmParser::DirectiveHandler(
+ &DarwinAsmParser::ParseDirectiveSecureLogUnique));
+ Parser.AddDirectiveHandler(this, ".secure_log_reset",
+ MCAsmParser::DirectiveHandler(
+ &DarwinAsmParser::ParseDirectiveSecureLogReset));
+ }
+
+ bool ParseDirectiveSubsectionsViaSymbols(StringRef, SMLoc);
+ bool ParseDirectiveDumpOrLoad(StringRef, SMLoc);
+ bool ParseDirectiveSecureLogUnique(StringRef, SMLoc);
+ bool ParseDirectiveSecureLogReset(StringRef, SMLoc);
};
}
@@ -822,20 +841,10 @@
if (IDVal == ".tbss")
return ParseDirectiveDarwinTBSS();
- if (IDVal == ".subsections_via_symbols")
- return ParseDirectiveDarwinSubsectionsViaSymbols();
if (IDVal == ".abort")
return ParseDirectiveAbort();
if (IDVal == ".include")
return ParseDirectiveInclude();
- if (IDVal == ".dump")
- return ParseDirectiveDarwinDumpOrLoad(IDLoc, /*IsDump=*/true);
- if (IDVal == ".load")
- return ParseDirectiveDarwinDumpOrLoad(IDLoc, /*IsLoad=*/false);
- if (IDVal == ".secure_log_unique")
- return ParseDirectiveDarwinSecureLogUnique(IDLoc);
- if (IDVal == ".secure_log_reset")
- return ParseDirectiveDarwinSecureLogReset(IDLoc);
// Look up the handler in the handler table.
std::pair<MCAsmParserExtension*, DirectiveHandler> Handler =
@@ -1663,9 +1672,9 @@
return false;
}
-/// ParseDirectiveDarwinSubsectionsViaSymbols
+/// ParseDirectiveSubsectionsViaSymbols
/// ::= .subsections_via_symbols
-bool AsmParser::ParseDirectiveDarwinSubsectionsViaSymbols() {
+bool DarwinAsmParser::ParseDirectiveSubsectionsViaSymbols(StringRef, SMLoc) {
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.subsections_via_symbols' directive");
@@ -1764,9 +1773,11 @@
return false;
}
-/// ParseDirectiveDarwinDumpOrLoad
+/// ParseDirectiveDumpOrLoad
/// ::= ( .dump | .load ) "filename"
-bool AsmParser::ParseDirectiveDarwinDumpOrLoad(SMLoc IDLoc, bool IsDump) {
+bool DarwinAsmParser::ParseDirectiveDumpOrLoad(StringRef Directive,
+ SMLoc IDLoc) {
+ bool IsDump = Directive == ".dump";
if (getLexer().isNot(AsmToken::String))
return TokError("expected string in '.dump' or '.load' directive");
@@ -1787,19 +1798,19 @@
return false;
}
-/// ParseDirectiveDarwinSecureLogUnique
+/// ParseDirectiveSecureLogUnique
/// ::= .secure_log_unique "log message"
-bool AsmParser::ParseDirectiveDarwinSecureLogUnique(SMLoc IDLoc) {
+bool DarwinAsmParser::ParseDirectiveSecureLogUnique(StringRef, SMLoc IDLoc) {
std::string LogMessage;
- if (Lexer.isNot(AsmToken::String))
+ if (getLexer().isNot(AsmToken::String))
LogMessage = "";
else{
LogMessage = getTok().getString();
Lex();
}
- if (Lexer.isNot(AsmToken::EndOfStatement))
+ if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.secure_log_unique' directive");
if (getContext().getSecureLogUsed() != false)
@@ -1822,9 +1833,9 @@
getContext().setSecureLog(OS);
}
- int CurBuf = SrcMgr.FindBufferContainingLoc(IDLoc);
- *OS << SrcMgr.getBufferInfo(CurBuf).Buffer->getBufferIdentifier() << ":"
- << SrcMgr.FindLineNumber(IDLoc, CurBuf) << ":"
+ int CurBuf = getSourceManager().FindBufferContainingLoc(IDLoc);
+ *OS << getSourceManager().getBufferInfo(CurBuf).Buffer->getBufferIdentifier()
+ << ":" << getSourceManager().FindLineNumber(IDLoc, CurBuf) << ":"
<< LogMessage + "\n";
getContext().setSecureLogUsed(true);
@@ -1832,9 +1843,9 @@
return false;
}
-/// ParseDirectiveDarwinSecureLogReset
+/// ParseDirectiveSecureLogReset
/// ::= .secure_log_reset
-bool AsmParser::ParseDirectiveDarwinSecureLogReset(SMLoc IDLoc) {
+bool DarwinAsmParser::ParseDirectiveSecureLogReset(StringRef, SMLoc IDLoc) {
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.secure_log_reset' directive");
Modified: llvm/trunk/test/MC/AsmParser/directive_subsections_via_symbols.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/directive_subsections_via_symbols.s?rev=108174&r1=108173&r2=108174&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/directive_subsections_via_symbols.s (original)
+++ llvm/trunk/test/MC/AsmParser/directive_subsections_via_symbols.s Mon Jul 12 13:49:22 2010
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+# RUN: llvm-mc -triple i386-apple-darwin9 %s | FileCheck %s
# CHECK: TEST0:
# CHECK: .subsections_via_symbols
Modified: llvm/trunk/test/MC/AsmParser/hello.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/hello.s?rev=108174&r1=108173&r2=108174&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/hello.s (original)
+++ llvm/trunk/test/MC/AsmParser/hello.s Mon Jul 12 13:49:22 2010
@@ -1,6 +1,6 @@
-// RUN: llvm-mc -triple i386-unknown-unknown %s -o -
-// RUN: llvm-mc -triple i386-unknown-unknown %s -o - -output-asm-variant=1
-
+// RUN: llvm-mc -triple i386-apple-darwin9 %s -o -
+// RUN: llvm-mc -triple i386-apple-darwin9 %s -o - -output-asm-variant=1
+
.text
.align 4,0x90
.globl _main
More information about the llvm-commits
mailing list