MC/AsmParser: Move .section parsing to Darwin specific parser.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108190 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-07-12 20:42:34 +00:00
parent 19ad3b88f7
commit 4d5fe97c47
2 changed files with 10 additions and 14 deletions

View File

@ -118,7 +118,6 @@ private:
bool ParseIdentifier(StringRef &Res); bool ParseIdentifier(StringRef &Res);
// Directive Parsing. // Directive Parsing.
bool ParseDirectiveDarwinSection(); // Darwin specific ".section".
bool ParseDirectiveAscii(bool ZeroTerminated); // ".ascii", ".asciiz" bool ParseDirectiveAscii(bool ZeroTerminated); // ".ascii", ".asciiz"
bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ... bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ...
bool ParseDirectiveFill(); // ".fill" bool ParseDirectiveFill(); // ".fill"

View File

@ -82,6 +82,8 @@ public:
&DarwinAsmParser::ParseDirectiveDumpOrLoad)); &DarwinAsmParser::ParseDirectiveDumpOrLoad));
Parser.AddDirectiveHandler(this, ".load", MCAsmParser::DirectiveHandler( Parser.AddDirectiveHandler(this, ".load", MCAsmParser::DirectiveHandler(
&DarwinAsmParser::ParseDirectiveDumpOrLoad)); &DarwinAsmParser::ParseDirectiveDumpOrLoad));
Parser.AddDirectiveHandler(this, ".section", MCAsmParser::DirectiveHandler(
&DarwinAsmParser::ParseDirectiveSection));
Parser.AddDirectiveHandler(this, ".secure_log_unique", Parser.AddDirectiveHandler(this, ".secure_log_unique",
MCAsmParser::DirectiveHandler( MCAsmParser::DirectiveHandler(
&DarwinAsmParser::ParseDirectiveSecureLogUnique)); &DarwinAsmParser::ParseDirectiveSecureLogUnique));
@ -230,6 +232,7 @@ public:
bool ParseDirectiveDesc(StringRef, SMLoc); bool ParseDirectiveDesc(StringRef, SMLoc);
bool ParseDirectiveDumpOrLoad(StringRef, SMLoc); bool ParseDirectiveDumpOrLoad(StringRef, SMLoc);
bool ParseDirectiveLsym(StringRef, SMLoc); bool ParseDirectiveLsym(StringRef, SMLoc);
bool ParseDirectiveSection();
bool ParseDirectiveSecureLogReset(StringRef, SMLoc); bool ParseDirectiveSecureLogReset(StringRef, SMLoc);
bool ParseDirectiveSecureLogUnique(StringRef, SMLoc); bool ParseDirectiveSecureLogUnique(StringRef, SMLoc);
bool ParseDirectiveSubsectionsViaSymbols(StringRef, SMLoc); bool ParseDirectiveSubsectionsViaSymbols(StringRef, SMLoc);
@ -947,10 +950,6 @@ bool AsmParser::ParseStatement() {
// Otherwise, we have a normal instruction or directive. // Otherwise, we have a normal instruction or directive.
if (IDVal[0] == '.') { if (IDVal[0] == '.') {
// FIXME: This should be driven based on a hash lookup and callback.
if (IDVal == ".section")
return ParseDirectiveDarwinSection();
// Assembler features // Assembler features
if (IDVal == ".set") if (IDVal == ".set")
return ParseDirectiveSet(); return ParseDirectiveSet();
@ -1168,13 +1167,11 @@ bool AsmParser::ParseDirectiveSet() {
/// ParseDirectiveSection: /// ParseDirectiveSection:
/// ::= .section identifier (',' identifier)* /// ::= .section identifier (',' identifier)*
/// FIXME: This should actually parse out the segment, section, attributes and bool DarwinAsmParser::ParseDirectiveSection() {
/// sizeof_stub fields.
bool AsmParser::ParseDirectiveDarwinSection() {
SMLoc Loc = getLexer().getLoc(); SMLoc Loc = getLexer().getLoc();
StringRef SectionName; StringRef SectionName;
if (ParseIdentifier(SectionName)) if (getParser().ParseIdentifier(SectionName))
return Error(Loc, "expected identifier after '.section' directive"); return Error(Loc, "expected identifier after '.section' directive");
// Verify there is a following comma. // Verify there is a following comma.
@ -1186,7 +1183,7 @@ bool AsmParser::ParseDirectiveDarwinSection() {
// Add all the tokens until the end of the line, ParseSectionSpecifier will // Add all the tokens until the end of the line, ParseSectionSpecifier will
// handle this. // handle this.
StringRef EOL = Lexer.LexUntilEndOfStatement(); StringRef EOL = getLexer().LexUntilEndOfStatement();
SectionSpec.append(EOL.begin(), EOL.end()); SectionSpec.append(EOL.begin(), EOL.end());
Lex(); Lex();
@ -1197,16 +1194,16 @@ bool AsmParser::ParseDirectiveDarwinSection() {
StringRef Segment, Section; StringRef Segment, Section;
unsigned TAA, StubSize; unsigned TAA, StubSize;
std::string ErrorStr = std::string ErrorStr =
MCSectionMachO::ParseSectionSpecifier(SectionSpec, Segment, Section, MCSectionMachO::ParseSectionSpecifier(SectionSpec, Segment, Section,
TAA, StubSize); TAA, StubSize);
if (!ErrorStr.empty()) if (!ErrorStr.empty())
return Error(Loc, ErrorStr.c_str()); return Error(Loc, ErrorStr.c_str());
// FIXME: Arch specific. // FIXME: Arch specific.
bool isText = Segment == "__TEXT"; // FIXME: Hack. bool isText = Segment == "__TEXT"; // FIXME: Hack.
getStreamer().SwitchSection(Ctx.getMachOSection( getStreamer().SwitchSection(getContext().getMachOSection(
Segment, Section, TAA, StubSize, Segment, Section, TAA, StubSize,
isText ? SectionKind::getText() isText ? SectionKind::getText()
: SectionKind::getDataRel())); : SectionKind::getDataRel()));