mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-11 05:17:36 +00:00
MC/AsmParser: Lift Run() and TargetParser to base class.
Also, add constructor function for creating AsmParser instances. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108604 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dd7d28a17b
commit
d1e3b44d6c
@ -46,7 +46,6 @@ private:
|
|||||||
SourceMgr &SrcMgr;
|
SourceMgr &SrcMgr;
|
||||||
MCAsmParserExtension *GenericParser;
|
MCAsmParserExtension *GenericParser;
|
||||||
MCAsmParserExtension *PlatformParser;
|
MCAsmParserExtension *PlatformParser;
|
||||||
TargetAsmParser *TargetParser;
|
|
||||||
|
|
||||||
/// This is the current buffer index we're lexing from as managed by the
|
/// This is the current buffer index we're lexing from as managed by the
|
||||||
/// SourceMgr object.
|
/// SourceMgr object.
|
||||||
@ -65,7 +64,7 @@ public:
|
|||||||
const MCAsmInfo &MAI);
|
const MCAsmInfo &MAI);
|
||||||
~AsmParser();
|
~AsmParser();
|
||||||
|
|
||||||
bool Run(bool NoInitialTextSection, bool NoFinalize = false);
|
virtual bool Run(bool NoInitialTextSection, bool NoFinalize = false);
|
||||||
|
|
||||||
void AddDirectiveHandler(MCAsmParserExtension *Object,
|
void AddDirectiveHandler(MCAsmParserExtension *Object,
|
||||||
StringRef Directive,
|
StringRef Directive,
|
||||||
@ -74,9 +73,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TargetAsmParser &getTargetParser() const { return *TargetParser; }
|
|
||||||
void setTargetParser(TargetAsmParser &P);
|
|
||||||
|
|
||||||
/// @name MCAsmParser Interface
|
/// @name MCAsmParser Interface
|
||||||
/// {
|
/// {
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class AsmToken;
|
class AsmToken;
|
||||||
|
class MCAsmInfo;
|
||||||
class MCAsmLexer;
|
class MCAsmLexer;
|
||||||
class MCAsmParserExtension;
|
class MCAsmParserExtension;
|
||||||
class MCContext;
|
class MCContext;
|
||||||
@ -22,6 +23,8 @@ class MCStreamer;
|
|||||||
class SMLoc;
|
class SMLoc;
|
||||||
class SourceMgr;
|
class SourceMgr;
|
||||||
class StringRef;
|
class StringRef;
|
||||||
|
class Target;
|
||||||
|
class TargetAsmParser;
|
||||||
class Twine;
|
class Twine;
|
||||||
|
|
||||||
/// MCAsmParser - Generic assembler parser interface, for use by target specific
|
/// MCAsmParser - Generic assembler parser interface, for use by target specific
|
||||||
@ -33,6 +36,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
MCAsmParser(const MCAsmParser &); // DO NOT IMPLEMENT
|
MCAsmParser(const MCAsmParser &); // DO NOT IMPLEMENT
|
||||||
void operator=(const MCAsmParser &); // DO NOT IMPLEMENT
|
void operator=(const MCAsmParser &); // DO NOT IMPLEMENT
|
||||||
|
|
||||||
|
TargetAsmParser *TargetParser;
|
||||||
|
|
||||||
protected: // Can only create subclasses.
|
protected: // Can only create subclasses.
|
||||||
MCAsmParser();
|
MCAsmParser();
|
||||||
|
|
||||||
@ -52,6 +58,12 @@ public:
|
|||||||
/// getStreamer - Return the output streamer for the assembler.
|
/// getStreamer - Return the output streamer for the assembler.
|
||||||
virtual MCStreamer &getStreamer() = 0;
|
virtual MCStreamer &getStreamer() = 0;
|
||||||
|
|
||||||
|
TargetAsmParser &getTargetParser() const { return *TargetParser; }
|
||||||
|
void setTargetParser(TargetAsmParser &P);
|
||||||
|
|
||||||
|
/// Run - Run the parser on the input source buffer.
|
||||||
|
virtual bool Run(bool NoInitialTextSection, bool NoFinalize = false) = 0;
|
||||||
|
|
||||||
/// Warning - Emit a warning at the location \arg L, with the message \arg
|
/// Warning - Emit a warning at the location \arg L, with the message \arg
|
||||||
/// Msg.
|
/// Msg.
|
||||||
virtual void Warning(SMLoc L, const Twine &Msg) = 0;
|
virtual void Warning(SMLoc L, const Twine &Msg) = 0;
|
||||||
@ -102,6 +114,10 @@ public:
|
|||||||
virtual bool ParseAbsoluteExpression(int64_t &Res) = 0;
|
virtual bool ParseAbsoluteExpression(int64_t &Res) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// \brief Create an MCAsmParser instance.
|
||||||
|
MCAsmParser *createMCAsmParser(const Target &, SourceMgr &, MCContext &,
|
||||||
|
MCStreamer &, const MCAsmInfo &);
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -69,7 +69,7 @@ AsmParser::AsmParser(const Target &T, SourceMgr &_SM, MCContext &_Ctx,
|
|||||||
MCStreamer &_Out, const MCAsmInfo &_MAI)
|
MCStreamer &_Out, const MCAsmInfo &_MAI)
|
||||||
: Lexer(_MAI), Ctx(_Ctx), Out(_Out), SrcMgr(_SM),
|
: Lexer(_MAI), Ctx(_Ctx), Out(_Out), SrcMgr(_SM),
|
||||||
GenericParser(new GenericAsmParser), PlatformParser(0),
|
GenericParser(new GenericAsmParser), PlatformParser(0),
|
||||||
TargetParser(0), CurBuffer(0) {
|
CurBuffer(0) {
|
||||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
|
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
|
||||||
|
|
||||||
// Initialize the generic parser.
|
// Initialize the generic parser.
|
||||||
@ -93,12 +93,6 @@ AsmParser::~AsmParser() {
|
|||||||
delete GenericParser;
|
delete GenericParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmParser::setTargetParser(TargetAsmParser &P) {
|
|
||||||
assert(!TargetParser && "Target parser is already initialized!");
|
|
||||||
TargetParser = &P;
|
|
||||||
TargetParser->Initialize(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AsmParser::Warning(SMLoc L, const Twine &Msg) {
|
void AsmParser::Warning(SMLoc L, const Twine &Msg) {
|
||||||
PrintMessage(L, Msg.str(), "warning");
|
PrintMessage(L, Msg.str(), "warning");
|
||||||
}
|
}
|
||||||
@ -1487,3 +1481,10 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// \brief Create an MCAsmParser instance.
|
||||||
|
MCAsmParser *llvm::createMCAsmParser(const Target &T, SourceMgr &SM,
|
||||||
|
MCContext &C, MCStreamer &Out,
|
||||||
|
const MCAsmInfo &MAI) {
|
||||||
|
return new AsmParser(T, SM, C, Out, MAI);
|
||||||
|
}
|
||||||
|
@ -12,14 +12,21 @@
|
|||||||
#include "llvm/MC/MCParser/MCAsmLexer.h"
|
#include "llvm/MC/MCParser/MCAsmLexer.h"
|
||||||
#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
|
#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
|
||||||
#include "llvm/Support/SourceMgr.h"
|
#include "llvm/Support/SourceMgr.h"
|
||||||
|
#include "llvm/Target/TargetAsmParser.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
MCAsmParser::MCAsmParser() {
|
MCAsmParser::MCAsmParser() : TargetParser(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MCAsmParser::~MCAsmParser() {
|
MCAsmParser::~MCAsmParser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MCAsmParser::setTargetParser(TargetAsmParser &P) {
|
||||||
|
assert(!TargetParser && "Target parser is already initialized!");
|
||||||
|
TargetParser = &P;
|
||||||
|
TargetParser->Initialize(*this);
|
||||||
|
}
|
||||||
|
|
||||||
const AsmToken &MCAsmParser::getTok() {
|
const AsmToken &MCAsmParser::getTok() {
|
||||||
return getLexer().getTok();
|
return getLexer().getTok();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user