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