LLVM  3.7.0
TargetRegistry.h
Go to the documentation of this file.
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"
26 #include <cassert>
27 #include <memory>
28 #include <string>
29 
30 namespace llvm {
31 class AsmPrinter;
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 MCTargetStreamer;
50 class TargetMachine;
51 class TargetOptions;
52 class raw_ostream;
53 class raw_pwrite_stream;
54 class formatted_raw_ostream;
55 
56 MCStreamer *createNullStreamer(MCContext &Ctx);
57 MCStreamer *createAsmStreamer(MCContext &Ctx,
58  std::unique_ptr<formatted_raw_ostream> OS,
59  bool isVerboseAsm, bool useDwarfDirectory,
60  MCInstPrinter *InstPrint, MCCodeEmitter *CE,
61  MCAsmBackend *TAB, bool ShowInst);
62 
63 /// Takes ownership of \p TAB and \p CE.
64 MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
65  raw_pwrite_stream &OS, MCCodeEmitter *CE,
66  bool RelaxAll);
67 MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
68  raw_pwrite_stream &OS, MCCodeEmitter *CE,
69  bool RelaxAll, bool DWARFMustBeAtTheEnd,
70  bool LabelSections = false);
71 
72 MCRelocationInfo *createMCRelocationInfo(const Triple &TT, MCContext &Ctx);
73 
74 MCSymbolizer *createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
75  LLVMSymbolLookupCallback SymbolLookUp,
76  void *DisInfo, MCContext *Ctx,
77  std::unique_ptr<MCRelocationInfo> &&RelInfo);
78 
79 /// Target - Wrapper for Target specific information.
80 ///
81 /// For registration purposes, this is a POD type so that targets can be
82 /// registered without the use of static constructors.
83 ///
84 /// Targets should implement a single global instance of this class (which
85 /// will be zero initialized), and pass that instance to the TargetRegistry as
86 /// part of their initialization.
87 class Target {
88 public:
89  friend struct TargetRegistry;
90 
92 
93  typedef MCAsmInfo *(*MCAsmInfoCtorFnTy)(const MCRegisterInfo &MRI,
94  const Triple &TT);
95  typedef MCCodeGenInfo *(*MCCodeGenInfoCtorFnTy)(const Triple &TT,
99  typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
100  typedef MCInstrAnalysis *(*MCInstrAnalysisCtorFnTy)(const MCInstrInfo *Info);
101  typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(const Triple &TT);
102  typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(const Triple &TT,
103  StringRef CPU,
105  typedef TargetMachine *(*TargetMachineCtorTy)(
106  const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
107  const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM,
108  CodeGenOpt::Level OL);
109  // If it weren't for layering issues (this header is in llvm/Support, but
110  // depends on MC?) this should take the Streamer by value rather than rvalue
111  // reference.
112  typedef AsmPrinter *(*AsmPrinterCtorTy)(
113  TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
114  typedef MCAsmBackend *(*MCAsmBackendCtorTy)(const Target &T,
115  const MCRegisterInfo &MRI,
116  const Triple &TT, StringRef CPU);
117  typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(
118  MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
119  const MCTargetOptions &Options);
120  typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T,
121  const MCSubtargetInfo &STI,
122  MCContext &Ctx);
123  typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Triple &T,
124  unsigned SyntaxVariant,
125  const MCAsmInfo &MAI,
126  const MCInstrInfo &MII,
127  const MCRegisterInfo &MRI);
128  typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
129  const MCRegisterInfo &MRI,
130  MCContext &Ctx);
131  typedef MCStreamer *(*ELFStreamerCtorTy)(const Triple &T, MCContext &Ctx,
132  MCAsmBackend &TAB,
133  raw_pwrite_stream &OS,
134  MCCodeEmitter *Emitter,
135  bool RelaxAll);
136  typedef MCStreamer *(*MachOStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB,
137  raw_pwrite_stream &OS,
138  MCCodeEmitter *Emitter,
139  bool RelaxAll,
140  bool DWARFMustBeAtTheEnd);
141  typedef MCStreamer *(*COFFStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB,
142  raw_pwrite_stream &OS,
143  MCCodeEmitter *Emitter,
144  bool RelaxAll);
145  typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
146  typedef MCTargetStreamer *(*AsmTargetStreamerCtorTy)(
147  MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
148  bool IsVerboseAsm);
149  typedef MCTargetStreamer *(*ObjectTargetStreamerCtorTy)(
150  MCStreamer &S, const MCSubtargetInfo &STI);
151  typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(const Triple &TT,
152  MCContext &Ctx);
153  typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
154  const Triple &TT, LLVMOpInfoCallback GetOpInfo,
155  LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
156  std::unique_ptr<MCRelocationInfo> &&RelInfo);
157 
158 private:
159  /// Next - The next registered target in the linked list, maintained by the
160  /// TargetRegistry.
161  Target *Next;
162 
163  /// The target function for checking if an architecture is supported.
164  ArchMatchFnTy ArchMatchFn;
165 
166  /// Name - The target name.
167  const char *Name;
168 
169  /// ShortDesc - A short description of the target.
170  const char *ShortDesc;
171 
172  /// HasJIT - Whether this target supports the JIT.
173  bool HasJIT;
174 
175  /// MCAsmInfoCtorFn - Constructor function for this target's MCAsmInfo, if
176  /// registered.
177  MCAsmInfoCtorFnTy MCAsmInfoCtorFn;
178 
179  /// MCCodeGenInfoCtorFn - Constructor function for this target's
180  /// MCCodeGenInfo, if registered.
181  MCCodeGenInfoCtorFnTy MCCodeGenInfoCtorFn;
182 
183  /// MCInstrInfoCtorFn - Constructor function for this target's MCInstrInfo,
184  /// if registered.
185  MCInstrInfoCtorFnTy MCInstrInfoCtorFn;
186 
187  /// MCInstrAnalysisCtorFn - Constructor function for this target's
188  /// MCInstrAnalysis, if registered.
189  MCInstrAnalysisCtorFnTy MCInstrAnalysisCtorFn;
190 
191  /// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
192  /// if registered.
193  MCRegInfoCtorFnTy MCRegInfoCtorFn;
194 
195  /// MCSubtargetInfoCtorFn - Constructor function for this target's
196  /// MCSubtargetInfo, if registered.
197  MCSubtargetInfoCtorFnTy MCSubtargetInfoCtorFn;
198 
199  /// TargetMachineCtorFn - Construction function for this target's
200  /// TargetMachine, if registered.
201  TargetMachineCtorTy TargetMachineCtorFn;
202 
203  /// MCAsmBackendCtorFn - Construction function for this target's
204  /// MCAsmBackend, if registered.
205  MCAsmBackendCtorTy MCAsmBackendCtorFn;
206 
207  /// MCAsmParserCtorFn - Construction function for this target's
208  /// MCTargetAsmParser, if registered.
209  MCAsmParserCtorTy MCAsmParserCtorFn;
210 
211  /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
212  /// if registered.
213  AsmPrinterCtorTy AsmPrinterCtorFn;
214 
215  /// MCDisassemblerCtorFn - Construction function for this target's
216  /// MCDisassembler, if registered.
217  MCDisassemblerCtorTy MCDisassemblerCtorFn;
218 
219  /// MCInstPrinterCtorFn - Construction function for this target's
220  /// MCInstPrinter, if registered.
221  MCInstPrinterCtorTy MCInstPrinterCtorFn;
222 
223  /// MCCodeEmitterCtorFn - Construction function for this target's
224  /// CodeEmitter, if registered.
225  MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
226 
227  // Construction functions for the various object formats, if registered.
228  COFFStreamerCtorTy COFFStreamerCtorFn;
229  MachOStreamerCtorTy MachOStreamerCtorFn;
230  ELFStreamerCtorTy ELFStreamerCtorFn;
231 
232  /// Construction function for this target's null TargetStreamer, if
233  /// registered (default = nullptr).
234  NullTargetStreamerCtorTy NullTargetStreamerCtorFn;
235 
236  /// Construction function for this target's asm TargetStreamer, if
237  /// registered (default = nullptr).
238  AsmTargetStreamerCtorTy AsmTargetStreamerCtorFn;
239 
240  /// Construction function for this target's obj TargetStreamer, if
241  /// registered (default = nullptr).
242  ObjectTargetStreamerCtorTy ObjectTargetStreamerCtorFn;
243 
244  /// MCRelocationInfoCtorFn - Construction function for this target's
245  /// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
246  MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
247 
248  /// MCSymbolizerCtorFn - Construction function for this target's
249  /// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
250  MCSymbolizerCtorTy MCSymbolizerCtorFn;
251 
252 public:
254  : COFFStreamerCtorFn(nullptr), MachOStreamerCtorFn(nullptr),
255  ELFStreamerCtorFn(nullptr), NullTargetStreamerCtorFn(nullptr),
256  AsmTargetStreamerCtorFn(nullptr), ObjectTargetStreamerCtorFn(nullptr),
257  MCRelocationInfoCtorFn(nullptr), MCSymbolizerCtorFn(nullptr) {}
258 
259  /// @name Target Information
260  /// @{
261 
262  // getNext - Return the next registered target.
263  const Target *getNext() const { return Next; }
264 
265  /// getName - Get the target name.
266  const char *getName() const { return Name; }
267 
268  /// getShortDescription - Get a short description of the target.
269  const char *getShortDescription() const { return ShortDesc; }
270 
271  /// @}
272  /// @name Feature Predicates
273  /// @{
274 
275  /// hasJIT - Check if this targets supports the just-in-time compilation.
276  bool hasJIT() const { return HasJIT; }
277 
278  /// hasTargetMachine - Check if this target supports code generation.
279  bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
280 
281  /// hasMCAsmBackend - Check if this target supports .o generation.
282  bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
283 
284  /// @}
285  /// @name Feature Constructors
286  /// @{
287 
288  /// createMCAsmInfo - Create a MCAsmInfo implementation for the specified
289  /// target triple.
290  ///
291  /// \param TheTriple This argument is used to determine the target machine
292  /// feature set; it should always be provided. Generally this should be
293  /// either the target triple from the module, or the target triple of the
294  /// host if that does not exist.
296  StringRef TheTriple) const {
297  if (!MCAsmInfoCtorFn)
298  return nullptr;
299  return MCAsmInfoCtorFn(MRI, Triple(TheTriple));
300  }
301 
302  /// createMCCodeGenInfo - Create a MCCodeGenInfo implementation.
303  ///
305  CodeModel::Model CM,
306  CodeGenOpt::Level OL) const {
307  if (!MCCodeGenInfoCtorFn)
308  return nullptr;
309  return MCCodeGenInfoCtorFn(Triple(TT), RM, CM, OL);
310  }
311 
312  /// createMCInstrInfo - Create a MCInstrInfo implementation.
313  ///
315  if (!MCInstrInfoCtorFn)
316  return nullptr;
317  return MCInstrInfoCtorFn();
318  }
319 
320  /// createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
321  ///
323  if (!MCInstrAnalysisCtorFn)
324  return nullptr;
325  return MCInstrAnalysisCtorFn(Info);
326  }
327 
328  /// createMCRegInfo - Create a MCRegisterInfo implementation.
329  ///
331  if (!MCRegInfoCtorFn)
332  return nullptr;
333  return MCRegInfoCtorFn(Triple(TT));
334  }
335 
336  /// createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
337  ///
338  /// \param TheTriple This argument is used to determine the target machine
339  /// feature set; it should always be provided. Generally this should be
340  /// either the target triple from the module, or the target triple of the
341  /// host if that does not exist.
342  /// \param CPU This specifies the name of the target CPU.
343  /// \param Features This specifies the string representation of the
344  /// additional target features.
346  StringRef Features) const {
347  if (!MCSubtargetInfoCtorFn)
348  return nullptr;
349  return MCSubtargetInfoCtorFn(Triple(TheTriple), CPU, Features);
350  }
351 
352  /// createTargetMachine - Create a target specific machine implementation
353  /// for the specified \p Triple.
354  ///
355  /// \param TT This argument is used to determine the target machine
356  /// feature set; it should always be provided. Generally this should be
357  /// either the target triple from the module, or the target triple of the
358  /// host if that does not exist.
359  TargetMachine *
361  const TargetOptions &Options,
365  if (!TargetMachineCtorFn)
366  return nullptr;
367  return TargetMachineCtorFn(*this, Triple(TT), CPU, Features, Options, RM,
368  CM, OL);
369  }
370 
371  /// createMCAsmBackend - Create a target specific assembly parser.
372  ///
373  /// \param TheTriple The target triple string.
375  StringRef TheTriple, StringRef CPU) const {
376  if (!MCAsmBackendCtorFn)
377  return nullptr;
378  return MCAsmBackendCtorFn(*this, MRI, Triple(TheTriple), CPU);
379  }
380 
381  /// createMCAsmParser - Create a target specific assembly parser.
382  ///
383  /// \param Parser The target independent parser implementation to use for
384  /// parsing and lexing.
386  MCAsmParser &Parser,
387  const MCInstrInfo &MII,
388  const MCTargetOptions &Options) const {
389  if (!MCAsmParserCtorFn)
390  return nullptr;
391  return MCAsmParserCtorFn(STI, Parser, MII, Options);
392  }
393 
394  /// createAsmPrinter - Create a target specific assembly printer pass. This
395  /// takes ownership of the MCStreamer object.
397  std::unique_ptr<MCStreamer> &&Streamer) const {
398  if (!AsmPrinterCtorFn)
399  return nullptr;
400  return AsmPrinterCtorFn(TM, std::move(Streamer));
401  }
402 
404  MCContext &Ctx) const {
405  if (!MCDisassemblerCtorFn)
406  return nullptr;
407  return MCDisassemblerCtorFn(*this, STI, Ctx);
408  }
409 
410  MCInstPrinter *createMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
411  const MCAsmInfo &MAI,
412  const MCInstrInfo &MII,
413  const MCRegisterInfo &MRI) const {
414  if (!MCInstPrinterCtorFn)
415  return nullptr;
416  return MCInstPrinterCtorFn(T, SyntaxVariant, MAI, MII, MRI);
417  }
418 
419  /// createMCCodeEmitter - Create a target specific code emitter.
421  const MCRegisterInfo &MRI,
422  MCContext &Ctx) const {
423  if (!MCCodeEmitterCtorFn)
424  return nullptr;
425  return MCCodeEmitterCtorFn(II, MRI, Ctx);
426  }
427 
428  /// Create a target specific MCStreamer.
429  ///
430  /// \param T The target triple.
431  /// \param Ctx The target context.
432  /// \param TAB The target assembler backend object. Takes ownership.
433  /// \param OS The stream object.
434  /// \param Emitter The target independent assembler object.Takes ownership.
435  /// \param RelaxAll Relax all fixups?
438  MCCodeEmitter *Emitter,
439  const MCSubtargetInfo &STI, bool RelaxAll,
440  bool DWARFMustBeAtTheEnd) const {
441  MCStreamer *S;
442  switch (T.getObjectFormat()) {
443  default:
444  llvm_unreachable("Unknown object format");
445  case Triple::COFF:
446  assert(T.isOSWindows() && "only Windows COFF is supported");
447  S = COFFStreamerCtorFn(Ctx, TAB, OS, Emitter, RelaxAll);
448  break;
449  case Triple::MachO:
450  if (MachOStreamerCtorFn)
451  S = MachOStreamerCtorFn(Ctx, TAB, OS, Emitter, RelaxAll,
452  DWARFMustBeAtTheEnd);
453  else
454  S = createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll,
455  DWARFMustBeAtTheEnd);
456  break;
457  case Triple::ELF:
458  if (ELFStreamerCtorFn)
459  S = ELFStreamerCtorFn(T, Ctx, TAB, OS, Emitter, RelaxAll);
460  else
461  S = createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
462  break;
463  }
464  if (ObjectTargetStreamerCtorFn)
465  ObjectTargetStreamerCtorFn(*S, STI);
466  return S;
467  }
468 
470  std::unique_ptr<formatted_raw_ostream> OS,
471  bool IsVerboseAsm, bool UseDwarfDirectory,
472  MCInstPrinter *InstPrint, MCCodeEmitter *CE,
473  MCAsmBackend *TAB, bool ShowInst) const {
474  formatted_raw_ostream &OSRef = *OS;
475  MCStreamer *S = llvm::createAsmStreamer(Ctx, std::move(OS), IsVerboseAsm,
476  UseDwarfDirectory, InstPrint, CE,
477  TAB, ShowInst);
478  createAsmTargetStreamer(*S, OSRef, InstPrint, IsVerboseAsm);
479  return S;
480  }
481 
484  MCInstPrinter *InstPrint,
485  bool IsVerboseAsm) const {
486  if (AsmTargetStreamerCtorFn)
487  return AsmTargetStreamerCtorFn(S, OS, InstPrint, IsVerboseAsm);
488  return nullptr;
489  }
490 
494  return S;
495  }
496 
498  if (NullTargetStreamerCtorFn)
499  return NullTargetStreamerCtorFn(S);
500  return nullptr;
501  }
502 
503  /// createMCRelocationInfo - Create a target specific MCRelocationInfo.
504  ///
505  /// \param TT The target triple.
506  /// \param Ctx The target context.
508  MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn
509  ? MCRelocationInfoCtorFn
511  return Fn(Triple(TT), Ctx);
512  }
513 
514  /// createMCSymbolizer - Create a target specific MCSymbolizer.
515  ///
516  /// \param TT The target triple.
517  /// \param GetOpInfo The function to get the symbolic information for
518  /// operands.
519  /// \param SymbolLookUp The function to lookup a symbol name.
520  /// \param DisInfo The pointer to the block of symbolic information for above
521  /// call
522  /// back.
523  /// \param Ctx The target context.
524  /// \param RelInfo The relocation information for this target. Takes
525  /// ownership.
526  MCSymbolizer *
528  LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
529  MCContext *Ctx,
530  std::unique_ptr<MCRelocationInfo> &&RelInfo) const {
531  MCSymbolizerCtorTy Fn =
532  MCSymbolizerCtorFn ? MCSymbolizerCtorFn : llvm::createMCSymbolizer;
533  return Fn(Triple(TT), GetOpInfo, SymbolLookUp, DisInfo, Ctx,
534  std::move(RelInfo));
535  }
536 
537  /// @}
538 };
539 
540 /// TargetRegistry - Generic interface to target specific features.
542  // FIXME: Make this a namespace, probably just move all the Register*
543  // functions into Target (currently they all just set members on the Target
544  // anyway, and Target friends this class so those functions can...
545  // function).
546  TargetRegistry() = delete;
547 
548  class iterator
549  : public std::iterator<std::forward_iterator_tag, Target, ptrdiff_t> {
550  const Target *Current;
551  explicit iterator(Target *T) : Current(T) {}
552  friend struct TargetRegistry;
553 
554  public:
555  iterator() : Current(nullptr) {}
556 
557  bool operator==(const iterator &x) const { return Current == x.Current; }
558  bool operator!=(const iterator &x) const { return !operator==(x); }
559 
560  // Iterator traversal: forward iteration only
561  iterator &operator++() { // Preincrement
562  assert(Current && "Cannot increment end iterator!");
563  Current = Current->getNext();
564  return *this;
565  }
566  iterator operator++(int) { // Postincrement
567  iterator tmp = *this;
568  ++*this;
569  return tmp;
570  }
571 
572  const Target &operator*() const {
573  assert(Current && "Cannot dereference end iterator!");
574  return *Current;
575  }
576 
577  const Target *operator->() const { return &operator*(); }
578  };
579 
580  /// printRegisteredTargetsForVersion - Print the registered targets
581  /// appropriately for inclusion in a tool's version output.
582  static void printRegisteredTargetsForVersion();
583 
584  /// @name Registry Access
585  /// @{
586 
588 
589  /// lookupTarget - Lookup a target based on a target triple.
590  ///
591  /// \param Triple - The triple to use for finding a target.
592  /// \param Error - On failure, an error string describing why no target was
593  /// found.
594  static const Target *lookupTarget(const std::string &Triple,
595  std::string &Error);
596 
597  /// lookupTarget - Lookup a target based on an architecture name
598  /// and a target triple. If the architecture name is non-empty,
599  /// then the lookup is done by architecture. Otherwise, the target
600  /// triple is used.
601  ///
602  /// \param ArchName - The architecture to use for finding a target.
603  /// \param TheTriple - The triple to use for finding a target. The
604  /// triple is updated with canonical architecture name if a lookup
605  /// by architecture is done.
606  /// \param Error - On failure, an error string describing why no target was
607  /// found.
608  static const Target *lookupTarget(const std::string &ArchName,
609  Triple &TheTriple, std::string &Error);
610 
611  /// @}
612  /// @name Target Registration
613  /// @{
614 
615  /// RegisterTarget - Register the given target. Attempts to register a
616  /// target which has already been registered will be ignored.
617  ///
618  /// Clients are responsible for ensuring that registration doesn't occur
619  /// while another thread is attempting to access the registry. Typically
620  /// this is done by initializing all targets at program startup.
621  ///
622  /// @param T - The target being registered.
623  /// @param Name - The target name. This should be a static string.
624  /// @param ShortDesc - A short target description. This should be a static
625  /// string.
626  /// @param ArchMatchFn - The arch match checking function for this target.
627  /// @param HasJIT - Whether the target supports JIT code
628  /// generation.
629  static void RegisterTarget(Target &T, const char *Name, const char *ShortDesc,
630  Target::ArchMatchFnTy ArchMatchFn,
631  bool HasJIT = false);
632 
633  /// RegisterMCAsmInfo - Register a MCAsmInfo implementation for the
634  /// given target.
635  ///
636  /// Clients are responsible for ensuring that registration doesn't occur
637  /// while another thread is attempting to access the registry. Typically
638  /// this is done by initializing all targets at program startup.
639  ///
640  /// @param T - The target being registered.
641  /// @param Fn - A function to construct a MCAsmInfo for the target.
643  T.MCAsmInfoCtorFn = Fn;
644  }
645 
646  /// RegisterMCCodeGenInfo - Register a MCCodeGenInfo 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 MCCodeGenInfo for the target.
657  T.MCCodeGenInfoCtorFn = Fn;
658  }
659 
660  /// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the
661  /// given target.
662  ///
663  /// Clients are responsible for ensuring that registration doesn't occur
664  /// while another thread is attempting to access the registry. Typically
665  /// this is done by initializing all targets at program startup.
666  ///
667  /// @param T - The target being registered.
668  /// @param Fn - A function to construct a MCInstrInfo for the target.
670  T.MCInstrInfoCtorFn = Fn;
671  }
672 
673  /// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for
674  /// the given target.
677  T.MCInstrAnalysisCtorFn = Fn;
678  }
679 
680  /// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
681  /// given target.
682  ///
683  /// Clients are responsible for ensuring that registration doesn't occur
684  /// while another thread is attempting to access the registry. Typically
685  /// this is done by initializing all targets at program startup.
686  ///
687  /// @param T - The target being registered.
688  /// @param Fn - A function to construct a MCRegisterInfo for the target.
690  T.MCRegInfoCtorFn = Fn;
691  }
692 
693  /// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for
694  /// the given target.
695  ///
696  /// Clients are responsible for ensuring that registration doesn't occur
697  /// while another thread is attempting to access the registry. Typically
698  /// this is done by initializing all targets at program startup.
699  ///
700  /// @param T - The target being registered.
701  /// @param Fn - A function to construct a MCSubtargetInfo for the target.
704  T.MCSubtargetInfoCtorFn = Fn;
705  }
706 
707  /// RegisterTargetMachine - Register a TargetMachine implementation for the
708  /// given 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 a TargetMachine for the target.
717  T.TargetMachineCtorFn = Fn;
718  }
719 
720  /// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
721  /// 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 AsmBackend for the target.
730  T.MCAsmBackendCtorFn = Fn;
731  }
732 
733  /// RegisterMCAsmParser - Register a MCTargetAsmParser implementation for
734  /// the given target.
735  ///
736  /// Clients are responsible for ensuring that registration doesn't occur
737  /// while another thread is attempting to access the registry. Typically
738  /// this is done by initializing all targets at program startup.
739  ///
740  /// @param T - The target being registered.
741  /// @param Fn - A function to construct an MCTargetAsmParser for the target.
743  T.MCAsmParserCtorFn = Fn;
744  }
745 
746  /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
747  /// target.
748  ///
749  /// Clients are responsible for ensuring that registration doesn't occur
750  /// while another thread is attempting to access the registry. Typically
751  /// this is done by initializing all targets at program startup.
752  ///
753  /// @param T - The target being registered.
754  /// @param Fn - A function to construct an AsmPrinter for the target.
756  T.AsmPrinterCtorFn = Fn;
757  }
758 
759  /// RegisterMCDisassembler - Register a MCDisassembler implementation for
760  /// the given target.
761  ///
762  /// Clients are responsible for ensuring that registration doesn't occur
763  /// while another thread is attempting to access the registry. Typically
764  /// this is done by initializing all targets at program startup.
765  ///
766  /// @param T - The target being registered.
767  /// @param Fn - A function to construct an MCDisassembler for the target.
770  T.MCDisassemblerCtorFn = Fn;
771  }
772 
773  /// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the
774  /// given target.
775  ///
776  /// Clients are responsible for ensuring that registration doesn't occur
777  /// while another thread is attempting to access the registry. Typically
778  /// this is done by initializing all targets at program startup.
779  ///
780  /// @param T - The target being registered.
781  /// @param Fn - A function to construct an MCInstPrinter for the target.
783  T.MCInstPrinterCtorFn = Fn;
784  }
785 
786  /// RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the
787  /// given target.
788  ///
789  /// Clients are responsible for ensuring that registration doesn't occur
790  /// while another thread is attempting to access the registry. Typically
791  /// this is done by initializing all targets at program startup.
792  ///
793  /// @param T - The target being registered.
794  /// @param Fn - A function to construct an MCCodeEmitter for the target.
796  T.MCCodeEmitterCtorFn = Fn;
797  }
798 
800  T.COFFStreamerCtorFn = Fn;
801  }
802 
804  T.MachOStreamerCtorFn = Fn;
805  }
806 
808  T.ELFStreamerCtorFn = Fn;
809  }
810 
813  T.NullTargetStreamerCtorFn = Fn;
814  }
815 
818  T.AsmTargetStreamerCtorFn = Fn;
819  }
820 
821  static void
824  T.ObjectTargetStreamerCtorFn = Fn;
825  }
826 
827  /// RegisterMCRelocationInfo - Register an MCRelocationInfo
828  /// implementation for the given target.
829  ///
830  /// Clients are responsible for ensuring that registration doesn't occur
831  /// while another thread is attempting to access the registry. Typically
832  /// this is done by initializing all targets at program startup.
833  ///
834  /// @param T - The target being registered.
835  /// @param Fn - A function to construct an MCRelocationInfo for the target.
838  T.MCRelocationInfoCtorFn = Fn;
839  }
840 
841  /// RegisterMCSymbolizer - Register an MCSymbolizer
842  /// implementation for the given target.
843  ///
844  /// Clients are responsible for ensuring that registration doesn't occur
845  /// while another thread is attempting to access the registry. Typically
846  /// this is done by initializing all targets at program startup.
847  ///
848  /// @param T - The target being registered.
849  /// @param Fn - A function to construct an MCSymbolizer for the target.
851  T.MCSymbolizerCtorFn = Fn;
852  }
853 
854  /// @}
855 };
856 
857 //===--------------------------------------------------------------------===//
858 
859 /// RegisterTarget - Helper template for registering a target, for use in the
860 /// target's initialization function. Usage:
861 ///
862 ///
863 /// Target TheFooTarget; // The global target instance.
864 ///
865 /// extern "C" void LLVMInitializeFooTargetInfo() {
866 /// RegisterTarget<Triple::foo> X(TheFooTarget, "foo", "Foo description");
867 /// }
868 template <Triple::ArchType TargetArchType = Triple::UnknownArch,
869  bool HasJIT = false>
871  RegisterTarget(Target &T, const char *Name, const char *Desc) {
872  TargetRegistry::RegisterTarget(T, Name, Desc, &getArchMatch, HasJIT);
873  }
874 
875  static bool getArchMatch(Triple::ArchType Arch) {
876  return Arch == TargetArchType;
877  }
878 };
879 
880 /// RegisterMCAsmInfo - Helper template for registering a target assembly info
881 /// implementation. This invokes the static "Create" method on the class to
882 /// actually do the construction. Usage:
883 ///
884 /// extern "C" void LLVMInitializeFooTarget() {
885 /// extern Target TheFooTarget;
886 /// RegisterMCAsmInfo<FooMCAsmInfo> X(TheFooTarget);
887 /// }
888 template <class MCAsmInfoImpl> struct RegisterMCAsmInfo {
890  TargetRegistry::RegisterMCAsmInfo(T, &Allocator);
891  }
892 
893 private:
894  static MCAsmInfo *Allocator(const MCRegisterInfo & /*MRI*/,
895  const Triple &TT) {
896  return new MCAsmInfoImpl(TT);
897  }
898 };
899 
900 /// RegisterMCAsmInfoFn - Helper template for registering a target assembly info
901 /// implementation. This invokes the specified function to do the
902 /// construction. Usage:
903 ///
904 /// extern "C" void LLVMInitializeFooTarget() {
905 /// extern Target TheFooTarget;
906 /// RegisterMCAsmInfoFn X(TheFooTarget, TheFunction);
907 /// }
911  }
912 };
913 
914 /// RegisterMCCodeGenInfo - Helper template for registering a target codegen
915 /// info
916 /// implementation. This invokes the static "Create" method on the class
917 /// to actually do the construction. Usage:
918 ///
919 /// extern "C" void LLVMInitializeFooTarget() {
920 /// extern Target TheFooTarget;
921 /// RegisterMCCodeGenInfo<FooMCCodeGenInfo> X(TheFooTarget);
922 /// }
923 template <class MCCodeGenInfoImpl> struct RegisterMCCodeGenInfo {
926  }
927 
928 private:
929  static MCCodeGenInfo *Allocator(const Triple & /*TT*/, Reloc::Model /*RM*/,
930  CodeModel::Model /*CM*/,
931  CodeGenOpt::Level /*OL*/) {
932  return new MCCodeGenInfoImpl();
933  }
934 };
935 
936 /// RegisterMCCodeGenInfoFn - Helper template for registering a target codegen
937 /// info implementation. This invokes the specified function to do the
938 /// construction. Usage:
939 ///
940 /// extern "C" void LLVMInitializeFooTarget() {
941 /// extern Target TheFooTarget;
942 /// RegisterMCCodeGenInfoFn X(TheFooTarget, TheFunction);
943 /// }
947  }
948 };
949 
950 /// RegisterMCInstrInfo - Helper template for registering a target instruction
951 /// info implementation. This invokes the static "Create" method on the class
952 /// to actually do the construction. Usage:
953 ///
954 /// extern "C" void LLVMInitializeFooTarget() {
955 /// extern Target TheFooTarget;
956 /// RegisterMCInstrInfo<FooMCInstrInfo> X(TheFooTarget);
957 /// }
958 template <class MCInstrInfoImpl> struct RegisterMCInstrInfo {
961  }
962 
963 private:
964  static MCInstrInfo *Allocator() { return new MCInstrInfoImpl(); }
965 };
966 
967 /// RegisterMCInstrInfoFn - Helper template for registering a target
968 /// instruction info implementation. This invokes the specified function to
969 /// do the construction. Usage:
970 ///
971 /// extern "C" void LLVMInitializeFooTarget() {
972 /// extern Target TheFooTarget;
973 /// RegisterMCInstrInfoFn X(TheFooTarget, TheFunction);
974 /// }
978  }
979 };
980 
981 /// RegisterMCInstrAnalysis - Helper template for registering a target
982 /// instruction analyzer implementation. This invokes the static "Create"
983 /// method on the class to actually do the construction. Usage:
984 ///
985 /// extern "C" void LLVMInitializeFooTarget() {
986 /// extern Target TheFooTarget;
987 /// RegisterMCInstrAnalysis<FooMCInstrAnalysis> X(TheFooTarget);
988 /// }
989 template <class MCInstrAnalysisImpl> struct RegisterMCInstrAnalysis {
992  }
993 
994 private:
995  static MCInstrAnalysis *Allocator(const MCInstrInfo *Info) {
996  return new MCInstrAnalysisImpl(Info);
997  }
998 };
999 
1000 /// RegisterMCInstrAnalysisFn - Helper template for registering a target
1001 /// instruction analyzer implementation. This invokes the specified function
1002 /// to do the construction. Usage:
1003 ///
1004 /// extern "C" void LLVMInitializeFooTarget() {
1005 /// extern Target TheFooTarget;
1006 /// RegisterMCInstrAnalysisFn X(TheFooTarget, TheFunction);
1007 /// }
1011  }
1012 };
1013 
1014 /// RegisterMCRegInfo - Helper template for registering a target register info
1015 /// implementation. This invokes the static "Create" method on the class to
1016 /// actually do the construction. Usage:
1017 ///
1018 /// extern "C" void LLVMInitializeFooTarget() {
1019 /// extern Target TheFooTarget;
1020 /// RegisterMCRegInfo<FooMCRegInfo> X(TheFooTarget);
1021 /// }
1022 template <class MCRegisterInfoImpl> struct RegisterMCRegInfo {
1024  TargetRegistry::RegisterMCRegInfo(T, &Allocator);
1025  }
1026 
1027 private:
1028  static MCRegisterInfo *Allocator(const Triple & /*TT*/) {
1029  return new MCRegisterInfoImpl();
1030  }
1031 };
1032 
1033 /// RegisterMCRegInfoFn - Helper template for registering a target register
1034 /// info implementation. This invokes the specified function to do the
1035 /// construction. Usage:
1036 ///
1037 /// extern "C" void LLVMInitializeFooTarget() {
1038 /// extern Target TheFooTarget;
1039 /// RegisterMCRegInfoFn X(TheFooTarget, TheFunction);
1040 /// }
1044  }
1045 };
1046 
1047 /// RegisterMCSubtargetInfo - Helper template for registering a target
1048 /// subtarget info implementation. This invokes the static "Create" method
1049 /// on the class to actually do the construction. Usage:
1050 ///
1051 /// extern "C" void LLVMInitializeFooTarget() {
1052 /// extern Target TheFooTarget;
1053 /// RegisterMCSubtargetInfo<FooMCSubtargetInfo> X(TheFooTarget);
1054 /// }
1055 template <class MCSubtargetInfoImpl> struct RegisterMCSubtargetInfo {
1058  }
1059 
1060 private:
1061  static MCSubtargetInfo *Allocator(const Triple & /*TT*/, StringRef /*CPU*/,
1062  StringRef /*FS*/) {
1063  return new MCSubtargetInfoImpl();
1064  }
1065 };
1066 
1067 /// RegisterMCSubtargetInfoFn - Helper template for registering a target
1068 /// subtarget info implementation. This invokes the specified function to
1069 /// do the construction. Usage:
1070 ///
1071 /// extern "C" void LLVMInitializeFooTarget() {
1072 /// extern Target TheFooTarget;
1073 /// RegisterMCSubtargetInfoFn X(TheFooTarget, TheFunction);
1074 /// }
1078  }
1079 };
1080 
1081 /// RegisterTargetMachine - Helper template for registering a target machine
1082 /// implementation, for use in the target machine initialization
1083 /// function. Usage:
1084 ///
1085 /// extern "C" void LLVMInitializeFooTarget() {
1086 /// extern Target TheFooTarget;
1087 /// RegisterTargetMachine<FooTargetMachine> X(TheFooTarget);
1088 /// }
1089 template <class TargetMachineImpl> struct RegisterTargetMachine {
1092  }
1093 
1094 private:
1095  static TargetMachine *Allocator(const Target &T, const Triple &TT,
1096  StringRef CPU, StringRef FS,
1097  const TargetOptions &Options, Reloc::Model RM,
1099  return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL);
1100  }
1101 };
1102 
1103 /// RegisterMCAsmBackend - Helper template for registering a target specific
1104 /// assembler backend. Usage:
1105 ///
1106 /// extern "C" void LLVMInitializeFooMCAsmBackend() {
1107 /// extern Target TheFooTarget;
1108 /// RegisterMCAsmBackend<FooAsmLexer> X(TheFooTarget);
1109 /// }
1110 template <class MCAsmBackendImpl> struct RegisterMCAsmBackend {
1112  TargetRegistry::RegisterMCAsmBackend(T, &Allocator);
1113  }
1114 
1115 private:
1116  static MCAsmBackend *Allocator(const Target &T, const MCRegisterInfo &MRI,
1117  const Triple &TheTriple, StringRef CPU) {
1118  return new MCAsmBackendImpl(T, MRI, TheTriple, CPU);
1119  }
1120 };
1121 
1122 /// RegisterMCAsmParser - Helper template for registering a target specific
1123 /// assembly parser, for use in the target machine initialization
1124 /// function. Usage:
1125 ///
1126 /// extern "C" void LLVMInitializeFooMCAsmParser() {
1127 /// extern Target TheFooTarget;
1128 /// RegisterMCAsmParser<FooAsmParser> X(TheFooTarget);
1129 /// }
1130 template <class MCAsmParserImpl> struct RegisterMCAsmParser {
1132  TargetRegistry::RegisterMCAsmParser(T, &Allocator);
1133  }
1134 
1135 private:
1136  static MCTargetAsmParser *Allocator(MCSubtargetInfo &STI, MCAsmParser &P,
1137  const MCInstrInfo &MII,
1138  const MCTargetOptions &Options) {
1139  return new MCAsmParserImpl(STI, P, MII, Options);
1140  }
1141 };
1142 
1143 /// RegisterAsmPrinter - Helper template for registering a target specific
1144 /// assembly printer, for use in the target machine initialization
1145 /// function. Usage:
1146 ///
1147 /// extern "C" void LLVMInitializeFooAsmPrinter() {
1148 /// extern Target TheFooTarget;
1149 /// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget);
1150 /// }
1151 template <class AsmPrinterImpl> struct RegisterAsmPrinter {
1153  TargetRegistry::RegisterAsmPrinter(T, &Allocator);
1154  }
1155 
1156 private:
1157  static AsmPrinter *Allocator(TargetMachine &TM,
1158  std::unique_ptr<MCStreamer> &&Streamer) {
1159  return new AsmPrinterImpl(TM, std::move(Streamer));
1160  }
1161 };
1162 
1163 /// RegisterMCCodeEmitter - Helper template for registering a target specific
1164 /// machine code emitter, for use in the target initialization
1165 /// function. Usage:
1166 ///
1167 /// extern "C" void LLVMInitializeFooMCCodeEmitter() {
1168 /// extern Target TheFooTarget;
1169 /// RegisterMCCodeEmitter<FooCodeEmitter> X(TheFooTarget);
1170 /// }
1171 template <class MCCodeEmitterImpl> struct RegisterMCCodeEmitter {
1174  }
1175 
1176 private:
1177  static MCCodeEmitter *Allocator(const MCInstrInfo & /*II*/,
1178  const MCRegisterInfo & /*MRI*/,
1179  MCContext & /*Ctx*/) {
1180  return new MCCodeEmitterImpl();
1181  }
1182 };
1183 }
1184 
1185 #endif
MCDisassembler * createMCDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) const
RegisterMCRegInfoFn - Helper template for registering a target register info implementation.
RegisterTarget - Helper template for registering a target, for use in the target's initialization fun...
const Target * getNext() const
MCInstrInfo *(* MCInstrInfoCtorFnTy)(void)
const char * getName() const
getName - Get the target name.
RegisterTarget(Target &T, const char *Name, const char *Desc)
Generic assembler parser interface, for use by target specific assembly parsers.
Definition: MCAsmParser.h:64
MCTargetStreamer *(* ObjectTargetStreamerCtorTy)(MCStreamer &S, const MCSubtargetInfo &STI)
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
static void RegisterMCInstrAnalysis(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for the given target...
MCTargetAsmParser - Generic interface to target specific assembly parsers.
Superclass for all disassemblers.
const char *(* LLVMSymbolLookupCallback)(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
The type for the symbol lookup function.
MCStreamer *(* ELFStreamerCtorTy)(const Triple &T, MCContext &Ctx, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *Emitter, bool RelaxAll)
RegisterMCAsmInfoFn(Target &T, Target::MCAsmInfoCtorFnTy Fn)
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
Target specific streamer interface.
Definition: MCStreamer.h:73
MCStreamer * createNullStreamer(MCContext &Ctx)
Create a dummy machine code streamer, which does nothing.
const FeatureBitset Features
RegisterMCInstrInfo - Helper template for registering a target instruction info implementation.
MCAsmBackend * createMCAsmBackend(const MCRegisterInfo &MRI, StringRef TheTriple, StringRef CPU) const
createMCAsmBackend - Create a target specific assembly parser.
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.
TargetRegistry - Generic interface to target specific features.
RegisterMCSubtargetInfoFn(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
MCSymbolizer * createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo)
bool hasTargetMachine() const
hasTargetMachine - Check if this target supports code generation.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
const Target & operator*() const
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:464
RegisterMCInstrAnalysis - Helper template for registering a target instruction analyzer implementatio...
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
bool hasMCAsmBackend() const
hasMCAsmBackend - Check if this target supports .o generation.
MCStreamer *(* COFFStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *Emitter, bool RelaxAll)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
RegisterMCCodeEmitter - Helper template for registering a target specific machine code emitter...
MCAsmBackend *(* MCAsmBackendCtorTy)(const Target &T, const MCRegisterInfo &MRI, const Triple &TT, StringRef CPU)
ObjectFormatType getObjectFormat() const
getFormat - Get the object format for this triple.
Definition: Triple.h:272
static void RegisterCOFFStreamer(Target &T, Target::COFFStreamerCtorTy Fn)
AsmPrinter * createAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) const
createAsmPrinter - Create a target specific assembly printer pass.
Context object for machine code objects.
Definition: MCContext.h:48
MCCodeEmitter *(* MCCodeEmitterCtorTy)(const MCInstrInfo &II, const MCRegisterInfo &MRI, MCContext &Ctx)
#define T
static void RegisterTargetMachine(Target &T, Target::TargetMachineCtorTy Fn)
RegisterTargetMachine - Register a TargetMachine implementation for the given target.
MCTargetStreamer * createAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool IsVerboseAsm) const
TargetMachine * createTargetMachine(StringRef TT, StringRef CPU, StringRef Features, const TargetOptions &Options, Reloc::Model RM=Reloc::Default, CodeModel::Model CM=CodeModel::Default, CodeGenOpt::Level OL=CodeGenOpt::Default) const
createTargetMachine - Create a target specific machine implementation for the specified Triple...
RegisterMCAsmBackend - Helper template for registering a target specific assembler backend...
static void RegisterTarget(Target &T, const char *Name, const char *ShortDesc, Target::ArchMatchFnTy ArchMatchFn, bool HasJIT=false)
RegisterTarget - Register the given target.
static iterator_range< iterator > targets()
MCRegisterInfo *(* MCRegInfoCtorFnTy)(const Triple &TT)
MCTargetAsmParser * createMCAsmParser(MCSubtargetInfo &STI, MCAsmParser &Parser, const MCInstrInfo &MII, const MCTargetOptions &Options) const
createMCAsmParser - Create a target specific assembly parser.
AsmPrinter *(* AsmPrinterCtorTy)(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer)
MCInstrAnalysis * createMCInstrAnalysis(const MCInstrInfo *Info) const
createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
MCRelocationInfo * createMCRelocationInfo(const Triple &TT, MCContext &Ctx)
RegisterMCRegInfoFn(Target &T, Target::MCRegInfoCtorFnTy Fn)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:58
MCStreamer * createNullStreamer(MCContext &Ctx) const
bool hasJIT() const
hasJIT - Check if this targets supports the just-in-time compilation.
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
#define P(N)
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple) const
createMCAsmInfo - Create a MCAsmInfo implementation for the specified target triple.
Streaming machine code generation interface.
Definition: MCStreamer.h:157
MCInstrAnalysis *(* MCInstrAnalysisCtorFnTy)(const MCInstrInfo *Info)
static void printRegisteredTargetsForVersion()
printRegisteredTargetsForVersion - Print the registered targets appropriately for inclusion in a tool...
RegisterMCInstrInfoFn(Target &T, Target::MCInstrInfoCtorFnTy Fn)
static void RegisterMCAsmParser(Target &T, Target::MCAsmParserCtorTy Fn)
RegisterMCAsmParser - Register a MCTargetAsmParser implementation for the given target.
Symbolize and annotate disassembled instructions.
Definition: MCSymbolizer.h:40
bool(* ArchMatchFnTy)(Triple::ArchType Arch)
MCDisassembler *(* MCDisassemblerCtorTy)(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static void RegisterMachOStreamer(Target &T, Target::MachOStreamerCtorTy Fn)
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool isVerboseAsm, bool useDwarfDirectory, MCInstPrinter *InstPrint, MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst)
Create a machine code streamer which will print out assembly for the native target, suitable for compiling with a native assembler.
RegisterMCInstrAnalysisFn(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
const char * getShortDescription() const
getShortDescription - Get a short description of the target.
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:23
MCCodeGenInfo * createMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) const
createMCCodeGenInfo - Create a MCCodeGenInfo implementation.
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:66
MCTargetStreamer *(* NullTargetStreamerCtorTy)(MCStreamer &S)
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, const MCRegisterInfo &MRI, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
Create MCExprs from relocations found in an object file.
MCTargetAsmParser *(* MCAsmParserCtorTy)(MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII, const MCTargetOptions &Options)
static void RegisterMCCodeGenInfo(Target &T, Target::MCCodeGenInfoCtorFnTy Fn)
RegisterMCCodeGenInfo - Register a MCCodeGenInfo implementation for the given target.
MCCodeGenInfo *(* MCCodeGenInfoCtorFnTy)(const Triple &TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL)
MCRelocationInfo * createMCRelocationInfo(StringRef TT, MCContext &Ctx) const
createMCRelocationInfo - Create a target specific MCRelocationInfo.
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCAsmInfo - Register a MCAsmInfo implementation for the given target.
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target...
MCSymbolizer *(* MCSymbolizerCtorTy)(const Triple &TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo)
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
RegisterMCAsmInfo - Helper template for registering a target assembly info implementation.
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
RegisterMCRegInfo - Helper template for registering a target register info implementation.
MCTargetStreamer * createNullTargetStreamer(MCStreamer &S) const
MCStreamer * createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *CE, bool RelaxAll)
Takes ownership of TAB and CE.
MCSymbolizer * createMCSymbolizer(StringRef TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo) const
createMCSymbolizer - Create a target specific MCSymbolizer.
bool operator!=(const iterator &x) const
const Target * operator->() const
bool operator==(const iterator &x) const
A range adaptor for a pair of iterators.
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Target - Wrapper for Target specific information.
MCSubtargetInfo *(* MCSubtargetInfoCtorFnTy)(const Triple &TT, StringRef CPU, StringRef Features)
MCAsmInfo *(* MCAsmInfoCtorFnTy)(const MCRegisterInfo &MRI, const Triple &TT)
MCStreamer * createMCObjectStreamer(const Triple &T, MCContext &Ctx, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *Emitter, const MCSubtargetInfo &STI, bool RelaxAll, bool DWARFMustBeAtTheEnd) const
Create a target specific MCStreamer.
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool IsVerboseAsm, bool UseDwarfDirectory, MCInstPrinter *InstPrint, MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst) const
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
static bool getArchMatch(Triple::ArchType Arch)
RegisterMCAsmParser - Helper template for registering a target specific assembly parser, for use in the target machine initialization function.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:38
MCRelocationInfo *(* MCRelocationInfoCtorTy)(const Triple &TT, MCContext &Ctx)
RegisterMCSubtargetInfoFn - Helper template for registering a target subtarget info implementation...
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target. ...
MCInstPrinter *(* MCInstPrinterCtorTy)(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
MCSubtargetInfo - Generic base class for all target subtargets.
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn)
static void RegisterMCSymbolizer(Target &T, Target::MCSymbolizerCtorTy Fn)
RegisterMCSymbolizer - Register an MCSymbolizer implementation for the given target.
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:321
cl::opt< bool > RelaxAll("mc-relax-all", cl::desc("When used with filetype=obj, ""relax all fixups in the emitted object file"))
RegisterTargetMachine - Helper template for registering a target machine implementation, for use in the target machine initialization function.
MCStreamer * createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *CE, bool RelaxAll, bool DWARFMustBeAtTheEnd, bool LabelSections=false)
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:34
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
RegisterMCCodeGenInfo - Helper template for registering a target codegen info implementation.
MCStreamer *(* MachOStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *Emitter, bool RelaxAll, bool DWARFMustBeAtTheEnd)
static void RegisterMCRelocationInfo(Target &T, Target::MCRelocationInfoCtorTy Fn)
RegisterMCRelocationInfo - Register an MCRelocationInfo implementation for the given target...
Primary interface to the complete machine description for the target machine.
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn)
RegisterAsmPrinter - Register an AsmPrinter implementation for the given target.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
RegisterMCInstrAnalysisFn - Helper template for registering a target instruction analyzer implementat...
MCTargetStreamer *(* AsmTargetStreamerCtorTy)(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool IsVerboseAsm)
RegisterMCCodeGenInfoFn - Helper template for registering a target codegen info implementation.
TargetMachine *(* TargetMachineCtorTy)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL)
int(* LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t Size, int TagType, void *TagBuf)
The type for the operand information call back function.
RegisterMCCodeGenInfoFn(Target &T, Target::MCCodeGenInfoCtorFnTy Fn)
RegisterMCInstrInfoFn - Helper template for registering a target instruction info implementation...
RegisterMCSubtargetInfo - Helper template for registering a target subtarget info implementation...