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