mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
MC: Make TargetAsmBackend available to the AsmStreamer.
- Treaty talks on the non-proliferation of MC objects broke down. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121949 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -426,6 +426,10 @@ namespace llvm {
|
|||||||
/// \param CE - If given, a code emitter to use to show the instruction
|
/// \param CE - If given, a code emitter to use to show the instruction
|
||||||
/// encoding inline with the assembly. This method takes ownership of \arg CE.
|
/// encoding inline with the assembly. This method takes ownership of \arg CE.
|
||||||
///
|
///
|
||||||
|
/// \param TAB - If given, a target asm backend to use to show the fixup
|
||||||
|
/// information in conjunction with encoding information. This method takes
|
||||||
|
/// ownership of \arg TAB.
|
||||||
|
///
|
||||||
/// \param ShowInst - Whether to show the MCInst representation inline with
|
/// \param ShowInst - Whether to show the MCInst representation inline with
|
||||||
/// the assembly.
|
/// the assembly.
|
||||||
MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||||
@@ -433,6 +437,7 @@ namespace llvm {
|
|||||||
bool useLoc,
|
bool useLoc,
|
||||||
MCInstPrinter *InstPrint = 0,
|
MCInstPrinter *InstPrint = 0,
|
||||||
MCCodeEmitter *CE = 0,
|
MCCodeEmitter *CE = 0,
|
||||||
|
TargetAsmBackend *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
|
||||||
|
@@ -46,6 +46,7 @@ namespace llvm {
|
|||||||
bool useLoc,
|
bool useLoc,
|
||||||
MCInstPrinter *InstPrint,
|
MCInstPrinter *InstPrint,
|
||||||
MCCodeEmitter *CE,
|
MCCodeEmitter *CE,
|
||||||
|
TargetAsmBackend *TAB,
|
||||||
bool ShowInst);
|
bool ShowInst);
|
||||||
|
|
||||||
/// Target - Wrapper for Target specific information.
|
/// Target - Wrapper for Target specific information.
|
||||||
@@ -95,6 +96,7 @@ namespace llvm {
|
|||||||
bool useLoc,
|
bool useLoc,
|
||||||
MCInstPrinter *InstPrint,
|
MCInstPrinter *InstPrint,
|
||||||
MCCodeEmitter *CE,
|
MCCodeEmitter *CE,
|
||||||
|
TargetAsmBackend *TAB,
|
||||||
bool ShowInst);
|
bool ShowInst);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -323,10 +325,11 @@ namespace llvm {
|
|||||||
bool useLoc,
|
bool useLoc,
|
||||||
MCInstPrinter *InstPrint,
|
MCInstPrinter *InstPrint,
|
||||||
MCCodeEmitter *CE,
|
MCCodeEmitter *CE,
|
||||||
|
TargetAsmBackend *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,
|
return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc,
|
||||||
InstPrint, CE, ShowInst);
|
InstPrint, CE, TAB, ShowInst);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
@@ -143,14 +143,17 @@ 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;
|
||||||
if (ShowMCEncoding)
|
TargetAsmBackend *TAB = 0;
|
||||||
|
if (ShowMCEncoding) {
|
||||||
MCE = getTarget().createCodeEmitter(*this, *Context);
|
MCE = getTarget().createCodeEmitter(*this, *Context);
|
||||||
|
TAB = getTarget().createAsmBackend(TargetTriple);
|
||||||
|
}
|
||||||
|
|
||||||
MCStreamer *S = getTarget().createAsmStreamer(*Context, Out,
|
MCStreamer *S = getTarget().createAsmStreamer(*Context, Out,
|
||||||
getVerboseAsm(),
|
getVerboseAsm(),
|
||||||
hasMCUseLoc(),
|
hasMCUseLoc(),
|
||||||
InstPrinter,
|
InstPrinter,
|
||||||
MCE,
|
MCE, TAB,
|
||||||
ShowMCInst);
|
ShowMCInst);
|
||||||
AsmStreamer.reset(S);
|
AsmStreamer.reset(S);
|
||||||
break;
|
break;
|
||||||
|
@@ -23,8 +23,9 @@
|
|||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Support/Format.h"
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/Support/FormattedStream.h"
|
#include "llvm/Support/FormattedStream.h"
|
||||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
#include "llvm/Target/TargetAsmBackend.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -34,6 +35,7 @@ class MCAsmStreamer : public MCStreamer {
|
|||||||
const MCAsmInfo &MAI;
|
const MCAsmInfo &MAI;
|
||||||
OwningPtr<MCInstPrinter> InstPrinter;
|
OwningPtr<MCInstPrinter> InstPrinter;
|
||||||
OwningPtr<MCCodeEmitter> Emitter;
|
OwningPtr<MCCodeEmitter> Emitter;
|
||||||
|
OwningPtr<TargetAsmBackend> AsmBackend;
|
||||||
|
|
||||||
SmallString<128> CommentToEmit;
|
SmallString<128> CommentToEmit;
|
||||||
raw_svector_ostream CommentStream;
|
raw_svector_ostream CommentStream;
|
||||||
@@ -48,10 +50,12 @@ public:
|
|||||||
MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os,
|
MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os,
|
||||||
bool isVerboseAsm,
|
bool isVerboseAsm,
|
||||||
bool useLoc,
|
bool useLoc,
|
||||||
MCInstPrinter *printer, MCCodeEmitter *emitter, bool showInst)
|
MCInstPrinter *printer, MCCodeEmitter *emitter,
|
||||||
|
TargetAsmBackend *asmbackend,
|
||||||
|
bool showInst)
|
||||||
: MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()),
|
: MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()),
|
||||||
InstPrinter(printer), Emitter(emitter), CommentStream(CommentToEmit),
|
InstPrinter(printer), Emitter(emitter), AsmBackend(asmbackend),
|
||||||
IsVerboseAsm(isVerboseAsm),
|
CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm),
|
||||||
ShowInst(showInst), UseLoc(useLoc) {
|
ShowInst(showInst), UseLoc(useLoc) {
|
||||||
if (InstPrinter && IsVerboseAsm)
|
if (InstPrinter && IsVerboseAsm)
|
||||||
InstPrinter->setCommentStream(CommentStream);
|
InstPrinter->setCommentStream(CommentStream);
|
||||||
@@ -893,8 +897,8 @@ void MCAsmStreamer::Finish() {
|
|||||||
MCStreamer *llvm::createAsmStreamer(MCContext &Context,
|
MCStreamer *llvm::createAsmStreamer(MCContext &Context,
|
||||||
formatted_raw_ostream &OS,
|
formatted_raw_ostream &OS,
|
||||||
bool isVerboseAsm, bool useLoc,
|
bool isVerboseAsm, bool useLoc,
|
||||||
MCInstPrinter *IP,
|
MCInstPrinter *IP, MCCodeEmitter *CE,
|
||||||
MCCodeEmitter *CE, bool ShowInst) {
|
TargetAsmBackend *TAB, bool ShowInst) {
|
||||||
return new MCAsmStreamer(Context, OS, isVerboseAsm, useLoc,
|
return new MCAsmStreamer(Context, OS, isVerboseAsm, useLoc,
|
||||||
IP, CE, ShowInst);
|
IP, CE, TAB, ShowInst);
|
||||||
}
|
}
|
||||||
|
@@ -540,7 +540,8 @@ namespace llvm {
|
|||||||
formatted_raw_ostream &OS,
|
formatted_raw_ostream &OS,
|
||||||
bool isVerboseAsm, bool useLoc,
|
bool isVerboseAsm, bool useLoc,
|
||||||
MCInstPrinter *IP,
|
MCInstPrinter *IP,
|
||||||
MCCodeEmitter *CE, bool ShowInst) {
|
MCCodeEmitter *CE, TargetAsmBackend *TAB,
|
||||||
|
bool ShowInst) {
|
||||||
return new PTXMCAsmStreamer(Context, OS, isVerboseAsm, useLoc,
|
return new PTXMCAsmStreamer(Context, OS, isVerboseAsm, useLoc,
|
||||||
IP, CE, ShowInst);
|
IP, CE, ShowInst);
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ namespace llvm {
|
|||||||
bool isVerboseAsm, bool useLoc,
|
bool isVerboseAsm, bool useLoc,
|
||||||
MCInstPrinter *InstPrint,
|
MCInstPrinter *InstPrint,
|
||||||
MCCodeEmitter *CE,
|
MCCodeEmitter *CE,
|
||||||
|
TargetAsmBackend *TAB,
|
||||||
bool ShowInst);
|
bool ShowInst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -340,10 +340,14 @@ static int AssembleInput(const char *ProgName) {
|
|||||||
MCInstPrinter *IP =
|
MCInstPrinter *IP =
|
||||||
TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI);
|
TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI);
|
||||||
MCCodeEmitter *CE = 0;
|
MCCodeEmitter *CE = 0;
|
||||||
if (ShowEncoding)
|
TargetAsmBackend *TAB = 0;
|
||||||
|
if (ShowEncoding) {
|
||||||
CE = TheTarget->createCodeEmitter(*TM, Ctx);
|
CE = TheTarget->createCodeEmitter(*TM, Ctx);
|
||||||
|
TAB = TheTarget->createAsmBackend(TripleName);
|
||||||
|
}
|
||||||
Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/true,
|
Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/true,
|
||||||
/*useLoc*/ true, IP, CE, ShowInst));
|
/*useLoc*/ true, IP, CE, TAB,
|
||||||
|
ShowInst));
|
||||||
} else if (FileType == OFT_Null) {
|
} else if (FileType == OFT_Null) {
|
||||||
Str.reset(createNullStreamer(Ctx));
|
Str.reset(createNullStreamer(Ctx));
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user