TargetAsmParser doesn't need reference to Target.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134721 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng 2011-07-08 19:33:14 +00:00
parent 11b4c952a6
commit 480cee5d43
6 changed files with 21 additions and 27 deletions

View File

@ -15,7 +15,6 @@
namespace llvm {
class MCStreamer;
class StringRef;
class Target;
class SMLoc;
class AsmToken;
class MCParsedAsmOperand;
@ -26,23 +25,19 @@ class TargetAsmParser : public MCAsmParserExtension {
TargetAsmParser(const TargetAsmParser &); // DO NOT IMPLEMENT
void operator=(const TargetAsmParser &); // DO NOT IMPLEMENT
protected: // Can only create subclasses.
TargetAsmParser(const Target &);
TargetAsmParser();
/// The Target that this machine was created for.
const Target &TheTarget;
/// The current set of available features.
/// AvailableFeatures - The current set of available features.
unsigned AvailableFeatures;
public:
virtual ~TargetAsmParser();
const Target &getTarget() const { return TheTarget; }
unsigned getAvailableFeatures() const { return AvailableFeatures; }
void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; }
virtual bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) = 0;
virtual bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc,
SMLoc &EndLoc) = 0;
/// ParseInstruction - Parse one assembly instruction.
///

View File

@ -79,7 +79,7 @@ namespace llvm {
const std::string &TT);
typedef TargetAsmLexer *(*AsmLexerCtorTy)(const Target &T,
const MCAsmInfo &MAI);
typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T, StringRef TT,
typedef TargetAsmParser *(*AsmParserCtorTy)(StringRef TT,
StringRef CPU, StringRef Features,
MCAsmParser &P);
typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T);
@ -300,10 +300,11 @@ namespace llvm {
/// \arg Parser - The target independent parser implementation to use for
/// parsing and lexing.
TargetAsmParser *createAsmParser(StringRef Triple, StringRef CPU,
StringRef Features, MCAsmParser &Parser) const {
StringRef Features,
MCAsmParser &Parser) const {
if (!AsmParserCtorFn)
return 0;
return AsmParserCtorFn(*this, Triple, CPU, Features, Parser);
return AsmParserCtorFn(Triple, CPU, Features, Parser);
}
/// createAsmPrinter - Create a target specific assembly printer pass. This
@ -858,10 +859,9 @@ namespace llvm {
}
private:
static TargetAsmParser *Allocator(const Target &T, StringRef TT,
StringRef CPU, StringRef FS,
MCAsmParser &P) {
return new AsmParserImpl(T, TT, CPU, FS, P);
static TargetAsmParser *Allocator(StringRef TT, StringRef CPU,
StringRef FS, MCAsmParser &P) {
return new AsmParserImpl(TT, CPU, FS, P);
}
};

View File

@ -10,8 +10,8 @@
#include "llvm/Target/TargetAsmParser.h"
using namespace llvm;
TargetAsmParser::TargetAsmParser(const Target &T)
: TheTarget(T), AvailableFeatures(0)
TargetAsmParser::TargetAsmParser()
: AvailableFeatures(0)
{
}

View File

@ -41,7 +41,7 @@ class ARMOperand;
class ARMAsmParser : public TargetAsmParser {
MCAsmParser &Parser;
MCSubtargetInfo *STI;
const MCSubtargetInfo *STI;
MCAsmParser &getParser() const { return Parser; }
MCAsmLexer &getLexer() const { return Parser.getLexer(); }
@ -127,9 +127,8 @@ class ARMAsmParser : public TargetAsmParser {
const SmallVectorImpl<MCParsedAsmOperand*> &);
public:
ARMAsmParser(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
MCAsmParser &_Parser)
: TargetAsmParser(T), Parser(_Parser) {
ARMAsmParser(StringRef TT, StringRef CPU, StringRef FS, MCAsmParser &_Parser)
: TargetAsmParser(), Parser(_Parser) {
STI = ARM_MC::createARMMCSubtargetInfo(TT, CPU, FS);
MCAsmParserExtension::Initialize(_Parser);

View File

@ -63,9 +63,9 @@ class MBlazeAsmParser : public TargetAsmParser {
public:
MBlazeAsmParser(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
MBlazeAsmParser(StringRef TT, StringRef CPU, StringRef FS,
MCAsmParser &_Parser)
: TargetAsmParser(T), Parser(_Parser) {}
: TargetAsmParser(), Parser(_Parser) {}
virtual bool ParseInstruction(StringRef Name, SMLoc NameLoc,
SmallVectorImpl<MCParsedAsmOperand*> &Operands);

View File

@ -37,7 +37,7 @@ struct X86Operand;
class X86ATTAsmParser : public TargetAsmParser {
MCAsmParser &Parser;
MCSubtargetInfo *STI;
const MCSubtargetInfo *STI;
private:
MCAsmParser &getParser() const { return Parser; }
@ -77,9 +77,9 @@ private:
/// }
public:
X86ATTAsmParser(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
X86ATTAsmParser(StringRef TT, StringRef CPU, StringRef FS,
MCAsmParser &parser)
: TargetAsmParser(T), Parser(parser) {
: TargetAsmParser(), Parser(parser) {
STI = X86_MC::createX86MCSubtargetInfo(TT, CPU, FS);
// Initialize the set of available features.