[PATCH] D11822: Resurrect RegisterAsmStreamer
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 6 15:50:01 PDT 2015
arsenm updated this revision to Diff 31486.
arsenm added a comment.
Rebase to remove unrelated context from diff
http://reviews.llvm.org/D11822
Files:
include/llvm/Support/TargetRegistry.h
Index: include/llvm/Support/TargetRegistry.h
===================================================================
--- include/llvm/Support/TargetRegistry.h
+++ include/llvm/Support/TargetRegistry.h
@@ -142,6 +142,15 @@
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter,
bool RelaxAll);
+ typedef MCStreamer *(*AsmStreamerCtorTy)(MCContext &Ctx,
+ std::unique_ptr<formatted_raw_ostream> OS,
+ bool IsVerboseAsm,
+ bool UseDwarfDirectory,
+ MCInstPrinter *InstPrint,
+ MCCodeEmitter *CE,
+ MCAsmBackend *TAB,
+ bool ShowInst);
+
typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
typedef MCTargetStreamer *(*AsmTargetStreamerCtorTy)(
MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
@@ -229,6 +238,10 @@
MachOStreamerCtorTy MachOStreamerCtorFn;
ELFStreamerCtorTy ELFStreamerCtorFn;
+ /// AsmStreamerCtorFn - Construction function for this target's
+ /// AsmStreamer, if registered (default = llvm::createAsmStreamer).
+ AsmStreamerCtorTy AsmStreamerCtorFn;
+
/// Construction function for this target's null TargetStreamer, if
/// registered (default = nullptr).
NullTargetStreamerCtorTy NullTargetStreamerCtorFn;
@@ -252,7 +265,8 @@
public:
Target()
: COFFStreamerCtorFn(nullptr), MachOStreamerCtorFn(nullptr),
- ELFStreamerCtorFn(nullptr), NullTargetStreamerCtorFn(nullptr),
+ ELFStreamerCtorFn(nullptr), AsmStreamerCtorFn(nullptr),
+ NullTargetStreamerCtorFn(nullptr),
AsmTargetStreamerCtorFn(nullptr), ObjectTargetStreamerCtorFn(nullptr),
MCRelocationInfoCtorFn(nullptr), MCSymbolizerCtorFn(nullptr) {}
@@ -472,9 +486,18 @@
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
MCAsmBackend *TAB, bool ShowInst) const {
formatted_raw_ostream &OSRef = *OS;
- MCStreamer *S = llvm::createAsmStreamer(Ctx, std::move(OS), IsVerboseAsm,
- UseDwarfDirectory, InstPrint, CE,
- TAB, ShowInst);
+
+ MCStreamer *S;
+ if (AsmStreamerCtorFn) {
+ S = AsmStreamerCtorFn(Ctx, std::move(OS), IsVerboseAsm,
+ UseDwarfDirectory, InstPrint, CE,
+ TAB, ShowInst);
+ } else {
+ S = llvm::createAsmStreamer(Ctx, std::move(OS), IsVerboseAsm,
+ UseDwarfDirectory, InstPrint, CE,
+ TAB, ShowInst);
+ }
+
createAsmTargetStreamer(*S, OSRef, InstPrint, IsVerboseAsm);
return S;
}
@@ -808,6 +831,19 @@
T.ELFStreamerCtorFn = 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) {
+ T.AsmStreamerCtorFn = Fn;
+ }
+
static void RegisterNullTargetStreamer(Target &T,
Target::NullTargetStreamerCtorTy Fn) {
T.NullTargetStreamerCtorFn = Fn;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11822.31486.patch
Type: text/x-patch
Size: 3814 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150806/2b930845/attachment.bin>
More information about the llvm-commits
mailing list