mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 02:33:33 +00:00
Add registry hook for assembly text output
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118394 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5991487c10
commit
6da24ca51d
@ -39,6 +39,13 @@ namespace llvm {
|
|||||||
class TargetAsmParser;
|
class TargetAsmParser;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
class formatted_raw_ostream;
|
||||||
|
|
||||||
|
MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||||
|
bool isLittleEndian, bool isVerboseAsm,
|
||||||
|
MCInstPrinter *InstPrint,
|
||||||
|
MCCodeEmitter *CE,
|
||||||
|
bool ShowInst);
|
||||||
|
|
||||||
/// Target - Wrapper for Target specific information.
|
/// Target - Wrapper for Target specific information.
|
||||||
///
|
///
|
||||||
@ -81,6 +88,13 @@ namespace llvm {
|
|||||||
raw_ostream &_OS,
|
raw_ostream &_OS,
|
||||||
MCCodeEmitter *_Emitter,
|
MCCodeEmitter *_Emitter,
|
||||||
bool RelaxAll);
|
bool RelaxAll);
|
||||||
|
typedef MCStreamer *(*AsmStreamerCtorTy)(MCContext &Ctx,
|
||||||
|
formatted_raw_ostream &OS,
|
||||||
|
bool isLittleEndian,
|
||||||
|
bool isVerboseAsm,
|
||||||
|
MCInstPrinter *InstPrint,
|
||||||
|
MCCodeEmitter *CE,
|
||||||
|
bool ShowInst);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Next - The next registered target in the linked list, maintained by the
|
/// Next - The next registered target in the linked list, maintained by the
|
||||||
@ -138,7 +152,13 @@ namespace llvm {
|
|||||||
/// ObjectStreamer, if registered.
|
/// ObjectStreamer, if registered.
|
||||||
ObjectStreamerCtorTy ObjectStreamerCtorFn;
|
ObjectStreamerCtorTy ObjectStreamerCtorFn;
|
||||||
|
|
||||||
|
/// AsmStreamerCtorFn - Construction function for this target's
|
||||||
|
/// AsmStreamer, if registered (default = llvm::createAsmStreamer).
|
||||||
|
AsmStreamerCtorTy AsmStreamerCtorFn;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Target() : AsmStreamerCtorFn(llvm::createAsmStreamer) {}
|
||||||
|
|
||||||
/// @name Target Information
|
/// @name Target Information
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
@ -185,6 +205,9 @@ namespace llvm {
|
|||||||
/// hasObjectStreamer - Check if this target supports streaming to files.
|
/// hasObjectStreamer - Check if this target supports streaming to files.
|
||||||
bool hasObjectStreamer() const { return ObjectStreamerCtorFn != 0; }
|
bool hasObjectStreamer() const { return ObjectStreamerCtorFn != 0; }
|
||||||
|
|
||||||
|
/// hasAsmStreamer - Check if this target supports streaming to files.
|
||||||
|
bool hasAsmStreamer() const { return AsmStreamerCtorFn != 0; }
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Feature Constructors
|
/// @name Feature Constructors
|
||||||
/// @{
|
/// @{
|
||||||
@ -292,6 +315,19 @@ namespace llvm {
|
|||||||
return ObjectStreamerCtorFn(*this, TT, Ctx, TAB, _OS, _Emitter, RelaxAll);
|
return ObjectStreamerCtorFn(*this, TT, Ctx, TAB, _OS, _Emitter, RelaxAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// createAsmStreamer - Create a target specific MCStreamer.
|
||||||
|
MCStreamer *createAsmStreamer(MCContext &Ctx,
|
||||||
|
formatted_raw_ostream &OS,
|
||||||
|
bool isLittleEndian,
|
||||||
|
bool isVerboseAsm,
|
||||||
|
MCInstPrinter *InstPrint,
|
||||||
|
MCCodeEmitter *CE,
|
||||||
|
bool ShowInst) const {
|
||||||
|
// AsmStreamerCtorFn is default to llvm::createAsmStreamer
|
||||||
|
return AsmStreamerCtorFn(Ctx, OS, isLittleEndian, isVerboseAsm,
|
||||||
|
InstPrint, CE, ShowInst);
|
||||||
|
}
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -513,7 +549,7 @@ namespace llvm {
|
|||||||
T.CodeEmitterCtorFn = Fn;
|
T.CodeEmitterCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RegisterObjectStreamer - Register an MCStreamer implementation
|
/// RegisterObjectStreamer - Register a object code MCStreamer implementation
|
||||||
/// for the given target.
|
/// for the given target.
|
||||||
///
|
///
|
||||||
/// Clients are responsible for ensuring that registration doesn't occur
|
/// Clients are responsible for ensuring that registration doesn't occur
|
||||||
@ -527,6 +563,20 @@ namespace llvm {
|
|||||||
T.ObjectStreamerCtorFn = Fn;
|
T.ObjectStreamerCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// RegisterAsmStreamer - Register an assembly MCStreamer implementation
|
||||||
|
/// for the given target.
|
||||||
|
///
|
||||||
|
/// Clients are responsible for ensuring that registration doesn't occur
|
||||||
|
/// while another thread is attempting to access the registry. Typically
|
||||||
|
/// this is done by initializing all targets at program startup.
|
||||||
|
///
|
||||||
|
/// @param T - The target being registered.
|
||||||
|
/// @param Fn - A function to construct an MCStreamer for the target.
|
||||||
|
static void RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn) {
|
||||||
|
if (T.AsmStreamerCtorFn == createAsmStreamer)
|
||||||
|
T.AsmStreamerCtorFn = Fn;
|
||||||
|
}
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -144,10 +144,11 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
|||||||
if (ShowMCEncoding)
|
if (ShowMCEncoding)
|
||||||
MCE = getTarget().createCodeEmitter(*this, *Context);
|
MCE = getTarget().createCodeEmitter(*this, *Context);
|
||||||
|
|
||||||
AsmStreamer.reset(createAsmStreamer(*Context, Out,
|
AsmStreamer.reset(getTarget().createAsmStreamer(*Context, Out,
|
||||||
getTargetData()->isLittleEndian(),
|
getTargetData()->isLittleEndian(),
|
||||||
getVerboseAsm(), InstPrinter,
|
getVerboseAsm(),
|
||||||
MCE, ShowMCInst));
|
InstPrinter, MCE,
|
||||||
|
ShowMCInst));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CGFT_ObjectFile: {
|
case CGFT_ObjectFile: {
|
||||||
|
@ -342,9 +342,9 @@ static int AssembleInput(const char *ProgName) {
|
|||||||
MCCodeEmitter *CE = 0;
|
MCCodeEmitter *CE = 0;
|
||||||
if (ShowEncoding)
|
if (ShowEncoding)
|
||||||
CE = TheTarget->createCodeEmitter(*TM, Ctx);
|
CE = TheTarget->createCodeEmitter(*TM, Ctx);
|
||||||
Str.reset(createAsmStreamer(Ctx, FOS,
|
Str.reset(TheTarget->createAsmStreamer(Ctx, FOS,
|
||||||
TM->getTargetData()->isLittleEndian(),
|
TM->getTargetData()->isLittleEndian(),
|
||||||
/*asmverbose*/true, IP, CE, ShowInst));
|
/*asmverbose*/true, IP, CE, ShowInst));
|
||||||
} else if (FileType == OFT_Null) {
|
} else if (FileType == OFT_Null) {
|
||||||
Str.reset(createNullStreamer(Ctx));
|
Str.reset(createNullStreamer(Ctx));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user