MC: Remove NullStreamer hook, as it is redundant with NullTargetStreamer.
[oota-llvm.git] / include / llvm / Support / TargetRegistry.h
1 //===-- Support/TargetRegistry.h - Target Registration ----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file exposes the TargetRegistry interface, which tools can use to access
11 // the appropriate target specific classes (TargetMachine, AsmPrinter, etc.)
12 // which have been registered.
13 //
14 // Target specific class implementations should register themselves using the
15 // appropriate TargetRegistry interfaces.
16 //
17 //===----------------------------------------------------------------------===//
18
19 #ifndef LLVM_SUPPORT_TARGETREGISTRY_H
20 #define LLVM_SUPPORT_TARGETREGISTRY_H
21
22 #include "llvm-c/Disassembler.h"
23 #include "llvm/ADT/Triple.h"
24 #include "llvm/Support/CodeGen.h"
25 #include <cassert>
26 #include <memory>
27 #include <string>
28
29 namespace llvm {
30   class AsmPrinter;
31   class Module;
32   class MCAssembler;
33   class MCAsmBackend;
34   class MCAsmInfo;
35   class MCAsmParser;
36   class MCCodeEmitter;
37   class MCCodeGenInfo;
38   class MCContext;
39   class MCDisassembler;
40   class MCInstrAnalysis;
41   class MCInstPrinter;
42   class MCInstrInfo;
43   class MCRegisterInfo;
44   class MCStreamer;
45   class MCSubtargetInfo;
46   class MCSymbolizer;
47   class MCRelocationInfo;
48   class MCTargetAsmParser;
49   class MCTargetOptions;
50   class MCTargetStreamer;
51   class TargetMachine;
52   class TargetOptions;
53   class raw_ostream;
54   class formatted_raw_ostream;
55
56   MCStreamer *createNullStreamer(MCContext &Ctx);
57   MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
58                                 bool isVerboseAsm, bool useDwarfDirectory,
59                                 MCInstPrinter *InstPrint, MCCodeEmitter *CE,
60                                 MCAsmBackend *TAB, bool ShowInst);
61
62   MCRelocationInfo *createMCRelocationInfo(StringRef TT, MCContext &Ctx);
63
64   MCSymbolizer *createMCSymbolizer(StringRef TT, LLVMOpInfoCallback GetOpInfo,
65                                    LLVMSymbolLookupCallback SymbolLookUp,
66                                    void *DisInfo, MCContext *Ctx,
67                                    std::unique_ptr<MCRelocationInfo> &&RelInfo);
68
69   /// Target - Wrapper for Target specific information.
70   ///
71   /// For registration purposes, this is a POD type so that targets can be
72   /// registered without the use of static constructors.
73   ///
74   /// Targets should implement a single global instance of this class (which
75   /// will be zero initialized), and pass that instance to the TargetRegistry as
76   /// part of their initialization.
77   class Target {
78   public:
79     friend struct TargetRegistry;
80
81     typedef bool (*ArchMatchFnTy)(Triple::ArchType Arch);
82
83     typedef MCAsmInfo *(*MCAsmInfoCtorFnTy)(const MCRegisterInfo &MRI,
84                                             StringRef TT);
85     typedef MCCodeGenInfo *(*MCCodeGenInfoCtorFnTy)(StringRef TT,
86                                                     Reloc::Model RM,
87                                                     CodeModel::Model CM,
88                                                     CodeGenOpt::Level OL);
89     typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
90     typedef MCInstrAnalysis *(*MCInstrAnalysisCtorFnTy)(const MCInstrInfo*Info);
91     typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(StringRef TT);
92     typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(StringRef TT,
93                                                         StringRef CPU,
94                                                         StringRef Features);
95     typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T,
96                                                   StringRef TT,
97                                                   StringRef CPU,
98                                                   StringRef Features,
99                                                   const TargetOptions &Options,
100                                                   Reloc::Model RM,
101                                                   CodeModel::Model CM,
102                                                   CodeGenOpt::Level OL);
103     // If it weren't for layering issues (this header is in llvm/Support, but
104     // depends on MC?) this should take the Streamer by value rather than rvalue
105     // reference.
106     typedef AsmPrinter *(*AsmPrinterCtorTy)(
107         TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
108     typedef MCAsmBackend *(*MCAsmBackendCtorTy)(const Target &T,
109                                                 const MCRegisterInfo &MRI,
110                                                 StringRef TT,
111                                                 StringRef CPU);
112     typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(
113         MCSubtargetInfo &STI,
114         MCAsmParser &P,
115         const MCInstrInfo &MII,
116         const MCTargetOptions &Options);
117     typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T,
118                                                     const MCSubtargetInfo &STI,
119                                                     MCContext &Ctx);
120     typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T,
121                                                   unsigned SyntaxVariant,
122                                                   const MCAsmInfo &MAI,
123                                                   const MCInstrInfo &MII,
124                                                   const MCRegisterInfo &MRI,
125                                                   const MCSubtargetInfo &STI);
126     typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
127                                                   const MCRegisterInfo &MRI,
128                                                   const MCSubtargetInfo &STI,
129                                                   MCContext &Ctx);
130     typedef MCStreamer *(*MCObjectStreamerCtorTy)(
131         const Target &T, StringRef TT, MCContext &Ctx, MCAsmBackend &TAB,
132         raw_ostream &_OS, MCCodeEmitter *_Emitter, const MCSubtargetInfo &STI,
133         bool RelaxAll);
134     typedef MCStreamer *(*AsmStreamerCtorTy)(MCContext &Ctx,
135                                              formatted_raw_ostream &OS,
136                                              bool isVerboseAsm,
137                                              bool useDwarfDirectory,
138                                              MCInstPrinter *InstPrint,
139                                              MCCodeEmitter *CE,
140                                              MCAsmBackend *TAB,
141                                              bool ShowInst);
142     typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
143     typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT,
144                                                         MCContext &Ctx);
145     typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
146         StringRef TT, LLVMOpInfoCallback GetOpInfo,
147         LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
148         std::unique_ptr<MCRelocationInfo> &&RelInfo);
149
150   private:
151     /// Next - The next registered target in the linked list, maintained by the
152     /// TargetRegistry.
153     Target *Next;
154
155     /// The target function for checking if an architecture is supported.
156     ArchMatchFnTy ArchMatchFn;
157
158     /// Name - The target name.
159     const char *Name;
160
161     /// ShortDesc - A short description of the target.
162     const char *ShortDesc;
163
164     /// HasJIT - Whether this target supports the JIT.
165     bool HasJIT;
166
167     /// MCAsmInfoCtorFn - Constructor function for this target's MCAsmInfo, if
168     /// registered.
169     MCAsmInfoCtorFnTy MCAsmInfoCtorFn;
170
171     /// MCCodeGenInfoCtorFn - Constructor function for this target's
172     /// MCCodeGenInfo, if registered.
173     MCCodeGenInfoCtorFnTy MCCodeGenInfoCtorFn;
174
175     /// MCInstrInfoCtorFn - Constructor function for this target's MCInstrInfo,
176     /// if registered.
177     MCInstrInfoCtorFnTy MCInstrInfoCtorFn;
178
179     /// MCInstrAnalysisCtorFn - Constructor function for this target's
180     /// MCInstrAnalysis, if registered.
181     MCInstrAnalysisCtorFnTy MCInstrAnalysisCtorFn;
182
183     /// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
184     /// if registered.
185     MCRegInfoCtorFnTy MCRegInfoCtorFn;
186
187     /// MCSubtargetInfoCtorFn - Constructor function for this target's
188     /// MCSubtargetInfo, if registered.
189     MCSubtargetInfoCtorFnTy MCSubtargetInfoCtorFn;
190
191     /// TargetMachineCtorFn - Construction function for this target's
192     /// TargetMachine, if registered.
193     TargetMachineCtorTy TargetMachineCtorFn;
194
195     /// MCAsmBackendCtorFn - Construction function for this target's
196     /// MCAsmBackend, if registered.
197     MCAsmBackendCtorTy MCAsmBackendCtorFn;
198
199     /// MCAsmParserCtorFn - Construction function for this target's
200     /// MCTargetAsmParser, if registered.
201     MCAsmParserCtorTy MCAsmParserCtorFn;
202
203     /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
204     /// if registered.
205     AsmPrinterCtorTy AsmPrinterCtorFn;
206
207     /// MCDisassemblerCtorFn - Construction function for this target's
208     /// MCDisassembler, if registered.
209     MCDisassemblerCtorTy MCDisassemblerCtorFn;
210
211     /// MCInstPrinterCtorFn - Construction function for this target's
212     /// MCInstPrinter, if registered.
213     MCInstPrinterCtorTy MCInstPrinterCtorFn;
214
215     /// MCCodeEmitterCtorFn - Construction function for this target's
216     /// CodeEmitter, if registered.
217     MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
218
219     /// MCObjectStreamerCtorFn - Construction function for this target's
220     /// MCObjectStreamer, if registered.
221     MCObjectStreamerCtorTy MCObjectStreamerCtorFn;
222
223     /// AsmStreamerCtorFn - Construction function for this target's
224     /// AsmStreamer, if registered (default = llvm::createAsmStreamer).
225     AsmStreamerCtorTy AsmStreamerCtorFn;
226
227     /// Construction function for this target's null TargetStreamer, if
228     /// registered (default = nullptr).
229     NullTargetStreamerCtorTy NullTargetStreamerCtorFn;
230
231     /// MCRelocationInfoCtorFn - Construction function for this target's
232     /// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
233     MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
234
235     /// MCSymbolizerCtorFn - Construction function for this target's
236     /// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
237     MCSymbolizerCtorTy MCSymbolizerCtorFn;
238
239   public:
240     Target()
241         : AsmStreamerCtorFn(nullptr), MCRelocationInfoCtorFn(nullptr),
242           MCSymbolizerCtorFn(nullptr) {}
243
244     /// @name Target Information
245     /// @{
246
247     // getNext - Return the next registered target.
248     const Target *getNext() const { return Next; }
249
250     /// getName - Get the target name.
251     const char *getName() const { return Name; }
252
253     /// getShortDescription - Get a short description of the target.
254     const char *getShortDescription() const { return ShortDesc; }
255
256     /// @}
257     /// @name Feature Predicates
258     /// @{
259
260     /// hasJIT - Check if this targets supports the just-in-time compilation.
261     bool hasJIT() const { return HasJIT; }
262
263     /// hasTargetMachine - Check if this target supports code generation.
264     bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
265
266     /// hasMCAsmBackend - Check if this target supports .o generation.
267     bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
268
269     /// @}
270     /// @name Feature Constructors
271     /// @{
272
273     /// createMCAsmInfo - Create a MCAsmInfo implementation for the specified
274     /// target triple.
275     ///
276     /// \param Triple This argument is used to determine the target machine
277     /// feature set; it should always be provided. Generally this should be
278     /// either the target triple from the module, or the target triple of the
279     /// host if that does not exist.
280     MCAsmInfo *createMCAsmInfo(const MCRegisterInfo &MRI,
281                                StringRef Triple) const {
282       if (!MCAsmInfoCtorFn)
283         return nullptr;
284       return MCAsmInfoCtorFn(MRI, Triple);
285     }
286
287     /// createMCCodeGenInfo - Create a MCCodeGenInfo implementation.
288     ///
289     MCCodeGenInfo *createMCCodeGenInfo(StringRef Triple, Reloc::Model RM,
290                                        CodeModel::Model CM,
291                                        CodeGenOpt::Level OL) const {
292       if (!MCCodeGenInfoCtorFn)
293         return nullptr;
294       return MCCodeGenInfoCtorFn(Triple, RM, CM, OL);
295     }
296
297     /// createMCInstrInfo - Create a MCInstrInfo implementation.
298     ///
299     MCInstrInfo *createMCInstrInfo() const {
300       if (!MCInstrInfoCtorFn)
301         return nullptr;
302       return MCInstrInfoCtorFn();
303     }
304
305     /// createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
306     ///
307     MCInstrAnalysis *createMCInstrAnalysis(const MCInstrInfo *Info) const {
308       if (!MCInstrAnalysisCtorFn)
309         return nullptr;
310       return MCInstrAnalysisCtorFn(Info);
311     }
312
313     /// createMCRegInfo - Create a MCRegisterInfo implementation.
314     ///
315     MCRegisterInfo *createMCRegInfo(StringRef Triple) const {
316       if (!MCRegInfoCtorFn)
317         return nullptr;
318       return MCRegInfoCtorFn(Triple);
319     }
320
321     /// createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
322     ///
323     /// \param Triple This argument is used to determine the target machine
324     /// feature set; it should always be provided. Generally this should be
325     /// either the target triple from the module, or the target triple of the
326     /// host if that does not exist.
327     /// \param CPU This specifies the name of the target CPU.
328     /// \param Features This specifies the string representation of the
329     /// additional target features.
330     MCSubtargetInfo *createMCSubtargetInfo(StringRef Triple, StringRef CPU,
331                                            StringRef Features) const {
332       if (!MCSubtargetInfoCtorFn)
333         return nullptr;
334       return MCSubtargetInfoCtorFn(Triple, CPU, Features);
335     }
336
337     /// createTargetMachine - Create a target specific machine implementation
338     /// for the specified \p Triple.
339     ///
340     /// \param Triple This argument is used to determine the target machine
341     /// feature set; it should always be provided. Generally this should be
342     /// either the target triple from the module, or the target triple of the
343     /// host if that does not exist.
344     TargetMachine *createTargetMachine(StringRef Triple, StringRef CPU,
345                              StringRef Features, const TargetOptions &Options,
346                              Reloc::Model RM = Reloc::Default,
347                              CodeModel::Model CM = CodeModel::Default,
348                              CodeGenOpt::Level OL = CodeGenOpt::Default) const {
349       if (!TargetMachineCtorFn)
350         return nullptr;
351       return TargetMachineCtorFn(*this, Triple, CPU, Features, Options,
352                                  RM, CM, OL);
353     }
354
355     /// createMCAsmBackend - Create a target specific assembly parser.
356     ///
357     /// \param Triple The target triple string.
358     MCAsmBackend *createMCAsmBackend(const MCRegisterInfo &MRI,
359                                      StringRef Triple, StringRef CPU) const {
360       if (!MCAsmBackendCtorFn)
361         return nullptr;
362       return MCAsmBackendCtorFn(*this, MRI, Triple, CPU);
363     }
364
365     /// createMCAsmParser - Create a target specific assembly parser.
366     ///
367     /// \param Parser The target independent parser implementation to use for
368     /// parsing and lexing.
369     MCTargetAsmParser *createMCAsmParser(
370         MCSubtargetInfo &STI,
371         MCAsmParser &Parser,
372         const MCInstrInfo &MII,
373         const MCTargetOptions &Options) const {
374       if (!MCAsmParserCtorFn)
375         return nullptr;
376       return MCAsmParserCtorFn(STI, Parser, MII, Options);
377     }
378
379     /// createAsmPrinter - Create a target specific assembly printer pass.  This
380     /// takes ownership of the MCStreamer object.
381     AsmPrinter *createAsmPrinter(TargetMachine &TM,
382                                  std::unique_ptr<MCStreamer> &&Streamer) const {
383       if (!AsmPrinterCtorFn)
384         return nullptr;
385       return AsmPrinterCtorFn(TM, std::move(Streamer));
386     }
387
388     MCDisassembler *createMCDisassembler(const MCSubtargetInfo &STI,
389                                          MCContext &Ctx) const {
390       if (!MCDisassemblerCtorFn)
391         return nullptr;
392       return MCDisassemblerCtorFn(*this, STI, Ctx);
393     }
394
395     MCInstPrinter *createMCInstPrinter(unsigned SyntaxVariant,
396                                        const MCAsmInfo &MAI,
397                                        const MCInstrInfo &MII,
398                                        const MCRegisterInfo &MRI,
399                                        const MCSubtargetInfo &STI) const {
400       if (!MCInstPrinterCtorFn)
401         return nullptr;
402       return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI, MII, MRI, STI);
403     }
404
405
406     /// createMCCodeEmitter - Create a target specific code emitter.
407     MCCodeEmitter *createMCCodeEmitter(const MCInstrInfo &II,
408                                        const MCRegisterInfo &MRI,
409                                        const MCSubtargetInfo &STI,
410                                        MCContext &Ctx) const {
411       if (!MCCodeEmitterCtorFn)
412         return nullptr;
413       return MCCodeEmitterCtorFn(II, MRI, STI, Ctx);
414     }
415
416     /// createMCObjectStreamer - Create a target specific MCStreamer.
417     ///
418     /// \param TT The target triple.
419     /// \param Ctx The target context.
420     /// \param TAB The target assembler backend object. Takes ownership.
421     /// \param _OS The stream object.
422     /// \param _Emitter The target independent assembler object.Takes ownership.
423     /// \param RelaxAll Relax all fixups?
424     MCStreamer *createMCObjectStreamer(StringRef TT, MCContext &Ctx,
425                                        MCAsmBackend &TAB, raw_ostream &_OS,
426                                        MCCodeEmitter *_Emitter,
427                                        const MCSubtargetInfo &STI,
428                                        bool RelaxAll) const {
429       if (!MCObjectStreamerCtorFn)
430         return nullptr;
431       return MCObjectStreamerCtorFn(*this, TT, Ctx, TAB, _OS, _Emitter, STI,
432                                     RelaxAll);
433     }
434
435     /// createAsmStreamer - Create a target specific MCStreamer.
436     MCStreamer *createAsmStreamer(MCContext &Ctx,
437                                   formatted_raw_ostream &OS,
438                                   bool isVerboseAsm,
439                                   bool useDwarfDirectory,
440                                   MCInstPrinter *InstPrint,
441                                   MCCodeEmitter *CE,
442                                   MCAsmBackend *TAB,
443                                   bool ShowInst) const {
444       if (AsmStreamerCtorFn)
445         return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useDwarfDirectory,
446                                  InstPrint, CE, TAB, ShowInst);
447       return llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useDwarfDirectory,
448                                      InstPrint, CE, TAB, ShowInst);
449     }
450
451     MCStreamer *createNullStreamer(MCContext &Ctx) const {
452       MCStreamer *S = llvm::createNullStreamer(Ctx);
453       createNullTargetStreamer(*S);
454       return S;
455     }
456
457     MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) const {
458       if (NullTargetStreamerCtorFn)
459         return NullTargetStreamerCtorFn(S);
460       return nullptr;
461     }
462
463     /// createMCRelocationInfo - Create a target specific MCRelocationInfo.
464     ///
465     /// \param TT The target triple.
466     /// \param Ctx The target context.
467     MCRelocationInfo *
468       createMCRelocationInfo(StringRef TT, MCContext &Ctx) const {
469       MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn
470                                       ? MCRelocationInfoCtorFn
471                                       : llvm::createMCRelocationInfo;
472       return Fn(TT, Ctx);
473     }
474
475     /// createMCSymbolizer - Create a target specific MCSymbolizer.
476     ///
477     /// \param TT The target triple.
478     /// \param GetOpInfo The function to get the symbolic information for operands.
479     /// \param SymbolLookUp The function to lookup a symbol name.
480     /// \param DisInfo The pointer to the block of symbolic information for above call
481     /// back.
482     /// \param Ctx The target context.
483     /// \param RelInfo The relocation information for this target. Takes ownership.
484     MCSymbolizer *
485     createMCSymbolizer(StringRef TT, LLVMOpInfoCallback GetOpInfo,
486                        LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
487                        MCContext *Ctx,
488                        std::unique_ptr<MCRelocationInfo> &&RelInfo) const {
489       MCSymbolizerCtorTy Fn =
490           MCSymbolizerCtorFn ? MCSymbolizerCtorFn : llvm::createMCSymbolizer;
491       return Fn(TT, GetOpInfo, SymbolLookUp, DisInfo, Ctx, std::move(RelInfo));
492     }
493
494     /// @}
495   };
496
497   /// TargetRegistry - Generic interface to target specific features.
498   struct TargetRegistry {
499     class iterator {
500       const Target *Current;
501       explicit iterator(Target *T) : Current(T) {}
502       friend struct TargetRegistry;
503     public:
504       iterator() : Current(nullptr) {}
505
506       bool operator==(const iterator &x) const {
507         return Current == x.Current;
508       }
509       bool operator!=(const iterator &x) const {
510         return !operator==(x);
511       }
512
513       // Iterator traversal: forward iteration only
514       iterator &operator++() {          // Preincrement
515         assert(Current && "Cannot increment end iterator!");
516         Current = Current->getNext();
517         return *this;
518       }
519       iterator operator++(int) {        // Postincrement
520         iterator tmp = *this;
521         ++*this;
522         return tmp;
523       }
524
525       const Target &operator*() const {
526         assert(Current && "Cannot dereference end iterator!");
527         return *Current;
528       }
529
530       const Target *operator->() const {
531         return &operator*();
532       }
533     };
534
535     /// printRegisteredTargetsForVersion - Print the registered targets
536     /// appropriately for inclusion in a tool's version output.
537     static void printRegisteredTargetsForVersion();
538
539     /// @name Registry Access
540     /// @{
541
542     static iterator begin();
543
544     static iterator end() { return iterator(); }
545
546     /// lookupTarget - Lookup a target based on a target triple.
547     ///
548     /// \param Triple - The triple to use for finding a target.
549     /// \param Error - On failure, an error string describing why no target was
550     /// found.
551     static const Target *lookupTarget(const std::string &Triple,
552                                       std::string &Error);
553
554     /// lookupTarget - Lookup a target based on an architecture name
555     /// and a target triple.  If the architecture name is non-empty,
556     /// then the lookup is done by architecture.  Otherwise, the target
557     /// triple is used.
558     ///
559     /// \param ArchName - The architecture to use for finding a target.
560     /// \param TheTriple - The triple to use for finding a target.  The
561     /// triple is updated with canonical architecture name if a lookup
562     /// by architecture is done.
563     /// \param Error - On failure, an error string describing why no target was
564     /// found.
565     static const Target *lookupTarget(const std::string &ArchName,
566                                       Triple &TheTriple,
567                                       std::string &Error);
568
569     /// @}
570     /// @name Target Registration
571     /// @{
572
573     /// RegisterTarget - Register the given target. Attempts to register a
574     /// target which has already been registered will be ignored.
575     ///
576     /// Clients are responsible for ensuring that registration doesn't occur
577     /// while another thread is attempting to access the registry. Typically
578     /// this is done by initializing all targets at program startup.
579     ///
580     /// @param T - The target being registered.
581     /// @param Name - The target name. This should be a static string.
582     /// @param ShortDesc - A short target description. This should be a static
583     /// string.
584     /// @param ArchMatchFn - The arch match checking function for this target.
585     /// @param HasJIT - Whether the target supports JIT code
586     /// generation.
587     static void RegisterTarget(Target &T,
588                                const char *Name,
589                                const char *ShortDesc,
590                                Target::ArchMatchFnTy ArchMatchFn,
591                                bool HasJIT = false);
592
593     /// RegisterMCAsmInfo - Register a MCAsmInfo implementation for the
594     /// given target.
595     ///
596     /// Clients are responsible for ensuring that registration doesn't occur
597     /// while another thread is attempting to access the registry. Typically
598     /// this is done by initializing all targets at program startup.
599     ///
600     /// @param T - The target being registered.
601     /// @param Fn - A function to construct a MCAsmInfo for the target.
602     static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn) {
603       T.MCAsmInfoCtorFn = Fn;
604     }
605
606     /// RegisterMCCodeGenInfo - Register a MCCodeGenInfo implementation for the
607     /// given target.
608     ///
609     /// Clients are responsible for ensuring that registration doesn't occur
610     /// while another thread is attempting to access the registry. Typically
611     /// this is done by initializing all targets at program startup.
612     ///
613     /// @param T - The target being registered.
614     /// @param Fn - A function to construct a MCCodeGenInfo for the target.
615     static void RegisterMCCodeGenInfo(Target &T,
616                                      Target::MCCodeGenInfoCtorFnTy Fn) {
617       T.MCCodeGenInfoCtorFn = Fn;
618     }
619
620     /// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the
621     /// given target.
622     ///
623     /// Clients are responsible for ensuring that registration doesn't occur
624     /// while another thread is attempting to access the registry. Typically
625     /// this is done by initializing all targets at program startup.
626     ///
627     /// @param T - The target being registered.
628     /// @param Fn - A function to construct a MCInstrInfo for the target.
629     static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn) {
630       T.MCInstrInfoCtorFn = Fn;
631     }
632
633     /// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for
634     /// the given target.
635     static void RegisterMCInstrAnalysis(Target &T,
636                                         Target::MCInstrAnalysisCtorFnTy Fn) {
637       T.MCInstrAnalysisCtorFn = Fn;
638     }
639
640     /// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
641     /// given target.
642     ///
643     /// Clients are responsible for ensuring that registration doesn't occur
644     /// while another thread is attempting to access the registry. Typically
645     /// this is done by initializing all targets at program startup.
646     ///
647     /// @param T - The target being registered.
648     /// @param Fn - A function to construct a MCRegisterInfo for the target.
649     static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn) {
650       T.MCRegInfoCtorFn = Fn;
651     }
652
653     /// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for
654     /// the given target.
655     ///
656     /// Clients are responsible for ensuring that registration doesn't occur
657     /// while another thread is attempting to access the registry. Typically
658     /// this is done by initializing all targets at program startup.
659     ///
660     /// @param T - The target being registered.
661     /// @param Fn - A function to construct a MCSubtargetInfo for the target.
662     static void RegisterMCSubtargetInfo(Target &T,
663                                         Target::MCSubtargetInfoCtorFnTy Fn) {
664       T.MCSubtargetInfoCtorFn = Fn;
665     }
666
667     /// RegisterTargetMachine - Register a TargetMachine implementation for the
668     /// given target.
669     ///
670     /// Clients are responsible for ensuring that registration doesn't occur
671     /// while another thread is attempting to access the registry. Typically
672     /// this is done by initializing all targets at program startup.
673     ///
674     /// @param T - The target being registered.
675     /// @param Fn - A function to construct a TargetMachine for the target.
676     static void RegisterTargetMachine(Target &T,
677                                       Target::TargetMachineCtorTy Fn) {
678       T.TargetMachineCtorFn = Fn;
679     }
680
681     /// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
682     /// given target.
683     ///
684     /// Clients are responsible for ensuring that registration doesn't occur
685     /// while another thread is attempting to access the registry. Typically
686     /// this is done by initializing all targets at program startup.
687     ///
688     /// @param T - The target being registered.
689     /// @param Fn - A function to construct an AsmBackend for the target.
690     static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn) {
691       T.MCAsmBackendCtorFn = Fn;
692     }
693
694     /// RegisterMCAsmParser - Register a MCTargetAsmParser implementation for
695     /// the given target.
696     ///
697     /// Clients are responsible for ensuring that registration doesn't occur
698     /// while another thread is attempting to access the registry. Typically
699     /// this is done by initializing all targets at program startup.
700     ///
701     /// @param T - The target being registered.
702     /// @param Fn - A function to construct an MCTargetAsmParser for the target.
703     static void RegisterMCAsmParser(Target &T, Target::MCAsmParserCtorTy Fn) {
704       T.MCAsmParserCtorFn = Fn;
705     }
706
707     /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
708     /// target.
709     ///
710     /// Clients are responsible for ensuring that registration doesn't occur
711     /// while another thread is attempting to access the registry. Typically
712     /// this is done by initializing all targets at program startup.
713     ///
714     /// @param T - The target being registered.
715     /// @param Fn - A function to construct an AsmPrinter for the target.
716     static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) {
717       T.AsmPrinterCtorFn = Fn;
718     }
719
720     /// RegisterMCDisassembler - Register a MCDisassembler implementation for
721     /// the given target.
722     ///
723     /// Clients are responsible for ensuring that registration doesn't occur
724     /// while another thread is attempting to access the registry. Typically
725     /// this is done by initializing all targets at program startup.
726     ///
727     /// @param T - The target being registered.
728     /// @param Fn - A function to construct an MCDisassembler for the target.
729     static void RegisterMCDisassembler(Target &T,
730                                        Target::MCDisassemblerCtorTy Fn) {
731       T.MCDisassemblerCtorFn = Fn;
732     }
733
734     /// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the
735     /// given target.
736     ///
737     /// Clients are responsible for ensuring that registration doesn't occur
738     /// while another thread is attempting to access the registry. Typically
739     /// this is done by initializing all targets at program startup.
740     ///
741     /// @param T - The target being registered.
742     /// @param Fn - A function to construct an MCInstPrinter for the target.
743     static void RegisterMCInstPrinter(Target &T,
744                                       Target::MCInstPrinterCtorTy Fn) {
745       T.MCInstPrinterCtorFn = Fn;
746     }
747
748     /// RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the
749     /// given target.
750     ///
751     /// Clients are responsible for ensuring that registration doesn't occur
752     /// while another thread is attempting to access the registry. Typically
753     /// this is done by initializing all targets at program startup.
754     ///
755     /// @param T - The target being registered.
756     /// @param Fn - A function to construct an MCCodeEmitter for the target.
757     static void RegisterMCCodeEmitter(Target &T,
758                                       Target::MCCodeEmitterCtorTy Fn) {
759       T.MCCodeEmitterCtorFn = Fn;
760     }
761
762     /// RegisterMCObjectStreamer - Register a object code MCStreamer
763     /// implementation for the given target.
764     ///
765     /// Clients are responsible for ensuring that registration doesn't occur
766     /// while another thread is attempting to access the registry. Typically
767     /// this is done by initializing all targets at program startup.
768     ///
769     /// @param T - The target being registered.
770     /// @param Fn - A function to construct an MCStreamer for the target.
771     static void RegisterMCObjectStreamer(Target &T,
772                                          Target::MCObjectStreamerCtorTy Fn) {
773       T.MCObjectStreamerCtorFn = Fn;
774     }
775
776     /// RegisterAsmStreamer - Register an assembly MCStreamer implementation
777     /// for the given target.
778     ///
779     /// Clients are responsible for ensuring that registration doesn't occur
780     /// while another thread is attempting to access the registry. Typically
781     /// this is done by initializing all targets at program startup.
782     ///
783     /// @param T - The target being registered.
784     /// @param Fn - A function to construct an MCStreamer for the target.
785     static void RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn) {
786       T.AsmStreamerCtorFn = Fn;
787     }
788
789     static void
790     RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn) {
791       T.NullTargetStreamerCtorFn = Fn;
792     }
793
794     /// RegisterMCRelocationInfo - Register an MCRelocationInfo
795     /// implementation for the given target.
796     ///
797     /// Clients are responsible for ensuring that registration doesn't occur
798     /// while another thread is attempting to access the registry. Typically
799     /// this is done by initializing all targets at program startup.
800     ///
801     /// @param T - The target being registered.
802     /// @param Fn - A function to construct an MCRelocationInfo for the target.
803     static void RegisterMCRelocationInfo(Target &T,
804                                          Target::MCRelocationInfoCtorTy Fn) {
805       T.MCRelocationInfoCtorFn = Fn;
806     }
807
808     /// RegisterMCSymbolizer - Register an MCSymbolizer
809     /// implementation for the given target.
810     ///
811     /// Clients are responsible for ensuring that registration doesn't occur
812     /// while another thread is attempting to access the registry. Typically
813     /// this is done by initializing all targets at program startup.
814     ///
815     /// @param T - The target being registered.
816     /// @param Fn - A function to construct an MCSymbolizer for the target.
817     static void RegisterMCSymbolizer(Target &T,
818                                      Target::MCSymbolizerCtorTy Fn) {
819       T.MCSymbolizerCtorFn = Fn;
820     }
821
822     /// @}
823   };
824
825
826   //===--------------------------------------------------------------------===//
827
828   /// RegisterTarget - Helper template for registering a target, for use in the
829   /// target's initialization function. Usage:
830   ///
831   ///
832   /// Target TheFooTarget; // The global target instance.
833   ///
834   /// extern "C" void LLVMInitializeFooTargetInfo() {
835   ///   RegisterTarget<Triple::foo> X(TheFooTarget, "foo", "Foo description");
836   /// }
837   template<Triple::ArchType TargetArchType = Triple::UnknownArch,
838            bool HasJIT = false>
839   struct RegisterTarget {
840     RegisterTarget(Target &T, const char *Name, const char *Desc) {
841       TargetRegistry::RegisterTarget(T, Name, Desc, &getArchMatch, HasJIT);
842     }
843
844     static bool getArchMatch(Triple::ArchType Arch) {
845       return Arch == TargetArchType;
846     }
847   };
848
849   /// RegisterMCAsmInfo - Helper template for registering a target assembly info
850   /// implementation.  This invokes the static "Create" method on the class to
851   /// actually do the construction.  Usage:
852   ///
853   /// extern "C" void LLVMInitializeFooTarget() {
854   ///   extern Target TheFooTarget;
855   ///   RegisterMCAsmInfo<FooMCAsmInfo> X(TheFooTarget);
856   /// }
857   template<class MCAsmInfoImpl>
858   struct RegisterMCAsmInfo {
859     RegisterMCAsmInfo(Target &T) {
860       TargetRegistry::RegisterMCAsmInfo(T, &Allocator);
861     }
862   private:
863     static MCAsmInfo *Allocator(const MCRegisterInfo &/*MRI*/, StringRef TT) {
864       return new MCAsmInfoImpl(TT);
865     }
866
867   };
868
869   /// RegisterMCAsmInfoFn - Helper template for registering a target assembly info
870   /// implementation.  This invokes the specified function to do the
871   /// construction.  Usage:
872   ///
873   /// extern "C" void LLVMInitializeFooTarget() {
874   ///   extern Target TheFooTarget;
875   ///   RegisterMCAsmInfoFn X(TheFooTarget, TheFunction);
876   /// }
877   struct RegisterMCAsmInfoFn {
878     RegisterMCAsmInfoFn(Target &T, Target::MCAsmInfoCtorFnTy Fn) {
879       TargetRegistry::RegisterMCAsmInfo(T, Fn);
880     }
881   };
882
883   /// RegisterMCCodeGenInfo - Helper template for registering a target codegen info
884   /// implementation.  This invokes the static "Create" method on the class
885   /// to actually do the construction.  Usage:
886   ///
887   /// extern "C" void LLVMInitializeFooTarget() {
888   ///   extern Target TheFooTarget;
889   ///   RegisterMCCodeGenInfo<FooMCCodeGenInfo> X(TheFooTarget);
890   /// }
891   template<class MCCodeGenInfoImpl>
892   struct RegisterMCCodeGenInfo {
893     RegisterMCCodeGenInfo(Target &T) {
894       TargetRegistry::RegisterMCCodeGenInfo(T, &Allocator);
895     }
896   private:
897     static MCCodeGenInfo *Allocator(StringRef /*TT*/, Reloc::Model /*RM*/,
898                                     CodeModel::Model /*CM*/,
899                                     CodeGenOpt::Level /*OL*/) {
900       return new MCCodeGenInfoImpl();
901     }
902   };
903
904   /// RegisterMCCodeGenInfoFn - Helper template for registering a target codegen
905   /// info implementation.  This invokes the specified function to do the
906   /// construction.  Usage:
907   ///
908   /// extern "C" void LLVMInitializeFooTarget() {
909   ///   extern Target TheFooTarget;
910   ///   RegisterMCCodeGenInfoFn X(TheFooTarget, TheFunction);
911   /// }
912   struct RegisterMCCodeGenInfoFn {
913     RegisterMCCodeGenInfoFn(Target &T, Target::MCCodeGenInfoCtorFnTy Fn) {
914       TargetRegistry::RegisterMCCodeGenInfo(T, Fn);
915     }
916   };
917
918   /// RegisterMCInstrInfo - Helper template for registering a target instruction
919   /// info implementation.  This invokes the static "Create" method on the class
920   /// to actually do the construction.  Usage:
921   ///
922   /// extern "C" void LLVMInitializeFooTarget() {
923   ///   extern Target TheFooTarget;
924   ///   RegisterMCInstrInfo<FooMCInstrInfo> X(TheFooTarget);
925   /// }
926   template<class MCInstrInfoImpl>
927   struct RegisterMCInstrInfo {
928     RegisterMCInstrInfo(Target &T) {
929       TargetRegistry::RegisterMCInstrInfo(T, &Allocator);
930     }
931   private:
932     static MCInstrInfo *Allocator() {
933       return new MCInstrInfoImpl();
934     }
935   };
936
937   /// RegisterMCInstrInfoFn - Helper template for registering a target
938   /// instruction info implementation.  This invokes the specified function to
939   /// do the construction.  Usage:
940   ///
941   /// extern "C" void LLVMInitializeFooTarget() {
942   ///   extern Target TheFooTarget;
943   ///   RegisterMCInstrInfoFn X(TheFooTarget, TheFunction);
944   /// }
945   struct RegisterMCInstrInfoFn {
946     RegisterMCInstrInfoFn(Target &T, Target::MCInstrInfoCtorFnTy Fn) {
947       TargetRegistry::RegisterMCInstrInfo(T, Fn);
948     }
949   };
950
951   /// RegisterMCInstrAnalysis - Helper template for registering a target
952   /// instruction analyzer implementation.  This invokes the static "Create"
953   /// method on the class to actually do the construction.  Usage:
954   ///
955   /// extern "C" void LLVMInitializeFooTarget() {
956   ///   extern Target TheFooTarget;
957   ///   RegisterMCInstrAnalysis<FooMCInstrAnalysis> X(TheFooTarget);
958   /// }
959   template<class MCInstrAnalysisImpl>
960   struct RegisterMCInstrAnalysis {
961     RegisterMCInstrAnalysis(Target &T) {
962       TargetRegistry::RegisterMCInstrAnalysis(T, &Allocator);
963     }
964   private:
965     static MCInstrAnalysis *Allocator(const MCInstrInfo *Info) {
966       return new MCInstrAnalysisImpl(Info);
967     }
968   };
969
970   /// RegisterMCInstrAnalysisFn - Helper template for registering a target
971   /// instruction analyzer implementation.  This invokes the specified function
972   /// to do the construction.  Usage:
973   ///
974   /// extern "C" void LLVMInitializeFooTarget() {
975   ///   extern Target TheFooTarget;
976   ///   RegisterMCInstrAnalysisFn X(TheFooTarget, TheFunction);
977   /// }
978   struct RegisterMCInstrAnalysisFn {
979     RegisterMCInstrAnalysisFn(Target &T, Target::MCInstrAnalysisCtorFnTy Fn) {
980       TargetRegistry::RegisterMCInstrAnalysis(T, Fn);
981     }
982   };
983
984   /// RegisterMCRegInfo - Helper template for registering a target register info
985   /// implementation.  This invokes the static "Create" method on the class to
986   /// actually do the construction.  Usage:
987   ///
988   /// extern "C" void LLVMInitializeFooTarget() {
989   ///   extern Target TheFooTarget;
990   ///   RegisterMCRegInfo<FooMCRegInfo> X(TheFooTarget);
991   /// }
992   template<class MCRegisterInfoImpl>
993   struct RegisterMCRegInfo {
994     RegisterMCRegInfo(Target &T) {
995       TargetRegistry::RegisterMCRegInfo(T, &Allocator);
996     }
997   private:
998     static MCRegisterInfo *Allocator(StringRef /*TT*/) {
999       return new MCRegisterInfoImpl();
1000     }
1001   };
1002
1003   /// RegisterMCRegInfoFn - Helper template for registering a target register
1004   /// info implementation.  This invokes the specified function to do the
1005   /// construction.  Usage:
1006   ///
1007   /// extern "C" void LLVMInitializeFooTarget() {
1008   ///   extern Target TheFooTarget;
1009   ///   RegisterMCRegInfoFn X(TheFooTarget, TheFunction);
1010   /// }
1011   struct RegisterMCRegInfoFn {
1012     RegisterMCRegInfoFn(Target &T, Target::MCRegInfoCtorFnTy Fn) {
1013       TargetRegistry::RegisterMCRegInfo(T, Fn);
1014     }
1015   };
1016
1017   /// RegisterMCSubtargetInfo - Helper template for registering a target
1018   /// subtarget info implementation.  This invokes the static "Create" method
1019   /// on the class to actually do the construction.  Usage:
1020   ///
1021   /// extern "C" void LLVMInitializeFooTarget() {
1022   ///   extern Target TheFooTarget;
1023   ///   RegisterMCSubtargetInfo<FooMCSubtargetInfo> X(TheFooTarget);
1024   /// }
1025   template<class MCSubtargetInfoImpl>
1026   struct RegisterMCSubtargetInfo {
1027     RegisterMCSubtargetInfo(Target &T) {
1028       TargetRegistry::RegisterMCSubtargetInfo(T, &Allocator);
1029     }
1030   private:
1031     static MCSubtargetInfo *Allocator(StringRef /*TT*/, StringRef /*CPU*/,
1032                                       StringRef /*FS*/) {
1033       return new MCSubtargetInfoImpl();
1034     }
1035   };
1036
1037   /// RegisterMCSubtargetInfoFn - Helper template for registering a target
1038   /// subtarget info implementation.  This invokes the specified function to
1039   /// do the construction.  Usage:
1040   ///
1041   /// extern "C" void LLVMInitializeFooTarget() {
1042   ///   extern Target TheFooTarget;
1043   ///   RegisterMCSubtargetInfoFn X(TheFooTarget, TheFunction);
1044   /// }
1045   struct RegisterMCSubtargetInfoFn {
1046     RegisterMCSubtargetInfoFn(Target &T, Target::MCSubtargetInfoCtorFnTy Fn) {
1047       TargetRegistry::RegisterMCSubtargetInfo(T, Fn);
1048     }
1049   };
1050
1051   /// RegisterTargetMachine - Helper template for registering a target machine
1052   /// implementation, for use in the target machine initialization
1053   /// function. Usage:
1054   ///
1055   /// extern "C" void LLVMInitializeFooTarget() {
1056   ///   extern Target TheFooTarget;
1057   ///   RegisterTargetMachine<FooTargetMachine> X(TheFooTarget);
1058   /// }
1059   template<class TargetMachineImpl>
1060   struct RegisterTargetMachine {
1061     RegisterTargetMachine(Target &T) {
1062       TargetRegistry::RegisterTargetMachine(T, &Allocator);
1063     }
1064
1065   private:
1066     static TargetMachine *Allocator(const Target &T, StringRef TT,
1067                                     StringRef CPU, StringRef FS,
1068                                     const TargetOptions &Options,
1069                                     Reloc::Model RM,
1070                                     CodeModel::Model CM,
1071                                     CodeGenOpt::Level OL) {
1072       return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL);
1073     }
1074   };
1075
1076   /// RegisterMCAsmBackend - Helper template for registering a target specific
1077   /// assembler backend. Usage:
1078   ///
1079   /// extern "C" void LLVMInitializeFooMCAsmBackend() {
1080   ///   extern Target TheFooTarget;
1081   ///   RegisterMCAsmBackend<FooAsmLexer> X(TheFooTarget);
1082   /// }
1083   template<class MCAsmBackendImpl>
1084   struct RegisterMCAsmBackend {
1085     RegisterMCAsmBackend(Target &T) {
1086       TargetRegistry::RegisterMCAsmBackend(T, &Allocator);
1087     }
1088
1089   private:
1090     static MCAsmBackend *Allocator(const Target &T,
1091                                    const MCRegisterInfo &MRI,
1092                                    StringRef Triple, StringRef CPU) {
1093       return new MCAsmBackendImpl(T, MRI, Triple, CPU);
1094     }
1095   };
1096
1097   /// RegisterMCAsmParser - Helper template for registering a target specific
1098   /// assembly parser, for use in the target machine initialization
1099   /// function. Usage:
1100   ///
1101   /// extern "C" void LLVMInitializeFooMCAsmParser() {
1102   ///   extern Target TheFooTarget;
1103   ///   RegisterMCAsmParser<FooAsmParser> X(TheFooTarget);
1104   /// }
1105   template<class MCAsmParserImpl>
1106   struct RegisterMCAsmParser {
1107     RegisterMCAsmParser(Target &T) {
1108       TargetRegistry::RegisterMCAsmParser(T, &Allocator);
1109     }
1110
1111   private:
1112     static MCTargetAsmParser *Allocator(MCSubtargetInfo &STI, MCAsmParser &P,
1113                                         const MCInstrInfo &MII,
1114                                         const MCTargetOptions &Options) {
1115       return new MCAsmParserImpl(STI, P, MII, Options);
1116     }
1117   };
1118
1119   /// RegisterAsmPrinter - Helper template for registering a target specific
1120   /// assembly printer, for use in the target machine initialization
1121   /// function. Usage:
1122   ///
1123   /// extern "C" void LLVMInitializeFooAsmPrinter() {
1124   ///   extern Target TheFooTarget;
1125   ///   RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget);
1126   /// }
1127   template<class AsmPrinterImpl>
1128   struct RegisterAsmPrinter {
1129     RegisterAsmPrinter(Target &T) {
1130       TargetRegistry::RegisterAsmPrinter(T, &Allocator);
1131     }
1132
1133   private:
1134     static AsmPrinter *Allocator(TargetMachine &TM,
1135                                  std::unique_ptr<MCStreamer> &&Streamer) {
1136       return new AsmPrinterImpl(TM, std::move(Streamer));
1137     }
1138   };
1139
1140   /// RegisterMCCodeEmitter - Helper template for registering a target specific
1141   /// machine code emitter, for use in the target initialization
1142   /// function. Usage:
1143   ///
1144   /// extern "C" void LLVMInitializeFooMCCodeEmitter() {
1145   ///   extern Target TheFooTarget;
1146   ///   RegisterMCCodeEmitter<FooCodeEmitter> X(TheFooTarget);
1147   /// }
1148   template<class MCCodeEmitterImpl>
1149   struct RegisterMCCodeEmitter {
1150     RegisterMCCodeEmitter(Target &T) {
1151       TargetRegistry::RegisterMCCodeEmitter(T, &Allocator);
1152     }
1153
1154   private:
1155     static MCCodeEmitter *Allocator(const MCInstrInfo &/*II*/,
1156                                     const MCRegisterInfo &/*MRI*/,
1157                                     const MCSubtargetInfo &/*STI*/,
1158                                     MCContext &/*Ctx*/) {
1159       return new MCCodeEmitterImpl();
1160     }
1161   };
1162
1163 }
1164
1165 #endif