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
This commit is contained in:
Daniel Dunbar 2010-07-01 20:41:56 +00:00
parent eb89c90f0b
commit 9186fa6b0c
5 changed files with 10 additions and 10 deletions

View File

@ -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<bool(AsmParser::*)(StringRef, SMLoc)> DirectiveMap;
public:
AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
AsmParser(const Target &T, SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
const MCAsmInfo &MAI);
~AsmParser();

View File

@ -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<TargetAsmParser> TAP(TM.getTarget().createAsmParser(Parser));
if (!TAP)
report_fatal_error("Inline asm not supported by this streamer because"

View File

@ -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() {
}

View File

@ -364,7 +364,7 @@ int EDDisassembler::parseInst(SmallVectorImpl<MCParsedAsmOperand*> &operands,
sourceMgr.AddNewSourceBuffer(buf, SMLoc()); // ownership of buf handed over
MCContext context(*AsmInfo);
OwningPtr<MCStreamer> streamer(createNullStreamer(context));
AsmParser genericParser(sourceMgr, context, *streamer, *AsmInfo);
AsmParser genericParser(*Tgt, sourceMgr, context, *streamer, *AsmInfo);
OwningPtr<TargetAsmParser> TargetParser(Tgt->createAsmParser(genericParser));
AsmToken OpcodeToken = genericParser.Lex();

View File

@ -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<TargetAsmParser> TAP(TheTarget->createAsmParser(Parser));
if (!TAP) {
errs() << ProgName