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