mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Target: Give the TargetAsmParser access to the TargetMachine.
- Unfortunate, but necessary for now to handle subtarget instruction matching. Eventually we should factor out the lower level target machine information so we don't need to do this. llvm-svn: 108664
This commit is contained in:
parent
2747a00d4f
commit
150021561c
@ -65,7 +65,8 @@ namespace llvm {
|
||||
const std::string &TT);
|
||||
typedef TargetAsmLexer *(*AsmLexerCtorTy)(const Target &T,
|
||||
const MCAsmInfo &MAI);
|
||||
typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T,MCAsmParser &P);
|
||||
typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T,MCAsmParser &P,
|
||||
TargetMachine &TM);
|
||||
typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T);
|
||||
typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T,
|
||||
unsigned SyntaxVariant,
|
||||
@ -237,10 +238,11 @@ namespace llvm {
|
||||
///
|
||||
/// \arg Parser - The target independent parser implementation to use for
|
||||
/// parsing and lexing.
|
||||
TargetAsmParser *createAsmParser(MCAsmParser &Parser) const {
|
||||
TargetAsmParser *createAsmParser(MCAsmParser &Parser,
|
||||
TargetMachine &TM) const {
|
||||
if (!AsmParserCtorFn)
|
||||
return 0;
|
||||
return AsmParserCtorFn(*this, Parser);
|
||||
return AsmParserCtorFn(*this, Parser, TM);
|
||||
}
|
||||
|
||||
/// createAsmPrinter - Create a target specific assembly printer pass. This
|
||||
@ -667,8 +669,9 @@ namespace llvm {
|
||||
}
|
||||
|
||||
private:
|
||||
static TargetAsmParser *Allocator(const Target &T, MCAsmParser &P) {
|
||||
return new AsmParserImpl(T, P);
|
||||
static TargetAsmParser *Allocator(const Target &T, MCAsmParser &P,
|
||||
TargetMachine &TM) {
|
||||
return new AsmParserImpl(T, P, TM);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -74,7 +74,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, unsigned LocCookie) const {
|
||||
OwningPtr<MCAsmParser> Parser(createMCAsmParser(TM.getTarget(), SrcMgr,
|
||||
OutContext, OutStreamer,
|
||||
*MAI));
|
||||
OwningPtr<TargetAsmParser> TAP(TM.getTarget().createAsmParser(*Parser));
|
||||
OwningPtr<TargetAsmParser> TAP(TM.getTarget().createAsmParser(*Parser, TM));
|
||||
if (!TAP)
|
||||
report_fatal_error("Inline asm not supported by this streamer because"
|
||||
" we don't have an asm parser for this target\n");
|
||||
|
@ -37,6 +37,7 @@ enum ShiftType {
|
||||
|
||||
class ARMAsmParser : public TargetAsmParser {
|
||||
MCAsmParser &Parser;
|
||||
TargetMachine &TM;
|
||||
|
||||
private:
|
||||
MCAsmParser &getParser() const { return Parser; }
|
||||
@ -94,8 +95,8 @@ private:
|
||||
|
||||
|
||||
public:
|
||||
ARMAsmParser(const Target &T, MCAsmParser &_Parser)
|
||||
: TargetAsmParser(T), Parser(_Parser) {}
|
||||
ARMAsmParser(const Target &T, MCAsmParser &_Parser, TargetMachine &_TM)
|
||||
: TargetAsmParser(T), Parser(_Parser), TM(_TM) {}
|
||||
|
||||
virtual bool ParseInstruction(StringRef Name, SMLoc NameLoc,
|
||||
SmallVectorImpl<MCParsedAsmOperand*> &Operands);
|
||||
|
@ -28,6 +28,7 @@ struct X86Operand;
|
||||
|
||||
class X86ATTAsmParser : public TargetAsmParser {
|
||||
MCAsmParser &Parser;
|
||||
TargetMachine &TM;
|
||||
|
||||
protected:
|
||||
unsigned Is64Bit : 1;
|
||||
@ -62,8 +63,8 @@ private:
|
||||
/// }
|
||||
|
||||
public:
|
||||
X86ATTAsmParser(const Target &T, MCAsmParser &_Parser)
|
||||
: TargetAsmParser(T), Parser(_Parser) {}
|
||||
X86ATTAsmParser(const Target &T, MCAsmParser &_Parser, TargetMachine &TM)
|
||||
: TargetAsmParser(T), Parser(_Parser), TM(TM) {}
|
||||
|
||||
virtual bool ParseInstruction(StringRef Name, SMLoc NameLoc,
|
||||
SmallVectorImpl<MCParsedAsmOperand*> &Operands);
|
||||
@ -73,16 +74,16 @@ public:
|
||||
|
||||
class X86_32ATTAsmParser : public X86ATTAsmParser {
|
||||
public:
|
||||
X86_32ATTAsmParser(const Target &T, MCAsmParser &_Parser)
|
||||
: X86ATTAsmParser(T, _Parser) {
|
||||
X86_32ATTAsmParser(const Target &T, MCAsmParser &_Parser, TargetMachine &TM)
|
||||
: X86ATTAsmParser(T, _Parser, TM) {
|
||||
Is64Bit = false;
|
||||
}
|
||||
};
|
||||
|
||||
class X86_64ATTAsmParser : public X86ATTAsmParser {
|
||||
public:
|
||||
X86_64ATTAsmParser(const Target &T, MCAsmParser &_Parser)
|
||||
: X86ATTAsmParser(T, _Parser) {
|
||||
X86_64ATTAsmParser(const Target &T, MCAsmParser &_Parser, TargetMachine &TM)
|
||||
: X86ATTAsmParser(T, _Parser, TM) {
|
||||
Is64Bit = true;
|
||||
}
|
||||
};
|
||||
|
@ -365,7 +365,8 @@ int EDDisassembler::parseInst(SmallVectorImpl<MCParsedAsmOperand*> &operands,
|
||||
OwningPtr<MCAsmParser> genericParser(createMCAsmParser(*Tgt, sourceMgr,
|
||||
context, *streamer,
|
||||
*AsmInfo));
|
||||
OwningPtr<TargetAsmParser> TargetParser(Tgt->createAsmParser(*genericParser));
|
||||
OwningPtr<TargetAsmParser> TargetParser(Tgt->createAsmParser(*genericParser,
|
||||
*TargetMachine));
|
||||
|
||||
AsmToken OpcodeToken = genericParser->Lex();
|
||||
AsmToken NextToken = genericParser->Lex(); // consume next token, because specificParser expects us to
|
||||
|
@ -314,7 +314,7 @@ static int AssembleInput(const char *ProgName) {
|
||||
|
||||
OwningPtr<MCAsmParser> Parser(createMCAsmParser(*TheTarget, SrcMgr, Ctx,
|
||||
*Str.get(), *MAI));
|
||||
OwningPtr<TargetAsmParser> TAP(TheTarget->createAsmParser(*Parser));
|
||||
OwningPtr<TargetAsmParser> TAP(TheTarget->createAsmParser(*Parser, *TM));
|
||||
if (!TAP) {
|
||||
errs() << ProgName
|
||||
<< ": error: this target does not support assembly parsing.\n";
|
||||
|
Loading…
Reference in New Issue
Block a user