2010-07-12 17:27:45 +00:00
|
|
|
//===-- 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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-10 00:45:19 +00:00
|
|
|
#ifndef LLVM_MC_MCPARSER_MCASMPARSEREXTENSION_H
|
|
|
|
#define LLVM_MC_MCPARSER_MCASMPARSEREXTENSION_H
|
2010-07-12 17:27:45 +00:00
|
|
|
|
2010-07-18 22:22:07 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2012-12-03 17:02:12 +00:00
|
|
|
#include "llvm/MC/MCParser/MCAsmParser.h"
|
2010-07-12 17:27:45 +00:00
|
|
|
#include "llvm/Support/SMLoc.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
2010-07-18 18:31:42 +00:00
|
|
|
class Twine;
|
2010-07-12 17:27:45 +00:00
|
|
|
|
|
|
|
/// \brief Generic interface for extending the MCAsmParser,
|
|
|
|
/// which is implemented by target and object file assembly parser
|
|
|
|
/// implementations.
|
|
|
|
class MCAsmParserExtension {
|
2015-02-15 22:54:22 +00:00
|
|
|
MCAsmParserExtension(const MCAsmParserExtension &) = delete;
|
|
|
|
void operator=(const MCAsmParserExtension &) = delete;
|
2010-07-12 17:27:45 +00:00
|
|
|
|
|
|
|
MCAsmParser *Parser;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
MCAsmParserExtension();
|
|
|
|
|
2010-07-18 22:22:07 +00:00
|
|
|
// Helper template for implementing static dispatch functions.
|
|
|
|
template<typename T, bool (T::*Handler)(StringRef, SMLoc)>
|
|
|
|
static bool HandleDirective(MCAsmParserExtension *Target,
|
|
|
|
StringRef Directive,
|
|
|
|
SMLoc DirectiveLoc) {
|
|
|
|
T *Obj = static_cast<T*>(Target);
|
|
|
|
return (Obj->*Handler)(Directive, DirectiveLoc);
|
|
|
|
}
|
|
|
|
|
2011-02-24 21:59:22 +00:00
|
|
|
bool BracketExpressionsSupported;
|
|
|
|
|
2010-07-12 17:27:45 +00:00
|
|
|
public:
|
|
|
|
virtual ~MCAsmParserExtension();
|
|
|
|
|
2012-09-14 14:57:36 +00:00
|
|
|
/// \brief Initialize the extension for parsing using the given \p Parser.
|
|
|
|
/// The extension should use the AsmParser interfaces to register its
|
2010-07-12 17:27:45 +00:00
|
|
|
/// parsing routines.
|
|
|
|
virtual void Initialize(MCAsmParser &Parser);
|
|
|
|
|
|
|
|
/// @name MCAsmParser Proxy Interfaces
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
MCContext &getContext() { return getParser().getContext(); }
|
2014-11-11 05:11:47 +00:00
|
|
|
|
2010-07-12 17:27:45 +00:00
|
|
|
MCAsmLexer &getLexer() { return getParser().getLexer(); }
|
2014-11-11 05:11:47 +00:00
|
|
|
const MCAsmLexer &getLexer() const {
|
|
|
|
return const_cast<MCAsmParserExtension *>(this)->getLexer();
|
|
|
|
}
|
|
|
|
|
2010-07-12 17:27:45 +00:00
|
|
|
MCAsmParser &getParser() { return *Parser; }
|
2014-11-11 05:11:47 +00:00
|
|
|
const MCAsmParser &getParser() const {
|
|
|
|
return const_cast<MCAsmParserExtension*>(this)->getParser();
|
|
|
|
}
|
|
|
|
|
2010-07-12 18:35:04 +00:00
|
|
|
SourceMgr &getSourceManager() { return getParser().getSourceManager(); }
|
2010-07-12 17:27:45 +00:00
|
|
|
MCStreamer &getStreamer() { return getParser().getStreamer(); }
|
2011-05-19 18:00:13 +00:00
|
|
|
bool Warning(SMLoc L, const Twine &Msg) {
|
2010-07-12 17:27:45 +00:00
|
|
|
return getParser().Warning(L, Msg);
|
|
|
|
}
|
|
|
|
bool Error(SMLoc L, const Twine &Msg) {
|
|
|
|
return getParser().Error(L, Msg);
|
|
|
|
}
|
2010-07-18 18:31:42 +00:00
|
|
|
bool TokError(const Twine &Msg) {
|
|
|
|
return getParser().TokError(Msg);
|
|
|
|
}
|
2010-07-12 17:27:45 +00:00
|
|
|
|
|
|
|
const AsmToken &Lex() { return getParser().Lex(); }
|
|
|
|
|
|
|
|
const AsmToken &getTok() { return getParser().getTok(); }
|
|
|
|
|
2011-02-24 21:59:22 +00:00
|
|
|
bool HasBracketExpressions() const { return BracketExpressionsSupported; }
|
|
|
|
|
2010-07-12 17:27:45 +00:00
|
|
|
/// @}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|