Rename TargetAsmBackend to MCAsmBackend; rename createAsmBackend to createMCAsmBackend.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136010 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng 2011-07-25 23:24:55 +00:00
parent 47f3513dd5
commit 78c10eeaa5
35 changed files with 156 additions and 170 deletions

View File

@ -1,4 +1,4 @@
//===-- llvm/MC/TargetAsmBackend.h - Target Asm Backend ---------*- C++ -*-===// //===-- llvm/MC/MCAsmBack.h - MC Asm Backend --------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -7,8 +7,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef LLVM_MC_TARGETASMBACKEND_H #ifndef LLVM_MC_MCASMBACKEND_H
#define LLVM_MC_TARGETASMBACKEND_H #define LLVM_MC_MCASMBACKEND_H
#include "llvm/MC/MCDirectives.h" #include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCFixup.h" #include "llvm/MC/MCFixup.h"
@ -25,17 +25,17 @@ template<typename T>
class SmallVectorImpl; class SmallVectorImpl;
class raw_ostream; class raw_ostream;
/// TargetAsmBackend - Generic interface to target specific assembler backends. /// MCAsmBackend - Generic interface to target specific assembler backends.
class TargetAsmBackend { class MCAsmBackend {
TargetAsmBackend(const TargetAsmBackend &); // DO NOT IMPLEMENT MCAsmBackend(const MCAsmBackend &); // DO NOT IMPLEMENT
void operator=(const TargetAsmBackend &); // DO NOT IMPLEMENT void operator=(const MCAsmBackend &); // DO NOT IMPLEMENT
protected: // Can only create subclasses. protected: // Can only create subclasses.
TargetAsmBackend(); MCAsmBackend();
unsigned HasReliableSymbolDifference : 1; unsigned HasReliableSymbolDifference : 1;
public: public:
virtual ~TargetAsmBackend(); virtual ~MCAsmBackend();
/// createObjectWriter - Create a new MCObjectWriter instance for use by the /// createObjectWriter - Create a new MCObjectWriter instance for use by the
/// assembler backend to emit the final object file. /// assembler backend to emit the final object file.

View File

@ -10,14 +10,14 @@
#ifndef LLVM_MC_MCASSEMBLER_H #ifndef LLVM_MC_MCASSEMBLER_H
#define LLVM_MC_MCASSEMBLER_H #define LLVM_MC_MCASSEMBLER_H
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCInst.h"
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist.h"
#include "llvm/ADT/ilist_node.h" #include "llvm/ADT/ilist_node.h"
#include "llvm/Support/Casting.h" #include "llvm/Support/Casting.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCInst.h"
#include "llvm/Support/DataTypes.h" #include "llvm/Support/DataTypes.h"
#include <vector> // FIXME: Shouldn't be needed. #include <vector> // FIXME: Shouldn't be needed.
@ -36,7 +36,7 @@ class MCSectionData;
class MCSymbol; class MCSymbol;
class MCSymbolData; class MCSymbolData;
class MCValue; class MCValue;
class TargetAsmBackend; class MCAsmBackend;
class MCFragment : public ilist_node<MCFragment> { class MCFragment : public ilist_node<MCFragment> {
friend class MCAsmLayout; friend class MCAsmLayout;
@ -660,7 +660,7 @@ private:
MCContext &Context; MCContext &Context;
TargetAsmBackend &Backend; MCAsmBackend &Backend;
MCCodeEmitter &Emitter; MCCodeEmitter &Emitter;
@ -780,14 +780,14 @@ public:
// concrete and require clients to pass in a target like object. The other // concrete and require clients to pass in a target like object. The other
// option is to make this abstract, and have targets provide concrete // option is to make this abstract, and have targets provide concrete
// implementations as we do with AsmParser. // implementations as we do with AsmParser.
MCAssembler(MCContext &Context_, TargetAsmBackend &Backend_, MCAssembler(MCContext &Context_, MCAsmBackend &Backend_,
MCCodeEmitter &Emitter_, MCObjectWriter &Writer_, MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
raw_ostream &OS); raw_ostream &OS);
~MCAssembler(); ~MCAssembler();
MCContext &getContext() const { return Context; } MCContext &getContext() const { return Context; }
TargetAsmBackend &getBackend() const { return Backend; } MCAsmBackend &getBackend() const { return Backend; }
MCCodeEmitter &getEmitter() const { return Emitter; } MCCodeEmitter &getEmitter() const { return Emitter; }

View File

@ -19,7 +19,7 @@ class MCSectionData;
class MCExpr; class MCExpr;
class MCFragment; class MCFragment;
class MCDataFragment; class MCDataFragment;
class TargetAsmBackend; class MCAsmBackend;
class raw_ostream; class raw_ostream;
/// \brief Streaming object file generation interface. /// \brief Streaming object file generation interface.
@ -36,9 +36,9 @@ class MCObjectStreamer : public MCStreamer {
virtual void EmitInstToData(const MCInst &Inst) = 0; virtual void EmitInstToData(const MCInst &Inst) = 0;
protected: protected:
MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB, MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &_OS, MCCodeEmitter *_Emitter); raw_ostream &_OS, MCCodeEmitter *_Emitter);
MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB, MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &_OS, MCCodeEmitter *_Emitter, raw_ostream &_OS, MCCodeEmitter *_Emitter,
MCAssembler *_Assembler); MCAssembler *_Assembler);
~MCObjectStreamer(); ~MCObjectStreamer();

View File

@ -22,6 +22,7 @@
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
namespace llvm { namespace llvm {
class MCAsmBackend;
class MCAsmInfo; class MCAsmInfo;
class MCCodeEmitter; class MCCodeEmitter;
class MCContext; class MCContext;
@ -31,7 +32,6 @@ namespace llvm {
class MCSection; class MCSection;
class MCSymbol; class MCSymbol;
class StringRef; class StringRef;
class TargetAsmBackend;
class TargetLoweringObjectFile; class TargetLoweringObjectFile;
class Twine; class Twine;
class raw_ostream; class raw_ostream;
@ -563,14 +563,14 @@ namespace llvm {
bool useCFI, bool useCFI,
MCInstPrinter *InstPrint = 0, MCInstPrinter *InstPrint = 0,
MCCodeEmitter *CE = 0, MCCodeEmitter *CE = 0,
TargetAsmBackend *TAB = 0, MCAsmBackend *TAB = 0,
bool ShowInst = false); bool ShowInst = false);
/// createMachOStreamer - Create a machine code streamer which will generate /// createMachOStreamer - Create a machine code streamer which will generate
/// Mach-O format object files. /// Mach-O format object files.
/// ///
/// Takes ownership of \arg TAB and \arg CE. /// Takes ownership of \arg TAB and \arg CE.
MCStreamer *createMachOStreamer(MCContext &Ctx, TargetAsmBackend &TAB, MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *CE, raw_ostream &OS, MCCodeEmitter *CE,
bool RelaxAll = false); bool RelaxAll = false);
@ -579,13 +579,13 @@ namespace llvm {
/// ///
/// Takes ownership of \arg TAB and \arg CE. /// Takes ownership of \arg TAB and \arg CE.
MCStreamer *createWinCOFFStreamer(MCContext &Ctx, MCStreamer *createWinCOFFStreamer(MCContext &Ctx,
TargetAsmBackend &TAB, MCAsmBackend &TAB,
MCCodeEmitter &CE, raw_ostream &OS, MCCodeEmitter &CE, raw_ostream &OS,
bool RelaxAll = false); bool RelaxAll = false);
/// createELFStreamer - Create a machine code streamer which will generate /// createELFStreamer - Create a machine code streamer which will generate
/// ELF format object files. /// ELF format object files.
MCStreamer *createELFStreamer(MCContext &Ctx, TargetAsmBackend &TAB, MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *CE, raw_ostream &OS, MCCodeEmitter *CE,
bool RelaxAll, bool NoExecStack); bool RelaxAll, bool NoExecStack);
@ -599,7 +599,7 @@ namespace llvm {
/// "pure" MC object files, for use with MC-JIT and testing tools. /// "pure" MC object files, for use with MC-JIT and testing tools.
/// ///
/// Takes ownership of \arg TAB and \arg CE. /// Takes ownership of \arg TAB and \arg CE.
MCStreamer *createPureStreamer(MCContext &Ctx, TargetAsmBackend &TAB, MCStreamer *createPureStreamer(MCContext &Ctx, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *CE); raw_ostream &OS, MCCodeEmitter *CE);
} // end namespace llvm } // end namespace llvm

View File

@ -39,7 +39,7 @@ namespace llvm {
class MCStreamer; class MCStreamer;
class MCSubtargetInfo; class MCSubtargetInfo;
class MCCodeGenInfo; class MCCodeGenInfo;
class TargetAsmBackend; class MCAsmBackend;
class TargetAsmLexer; class TargetAsmLexer;
class TargetAsmParser; class TargetAsmParser;
class TargetMachine; class TargetMachine;
@ -51,7 +51,7 @@ namespace llvm {
bool useLoc, bool useCFI, bool useLoc, bool useCFI,
MCInstPrinter *InstPrint, MCInstPrinter *InstPrint,
MCCodeEmitter *CE, MCCodeEmitter *CE,
TargetAsmBackend *TAB, MCAsmBackend *TAB,
bool ShowInst); bool ShowInst);
/// Target - Wrapper for Target specific information. /// Target - Wrapper for Target specific information.
@ -86,8 +86,7 @@ namespace llvm {
CodeModel::Model CM); CodeModel::Model CM);
typedef AsmPrinter *(*AsmPrinterCtorTy)(TargetMachine &TM, typedef AsmPrinter *(*AsmPrinterCtorTy)(TargetMachine &TM,
MCStreamer &Streamer); MCStreamer &Streamer);
typedef TargetAsmBackend *(*AsmBackendCtorTy)(const Target &T, typedef MCAsmBackend *(*MCAsmBackendCtorTy)(const Target &T, StringRef TT);
const std::string &TT);
typedef TargetAsmLexer *(*AsmLexerCtorTy)(const Target &T, typedef TargetAsmLexer *(*AsmLexerCtorTy)(const Target &T,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCAsmInfo &MAI); const MCAsmInfo &MAI);
@ -103,7 +102,7 @@ namespace llvm {
typedef MCStreamer *(*ObjectStreamerCtorTy)(const Target &T, typedef MCStreamer *(*ObjectStreamerCtorTy)(const Target &T,
const std::string &TT, const std::string &TT,
MCContext &Ctx, MCContext &Ctx,
TargetAsmBackend &TAB, MCAsmBackend &TAB,
raw_ostream &_OS, raw_ostream &_OS,
MCCodeEmitter *_Emitter, MCCodeEmitter *_Emitter,
bool RelaxAll, bool RelaxAll,
@ -115,7 +114,7 @@ namespace llvm {
bool useCFI, bool useCFI,
MCInstPrinter *InstPrint, MCInstPrinter *InstPrint,
MCCodeEmitter *CE, MCCodeEmitter *CE,
TargetAsmBackend *TAB, MCAsmBackend *TAB,
bool ShowInst); bool ShowInst);
private: private:
@ -160,9 +159,9 @@ namespace llvm {
/// TargetMachine, if registered. /// TargetMachine, if registered.
TargetMachineCtorTy TargetMachineCtorFn; TargetMachineCtorTy TargetMachineCtorFn;
/// AsmBackendCtorFn - Construction function for this target's /// MCAsmBackendCtorFn - Construction function for this target's
/// TargetAsmBackend, if registered. /// MCAsmBackend, if registered.
AsmBackendCtorTy AsmBackendCtorFn; MCAsmBackendCtorTy MCAsmBackendCtorFn;
/// AsmLexerCtorFn - Construction function for this target's TargetAsmLexer, /// AsmLexerCtorFn - Construction function for this target's TargetAsmLexer,
/// if registered. /// if registered.
@ -221,8 +220,8 @@ namespace llvm {
/// hasTargetMachine - Check if this target supports code generation. /// hasTargetMachine - Check if this target supports code generation.
bool hasTargetMachine() const { return TargetMachineCtorFn != 0; } bool hasTargetMachine() const { return TargetMachineCtorFn != 0; }
/// hasAsmBackend - Check if this target supports .o generation. /// hasMCAsmBackend - Check if this target supports .o generation.
bool hasAsmBackend() const { return AsmBackendCtorFn != 0; } bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != 0; }
/// hasAsmLexer - Check if this target supports .s lexing. /// hasAsmLexer - Check if this target supports .s lexing.
bool hasAsmLexer() const { return AsmLexerCtorFn != 0; } bool hasAsmLexer() const { return AsmLexerCtorFn != 0; }
@ -322,14 +321,14 @@ namespace llvm {
return TargetMachineCtorFn(*this, Triple, CPU, Features, RM, CM); return TargetMachineCtorFn(*this, Triple, CPU, Features, RM, CM);
} }
/// createAsmBackend - Create a target specific assembly parser. /// createMCAsmBackend - Create a target specific assembly parser.
/// ///
/// \arg Triple - The target triple string. /// \arg Triple - The target triple string.
/// \arg Backend - The target independent assembler object. /// \arg Backend - The target independent assembler object.
TargetAsmBackend *createAsmBackend(const std::string &Triple) const { MCAsmBackend *createMCAsmBackend(StringRef Triple) const {
if (!AsmBackendCtorFn) if (!MCAsmBackendCtorFn)
return 0; return 0;
return AsmBackendCtorFn(*this, Triple); return MCAsmBackendCtorFn(*this, Triple);
} }
/// createAsmLexer - Create a target specific assembly lexer. /// createAsmLexer - Create a target specific assembly lexer.
@ -393,7 +392,7 @@ namespace llvm {
/// \arg RelaxAll - Relax all fixups? /// \arg RelaxAll - Relax all fixups?
/// \arg NoExecStack - Mark file as not needing a executable stack. /// \arg NoExecStack - Mark file as not needing a executable stack.
MCStreamer *createObjectStreamer(const std::string &TT, MCContext &Ctx, MCStreamer *createObjectStreamer(const std::string &TT, MCContext &Ctx,
TargetAsmBackend &TAB, MCAsmBackend &TAB,
raw_ostream &_OS, raw_ostream &_OS,
MCCodeEmitter *_Emitter, MCCodeEmitter *_Emitter,
bool RelaxAll, bool RelaxAll,
@ -412,7 +411,7 @@ namespace llvm {
bool useCFI, bool useCFI,
MCInstPrinter *InstPrint, MCInstPrinter *InstPrint,
MCCodeEmitter *CE, MCCodeEmitter *CE,
TargetAsmBackend *TAB, MCAsmBackend *TAB,
bool ShowInst) const { bool ShowInst) const {
// AsmStreamerCtorFn is default to llvm::createAsmStreamer // AsmStreamerCtorFn is default to llvm::createAsmStreamer
return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI, return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI,
@ -605,7 +604,7 @@ namespace llvm {
T.TargetMachineCtorFn = Fn; T.TargetMachineCtorFn = Fn;
} }
/// RegisterAsmBackend - Register a TargetAsmBackend implementation for the /// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
/// given target. /// given target.
/// ///
/// Clients are responsible for ensuring that registration doesn't occur /// Clients are responsible for ensuring that registration doesn't occur
@ -614,9 +613,9 @@ namespace llvm {
/// ///
/// @param T - The target being registered. /// @param T - The target being registered.
/// @param Fn - A function to construct an AsmBackend for the target. /// @param Fn - A function to construct an AsmBackend for the target.
static void RegisterAsmBackend(Target &T, Target::AsmBackendCtorTy Fn) { static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn) {
if (!T.AsmBackendCtorFn) if (!T.MCAsmBackendCtorFn)
T.AsmBackendCtorFn = Fn; T.MCAsmBackendCtorFn = Fn;
} }
/// RegisterAsmLexer - Register a TargetAsmLexer implementation for the /// RegisterAsmLexer - Register a TargetAsmLexer implementation for the
@ -956,23 +955,22 @@ namespace llvm {
} }
}; };
/// RegisterAsmBackend - Helper template for registering a target specific /// RegisterMCAsmBackend - Helper template for registering a target specific
/// assembler backend. Usage: /// assembler backend. Usage:
/// ///
/// extern "C" void LLVMInitializeFooAsmBackend() { /// extern "C" void LLVMInitializeFooMCAsmBackend() {
/// extern Target TheFooTarget; /// extern Target TheFooTarget;
/// RegisterAsmBackend<FooAsmLexer> X(TheFooTarget); /// RegisterMCAsmBackend<FooAsmLexer> X(TheFooTarget);
/// } /// }
template<class AsmBackendImpl> template<class MCAsmBackendImpl>
struct RegisterAsmBackend { struct RegisterMCAsmBackend {
RegisterAsmBackend(Target &T) { RegisterMCAsmBackend(Target &T) {
TargetRegistry::RegisterAsmBackend(T, &Allocator); TargetRegistry::RegisterMCAsmBackend(T, &Allocator);
} }
private: private:
static TargetAsmBackend *Allocator(const Target &T, static MCAsmBackend *Allocator(const Target &T, StringRef Triple) {
const std::string &Triple) { return new MCAsmBackendImpl(T, Triple);
return new AsmBackendImpl(T, Triple);
} }
}; };

View File

@ -137,11 +137,11 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
// Create a code emitter if asked to show the encoding. // Create a code emitter if asked to show the encoding.
MCCodeEmitter *MCE = 0; MCCodeEmitter *MCE = 0;
TargetAsmBackend *TAB = 0; MCAsmBackend *MAB = 0;
if (ShowMCEncoding) { if (ShowMCEncoding) {
const MCSubtargetInfo &STI = getSubtarget<MCSubtargetInfo>(); const MCSubtargetInfo &STI = getSubtarget<MCSubtargetInfo>();
MCE = getTarget().createCodeEmitter(*getInstrInfo(), STI, *Context); MCE = getTarget().createCodeEmitter(*getInstrInfo(), STI, *Context);
TAB = getTarget().createAsmBackend(getTargetTriple()); MAB = getTarget().createMCAsmBackend(getTargetTriple());
} }
MCStreamer *S = getTarget().createAsmStreamer(*Context, Out, MCStreamer *S = getTarget().createAsmStreamer(*Context, Out,
@ -149,7 +149,7 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
hasMCUseLoc(), hasMCUseLoc(),
hasMCUseCFI(), hasMCUseCFI(),
InstPrinter, InstPrinter,
MCE, TAB, MCE, MAB,
ShowMCInst); ShowMCInst);
AsmStreamer.reset(S); AsmStreamer.reset(S);
break; break;
@ -160,12 +160,12 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
const MCSubtargetInfo &STI = getSubtarget<MCSubtargetInfo>(); const MCSubtargetInfo &STI = getSubtarget<MCSubtargetInfo>();
MCCodeEmitter *MCE = getTarget().createCodeEmitter(*getInstrInfo(), STI, MCCodeEmitter *MCE = getTarget().createCodeEmitter(*getInstrInfo(), STI,
*Context); *Context);
TargetAsmBackend *TAB = getTarget().createAsmBackend(getTargetTriple()); MCAsmBackend *MAB = getTarget().createMCAsmBackend(getTargetTriple());
if (MCE == 0 || TAB == 0) if (MCE == 0 || MAB == 0)
return true; return true;
AsmStreamer.reset(getTarget().createObjectStreamer(getTargetTriple(), AsmStreamer.reset(getTarget().createObjectStreamer(getTargetTriple(),
*Context, *TAB, Out, MCE, *Context, *MAB, Out, MCE,
hasMCRelaxAll(), hasMCRelaxAll(),
hasMCNoExecStack())); hasMCNoExecStack()));
AsmStreamer.get()->InitSections(); AsmStreamer.get()->InitSections();
@ -237,13 +237,13 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM,
// emission fails. // emission fails.
const MCSubtargetInfo &STI = getSubtarget<MCSubtargetInfo>(); const MCSubtargetInfo &STI = getSubtarget<MCSubtargetInfo>();
MCCodeEmitter *MCE = getTarget().createCodeEmitter(*getInstrInfo(),STI, *Ctx); MCCodeEmitter *MCE = getTarget().createCodeEmitter(*getInstrInfo(),STI, *Ctx);
TargetAsmBackend *TAB = getTarget().createAsmBackend(getTargetTriple()); MCAsmBackend *MAB = getTarget().createMCAsmBackend(getTargetTriple());
if (MCE == 0 || TAB == 0) if (MCE == 0 || MAB == 0)
return true; return true;
OwningPtr<MCStreamer> AsmStreamer; OwningPtr<MCStreamer> AsmStreamer;
AsmStreamer.reset(getTarget().createObjectStreamer(getTargetTriple(), *Ctx, AsmStreamer.reset(getTarget().createObjectStreamer(getTargetTriple(), *Ctx,
*TAB, Out, MCE, *MAB, Out, MCE,
hasMCRelaxAll(), hasMCRelaxAll(),
hasMCNoExecStack())); hasMCNoExecStack()));
AsmStreamer.get()->InitSections(); AsmStreamer.get()->InitSections();

View File

@ -15,12 +15,12 @@
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCValue.h" #include "llvm/MC/MCValue.h"
#include "llvm/MC/TargetAsmBackend.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ELF.h" #include "llvm/Support/ELF.h"

View File

@ -1,4 +1,4 @@
//===-- TargetAsmBackend.cpp - Target Assembly Backend ---------------------==// //===-- MCAsmBackend.cpp - Target MC Assembly Backend ----------------------==//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@ -7,19 +7,19 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/MC/TargetAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
using namespace llvm; using namespace llvm;
TargetAsmBackend::TargetAsmBackend() MCAsmBackend::MCAsmBackend()
: HasReliableSymbolDifference(false) : HasReliableSymbolDifference(false)
{ {
} }
TargetAsmBackend::~TargetAsmBackend() { MCAsmBackend::~MCAsmBackend() {
} }
const MCFixupKindInfo & const MCFixupKindInfo &
TargetAsmBackend::getFixupKindInfo(MCFixupKind Kind) const { MCAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
static const MCFixupKindInfo Builtins[] = { static const MCFixupKindInfo Builtins[] = {
{ "FK_Data_1", 0, 8, 0 }, { "FK_Data_1", 0, 8, 0 },
{ "FK_Data_2", 0, 16, 0 }, { "FK_Data_2", 0, 16, 0 },

View File

@ -19,7 +19,7 @@
#include "llvm/MC/MCSectionCOFF.h" #include "llvm/MC/MCSectionCOFF.h"
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/MC/TargetAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
@ -41,7 +41,7 @@ protected:
private: private:
OwningPtr<MCInstPrinter> InstPrinter; OwningPtr<MCInstPrinter> InstPrinter;
OwningPtr<MCCodeEmitter> Emitter; OwningPtr<MCCodeEmitter> Emitter;
OwningPtr<TargetAsmBackend> AsmBackend; OwningPtr<MCAsmBackend> AsmBackend;
SmallString<128> CommentToEmit; SmallString<128> CommentToEmit;
raw_svector_ostream CommentStream; raw_svector_ostream CommentStream;
@ -64,7 +64,7 @@ public:
MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os, MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os,
bool isVerboseAsm, bool useLoc, bool useCFI, bool isVerboseAsm, bool useLoc, bool useCFI,
MCInstPrinter *printer, MCCodeEmitter *emitter, MCInstPrinter *printer, MCCodeEmitter *emitter,
TargetAsmBackend *asmbackend, MCAsmBackend *asmbackend,
bool showInst) bool showInst)
: MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()), : MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()),
InstPrinter(printer), Emitter(emitter), AsmBackend(asmbackend), InstPrinter(printer), Emitter(emitter), AsmBackend(asmbackend),
@ -1262,8 +1262,8 @@ MCStreamer *llvm::createAsmStreamer(MCContext &Context,
formatted_raw_ostream &OS, formatted_raw_ostream &OS,
bool isVerboseAsm, bool useLoc, bool isVerboseAsm, bool useLoc,
bool useCFI, MCInstPrinter *IP, bool useCFI, MCInstPrinter *IP,
MCCodeEmitter *CE, TargetAsmBackend *TAB, MCCodeEmitter *CE, MCAsmBackend *MAB,
bool ShowInst) { bool ShowInst) {
return new MCAsmStreamer(Context, OS, isVerboseAsm, useLoc, useCFI, return new MCAsmStreamer(Context, OS, isVerboseAsm, useLoc, useCFI,
IP, CE, TAB, ShowInst); IP, CE, MAB, ShowInst);
} }

View File

@ -18,7 +18,7 @@
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h" #include "llvm/MC/MCValue.h"
#include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCDwarf.h"
#include "llvm/MC/TargetAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
@ -194,7 +194,7 @@ MCSymbolData::MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment,
/* *** */ /* *** */
MCAssembler::MCAssembler(MCContext &Context_, TargetAsmBackend &Backend_, MCAssembler::MCAssembler(MCContext &Context_, MCAsmBackend &Backend_,
MCCodeEmitter &Emitter_, MCObjectWriter &Writer_, MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
raw_ostream &OS_) raw_ostream &OS_)
: Context(Context_), Backend(Backend_), Emitter(Emitter_), Writer(Writer_), : Context(Context_), Backend(Backend_), Emitter(Emitter_), Writer(Writer_),

View File

@ -15,7 +15,6 @@
#include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCELFSymbolFlags.h" #include "llvm/MC/MCELFSymbolFlags.h"
#include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCFixupKindInfo.h"
#include "llvm/MC/TargetAsmBackend.h"
#include "llvm/Support/ELF.h" #include "llvm/Support/ELF.h"
namespace llvm { namespace llvm {

View File

@ -21,7 +21,7 @@
#include "llvm/MC/MCSection.h" #include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h" #include "llvm/MC/MCValue.h"
#include "llvm/MC/TargetAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/ELF.h" #include "llvm/Support/ELF.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
@ -374,10 +374,10 @@ void MCELFStreamer::Finish() {
this->MCObjectStreamer::Finish(); this->MCObjectStreamer::Finish();
} }
MCStreamer *llvm::createELFStreamer(MCContext &Context, TargetAsmBackend &TAB, MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB,
raw_ostream &OS, MCCodeEmitter *CE, raw_ostream &OS, MCCodeEmitter *CE,
bool RelaxAll, bool NoExecStack) { bool RelaxAll, bool NoExecStack) {
MCELFStreamer *S = new MCELFStreamer(Context, TAB, OS, CE); MCELFStreamer *S = new MCELFStreamer(Context, MAB, OS, CE);
if (RelaxAll) if (RelaxAll)
S->getAssembler().setRelaxAll(true); S->getAssembler().setRelaxAll(true);
if (NoExecStack) if (NoExecStack)

View File

@ -25,11 +25,11 @@ namespace llvm {
class MCELFStreamer : public MCObjectStreamer { class MCELFStreamer : public MCObjectStreamer {
public: public:
MCELFStreamer(MCContext &Context, TargetAsmBackend &TAB, MCELFStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *Emitter) raw_ostream &OS, MCCodeEmitter *Emitter)
: MCObjectStreamer(Context, TAB, OS, Emitter) {} : MCObjectStreamer(Context, TAB, OS, Emitter) {}
MCELFStreamer(MCContext &Context, TargetAsmBackend &TAB, MCELFStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *Emitter, raw_ostream &OS, MCCodeEmitter *Emitter,
MCAssembler *Assembler) MCAssembler *Assembler)
: MCObjectStreamer(Context, TAB, OS, Emitter, Assembler) {} : MCObjectStreamer(Context, TAB, OS, Emitter, Assembler) {}

View File

@ -16,7 +16,6 @@
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h" #include "llvm/MC/MCValue.h"
#include "llvm/MC/TargetAsmBackend.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
using namespace llvm; using namespace llvm;

View File

@ -20,7 +20,7 @@
#include "llvm/MC/MCMachOSymbolFlags.h" #include "llvm/MC/MCMachOSymbolFlags.h"
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCDwarf.h"
#include "llvm/MC/TargetAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
#include "llvm/Support/Dwarf.h" #include "llvm/Support/Dwarf.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
@ -34,9 +34,9 @@ private:
virtual void EmitInstToData(const MCInst &Inst); virtual void EmitInstToData(const MCInst &Inst);
public: public:
MCMachOStreamer(MCContext &Context, TargetAsmBackend &TAB, MCMachOStreamer(MCContext &Context, MCAsmBackend &MAB,
raw_ostream &OS, MCCodeEmitter *Emitter) raw_ostream &OS, MCCodeEmitter *Emitter)
: MCObjectStreamer(Context, TAB, OS, Emitter) {} : MCObjectStreamer(Context, MAB, OS, Emitter) {}
/// @name MCStreamer Interface /// @name MCStreamer Interface
/// @{ /// @{
@ -410,10 +410,10 @@ void MCMachOStreamer::Finish() {
this->MCObjectStreamer::Finish(); this->MCObjectStreamer::Finish();
} }
MCStreamer *llvm::createMachOStreamer(MCContext &Context, TargetAsmBackend &TAB, MCStreamer *llvm::createMachOStreamer(MCContext &Context, MCAsmBackend &MAB,
raw_ostream &OS, MCCodeEmitter *CE, raw_ostream &OS, MCCodeEmitter *CE,
bool RelaxAll) { bool RelaxAll) {
MCMachOStreamer *S = new MCMachOStreamer(Context, TAB, OS, CE); MCMachOStreamer *S = new MCMachOStreamer(Context, MAB, OS, CE);
if (RelaxAll) if (RelaxAll)
S->getAssembler().setRelaxAll(true); S->getAssembler().setRelaxAll(true);
return S; return S;

View File

@ -17,10 +17,10 @@
#include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/MC/TargetAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
using namespace llvm; using namespace llvm;
MCObjectStreamer::MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB, MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *Emitter_) raw_ostream &OS, MCCodeEmitter *Emitter_)
: MCStreamer(Context), : MCStreamer(Context),
Assembler(new MCAssembler(Context, TAB, Assembler(new MCAssembler(Context, TAB,
@ -30,7 +30,7 @@ MCObjectStreamer::MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB,
{ {
} }
MCObjectStreamer::MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB, MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *Emitter_, raw_ostream &OS, MCCodeEmitter *Emitter_,
MCAssembler *_Assembler) MCAssembler *_Assembler)
: MCStreamer(Context), Assembler(_Assembler), CurSectionData(0) : MCStreamer(Context), Assembler(_Assembler), CurSectionData(0)

View File

@ -28,7 +28,7 @@ private:
virtual void EmitInstToData(const MCInst &Inst); virtual void EmitInstToData(const MCInst &Inst);
public: public:
MCPureStreamer(MCContext &Context, TargetAsmBackend &TAB, MCPureStreamer(MCContext &Context, MCAsmBackend &TAB,
raw_ostream &OS, MCCodeEmitter *Emitter) raw_ostream &OS, MCCodeEmitter *Emitter)
: MCObjectStreamer(Context, TAB, OS, Emitter) {} : MCObjectStreamer(Context, TAB, OS, Emitter) {}
@ -228,7 +228,7 @@ void MCPureStreamer::Finish() {
this->MCObjectStreamer::Finish(); this->MCObjectStreamer::Finish();
} }
MCStreamer *llvm::createPureStreamer(MCContext &Context, TargetAsmBackend &TAB, MCStreamer *llvm::createPureStreamer(MCContext &Context, MCAsmBackend &MAB,
raw_ostream &OS, MCCodeEmitter *CE) { raw_ostream &OS, MCCodeEmitter *CE) {
return new MCPureStreamer(Context, TAB, OS, CE); return new MCPureStreamer(Context, MAB, OS, CE);
} }

View File

@ -12,6 +12,7 @@
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCObjectWriter.h"
@ -19,7 +20,6 @@
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCMachOSymbolFlags.h" #include "llvm/MC/MCMachOSymbolFlags.h"
#include "llvm/MC/MCValue.h" #include "llvm/MC/MCValue.h"
#include "llvm/MC/TargetAsmBackend.h"
#include "llvm/Object/MachOFormat.h" #include "llvm/Object/MachOFormat.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"

View File

@ -24,7 +24,7 @@
#include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCSectionCOFF.h" #include "llvm/MC/MCSectionCOFF.h"
#include "llvm/MC/MCWin64EH.h" #include "llvm/MC/MCWin64EH.h"
#include "llvm/MC/TargetAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"
@ -40,7 +40,7 @@ public:
MCSymbol const *CurSymbol; MCSymbol const *CurSymbol;
WinCOFFStreamer(MCContext &Context, WinCOFFStreamer(MCContext &Context,
TargetAsmBackend &TAB, MCAsmBackend &MAB,
MCCodeEmitter &CE, MCCodeEmitter &CE,
raw_ostream &OS); raw_ostream &OS);
@ -123,10 +123,10 @@ private:
} // end anonymous namespace. } // end anonymous namespace.
WinCOFFStreamer::WinCOFFStreamer(MCContext &Context, WinCOFFStreamer::WinCOFFStreamer(MCContext &Context,
TargetAsmBackend &TAB, MCAsmBackend &MAB,
MCCodeEmitter &CE, MCCodeEmitter &CE,
raw_ostream &OS) raw_ostream &OS)
: MCObjectStreamer(Context, TAB, OS, &CE) : MCObjectStreamer(Context, MAB, OS, &CE)
, CurSymbol(NULL) { , CurSymbol(NULL) {
} }
@ -395,11 +395,11 @@ void WinCOFFStreamer::Finish() {
namespace llvm namespace llvm
{ {
MCStreamer *createWinCOFFStreamer(MCContext &Context, MCStreamer *createWinCOFFStreamer(MCContext &Context,
TargetAsmBackend &TAB, MCAsmBackend &MAB,
MCCodeEmitter &CE, MCCodeEmitter &CE,
raw_ostream &OS, raw_ostream &OS,
bool RelaxAll) { bool RelaxAll) {
WinCOFFStreamer *S = new WinCOFFStreamer(Context, TAB, CE, OS); WinCOFFStreamer *S = new WinCOFFStreamer(Context, MAB, CE, OS);
S->getAssembler().setRelaxAll(RelaxAll); S->getAssembler().setRelaxAll(RelaxAll);
return S; return S;
} }

View File

@ -19,7 +19,7 @@
#include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/TargetAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
#include "llvm/Object/MachOFormat.h" #include "llvm/Object/MachOFormat.h"
#include "llvm/Support/ELF.h" #include "llvm/Support/ELF.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
@ -34,10 +34,10 @@ public:
/*HasRelocationAddend*/ false) {} /*HasRelocationAddend*/ false) {}
}; };
class ARMAsmBackend : public TargetAsmBackend { class ARMAsmBackend : public MCAsmBackend {
bool isThumbMode; // Currently emitting Thumb code. bool isThumbMode; // Currently emitting Thumb code.
public: public:
ARMAsmBackend(const Target &T) : TargetAsmBackend(), isThumbMode(false) {} ARMAsmBackend(const Target &T) : MCAsmBackend(), isThumbMode(false) {}
unsigned getNumFixupKinds() const { return ARM::NumTargetFixupKinds; } unsigned getNumFixupKinds() const { return ARM::NumTargetFixupKinds; }
@ -80,7 +80,7 @@ public:
}; };
if (Kind < FirstTargetFixupKind) if (Kind < FirstTargetFixupKind)
return TargetAsmBackend::getFixupKindInfo(Kind); return MCAsmBackend::getFixupKindInfo(Kind);
assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() && assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
"Invalid kind!"); "Invalid kind!");
@ -491,8 +491,7 @@ void DarwinARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
} // end anonymous namespace } // end anonymous namespace
TargetAsmBackend *llvm::createARMAsmBackend(const Target &T, MCAsmBackend *llvm::createARMAsmBackend(const Target &T, StringRef TT) {
const std::string &TT) {
Triple TheTriple(TT); Triple TheTriple(TT);
if (TheTriple.isOSDarwin()) { if (TheTriple.isOSDarwin()) {

View File

@ -133,7 +133,7 @@ static MCCodeGenInfo *createARMMCCodeGenInfo(StringRef TT, Reloc::Model RM,
// This is duplicated code. Refactor this. // This is duplicated code. Refactor this.
static MCStreamer *createMCStreamer(const Target &T, const std::string &TT, static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
MCContext &Ctx, TargetAsmBackend &TAB, MCContext &Ctx, MCAsmBackend &MAB,
raw_ostream &OS, raw_ostream &OS,
MCCodeEmitter *Emitter, MCCodeEmitter *Emitter,
bool RelaxAll, bool RelaxAll,
@ -141,14 +141,14 @@ static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
Triple TheTriple(TT); Triple TheTriple(TT);
if (TheTriple.isOSDarwin()) if (TheTriple.isOSDarwin())
return createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll); return createMachOStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
if (TheTriple.isOSWindows()) { if (TheTriple.isOSWindows()) {
llvm_unreachable("ARM does not support Windows COFF format"); llvm_unreachable("ARM does not support Windows COFF format");
return NULL; return NULL;
} }
return createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll, NoExecStack); return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll, NoExecStack);
} }
static MCInstPrinter *createARMMCInstPrinter(const Target &T, static MCInstPrinter *createARMMCInstPrinter(const Target &T,
@ -189,8 +189,8 @@ extern "C" void LLVMInitializeARMTargetMC() {
TargetRegistry::RegisterCodeEmitter(TheThumbTarget, createARMMCCodeEmitter); TargetRegistry::RegisterCodeEmitter(TheThumbTarget, createARMMCCodeEmitter);
// Register the asm backend. // Register the asm backend.
TargetRegistry::RegisterAsmBackend(TheARMTarget, createARMAsmBackend); TargetRegistry::RegisterMCAsmBackend(TheARMTarget, createARMAsmBackend);
TargetRegistry::RegisterAsmBackend(TheThumbTarget, createARMAsmBackend); TargetRegistry::RegisterMCAsmBackend(TheThumbTarget, createARMAsmBackend);
// Register the object streamer. // Register the object streamer.
TargetRegistry::RegisterObjectStreamer(TheARMTarget, createMCStreamer); TargetRegistry::RegisterObjectStreamer(TheARMTarget, createMCStreamer);

View File

@ -18,6 +18,7 @@
#include <string> #include <string>
namespace llvm { namespace llvm {
class MCAsmBackend;
class MCCodeEmitter; class MCCodeEmitter;
class MCContext; class MCContext;
class MCInstrInfo; class MCInstrInfo;
@ -25,7 +26,6 @@ class MCObjectWriter;
class MCSubtargetInfo; class MCSubtargetInfo;
class StringRef; class StringRef;
class Target; class Target;
class TargetAsmBackend;
class raw_ostream; class raw_ostream;
extern Target TheARMTarget, TheThumbTarget; extern Target TheARMTarget, TheThumbTarget;
@ -44,7 +44,7 @@ MCCodeEmitter *createARMMCCodeEmitter(const MCInstrInfo &MCII,
const MCSubtargetInfo &STI, const MCSubtargetInfo &STI,
MCContext &Ctx); MCContext &Ctx);
TargetAsmBackend *createARMAsmBackend(const Target&, const std::string &); MCAsmBackend *createARMAsmBackend(const Target &T, StringRef TT);
/// createARMMachObjectWriter - Construct an ARM Mach-O object writer. /// createARMMachObjectWriter - Construct an ARM Mach-O object writer.
MCObjectWriter *createARMMachObjectWriter(raw_ostream &OS, MCObjectWriter *createARMMachObjectWriter(raw_ostream &OS,

View File

@ -17,7 +17,6 @@
#include "llvm/MC/MCFixup.h" #include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCFixupKindInfo.h"
#include "llvm/MC/MCValue.h" #include "llvm/MC/MCValue.h"
#include "llvm/MC/TargetAsmBackend.h"
#include "llvm/Object/MachOFormat.h" #include "llvm/Object/MachOFormat.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
using namespace llvm; using namespace llvm;

View File

@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "MCTargetDesc/MBlazeMCTargetDesc.h" #include "MCTargetDesc/MBlazeMCTargetDesc.h"
#include "llvm/MC/TargetAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCELFObjectWriter.h" #include "llvm/MC/MCELFObjectWriter.h"
@ -46,10 +46,10 @@ public:
/*HasRelocationAddend*/ true) {} /*HasRelocationAddend*/ true) {}
}; };
class MBlazeAsmBackend : public TargetAsmBackend { class MBlazeAsmBackend : public MCAsmBackend {
public: public:
MBlazeAsmBackend(const Target &T) MBlazeAsmBackend(const Target &T)
: TargetAsmBackend() { : MCAsmBackend() {
} }
unsigned getNumFixupKinds() const { unsigned getNumFixupKinds() const {
@ -146,8 +146,7 @@ void ELFMBlazeAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
} }
} // end anonymous namespace } // end anonymous namespace
TargetAsmBackend *llvm::createMBlazeAsmBackend(const Target &T, MCAsmBackend *llvm::createMBlazeAsmBackend(const Target &T, StringRef TT) {
const std::string &TT) {
Triple TheTriple(TT); Triple TheTriple(TT);
if (TheTriple.isOSDarwin()) if (TheTriple.isOSDarwin())

View File

@ -72,7 +72,7 @@ static MCCodeGenInfo *createMBlazeMCCodeGenInfo(StringRef TT, Reloc::Model RM,
} }
static MCStreamer *createMCStreamer(const Target &T, const std::string &TT, static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
MCContext &Ctx, TargetAsmBackend &TAB, MCContext &Ctx, MCAsmBackend &MAB,
raw_ostream &_OS, raw_ostream &_OS,
MCCodeEmitter *_Emitter, MCCodeEmitter *_Emitter,
bool RelaxAll, bool RelaxAll,
@ -89,7 +89,7 @@ static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
return NULL; return NULL;
} }
return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack); return createELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
} }
static MCInstPrinter *createMBlazeMCInstPrinter(const Target &T, static MCInstPrinter *createMBlazeMCInstPrinter(const Target &T,
@ -125,8 +125,8 @@ extern "C" void LLVMInitializeMBlazeTargetMC() {
llvm::createMBlazeMCCodeEmitter); llvm::createMBlazeMCCodeEmitter);
// Register the asm backend // Register the asm backend
TargetRegistry::RegisterAsmBackend(TheMBlazeTarget, TargetRegistry::RegisterMCAsmBackend(TheMBlazeTarget,
createMBlazeAsmBackend); createMBlazeAsmBackend);
// Register the object streamer // Register the object streamer
TargetRegistry::RegisterObjectStreamer(TheMBlazeTarget, TargetRegistry::RegisterObjectStreamer(TheMBlazeTarget,

View File

@ -14,15 +14,13 @@
#ifndef MBLAZEMCTARGETDESC_H #ifndef MBLAZEMCTARGETDESC_H
#define MBLAZEMCTARGETDESC_H #define MBLAZEMCTARGETDESC_H
#include <string>
namespace llvm { namespace llvm {
class MCAsmBackend;
class MCContext; class MCContext;
class MCCodeEmitter; class MCCodeEmitter;
class MCInstrInfo; class MCInstrInfo;
class MCSubtargetInfo; class MCSubtargetInfo;
class Target; class Target;
class TargetAsmBackend;
class StringRef; class StringRef;
class formatted_raw_ostream; class formatted_raw_ostream;
@ -32,7 +30,7 @@ MCCodeEmitter *createMBlazeMCCodeEmitter(const MCInstrInfo &MCII,
const MCSubtargetInfo &STI, const MCSubtargetInfo &STI,
MCContext &Ctx); MCContext &Ctx);
TargetAsmBackend *createMBlazeAsmBackend(const Target &, const std::string &); MCAsmBackend *createMBlazeAsmBackend(const Target &T, StringRef TT);
} // End llvm namespace } // End llvm namespace

View File

@ -533,7 +533,7 @@ namespace llvm {
formatted_raw_ostream &OS, formatted_raw_ostream &OS,
bool isVerboseAsm, bool useLoc, bool useCFI, bool isVerboseAsm, bool useLoc, bool useCFI,
MCInstPrinter *IP, MCInstPrinter *IP,
MCCodeEmitter *CE, TargetAsmBackend *TAB, MCCodeEmitter *CE, MCAsmBackend *MAB,
bool ShowInst) { bool ShowInst) {
return new PTXMCAsmStreamer(Context, OS, isVerboseAsm, useLoc, return new PTXMCAsmStreamer(Context, OS, isVerboseAsm, useLoc,
IP, CE, ShowInst); IP, CE, ShowInst);

View File

@ -25,7 +25,7 @@ namespace llvm {
bool useCFI, bool useCFI,
MCInstPrinter *InstPrint, MCInstPrinter *InstPrint,
MCCodeEmitter *CE, MCCodeEmitter *CE,
TargetAsmBackend *TAB, MCAsmBackend *MAB,
bool ShowInst); bool ShowInst);
} }

View File

@ -7,7 +7,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/MC/TargetAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
#include "MCTargetDesc/PPCMCTargetDesc.h" #include "MCTargetDesc/PPCMCTargetDesc.h"
#include "MCTargetDesc/PPCFixupKinds.h" #include "MCTargetDesc/PPCFixupKinds.h"
#include "llvm/MC/MCMachObjectWriter.h" #include "llvm/MC/MCMachObjectWriter.h"
@ -31,10 +31,10 @@ public:
MCValue Target, uint64_t &FixedValue) {} MCValue Target, uint64_t &FixedValue) {}
}; };
class PPCAsmBackend : public TargetAsmBackend { class PPCAsmBackend : public MCAsmBackend {
const Target &TheTarget; const Target &TheTarget;
public: public:
PPCAsmBackend(const Target &T) : TargetAsmBackend(), TheTarget(T) {} PPCAsmBackend(const Target &T) : MCAsmBackend(), TheTarget(T) {}
unsigned getNumFixupKinds() const { return PPC::NumTargetFixupKinds; } unsigned getNumFixupKinds() const { return PPC::NumTargetFixupKinds; }
@ -49,7 +49,7 @@ public:
}; };
if (Kind < FirstTargetFixupKind) if (Kind < FirstTargetFixupKind)
return TargetAsmBackend::getFixupKindInfo(Kind); return MCAsmBackend::getFixupKindInfo(Kind);
assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() && assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
"Invalid kind!"); "Invalid kind!");
@ -114,8 +114,7 @@ namespace {
TargetAsmBackend *llvm::createPPCAsmBackend(const Target &T, MCAsmBackend *llvm::createPPCAsmBackend(const Target &T, StringRef TT) {
const std::string &TT) {
if (Triple(TT).isOSDarwin()) if (Triple(TT).isOSDarwin())
return new DarwinPPCAsmBackend(T); return new DarwinPPCAsmBackend(T);

View File

@ -91,13 +91,13 @@ static MCCodeGenInfo *createPPCMCCodeGenInfo(StringRef TT, Reloc::Model RM,
// This is duplicated code. Refactor this. // This is duplicated code. Refactor this.
static MCStreamer *createMCStreamer(const Target &T, const std::string &TT, static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
MCContext &Ctx, TargetAsmBackend &TAB, MCContext &Ctx, MCAsmBackend &MAB,
raw_ostream &OS, raw_ostream &OS,
MCCodeEmitter *Emitter, MCCodeEmitter *Emitter,
bool RelaxAll, bool RelaxAll,
bool NoExecStack) { bool NoExecStack) {
if (Triple(TT).isOSDarwin()) if (Triple(TT).isOSDarwin())
return createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll); return createMachOStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
return NULL; return NULL;
} }
@ -136,8 +136,8 @@ extern "C" void LLVMInitializePowerPCTargetMC() {
TargetRegistry::RegisterCodeEmitter(ThePPC64Target, createPPCMCCodeEmitter); TargetRegistry::RegisterCodeEmitter(ThePPC64Target, createPPCMCCodeEmitter);
// Register the asm backend. // Register the asm backend.
TargetRegistry::RegisterAsmBackend(ThePPC32Target, createPPCAsmBackend); TargetRegistry::RegisterMCAsmBackend(ThePPC32Target, createPPCAsmBackend);
TargetRegistry::RegisterAsmBackend(ThePPC64Target, createPPCAsmBackend); TargetRegistry::RegisterMCAsmBackend(ThePPC64Target, createPPCAsmBackend);
// Register the object streamer. // Register the object streamer.
TargetRegistry::RegisterObjectStreamer(ThePPC32Target, createMCStreamer); TargetRegistry::RegisterObjectStreamer(ThePPC32Target, createMCStreamer);

View File

@ -14,15 +14,13 @@
#ifndef PPCMCTARGETDESC_H #ifndef PPCMCTARGETDESC_H
#define PPCMCTARGETDESC_H #define PPCMCTARGETDESC_H
#include <string>
namespace llvm { namespace llvm {
class MCAsmBackend;
class MCCodeEmitter; class MCCodeEmitter;
class MCContext; class MCContext;
class MCInstrInfo; class MCInstrInfo;
class MCSubtargetInfo; class MCSubtargetInfo;
class Target; class Target;
class TargetAsmBackend;
class StringRef; class StringRef;
extern Target ThePPC32Target; extern Target ThePPC32Target;
@ -32,7 +30,7 @@ MCCodeEmitter *createPPCMCCodeEmitter(const MCInstrInfo &MCII,
const MCSubtargetInfo &STI, const MCSubtargetInfo &STI,
MCContext &Ctx); MCContext &Ctx);
TargetAsmBackend *createPPCAsmBackend(const Target &, const std::string &); MCAsmBackend *createPPCAsmBackend(const Target &T, StringRef TT);
} // End llvm namespace } // End llvm namespace

View File

@ -7,7 +7,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/MC/TargetAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
#include "MCTargetDesc/X86BaseInfo.h" #include "MCTargetDesc/X86BaseInfo.h"
#include "MCTargetDesc/X86FixupKinds.h" #include "MCTargetDesc/X86FixupKinds.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
@ -62,10 +62,10 @@ public:
: MCELFObjectTargetWriter(is64Bit, OSType, EMachine, HasRelocationAddend) {} : MCELFObjectTargetWriter(is64Bit, OSType, EMachine, HasRelocationAddend) {}
}; };
class X86AsmBackend : public TargetAsmBackend { class X86AsmBackend : public MCAsmBackend {
public: public:
X86AsmBackend(const Target &T) X86AsmBackend(const Target &T)
: TargetAsmBackend() {} : MCAsmBackend() {}
unsigned getNumFixupKinds() const { unsigned getNumFixupKinds() const {
return X86::NumTargetFixupKinds; return X86::NumTargetFixupKinds;
@ -80,7 +80,7 @@ public:
}; };
if (Kind < FirstTargetFixupKind) if (Kind < FirstTargetFixupKind)
return TargetAsmBackend::getFixupKindInfo(Kind); return MCAsmBackend::getFixupKindInfo(Kind);
assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() && assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
"Invalid kind!"); "Invalid kind!");
@ -425,8 +425,7 @@ public:
} // end anonymous namespace } // end anonymous namespace
TargetAsmBackend *llvm::createX86_32AsmBackend(const Target &T, MCAsmBackend *llvm::createX86_32AsmBackend(const Target &T, StringRef TT) {
const std::string &TT) {
Triple TheTriple(TT); Triple TheTriple(TT);
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
@ -438,8 +437,7 @@ TargetAsmBackend *llvm::createX86_32AsmBackend(const Target &T,
return new ELFX86_32AsmBackend(T, TheTriple.getOS()); return new ELFX86_32AsmBackend(T, TheTriple.getOS());
} }
TargetAsmBackend *llvm::createX86_64AsmBackend(const Target &T, MCAsmBackend *llvm::createX86_64AsmBackend(const Target &T, StringRef TT) {
const std::string &TT) {
Triple TheTriple(TT); Triple TheTriple(TT);
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)

View File

@ -367,7 +367,7 @@ static MCCodeGenInfo *createX86MCCodeGenInfo(StringRef TT, Reloc::Model RM,
} }
static MCStreamer *createMCStreamer(const Target &T, const std::string &TT, static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
MCContext &Ctx, TargetAsmBackend &TAB, MCContext &Ctx, MCAsmBackend &MAB,
raw_ostream &_OS, raw_ostream &_OS,
MCCodeEmitter *_Emitter, MCCodeEmitter *_Emitter,
bool RelaxAll, bool RelaxAll,
@ -375,12 +375,12 @@ static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
Triple TheTriple(TT); Triple TheTriple(TT);
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
return createMachOStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll); return createMachOStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll);
if (TheTriple.isOSWindows()) if (TheTriple.isOSWindows())
return createWinCOFFStreamer(Ctx, TAB, *_Emitter, _OS, RelaxAll); return createWinCOFFStreamer(Ctx, MAB, *_Emitter, _OS, RelaxAll);
return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack); return createELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
} }
static MCInstPrinter *createX86MCInstPrinter(const Target &T, static MCInstPrinter *createX86MCInstPrinter(const Target &T,
@ -424,10 +424,10 @@ extern "C" void LLVMInitializeX86TargetMC() {
createX86MCCodeEmitter); createX86MCCodeEmitter);
// Register the asm backend. // Register the asm backend.
TargetRegistry::RegisterAsmBackend(TheX86_32Target, TargetRegistry::RegisterMCAsmBackend(TheX86_32Target,
createX86_32AsmBackend); createX86_32AsmBackend);
TargetRegistry::RegisterAsmBackend(TheX86_64Target, TargetRegistry::RegisterMCAsmBackend(TheX86_64Target,
createX86_64AsmBackend); createX86_64AsmBackend);
// Register the object streamer. // Register the object streamer.
TargetRegistry::RegisterObjectStreamer(TheX86_32Target, TargetRegistry::RegisterObjectStreamer(TheX86_32Target,

View File

@ -18,6 +18,7 @@
#include <string> #include <string>
namespace llvm { namespace llvm {
class MCAsmBackend;
class MCCodeEmitter; class MCCodeEmitter;
class MCContext; class MCContext;
class MCInstrInfo; class MCInstrInfo;
@ -25,7 +26,6 @@ class MCObjectWriter;
class MCRegisterInfo; class MCRegisterInfo;
class MCSubtargetInfo; class MCSubtargetInfo;
class Target; class Target;
class TargetAsmBackend;
class StringRef; class StringRef;
class raw_ostream; class raw_ostream;
@ -74,8 +74,8 @@ MCCodeEmitter *createX86MCCodeEmitter(const MCInstrInfo &MCII,
const MCSubtargetInfo &STI, const MCSubtargetInfo &STI,
MCContext &Ctx); MCContext &Ctx);
TargetAsmBackend *createX86_32AsmBackend(const Target &, const std::string &); MCAsmBackend *createX86_32AsmBackend(const Target &T, StringRef TT);
TargetAsmBackend *createX86_64AsmBackend(const Target &, const std::string &); MCAsmBackend *createX86_64AsmBackend(const Target &T, StringRef TT);
/// createX86MachObjectWriter - Construct an X86 Mach-O object writer. /// createX86MachObjectWriter - Construct an X86 Mach-O object writer.
MCObjectWriter *createX86MachObjectWriter(raw_ostream &OS, MCObjectWriter *createX86MachObjectWriter(raw_ostream &OS,

View File

@ -14,6 +14,7 @@
#include "llvm/MC/MCParser/AsmLexer.h" #include "llvm/MC/MCParser/AsmLexer.h"
#include "llvm/MC/MCParser/MCAsmLexer.h" #include "llvm/MC/MCParser/MCAsmLexer.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCInstPrinter.h"
@ -24,7 +25,6 @@
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/SubtargetFeature.h" #include "llvm/MC/SubtargetFeature.h"
#include "llvm/MC/TargetAsmBackend.h"
#include "llvm/MC/TargetAsmParser.h" #include "llvm/MC/TargetAsmParser.h"
#include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetRegistry.h"
#include "llvm/Target/TargetSelect.h" #include "llvm/Target/TargetSelect.h"
@ -368,22 +368,22 @@ static int AssembleInput(const char *ProgName) {
MCInstPrinter *IP = MCInstPrinter *IP =
TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI); TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI);
MCCodeEmitter *CE = 0; MCCodeEmitter *CE = 0;
TargetAsmBackend *TAB = 0; MCAsmBackend *MAB = 0;
if (ShowEncoding) { if (ShowEncoding) {
CE = TheTarget->createCodeEmitter(*MCII, *STI, Ctx); CE = TheTarget->createCodeEmitter(*MCII, *STI, Ctx);
TAB = TheTarget->createAsmBackend(TripleName); MAB = TheTarget->createMCAsmBackend(TripleName);
} }
Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/true, Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/true,
/*useLoc*/ true, /*useLoc*/ true,
/*useCFI*/ true, IP, CE, TAB, /*useCFI*/ true, IP, CE, MAB,
ShowInst)); ShowInst));
} else if (FileType == OFT_Null) { } else if (FileType == OFT_Null) {
Str.reset(createNullStreamer(Ctx)); Str.reset(createNullStreamer(Ctx));
} else { } else {
assert(FileType == OFT_ObjectFile && "Invalid file type!"); assert(FileType == OFT_ObjectFile && "Invalid file type!");
MCCodeEmitter *CE = TheTarget->createCodeEmitter(*MCII, *STI, Ctx); MCCodeEmitter *CE = TheTarget->createCodeEmitter(*MCII, *STI, Ctx);
TargetAsmBackend *TAB = TheTarget->createAsmBackend(TripleName); MCAsmBackend *MAB = TheTarget->createMCAsmBackend(TripleName);
Str.reset(TheTarget->createObjectStreamer(TripleName, Ctx, *TAB, Str.reset(TheTarget->createObjectStreamer(TripleName, Ctx, *MAB,
FOS, CE, RelaxAll, FOS, CE, RelaxAll,
NoExecStack)); NoExecStack));
} }