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