From 9186fa6b0c8806786cae78bed50f95d1c7ce2b00 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 1 Jul 2010 20:41:56 +0000 Subject: [PATCH] MC: Pass the target instance to the AsmParser constructor. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107426 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCParser/AsmParser.h | 5 ++++- lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp | 2 +- lib/MC/MCParser/AsmParser.cpp | 9 +++------ tools/edis/EDDisassembler.cpp | 2 +- tools/llvm-mc/llvm-mc.cpp | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/llvm/MC/MCParser/AsmParser.h b/include/llvm/MC/MCParser/AsmParser.h index 99b48bb8a44..8faa1a42e6d 100644 --- a/include/llvm/MC/MCParser/AsmParser.h +++ b/include/llvm/MC/MCParser/AsmParser.h @@ -36,11 +36,14 @@ class TargetAsmParser; class Twine; class AsmParser : public MCAsmParser { + AsmParser(const AsmParser &); // DO NOT IMPLEMENT + void operator=(const AsmParser &); // DO NOT IMPLEMENT private: AsmLexer Lexer; MCContext &Ctx; MCStreamer &Out; SourceMgr &SrcMgr; + TargetAsmParser *GenericTargetParser; TargetAsmParser *TargetParser; /// This is the current buffer index we're lexing from as managed by the @@ -56,7 +59,7 @@ private: /// in the directive name and the location of the directive keyword. StringMap DirectiveMap; public: - AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out, + AsmParser(const Target &T, SourceMgr &SM, MCContext &Ctx, MCStreamer &Out, const MCAsmInfo &MAI); ~AsmParser(); diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index ba6fed2a78b..e181305ea90 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -83,7 +83,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, unsigned LocCookie) const { // Tell SrcMgr about this buffer, it takes ownership of the buffer. SrcMgr.AddNewSourceBuffer(Buffer, SMLoc()); - AsmParser Parser(SrcMgr, OutContext, OutStreamer, *MAI); + AsmParser Parser(TM.getTarget(), SrcMgr, OutContext, OutStreamer, *MAI); OwningPtr TAP(TM.getTarget().createAsmParser(Parser)); if (!TAP) report_fatal_error("Inline asm not supported by this streamer because" diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index dc63e1dc5fe..860277409d9 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -32,10 +32,9 @@ using namespace llvm; enum { DEFAULT_ADDRSPACE = 0 }; -AsmParser::AsmParser(SourceMgr &_SM, MCContext &_Ctx, MCStreamer &_Out, - const MCAsmInfo &_MAI) - : Lexer(_MAI), Ctx(_Ctx), Out(_Out), SrcMgr(_SM), TargetParser(0), - CurBuffer(0) { +AsmParser::AsmParser(const Target &T, SourceMgr &_SM, MCContext &_Ctx, + MCStreamer &_Out, const MCAsmInfo &_MAI) + : Lexer(_MAI), Ctx(_Ctx), Out(_Out), SrcMgr(_SM), CurBuffer(0) { Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)); // Debugging directives. @@ -44,8 +43,6 @@ AsmParser::AsmParser(SourceMgr &_SM, MCContext &_Ctx, MCStreamer &_Out, AddDirectiveHandler(".loc", &AsmParser::ParseDirectiveLoc); } - - AsmParser::~AsmParser() { } diff --git a/tools/edis/EDDisassembler.cpp b/tools/edis/EDDisassembler.cpp index 00b5d8d33a0..85e41e61af9 100644 --- a/tools/edis/EDDisassembler.cpp +++ b/tools/edis/EDDisassembler.cpp @@ -364,7 +364,7 @@ int EDDisassembler::parseInst(SmallVectorImpl &operands, sourceMgr.AddNewSourceBuffer(buf, SMLoc()); // ownership of buf handed over MCContext context(*AsmInfo); OwningPtr streamer(createNullStreamer(context)); - AsmParser genericParser(sourceMgr, context, *streamer, *AsmInfo); + AsmParser genericParser(*Tgt, sourceMgr, context, *streamer, *AsmInfo); OwningPtr TargetParser(Tgt->createAsmParser(genericParser)); AsmToken OpcodeToken = genericParser.Lex(); diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 6de6bfb3c8a..fc8a1c5523a 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -312,7 +312,7 @@ static int AssembleInput(const char *ProgName) { Str.reset(createLoggingStreamer(Str.take(), errs())); } - AsmParser Parser(SrcMgr, Ctx, *Str.get(), *MAI); + AsmParser Parser(*TheTarget, SrcMgr, Ctx, *Str.get(), *MAI); OwningPtr TAP(TheTarget->createAsmParser(Parser)); if (!TAP) { errs() << ProgName