From: Daniel Dunbar Date: Mon, 12 Jul 2010 18:12:02 +0000 (+0000) Subject: MC/AsmParser: Add a DarwinAsmParser extension. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e47497087b00fd4519057d3bd30e8bd4af61c6ca;p=oota-llvm.git MC/AsmParser: Add a DarwinAsmParser extension. - Currently initialization is a bit of a hack, but harmless. We need to rework various parts of target initialization to clean this up. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108165 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/MC/MCParser/AsmParser.h b/include/llvm/MC/MCParser/AsmParser.h index bbf2ebfbed5..348351180a5 100644 --- a/include/llvm/MC/MCParser/AsmParser.h +++ b/include/llvm/MC/MCParser/AsmParser.h @@ -45,6 +45,7 @@ private: MCStreamer &Out; SourceMgr &SrcMgr; MCAsmParserExtension *GenericParser; + MCAsmParserExtension *PlatformParser; TargetAsmParser *TargetParser; /// This is the current buffer index we're lexing from as managed by the diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 05c878e27ce..c4c3ce14506 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -56,6 +56,18 @@ public: bool ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc); // ".loc" }; +/// \brief Implementation of directive handling which is shared across all +/// Darwin targets. +class DarwinAsmParser : public MCAsmParserExtension { +public: + DarwinAsmParser() {} + + virtual void Initialize(MCAsmParser &Parser) { + // Call the base implementation. + this->MCAsmParserExtension::Initialize(Parser); + } +}; + } enum { DEFAULT_ADDRSPACE = 0 }; @@ -63,14 +75,25 @@ enum { DEFAULT_ADDRSPACE = 0 }; AsmParser::AsmParser(const Target &T, SourceMgr &_SM, MCContext &_Ctx, MCStreamer &_Out, const MCAsmInfo &_MAI) : Lexer(_MAI), Ctx(_Ctx), Out(_Out), SrcMgr(_SM), - GenericParser(new GenericAsmParser), TargetParser(0), CurBuffer(0) { + GenericParser(new GenericAsmParser), PlatformParser(0), + TargetParser(0), CurBuffer(0) { Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)); // Initialize the generic parser. GenericParser->Initialize(*this); + + // Initialize the platform / file format parser. + // + // FIXME: This is a hack, we need to (majorly) cleanup how these objects are + // created. + if (_MAI.hasSubsectionsViaSymbols()) { + PlatformParser = new DarwinAsmParser; + PlatformParser->Initialize(*this); + } } AsmParser::~AsmParser() { + delete PlatformParser; delete GenericParser; }