[llvm-commits] [llvm] r108165 - in /llvm/trunk: include/llvm/MC/MCParser/AsmParser.h lib/MC/MCParser/AsmParser.cpp
Daniel Dunbar
daniel at zuster.org
Mon Jul 12 11:12:02 PDT 2010
Author: ddunbar
Date: Mon Jul 12 13:12:02 2010
New Revision: 108165
URL: http://llvm.org/viewvc/llvm-project?rev=108165&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/MC/MCParser/AsmParser.h
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
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=108165&r1=108164&r2=108165&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/AsmParser.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/AsmParser.h Mon Jul 12 13:12:02 2010
@@ -45,6 +45,7 @@
MCStreamer &Out;
SourceMgr &SrcMgr;
MCAsmParserExtension *GenericParser;
+ MCAsmParserExtension *PlatformParser;
TargetAsmParser *TargetParser;
/// This is the current buffer index we're lexing from as managed by the
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=108165&r1=108164&r2=108165&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Mon Jul 12 13:12:02 2010
@@ -56,6 +56,18 @@
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 @@
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;
}
More information about the llvm-commits
mailing list