mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
MC: Add MCAsmParserExtension, a base class for all the target/object specific
classes which want to extend the basic asm parser. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108158 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dc4c7da5d4
commit
53131982d6
@ -63,7 +63,6 @@ public:
|
|||||||
~AsmParser();
|
~AsmParser();
|
||||||
|
|
||||||
bool Run(bool NoInitialTextSection, bool NoFinalize = false);
|
bool Run(bool NoInitialTextSection, bool NoFinalize = false);
|
||||||
|
|
||||||
|
|
||||||
void AddDirectiveHandler(StringRef Directive,
|
void AddDirectiveHandler(StringRef Directive,
|
||||||
bool (AsmParser::*Handler)(StringRef, SMLoc)) {
|
bool (AsmParser::*Handler)(StringRef, SMLoc)) {
|
||||||
@ -71,7 +70,7 @@ public:
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
TargetAsmParser &getTargetParser() const { return *TargetParser; }
|
TargetAsmParser &getTargetParser() const { return *TargetParser; }
|
||||||
void setTargetParser(TargetAsmParser &P) { TargetParser = &P; }
|
void setTargetParser(TargetAsmParser &P);
|
||||||
|
|
||||||
/// @name MCAsmParser Interface
|
/// @name MCAsmParser Interface
|
||||||
/// {
|
/// {
|
||||||
|
65
include/llvm/MC/MCParser/MCAsmParserExtension.h
Normal file
65
include/llvm/MC/MCParser/MCAsmParserExtension.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
//===-- llvm/MC/MCAsmParserExtension.h - Asm Parser Hooks -------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_MC_MCASMPARSEREXTENSION_H
|
||||||
|
#define LLVM_MC_MCASMPARSEREXTENSION_H
|
||||||
|
|
||||||
|
#include "llvm/MC/MCParser/MCAsmParser.h"
|
||||||
|
#include "llvm/Support/SMLoc.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
|
||||||
|
/// \brief Generic interface for extending the MCAsmParser,
|
||||||
|
/// which is implemented by target and object file assembly parser
|
||||||
|
/// implementations.
|
||||||
|
class MCAsmParserExtension {
|
||||||
|
MCAsmParserExtension(const MCAsmParserExtension &); // DO NOT IMPLEMENT
|
||||||
|
void operator=(const MCAsmParserExtension &); // DO NOT IMPLEMENT
|
||||||
|
|
||||||
|
MCAsmParser *Parser;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
MCAsmParserExtension();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~MCAsmParserExtension();
|
||||||
|
|
||||||
|
/// \brief Initialize the extension for parsing using the given \arg
|
||||||
|
/// Parser. The extension should use the AsmParser interfaces to register its
|
||||||
|
/// parsing routines.
|
||||||
|
virtual void Initialize(MCAsmParser &Parser);
|
||||||
|
|
||||||
|
/// @name MCAsmParser Proxy Interfaces
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
MCContext &getContext() { return getParser().getContext(); }
|
||||||
|
MCAsmLexer &getLexer() { return getParser().getLexer(); }
|
||||||
|
MCAsmParser &getParser() { return *Parser; }
|
||||||
|
MCStreamer &getStreamer() { return getParser().getStreamer(); }
|
||||||
|
void Warning(SMLoc L, const Twine &Msg) {
|
||||||
|
return getParser().Warning(L, Msg);
|
||||||
|
}
|
||||||
|
bool Error(SMLoc L, const Twine &Msg) {
|
||||||
|
return getParser().Error(L, Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
const AsmToken &Lex() { return getParser().Lex(); }
|
||||||
|
|
||||||
|
const AsmToken &getTok() { return getParser().getTok(); }
|
||||||
|
|
||||||
|
bool TokError(const char *Msg) {
|
||||||
|
return getParser().TokError(Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // End llvm namespace
|
||||||
|
|
||||||
|
#endif
|
@ -10,6 +10,8 @@
|
|||||||
#ifndef LLVM_TARGET_TARGETPARSER_H
|
#ifndef LLVM_TARGET_TARGETPARSER_H
|
||||||
#define LLVM_TARGET_TARGETPARSER_H
|
#define LLVM_TARGET_TARGETPARSER_H
|
||||||
|
|
||||||
|
#include "llvm/MC/MCParser/MCAsmParserExtension.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class MCInst;
|
class MCInst;
|
||||||
class StringRef;
|
class StringRef;
|
||||||
@ -20,7 +22,7 @@ class MCParsedAsmOperand;
|
|||||||
template <typename T> class SmallVectorImpl;
|
template <typename T> class SmallVectorImpl;
|
||||||
|
|
||||||
/// TargetAsmParser - Generic interface to target specific assembly parsers.
|
/// TargetAsmParser - Generic interface to target specific assembly parsers.
|
||||||
class TargetAsmParser {
|
class TargetAsmParser : public MCAsmParserExtension {
|
||||||
TargetAsmParser(const TargetAsmParser &); // DO NOT IMPLEMENT
|
TargetAsmParser(const TargetAsmParser &); // DO NOT IMPLEMENT
|
||||||
void operator=(const TargetAsmParser &); // DO NOT IMPLEMENT
|
void operator=(const TargetAsmParser &); // DO NOT IMPLEMENT
|
||||||
protected: // Can only create subclasses.
|
protected: // Can only create subclasses.
|
||||||
|
@ -47,6 +47,12 @@ AsmParser::AsmParser(const Target &T, SourceMgr &_SM, MCContext &_Ctx,
|
|||||||
AsmParser::~AsmParser() {
|
AsmParser::~AsmParser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,6 @@ add_llvm_library(LLVMMCParser
|
|||||||
AsmParser.cpp
|
AsmParser.cpp
|
||||||
MCAsmLexer.cpp
|
MCAsmLexer.cpp
|
||||||
MCAsmParser.cpp
|
MCAsmParser.cpp
|
||||||
|
MCAsmParserExtension.cpp
|
||||||
TargetAsmParser.cpp
|
TargetAsmParser.cpp
|
||||||
)
|
)
|
||||||
|
21
lib/MC/MCParser/MCAsmParserExtension.cpp
Normal file
21
lib/MC/MCParser/MCAsmParserExtension.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
//===-- MCAsmParserExtension.cpp - Asm Parser Hooks -----------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/MC/MCParser/MCAsmParserExtension.h"
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
MCAsmParserExtension::MCAsmParserExtension() {
|
||||||
|
}
|
||||||
|
|
||||||
|
MCAsmParserExtension::~MCAsmParserExtension() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCAsmParserExtension::Initialize(MCAsmParser &Parser) {
|
||||||
|
this->Parser = &Parser;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user