LLVM  9.0.0svn
TargetRegistry.h
Go to the documentation of this file.
1 //===- Support/TargetRegistry.h - Target Registration -----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file exposes the TargetRegistry interface, which tools can use to access
10 // the appropriate target specific classes (TargetMachine, AsmPrinter, etc.)
11 // which have been registered.
12 //
13 // Target specific class implementations should register themselves using the
14 // appropriate TargetRegistry interfaces.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_SUPPORT_TARGETREGISTRY_H
19 #define LLVM_SUPPORT_TARGETREGISTRY_H
20 
22 #include "llvm/ADT/Optional.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/ADT/Triple.h"
26 #include "llvm/Support/CodeGen.h"
29 #include <algorithm>
30 #include <cassert>
31 #include <cstddef>
32 #include <iterator>
33 #include <memory>
34 #include <string>
35 
36 namespace llvm {
37 
38 class AsmPrinter;
39 class MCAsmBackend;
40 class MCAsmInfo;
41 class MCAsmParser;
42 class MCCodeEmitter;
43 class MCContext;
44 class MCDisassembler;
45 class MCInstPrinter;
46 class MCInstrAnalysis;
47 class MCInstrInfo;
48 class MCObjectWriter;
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 // Takes ownership of \p TAB and \p CE.
64 
65 /// Create a machine code streamer which will print out assembly for the native
66 /// target, suitable for compiling with a native assembler.
67 ///
68 /// \param InstPrint - If given, the instruction printer to use. If not given
69 /// the MCInst representation will be printed. This method takes ownership of
70 /// InstPrint.
71 ///
72 /// \param CE - If given, a code emitter to use to show the instruction
73 /// encoding inline with the assembly. This method takes ownership of \p CE.
74 ///
75 /// \param TAB - If given, a target asm backend to use to show the fixup
76 /// information in conjunction with encoding information. This method takes
77 /// ownership of \p TAB.
78 ///
79 /// \param ShowInst - Whether to show the MCInst representation inline with
80 /// the assembly.
81 MCStreamer *
82 createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS,
83  bool isVerboseAsm, bool useDwarfDirectory,
84  MCInstPrinter *InstPrint, std::unique_ptr<MCCodeEmitter> &&CE,
85  std::unique_ptr<MCAsmBackend> &&TAB, bool ShowInst);
86 
87 MCStreamer *createELFStreamer(MCContext &Ctx,
88  std::unique_ptr<MCAsmBackend> &&TAB,
89  std::unique_ptr<MCObjectWriter> &&OW,
90  std::unique_ptr<MCCodeEmitter> &&CE,
91  bool RelaxAll);
92 MCStreamer *createMachOStreamer(MCContext &Ctx,
93  std::unique_ptr<MCAsmBackend> &&TAB,
94  std::unique_ptr<MCObjectWriter> &&OW,
95  std::unique_ptr<MCCodeEmitter> &&CE,
96  bool RelaxAll, bool DWARFMustBeAtTheEnd,
97  bool LabelSections = false);
98 MCStreamer *createWasmStreamer(MCContext &Ctx,
99  std::unique_ptr<MCAsmBackend> &&TAB,
100  std::unique_ptr<MCObjectWriter> &&OW,
101  std::unique_ptr<MCCodeEmitter> &&CE,
102  bool RelaxAll);
103 
104 MCRelocationInfo *createMCRelocationInfo(const Triple &TT, MCContext &Ctx);
105 
106 MCSymbolizer *createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
107  LLVMSymbolLookupCallback SymbolLookUp,
108  void *DisInfo, MCContext *Ctx,
109  std::unique_ptr<MCRelocationInfo> &&RelInfo);
110 
111 /// Target - Wrapper for Target specific information.
112 ///
113 /// For registration purposes, this is a POD type so that targets can be
114 /// registered without the use of static constructors.
115 ///
116 /// Targets should implement a single global instance of this class (which
117 /// will be zero initialized), and pass that instance to the TargetRegistry as
118 /// part of their initialization.
119 class Target {
120 public:
121  friend struct TargetRegistry;
122 
124 
125  using MCAsmInfoCtorFnTy = MCAsmInfo *(*)(const MCRegisterInfo &MRI,
126  const Triple &TT);
129  using MCRegInfoCtorFnTy = MCRegisterInfo *(*)(const Triple &TT);
130  using MCSubtargetInfoCtorFnTy = MCSubtargetInfo *(*)(const Triple &TT,
131  StringRef CPU,
132  StringRef Features);
134  *(*)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
135  const TargetOptions &Options, Optional<Reloc::Model> RM,
137  // If it weren't for layering issues (this header is in llvm/Support, but
138  // depends on MC?) this should take the Streamer by value rather than rvalue
139  // reference.
140  using AsmPrinterCtorTy = AsmPrinter *(*)(
141  TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
142  using MCAsmBackendCtorTy = MCAsmBackend *(*)(const Target &T,
143  const MCSubtargetInfo &STI,
144  const MCRegisterInfo &MRI,
145  const MCTargetOptions &Options);
147  const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
148  const MCTargetOptions &Options);
149  using MCDisassemblerCtorTy = MCDisassembler *(*)(const Target &T,
150  const MCSubtargetInfo &STI,
151  MCContext &Ctx);
152  using MCInstPrinterCtorTy = MCInstPrinter *(*)(const Triple &T,
153  unsigned SyntaxVariant,
154  const MCAsmInfo &MAI,
155  const MCInstrInfo &MII,
157  using MCCodeEmitterCtorTy = MCCodeEmitter *(*)(const MCInstrInfo &II,
158  const MCRegisterInfo &MRI,
159  MCContext &Ctx);
160  using ELFStreamerCtorTy =
161  MCStreamer *(*)(const Triple &T, MCContext &Ctx,
162  std::unique_ptr<MCAsmBackend> &&TAB,
163  std::unique_ptr<MCObjectWriter> &&OW,
164  std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll);
165  using MachOStreamerCtorTy =
166  MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
167  std::unique_ptr<MCObjectWriter> &&OW,
168  std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll,
169  bool DWARFMustBeAtTheEnd);
170  using COFFStreamerCtorTy =
171  MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
172  std::unique_ptr<MCObjectWriter> &&OW,
173  std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll,
174  bool IncrementalLinkerCompatible);
175  using WasmStreamerCtorTy =
176  MCStreamer *(*)(const Triple &T, MCContext &Ctx,
177  std::unique_ptr<MCAsmBackend> &&TAB,
178  std::unique_ptr<MCObjectWriter> &&OW,
179  std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll);
182  MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
183  bool IsVerboseAsm);
185  MCStreamer &S, const MCSubtargetInfo &STI);
186  using MCRelocationInfoCtorTy = MCRelocationInfo *(*)(const Triple &TT,
187  MCContext &Ctx);
188  using MCSymbolizerCtorTy = MCSymbolizer *(*)(
189  const Triple &TT, LLVMOpInfoCallback GetOpInfo,
190  LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
191  std::unique_ptr<MCRelocationInfo> &&RelInfo);
192 
193 private:
194  /// Next - The next registered target in the linked list, maintained by the
195  /// TargetRegistry.
196  Target *Next;
197 
198  /// The target function for checking if an architecture is supported.
199  ArchMatchFnTy ArchMatchFn;
200 
201  /// Name - The target name.
202  const char *Name;
203 
204  /// ShortDesc - A short description of the target.
205  const char *ShortDesc;
206 
207  /// BackendName - The name of the backend implementation. This must match the
208  /// name of the 'def X : Target ...' in TableGen.
209  const char *BackendName;
210 
211  /// HasJIT - Whether this target supports the JIT.
212  bool HasJIT;
213 
214  /// MCAsmInfoCtorFn - Constructor function for this target's MCAsmInfo, if
215  /// registered.
216  MCAsmInfoCtorFnTy MCAsmInfoCtorFn;
217 
218  /// MCInstrInfoCtorFn - Constructor function for this target's MCInstrInfo,
219  /// if registered.
220  MCInstrInfoCtorFnTy MCInstrInfoCtorFn;
221 
222  /// MCInstrAnalysisCtorFn - Constructor function for this target's
223  /// MCInstrAnalysis, if registered.
224  MCInstrAnalysisCtorFnTy MCInstrAnalysisCtorFn;
225 
226  /// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
227  /// if registered.
228  MCRegInfoCtorFnTy MCRegInfoCtorFn;
229 
230  /// MCSubtargetInfoCtorFn - Constructor function for this target's
231  /// MCSubtargetInfo, if registered.
232  MCSubtargetInfoCtorFnTy MCSubtargetInfoCtorFn;
233 
234  /// TargetMachineCtorFn - Construction function for this target's
235  /// TargetMachine, if registered.
236  TargetMachineCtorTy TargetMachineCtorFn;
237 
238  /// MCAsmBackendCtorFn - Construction function for this target's
239  /// MCAsmBackend, if registered.
240  MCAsmBackendCtorTy MCAsmBackendCtorFn;
241 
242  /// MCAsmParserCtorFn - Construction function for this target's
243  /// MCTargetAsmParser, if registered.
244  MCAsmParserCtorTy MCAsmParserCtorFn;
245 
246  /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
247  /// if registered.
248  AsmPrinterCtorTy AsmPrinterCtorFn;
249 
250  /// MCDisassemblerCtorFn - Construction function for this target's
251  /// MCDisassembler, if registered.
252  MCDisassemblerCtorTy MCDisassemblerCtorFn;
253 
254  /// MCInstPrinterCtorFn - Construction function for this target's
255  /// MCInstPrinter, if registered.
256  MCInstPrinterCtorTy MCInstPrinterCtorFn;
257 
258  /// MCCodeEmitterCtorFn - Construction function for this target's
259  /// CodeEmitter, if registered.
260  MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
261 
262  // Construction functions for the various object formats, if registered.
263  COFFStreamerCtorTy COFFStreamerCtorFn = nullptr;
264  MachOStreamerCtorTy MachOStreamerCtorFn = nullptr;
265  ELFStreamerCtorTy ELFStreamerCtorFn = nullptr;
266  WasmStreamerCtorTy WasmStreamerCtorFn = nullptr;
267 
268  /// Construction function for this target's null TargetStreamer, if
269  /// registered (default = nullptr).
270  NullTargetStreamerCtorTy NullTargetStreamerCtorFn = nullptr;
271 
272  /// Construction function for this target's asm TargetStreamer, if
273  /// registered (default = nullptr).
274  AsmTargetStreamerCtorTy AsmTargetStreamerCtorFn = nullptr;
275 
276  /// Construction function for this target's obj TargetStreamer, if
277  /// registered (default = nullptr).
278  ObjectTargetStreamerCtorTy ObjectTargetStreamerCtorFn = nullptr;
279 
280  /// MCRelocationInfoCtorFn - Construction function for this target's
281  /// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
282  MCRelocationInfoCtorTy MCRelocationInfoCtorFn = nullptr;
283 
284  /// MCSymbolizerCtorFn - Construction function for this target's
285  /// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
286  MCSymbolizerCtorTy MCSymbolizerCtorFn = nullptr;
287 
288 public:
289  Target() = default;
290 
291  /// @name Target Information
292  /// @{
293 
294  // getNext - Return the next registered target.
295  const Target *getNext() const { return Next; }
296 
297  /// getName - Get the target name.
298  const char *getName() const { return Name; }
299 
300  /// getShortDescription - Get a short description of the target.
301  const char *getShortDescription() const { return ShortDesc; }
302 
303  /// getBackendName - Get the backend name.
304  const char *getBackendName() const { return BackendName; }
305 
306  /// @}
307  /// @name Feature Predicates
308  /// @{
309 
310  /// hasJIT - Check if this targets supports the just-in-time compilation.
311  bool hasJIT() const { return HasJIT; }
312 
313  /// hasTargetMachine - Check if this target supports code generation.
314  bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
315 
316  /// hasMCAsmBackend - Check if this target supports .o generation.
317  bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
318 
319  /// hasMCAsmParser - Check if this target supports assembly parsing.
320  bool hasMCAsmParser() const { return MCAsmParserCtorFn != nullptr; }
321 
322  /// @}
323  /// @name Feature Constructors
324  /// @{
325 
326  /// createMCAsmInfo - Create a MCAsmInfo implementation for the specified
327  /// target triple.
328  ///
329  /// \param TheTriple This argument is used to determine the target machine
330  /// feature set; it should always be provided. Generally this should be
331  /// either the target triple from the module, or the target triple of the
332  /// host if that does not exist.
334  StringRef TheTriple) const {
335  if (!MCAsmInfoCtorFn)
336  return nullptr;
337  return MCAsmInfoCtorFn(MRI, Triple(TheTriple));
338  }
339 
340  /// createMCInstrInfo - Create a MCInstrInfo implementation.
341  ///
343  if (!MCInstrInfoCtorFn)
344  return nullptr;
345  return MCInstrInfoCtorFn();
346  }
347 
348  /// createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
349  ///
351  if (!MCInstrAnalysisCtorFn)
352  return nullptr;
353  return MCInstrAnalysisCtorFn(Info);
354  }
355 
356  /// createMCRegInfo - Create a MCRegisterInfo implementation.
357  ///
359  if (!MCRegInfoCtorFn)
360  return nullptr;
361  return MCRegInfoCtorFn(Triple(TT));
362  }
363 
364  /// createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
365  ///
366  /// \param TheTriple This argument is used to determine the target machine
367  /// feature set; it should always be provided. Generally this should be
368  /// either the target triple from the module, or the target triple of the
369  /// host if that does not exist.
370  /// \param CPU This specifies the name of the target CPU.
371  /// \param Features This specifies the string representation of the
372  /// additional target features.
374  StringRef Features) const {
375  if (!MCSubtargetInfoCtorFn)
376  return nullptr;
377  return MCSubtargetInfoCtorFn(Triple(TheTriple), CPU, Features);
378  }
379 
380  /// createTargetMachine - Create a target specific machine implementation
381  /// for the specified \p Triple.
382  ///
383  /// \param TT This argument is used to determine the target machine
384  /// feature set; it should always be provided. Generally this should be
385  /// either the target triple from the module, or the target triple of the
386  /// host if that does not exist.
388  StringRef Features,
389  const TargetOptions &Options,
393  bool JIT = false) const {
394  if (!TargetMachineCtorFn)
395  return nullptr;
396  return TargetMachineCtorFn(*this, Triple(TT), CPU, Features, Options, RM,
397  CM, OL, JIT);
398  }
399 
400  /// createMCAsmBackend - Create a target specific assembly parser.
402  const MCRegisterInfo &MRI,
403  const MCTargetOptions &Options) const {
404  if (!MCAsmBackendCtorFn)
405  return nullptr;
406  return MCAsmBackendCtorFn(*this, STI, MRI, Options);
407  }
408 
409  /// createMCAsmParser - Create a target specific assembly parser.
410  ///
411  /// \param Parser The target independent parser implementation to use for
412  /// parsing and lexing.
414  MCAsmParser &Parser,
415  const MCInstrInfo &MII,
416  const MCTargetOptions &Options) const {
417  if (!MCAsmParserCtorFn)
418  return nullptr;
419  return MCAsmParserCtorFn(STI, Parser, MII, Options);
420  }
421 
422  /// createAsmPrinter - Create a target specific assembly printer pass. This
423  /// takes ownership of the MCStreamer object.
425  std::unique_ptr<MCStreamer> &&Streamer) const {
426  if (!AsmPrinterCtorFn)
427  return nullptr;
428  return AsmPrinterCtorFn(TM, std::move(Streamer));
429  }
430 
432  MCContext &Ctx) const {
433  if (!MCDisassemblerCtorFn)
434  return nullptr;
435  return MCDisassemblerCtorFn(*this, STI, Ctx);
436  }
437 
438  MCInstPrinter *createMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
439  const MCAsmInfo &MAI,
440  const MCInstrInfo &MII,
441  const MCRegisterInfo &MRI) const {
442  if (!MCInstPrinterCtorFn)
443  return nullptr;
444  return MCInstPrinterCtorFn(T, SyntaxVariant, MAI, MII, MRI);
445  }
446 
447  /// createMCCodeEmitter - Create a target specific code emitter.
449  const MCRegisterInfo &MRI,
450  MCContext &Ctx) const {
451  if (!MCCodeEmitterCtorFn)
452  return nullptr;
453  return MCCodeEmitterCtorFn(II, MRI, Ctx);
454  }
455 
456  /// Create a target specific MCStreamer.
457  ///
458  /// \param T The target triple.
459  /// \param Ctx The target context.
460  /// \param TAB The target assembler backend object. Takes ownership.
461  /// \param OW The stream object.
462  /// \param Emitter The target independent assembler object.Takes ownership.
463  /// \param RelaxAll Relax all fixups?
465  std::unique_ptr<MCAsmBackend> &&TAB,
466  std::unique_ptr<MCObjectWriter> &&OW,
467  std::unique_ptr<MCCodeEmitter> &&Emitter,
468  const MCSubtargetInfo &STI, bool RelaxAll,
469  bool IncrementalLinkerCompatible,
470  bool DWARFMustBeAtTheEnd) const {
471  MCStreamer *S;
472  switch (T.getObjectFormat()) {
473  default:
474  llvm_unreachable("Unknown object format");
475  case Triple::COFF:
476  assert(T.isOSWindows() && "only Windows COFF is supported");
477  S = COFFStreamerCtorFn(Ctx, std::move(TAB), std::move(OW),
478  std::move(Emitter), RelaxAll,
479  IncrementalLinkerCompatible);
480  break;
481  case Triple::MachO:
482  if (MachOStreamerCtorFn)
483  S = MachOStreamerCtorFn(Ctx, std::move(TAB), std::move(OW),
484  std::move(Emitter), RelaxAll,
485  DWARFMustBeAtTheEnd);
486  else
487  S = createMachOStreamer(Ctx, std::move(TAB), std::move(OW),
488  std::move(Emitter), RelaxAll,
489  DWARFMustBeAtTheEnd);
490  break;
491  case Triple::ELF:
492  if (ELFStreamerCtorFn)
493  S = ELFStreamerCtorFn(T, Ctx, std::move(TAB), std::move(OW),
494  std::move(Emitter), RelaxAll);
495  else
496  S = createELFStreamer(Ctx, std::move(TAB), std::move(OW),
497  std::move(Emitter), RelaxAll);
498  break;
499  case Triple::Wasm:
500  if (WasmStreamerCtorFn)
501  S = WasmStreamerCtorFn(T, Ctx, std::move(TAB), std::move(OW),
502  std::move(Emitter), RelaxAll);
503  else
504  S = createWasmStreamer(Ctx, std::move(TAB), std::move(OW),
505  std::move(Emitter), RelaxAll);
506  break;
507  }
508  if (ObjectTargetStreamerCtorFn)
509  ObjectTargetStreamerCtorFn(*S, STI);
510  return S;
511  }
512 
514  std::unique_ptr<formatted_raw_ostream> OS,
515  bool IsVerboseAsm, bool UseDwarfDirectory,
516  MCInstPrinter *InstPrint,
517  std::unique_ptr<MCCodeEmitter> &&CE,
518  std::unique_ptr<MCAsmBackend> &&TAB,
519  bool ShowInst) const {
520  formatted_raw_ostream &OSRef = *OS;
522  Ctx, std::move(OS), IsVerboseAsm, UseDwarfDirectory, InstPrint,
523  std::move(CE), std::move(TAB), ShowInst);
524  createAsmTargetStreamer(*S, OSRef, InstPrint, IsVerboseAsm);
525  return S;
526  }
527 
530  MCInstPrinter *InstPrint,
531  bool IsVerboseAsm) const {
532  if (AsmTargetStreamerCtorFn)
533  return AsmTargetStreamerCtorFn(S, OS, InstPrint, IsVerboseAsm);
534  return nullptr;
535  }
536 
540  return S;
541  }
542 
544  if (NullTargetStreamerCtorFn)
545  return NullTargetStreamerCtorFn(S);
546  return nullptr;
547  }
548 
549  /// createMCRelocationInfo - Create a target specific MCRelocationInfo.
550  ///
551  /// \param TT The target triple.
552  /// \param Ctx The target context.
554  MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn
555  ? MCRelocationInfoCtorFn
557  return Fn(Triple(TT), Ctx);
558  }
559 
560  /// createMCSymbolizer - Create a target specific MCSymbolizer.
561  ///
562  /// \param TT The target triple.
563  /// \param GetOpInfo The function to get the symbolic information for
564  /// operands.
565  /// \param SymbolLookUp The function to lookup a symbol name.
566  /// \param DisInfo The pointer to the block of symbolic information for above
567  /// call
568  /// back.
569  /// \param Ctx The target context.
570  /// \param RelInfo The relocation information for this target. Takes
571  /// ownership.
572  MCSymbolizer *
574  LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
575  MCContext *Ctx,
576  std::unique_ptr<MCRelocationInfo> &&RelInfo) const {
577  MCSymbolizerCtorTy Fn =
578  MCSymbolizerCtorFn ? MCSymbolizerCtorFn : llvm::createMCSymbolizer;
579  return Fn(Triple(TT), GetOpInfo, SymbolLookUp, DisInfo, Ctx,
580  std::move(RelInfo));
581  }
582 
583  /// @}
584 };
585 
586 /// TargetRegistry - Generic interface to target specific features.
588  // FIXME: Make this a namespace, probably just move all the Register*
589  // functions into Target (currently they all just set members on the Target
590  // anyway, and Target friends this class so those functions can...
591  // function).
592  TargetRegistry() = delete;
593 
594  class iterator
595  : public std::iterator<std::forward_iterator_tag, Target, ptrdiff_t> {
596  friend struct TargetRegistry;
597 
598  const Target *Current = nullptr;
599 
600  explicit iterator(Target *T) : Current(T) {}
601 
602  public:
603  iterator() = default;
604 
605  bool operator==(const iterator &x) const { return Current == x.Current; }
606  bool operator!=(const iterator &x) const { return !operator==(x); }
607 
608  // Iterator traversal: forward iteration only
609  iterator &operator++() { // Preincrement
610  assert(Current && "Cannot increment end iterator!");
611  Current = Current->getNext();
612  return *this;
613  }
614  iterator operator++(int) { // Postincrement
615  iterator tmp = *this;
616  ++*this;
617  return tmp;
618  }
619 
620  const Target &operator*() const {
621  assert(Current && "Cannot dereference end iterator!");
622  return *Current;
623  }
624 
625  const Target *operator->() const { return &operator*(); }
626  };
627 
628  /// printRegisteredTargetsForVersion - Print the registered targets
629  /// appropriately for inclusion in a tool's version output.
630  static void printRegisteredTargetsForVersion(raw_ostream &OS);
631 
632  /// @name Registry Access
633  /// @{
634 
635  static iterator_range<iterator> targets();
636 
637  /// lookupTarget - Lookup a target based on a target triple.
638  ///
639  /// \param Triple - The triple to use for finding a target.
640  /// \param Error - On failure, an error string describing why no target was
641  /// found.
642  static const Target *lookupTarget(const std::string &Triple,
643  std::string &Error);
644 
645  /// lookupTarget - Lookup a target based on an architecture name
646  /// and a target triple. If the architecture name is non-empty,
647  /// then the lookup is done by architecture. Otherwise, the target
648  /// triple is used.
649  ///
650  /// \param ArchName - The architecture to use for finding a target.
651  /// \param TheTriple - The triple to use for finding a target. The
652  /// triple is updated with canonical architecture name if a lookup
653  /// by architecture is done.
654  /// \param Error - On failure, an error string describing why no target was
655  /// found.
656  static const Target *lookupTarget(const std::string &ArchName,
657  Triple &TheTriple, std::string &Error);
658 
659  /// @}
660  /// @name Target Registration
661  /// @{
662 
663  /// RegisterTarget - Register the given target. Attempts to register a
664  /// target which has already been registered will be ignored.
665  ///
666  /// Clients are responsible for ensuring that registration doesn't occur
667  /// while another thread is attempting to access the registry. Typically
668  /// this is done by initializing all targets at program startup.
669  ///
670  /// @param T - The target being registered.
671  /// @param Name - The target name. This should be a static string.
672  /// @param ShortDesc - A short target description. This should be a static
673  /// string.
674  /// @param BackendName - The name of the backend. This should be a static
675  /// string that is the same for all targets that share a backend
676  /// implementation and must match the name used in the 'def X : Target ...' in
677  /// TableGen.
678  /// @param ArchMatchFn - The arch match checking function for this target.
679  /// @param HasJIT - Whether the target supports JIT code
680  /// generation.
681  static void RegisterTarget(Target &T, const char *Name, const char *ShortDesc,
682  const char *BackendName,
683  Target::ArchMatchFnTy ArchMatchFn,
684  bool HasJIT = false);
685 
686  /// RegisterMCAsmInfo - Register a MCAsmInfo implementation for the
687  /// given target.
688  ///
689  /// Clients are responsible for ensuring that registration doesn't occur
690  /// while another thread is attempting to access the registry. Typically
691  /// this is done by initializing all targets at program startup.
692  ///
693  /// @param T - The target being registered.
694  /// @param Fn - A function to construct a MCAsmInfo for the target.
696  T.MCAsmInfoCtorFn = Fn;
697  }
698 
699  /// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the
700  /// given target.
701  ///
702  /// Clients are responsible for ensuring that registration doesn't occur
703  /// while another thread is attempting to access the registry. Typically
704  /// this is done by initializing all targets at program startup.
705  ///
706  /// @param T - The target being registered.
707  /// @param Fn - A function to construct a MCInstrInfo for the target.
709  T.MCInstrInfoCtorFn = Fn;
710  }
711 
712  /// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for
713  /// the given target.
716  T.MCInstrAnalysisCtorFn = Fn;
717  }
718 
719  /// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
720  /// given target.
721  ///
722  /// Clients are responsible for ensuring that registration doesn't occur
723  /// while another thread is attempting to access the registry. Typically
724  /// this is done by initializing all targets at program startup.
725  ///
726  /// @param T - The target being registered.
727  /// @param Fn - A function to construct a MCRegisterInfo for the target.
729  T.MCRegInfoCtorFn = Fn;
730  }
731 
732  /// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for
733  /// the given target.
734  ///
735  /// Clients are responsible for ensuring that registration doesn't occur
736  /// while another thread is attempting to access the registry. Typically
737  /// this is done by initializing all targets at program startup.
738  ///
739  /// @param T - The target being registered.
740  /// @param Fn - A function to construct a MCSubtargetInfo for the target.
743  T.MCSubtargetInfoCtorFn = Fn;
744  }
745 
746  /// RegisterTargetMachine - Register a TargetMachine implementation for the
747  /// given 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 a TargetMachine for the target.
756  T.TargetMachineCtorFn = Fn;
757  }
758 
759  /// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
760  /// 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 AsmBackend for the target.
769  T.MCAsmBackendCtorFn = Fn;
770  }
771 
772  /// RegisterMCAsmParser - Register a MCTargetAsmParser implementation for
773  /// the given target.
774  ///
775  /// Clients are responsible for ensuring that registration doesn't occur
776  /// while another thread is attempting to access the registry. Typically
777  /// this is done by initializing all targets at program startup.
778  ///
779  /// @param T - The target being registered.
780  /// @param Fn - A function to construct an MCTargetAsmParser for the target.
782  T.MCAsmParserCtorFn = Fn;
783  }
784 
785  /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
786  /// target.
787  ///
788  /// Clients are responsible for ensuring that registration doesn't occur
789  /// while another thread is attempting to access the registry. Typically
790  /// this is done by initializing all targets at program startup.
791  ///
792  /// @param T - The target being registered.
793  /// @param Fn - A function to construct an AsmPrinter for the target.
795  T.AsmPrinterCtorFn = Fn;
796  }
797 
798  /// RegisterMCDisassembler - Register a MCDisassembler implementation for
799  /// the given target.
800  ///
801  /// Clients are responsible for ensuring that registration doesn't occur
802  /// while another thread is attempting to access the registry. Typically
803  /// this is done by initializing all targets at program startup.
804  ///
805  /// @param T - The target being registered.
806  /// @param Fn - A function to construct an MCDisassembler for the target.
809  T.MCDisassemblerCtorFn = Fn;
810  }
811 
812  /// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the
813  /// given target.
814  ///
815  /// Clients are responsible for ensuring that registration doesn't occur
816  /// while another thread is attempting to access the registry. Typically
817  /// this is done by initializing all targets at program startup.
818  ///
819  /// @param T - The target being registered.
820  /// @param Fn - A function to construct an MCInstPrinter for the target.
822  T.MCInstPrinterCtorFn = Fn;
823  }
824 
825  /// RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the
826  /// given target.
827  ///
828  /// Clients are responsible for ensuring that registration doesn't occur
829  /// while another thread is attempting to access the registry. Typically
830  /// this is done by initializing all targets at program startup.
831  ///
832  /// @param T - The target being registered.
833  /// @param Fn - A function to construct an MCCodeEmitter for the target.
835  T.MCCodeEmitterCtorFn = Fn;
836  }
837 
839  T.COFFStreamerCtorFn = Fn;
840  }
841 
843  T.MachOStreamerCtorFn = Fn;
844  }
845 
847  T.ELFStreamerCtorFn = Fn;
848  }
849 
851  T.WasmStreamerCtorFn = Fn;
852  }
853 
856  T.NullTargetStreamerCtorFn = Fn;
857  }
858 
861  T.AsmTargetStreamerCtorFn = Fn;
862  }
863 
864  static void
867  T.ObjectTargetStreamerCtorFn = Fn;
868  }
869 
870  /// RegisterMCRelocationInfo - Register an MCRelocationInfo
871  /// implementation for the given target.
872  ///
873  /// Clients are responsible for ensuring that registration doesn't occur
874  /// while another thread is attempting to access the registry. Typically
875  /// this is done by initializing all targets at program startup.
876  ///
877  /// @param T - The target being registered.
878  /// @param Fn - A function to construct an MCRelocationInfo for the target.
881  T.MCRelocationInfoCtorFn = Fn;
882  }
883 
884  /// RegisterMCSymbolizer - Register an MCSymbolizer
885  /// implementation for the given target.
886  ///
887  /// Clients are responsible for ensuring that registration doesn't occur
888  /// while another thread is attempting to access the registry. Typically
889  /// this is done by initializing all targets at program startup.
890  ///
891  /// @param T - The target being registered.
892  /// @param Fn - A function to construct an MCSymbolizer for the target.
894  T.MCSymbolizerCtorFn = Fn;
895  }
896 
897  /// @}
898 };
899 
900 //===--------------------------------------------------------------------===//
901 
902 /// RegisterTarget - Helper template for registering a target, for use in the
903 /// target's initialization function. Usage:
904 ///
905 ///
906 /// Target &getTheFooTarget() { // The global target instance.
907 /// static Target TheFooTarget;
908 /// return TheFooTarget;
909 /// }
910 /// extern "C" void LLVMInitializeFooTargetInfo() {
911 /// RegisterTarget<Triple::foo> X(getTheFooTarget(), "foo", "Foo
912 /// description", "Foo" /* Backend Name */);
913 /// }
914 template <Triple::ArchType TargetArchType = Triple::UnknownArch,
915  bool HasJIT = false>
917  RegisterTarget(Target &T, const char *Name, const char *Desc,
918  const char *BackendName) {
919  TargetRegistry::RegisterTarget(T, Name, Desc, BackendName, &getArchMatch,
920  HasJIT);
921  }
922 
923  static bool getArchMatch(Triple::ArchType Arch) {
924  return Arch == TargetArchType;
925  }
926 };
927 
928 /// RegisterMCAsmInfo - Helper template for registering a target assembly info
929 /// implementation. This invokes the static "Create" method on the class to
930 /// actually do the construction. Usage:
931 ///
932 /// extern "C" void LLVMInitializeFooTarget() {
933 /// extern Target TheFooTarget;
934 /// RegisterMCAsmInfo<FooMCAsmInfo> X(TheFooTarget);
935 /// }
936 template <class MCAsmInfoImpl> struct RegisterMCAsmInfo {
939  }
940 
941 private:
942  static MCAsmInfo *Allocator(const MCRegisterInfo & /*MRI*/,
943  const Triple &TT) {
944  return new MCAsmInfoImpl(TT);
945  }
946 };
947 
948 /// RegisterMCAsmInfoFn - Helper template for registering a target assembly info
949 /// implementation. This invokes the specified function to do the
950 /// construction. Usage:
951 ///
952 /// extern "C" void LLVMInitializeFooTarget() {
953 /// extern Target TheFooTarget;
954 /// RegisterMCAsmInfoFn X(TheFooTarget, TheFunction);
955 /// }
959  }
960 };
961 
962 /// RegisterMCInstrInfo - Helper template for registering a target instruction
963 /// info implementation. This invokes the static "Create" method on the class
964 /// to actually do the construction. Usage:
965 ///
966 /// extern "C" void LLVMInitializeFooTarget() {
967 /// extern Target TheFooTarget;
968 /// RegisterMCInstrInfo<FooMCInstrInfo> X(TheFooTarget);
969 /// }
970 template <class MCInstrInfoImpl> struct RegisterMCInstrInfo {
973  }
974 
975 private:
976  static MCInstrInfo *Allocator() { return new MCInstrInfoImpl(); }
977 };
978 
979 /// RegisterMCInstrInfoFn - Helper template for registering a target
980 /// instruction info implementation. This invokes the specified function to
981 /// do the construction. Usage:
982 ///
983 /// extern "C" void LLVMInitializeFooTarget() {
984 /// extern Target TheFooTarget;
985 /// RegisterMCInstrInfoFn X(TheFooTarget, TheFunction);
986 /// }
990  }
991 };
992 
993 /// RegisterMCInstrAnalysis - Helper template for registering a target
994 /// instruction analyzer implementation. This invokes the static "Create"
995 /// method on the class to actually do the construction. Usage:
996 ///
997 /// extern "C" void LLVMInitializeFooTarget() {
998 /// extern Target TheFooTarget;
999 /// RegisterMCInstrAnalysis<FooMCInstrAnalysis> X(TheFooTarget);
1000 /// }
1001 template <class MCInstrAnalysisImpl> struct RegisterMCInstrAnalysis {
1004  }
1005 
1006 private:
1007  static MCInstrAnalysis *Allocator(const MCInstrInfo *Info) {
1008  return new MCInstrAnalysisImpl(Info);
1009  }
1010 };
1011 
1012 /// RegisterMCInstrAnalysisFn - Helper template for registering a target
1013 /// instruction analyzer implementation. This invokes the specified function
1014 /// to do the construction. Usage:
1015 ///
1016 /// extern "C" void LLVMInitializeFooTarget() {
1017 /// extern Target TheFooTarget;
1018 /// RegisterMCInstrAnalysisFn X(TheFooTarget, TheFunction);
1019 /// }
1023  }
1024 };
1025 
1026 /// RegisterMCRegInfo - Helper template for registering a target register info
1027 /// implementation. This invokes the static "Create" method on the class to
1028 /// actually do the construction. Usage:
1029 ///
1030 /// extern "C" void LLVMInitializeFooTarget() {
1031 /// extern Target TheFooTarget;
1032 /// RegisterMCRegInfo<FooMCRegInfo> X(TheFooTarget);
1033 /// }
1034 template <class MCRegisterInfoImpl> struct RegisterMCRegInfo {
1037  }
1038 
1039 private:
1040  static MCRegisterInfo *Allocator(const Triple & /*TT*/) {
1041  return new MCRegisterInfoImpl();
1042  }
1043 };
1044 
1045 /// RegisterMCRegInfoFn - Helper template for registering a target register
1046 /// info implementation. This invokes the specified function to do the
1047 /// construction. Usage:
1048 ///
1049 /// extern "C" void LLVMInitializeFooTarget() {
1050 /// extern Target TheFooTarget;
1051 /// RegisterMCRegInfoFn X(TheFooTarget, TheFunction);
1052 /// }
1056  }
1057 };
1058 
1059 /// RegisterMCSubtargetInfo - Helper template for registering a target
1060 /// subtarget info implementation. This invokes the static "Create" method
1061 /// on the class to actually do the construction. Usage:
1062 ///
1063 /// extern "C" void LLVMInitializeFooTarget() {
1064 /// extern Target TheFooTarget;
1065 /// RegisterMCSubtargetInfo<FooMCSubtargetInfo> X(TheFooTarget);
1066 /// }
1067 template <class MCSubtargetInfoImpl> struct RegisterMCSubtargetInfo {
1070  }
1071 
1072 private:
1073  static MCSubtargetInfo *Allocator(const Triple & /*TT*/, StringRef /*CPU*/,
1074  StringRef /*FS*/) {
1075  return new MCSubtargetInfoImpl();
1076  }
1077 };
1078 
1079 /// RegisterMCSubtargetInfoFn - Helper template for registering a target
1080 /// subtarget info implementation. This invokes the specified function to
1081 /// do the construction. Usage:
1082 ///
1083 /// extern "C" void LLVMInitializeFooTarget() {
1084 /// extern Target TheFooTarget;
1085 /// RegisterMCSubtargetInfoFn X(TheFooTarget, TheFunction);
1086 /// }
1090  }
1091 };
1092 
1093 /// RegisterTargetMachine - Helper template for registering a target machine
1094 /// implementation, for use in the target machine initialization
1095 /// function. Usage:
1096 ///
1097 /// extern "C" void LLVMInitializeFooTarget() {
1098 /// extern Target TheFooTarget;
1099 /// RegisterTargetMachine<FooTargetMachine> X(TheFooTarget);
1100 /// }
1101 template <class TargetMachineImpl> struct RegisterTargetMachine {
1104  }
1105 
1106 private:
1107  static TargetMachine *
1108  Allocator(const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
1109  const TargetOptions &Options, Optional<Reloc::Model> RM,
1110  Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool JIT) {
1111  return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL, JIT);
1112  }
1113 };
1114 
1115 /// RegisterMCAsmBackend - Helper template for registering a target specific
1116 /// assembler backend. Usage:
1117 ///
1118 /// extern "C" void LLVMInitializeFooMCAsmBackend() {
1119 /// extern Target TheFooTarget;
1120 /// RegisterMCAsmBackend<FooAsmLexer> X(TheFooTarget);
1121 /// }
1122 template <class MCAsmBackendImpl> struct RegisterMCAsmBackend {
1125  }
1126 
1127 private:
1128  static MCAsmBackend *Allocator(const Target &T, const MCSubtargetInfo &STI,
1129  const MCRegisterInfo &MRI,
1130  const MCTargetOptions &Options) {
1131  return new MCAsmBackendImpl(T, STI, MRI);
1132  }
1133 };
1134 
1135 /// RegisterMCAsmParser - Helper template for registering a target specific
1136 /// assembly parser, for use in the target machine initialization
1137 /// function. Usage:
1138 ///
1139 /// extern "C" void LLVMInitializeFooMCAsmParser() {
1140 /// extern Target TheFooTarget;
1141 /// RegisterMCAsmParser<FooAsmParser> X(TheFooTarget);
1142 /// }
1143 template <class MCAsmParserImpl> struct RegisterMCAsmParser {
1146  }
1147 
1148 private:
1149  static MCTargetAsmParser *Allocator(const MCSubtargetInfo &STI,
1150  MCAsmParser &P, const MCInstrInfo &MII,
1151  const MCTargetOptions &Options) {
1152  return new MCAsmParserImpl(STI, P, MII, Options);
1153  }
1154 };
1155 
1156 /// RegisterAsmPrinter - Helper template for registering a target specific
1157 /// assembly printer, for use in the target machine initialization
1158 /// function. Usage:
1159 ///
1160 /// extern "C" void LLVMInitializeFooAsmPrinter() {
1161 /// extern Target TheFooTarget;
1162 /// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget);
1163 /// }
1164 template <class AsmPrinterImpl> struct RegisterAsmPrinter {
1167  }
1168 
1169 private:
1170  static AsmPrinter *Allocator(TargetMachine &TM,
1171  std::unique_ptr<MCStreamer> &&Streamer) {
1172  return new AsmPrinterImpl(TM, std::move(Streamer));
1173  }
1174 };
1175 
1176 /// RegisterMCCodeEmitter - Helper template for registering a target specific
1177 /// machine code emitter, for use in the target initialization
1178 /// function. Usage:
1179 ///
1180 /// extern "C" void LLVMInitializeFooMCCodeEmitter() {
1181 /// extern Target TheFooTarget;
1182 /// RegisterMCCodeEmitter<FooCodeEmitter> X(TheFooTarget);
1183 /// }
1184 template <class MCCodeEmitterImpl> struct RegisterMCCodeEmitter {
1187  }
1188 
1189 private:
1190  static MCCodeEmitter *Allocator(const MCInstrInfo & /*II*/,
1191  const MCRegisterInfo & /*MRI*/,
1192  MCContext & /*Ctx*/) {
1193  return new MCCodeEmitterImpl();
1194  }
1195 };
1196 
1197 } // end namespace llvm
1198 
1199 #endif // LLVM_SUPPORT_TARGETREGISTRY_H
const Target * operator->() const
RegisterMCSubtargetInfoFn(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
MCTargetStreamer *(*)(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool IsVerboseAsm) AsmTargetStreamerCtorTy
MCStreamer * createMCObjectStreamer(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, const MCSubtargetInfo &STI, bool RelaxAll, bool IncrementalLinkerCompatible, bool DWARFMustBeAtTheEnd) const
Create a target specific MCStreamer.
Target()=default
RegisterMCInstrInfoFn - Helper template for registering a target instruction info implementation...
This class represents lattice values for constants.
Definition: AllocatorList.h:23
RegisterMCAsmInfoFn(Target &T, Target::MCAsmInfoCtorFnTy Fn)
Generic assembler parser interface, for use by target specific assembly parsers.
Definition: MCAsmParser.h:109
TargetMachine * createTargetMachine(StringRef TT, StringRef CPU, StringRef Features, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM=None, CodeGenOpt::Level OL=CodeGenOpt::Default, bool JIT=false) const
createTargetMachine - Create a target specific machine implementation for the specified Triple...
bool hasTargetMachine() const
hasTargetMachine - Check if this target supports code generation.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
RegisterMCSubtargetInfo - Helper template for registering a target subtarget info implementation...
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.
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
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:83
MCAsmBackend * createMCAsmBackend(const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) const
createMCAsmBackend - Create a target specific assembly parser.
RegisterMCCodeEmitter(Target &T)
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
MCSubtargetInfo *(*)(const Triple &TT, StringRef CPU, StringRef Features) MCSubtargetInfoCtorFnTy
MCStreamer * createNullStreamer(MCContext &Ctx)
Create a dummy machine code streamer, which does nothing.
RegisterMCInstrAnalysis(Target &T)
MCTargetStreamer *(*)(MCStreamer &S) NullTargetStreamerCtorTy
MCDisassembler * createMCDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) const
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.
TargetRegistry - Generic interface to target specific features.
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)
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
RegisterMCInstrAnalysisFn - Helper template for registering a target instruction analyzer implementat...
static void RegisterWasmStreamer(Target &T, Target::WasmStreamerCtorTy Fn)
const char * getShortDescription() const
getShortDescription - Get a short description of the target.
const char * getName() const
getName - Get the target name.
RegisterMCAsmBackend(Target &T)
RegisterTargetMachine(Target &T)
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
bool hasMCAsmParser() const
hasMCAsmParser - Check if this target supports assembly parsing.
RegisterMCRegInfoFn - Helper template for registering a target register info implementation.
static void RegisterCOFFStreamer(Target &T, Target::COFFStreamerCtorTy Fn)
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.
MCAsmBackend *(*)(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) MCAsmBackendCtorTy
APInt operator*(APInt a, uint64_t RHS)
Definition: APInt.h:2090
MCInstrAnalysis *(*)(const MCInstrInfo *Info) MCInstrAnalysisCtorFnTy
Context object for machine code objects.
Definition: MCContext.h:62
MCStreamer * createNullStreamer(MCContext &Ctx) const
MCRegisterInfo *(*)(const Triple &TT) MCRegInfoCtorFnTy
RegisterTargetMachine - Helper template for registering a target machine implementation, for use in the target machine initialization function.
RegisterMCAsmParser - Helper template for registering a target specific assembly parser, for use in the target machine initialization function.
#define T
static void RegisterTargetMachine(Target &T, Target::TargetMachineCtorTy Fn)
RegisterTargetMachine - Register a TargetMachine implementation for the given target.
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.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
RegisterMCInstrAnalysis - Helper template for registering a target instruction analyzer implementatio...
const Target & operator*() const
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, const MCRegisterInfo &MRI, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
AsmPrinter *(*)(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) AsmPrinterCtorTy
Analysis containing CSE Info
Definition: CSEInfo.cpp:20
MCRelocationInfo * createMCRelocationInfo(const Triple &TT, MCContext &Ctx)
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
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:532
const Target * getNext() const
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
#define P(N)
RegisterMCSubtargetInfoFn - Helper template for registering a target subtarget info implementation...
Streaming machine code generation interface.
Definition: MCStreamer.h:188
MCTargetAsmParser *(*)(const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII, const MCTargetOptions &Options) MCAsmParserCtorTy
unsigned const MachineRegisterInfo * MRI
RegisterAsmPrinter(Target &T)
AsmPrinter * createAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) const
createAsmPrinter - Create a target specific assembly printer pass.
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:38
MCDisassembler *(*)(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx) MCDisassemblerCtorTy
static void RegisterMachOStreamer(Target &T, Target::MachOStreamerCtorTy Fn)
MCStreamer * createELFStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll)
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:21
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:23
RegisterMCRegInfo(Target &T)
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:78
bool(*)(Triple::ArchType Arch) ArchMatchFnTy
static void RegisterTarget(Target &T, const char *Name, const char *ShortDesc, const char *BackendName, Target::ArchMatchFnTy ArchMatchFn, bool HasJIT=false)
RegisterTarget - Register the given target.
Create MCExprs from relocations found in an object file.
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCAsmInfo - Register a MCAsmInfo implementation for the given target.
MCTargetAsmParser * createMCAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser, const MCInstrInfo &MII, const MCTargetOptions &Options) const
createMCAsmParser - Create a target specific assembly parser.
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target...
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
friend struct TargetRegistry
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
MCTargetStreamer * createAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool IsVerboseAsm) const
RegisterMCAsmBackend - Helper template for registering a target specific assembler backend...
Basic Register Allocator
MCInstrAnalysis * createMCInstrAnalysis(const MCInstrInfo *Info) const
createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
RegisterTarget(Target &T, const char *Name, const char *Desc, const char *BackendName)
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
bool hasMCAsmBackend() const
hasMCAsmBackend - Check if this target supports .o generation.
MCTargetStreamer *(*)(MCStreamer &S, const MCSubtargetInfo &STI) ObjectTargetStreamerCtorTy
RegisterMCSubtargetInfo(Target &T)
RegisterMCAsmInfo(Target &T)
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple) const
createMCAsmInfo - Create a MCAsmInfo implementation for the specified target triple.
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.
RegisterMCInstrInfo(Target &T)
RegisterMCInstrAnalysisFn(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
MCAsmInfo *(*)(const MCRegisterInfo &MRI, const Triple &TT) MCAsmInfoCtorFnTy
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
RegisterMCAsmParser(Target &T)
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:39
ObjectFormatType getObjectFormat() const
getFormat - Get the object format for this triple.
Definition: Triple.h:324
MCRelocationInfo *(*)(const Triple &TT, MCContext &Ctx) MCRelocationInfoCtorTy
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target. ...
Generic base class for all target subtargets.
TargetMachine *(*)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features, const TargetOptions &Options, Optional< Reloc::Model > RM, Optional< CodeModel::Model > CM, CodeGenOpt::Level OL, bool JIT) TargetMachineCtorTy
MCSymbolizer * createMCSymbolizer(StringRef TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo) const
createMCSymbolizer - Create a target specific MCSymbolizer.
static bool getArchMatch(Triple::ArchType Arch)
const char * getBackendName() const
getBackendName - Get the backend name.
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn)
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool IsVerboseAsm, bool UseDwarfDirectory, MCInstPrinter *InstPrint, std::unique_ptr< MCCodeEmitter > &&CE, std::unique_ptr< MCAsmBackend > &&TAB, bool ShowInst) const
bool operator!=(const iterator &x) const
MCStreamer *(*)(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll, bool DWARFMustBeAtTheEnd) MachOStreamerCtorTy
static void RegisterMCSymbolizer(Target &T, Target::MCSymbolizerCtorTy Fn)
RegisterMCSymbolizer - Register an MCSymbolizer implementation for the given target.
RegisterMCInstrInfoFn(Target &T, Target::MCInstrInfoCtorFnTy Fn)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
RegisterMCRegInfo - Helper template for registering a target register info implementation.
MCRelocationInfo * createMCRelocationInfo(StringRef TT, MCContext &Ctx) const
createMCRelocationInfo - Create a target specific MCRelocationInfo.
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:41
RegisterMCAsmInfo - Helper template for registering a target assembly info implementation.
bool hasJIT() const
hasJIT - Check if this targets supports the just-in-time compilation.
MCStreamer *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll) ELFStreamerCtorTy
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
MCTargetStreamer * createNullTargetStreamer(MCStreamer &S) const
static void RegisterMCRelocationInfo(Target &T, Target::MCRelocationInfoCtorTy Fn)
RegisterMCRelocationInfo - Register an MCRelocationInfo implementation for the given target...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
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:65
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn)
RegisterAsmPrinter - Register an AsmPrinter implementation for the given target.
MCStreamer * createWasmStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll)
MCInstrInfo *(*)() MCInstrInfoCtorFnTy
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
MCStreamer *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll) WasmStreamerCtorTy
bool operator==(uint64_t V1, const APInt &V2)
Definition: APInt.h:1966
MCStreamer * createMachOStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll, bool DWARFMustBeAtTheEnd, bool LabelSections=false)
const char *(* LLVMSymbolLookupCallback)(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
The type for the symbol lookup function.
bool operator==(const iterator &x) const
RegisterMCCodeEmitter - Helper template for registering a target specific machine code emitter...
RegisterMCRegInfoFn(Target &T, Target::MCRegInfoCtorFnTy Fn)
MCStreamer *(*)(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll, bool IncrementalLinkerCompatible) COFFStreamerCtorTy
RegisterMCInstrInfo - Helper template for registering a target instruction info implementation.