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