LLVM  14.0.0git
TargetRegistry.h
Go to the documentation of this file.
1 //===- Support/TargetRegistry.h - Target Registration -----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file exposes the TargetRegistry interface, which tools can use to access
10 // the appropriate target specific classes (TargetMachine, AsmPrinter, etc.)
11 // which have been registered.
12 //
13 // Target specific class implementations should register themselves using the
14 // appropriate TargetRegistry interfaces.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_SUPPORT_TARGETREGISTRY_H
19 #define LLVM_SUPPORT_TARGETREGISTRY_H
20 
22 #include "llvm/ADT/Optional.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/ADT/Triple.h"
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 MCObjectWriter;
50 class MCRegisterInfo;
51 class MCRelocationInfo;
52 class MCStreamer;
53 class MCSubtargetInfo;
54 class MCSymbolizer;
55 class MCTargetAsmParser;
56 class MCTargetOptions;
57 class MCTargetStreamer;
58 class raw_ostream;
59 class raw_pwrite_stream;
60 class TargetMachine;
61 class TargetOptions;
62 namespace mca {
63 class CustomBehaviour;
64 class InstrPostProcess;
65 class SourceMgr;
66 } // namespace mca
67 
68 MCStreamer *createNullStreamer(MCContext &Ctx);
69 // Takes ownership of \p TAB and \p CE.
70 
71 /// Create a machine code streamer which will print out assembly for the native
72 /// target, suitable for compiling with a native assembler.
73 ///
74 /// \param InstPrint - If given, the instruction printer to use. If not given
75 /// the MCInst representation will be printed. This method takes ownership of
76 /// InstPrint.
77 ///
78 /// \param CE - If given, a code emitter to use to show the instruction
79 /// encoding inline with the assembly. This method takes ownership of \p CE.
80 ///
81 /// \param TAB - If given, a target asm backend to use to show the fixup
82 /// information in conjunction with encoding information. This method takes
83 /// ownership of \p TAB.
84 ///
85 /// \param ShowInst - Whether to show the MCInst representation inline with
86 /// the assembly.
87 MCStreamer *
88 createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS,
89  bool isVerboseAsm, bool useDwarfDirectory,
90  MCInstPrinter *InstPrint, std::unique_ptr<MCCodeEmitter> &&CE,
91  std::unique_ptr<MCAsmBackend> &&TAB, bool ShowInst);
92 
93 MCStreamer *createELFStreamer(MCContext &Ctx,
94  std::unique_ptr<MCAsmBackend> &&TAB,
95  std::unique_ptr<MCObjectWriter> &&OW,
96  std::unique_ptr<MCCodeEmitter> &&CE,
97  bool RelaxAll);
98 MCStreamer *createMachOStreamer(MCContext &Ctx,
99  std::unique_ptr<MCAsmBackend> &&TAB,
100  std::unique_ptr<MCObjectWriter> &&OW,
101  std::unique_ptr<MCCodeEmitter> &&CE,
102  bool RelaxAll, bool DWARFMustBeAtTheEnd,
103  bool LabelSections = false);
104 MCStreamer *createWasmStreamer(MCContext &Ctx,
105  std::unique_ptr<MCAsmBackend> &&TAB,
106  std::unique_ptr<MCObjectWriter> &&OW,
107  std::unique_ptr<MCCodeEmitter> &&CE,
108  bool RelaxAll);
109 MCStreamer *createXCOFFStreamer(MCContext &Ctx,
110  std::unique_ptr<MCAsmBackend> &&TAB,
111  std::unique_ptr<MCObjectWriter> &&OW,
112  std::unique_ptr<MCCodeEmitter> &&CE,
113  bool RelaxAll);
114 
115 MCRelocationInfo *createMCRelocationInfo(const Triple &TT, MCContext &Ctx);
116 
117 MCSymbolizer *createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
118  LLVMSymbolLookupCallback SymbolLookUp,
119  void *DisInfo, MCContext *Ctx,
120  std::unique_ptr<MCRelocationInfo> &&RelInfo);
121 
122 mca::CustomBehaviour *createCustomBehaviour(const MCSubtargetInfo &STI,
123  const mca::SourceMgr &SrcMgr,
124  const MCInstrInfo &MCII);
125 
126 mca::InstrPostProcess *createInstrPostProcess(const MCSubtargetInfo &STI,
127  const MCInstrInfo &MCII);
128 
129 /// Target - Wrapper for Target specific information.
130 ///
131 /// For registration purposes, this is a POD type so that targets can be
132 /// registered without the use of static constructors.
133 ///
134 /// Targets should implement a single global instance of this class (which
135 /// will be zero initialized), and pass that instance to the TargetRegistry as
136 /// part of their initialization.
137 class Target {
138 public:
139  friend struct TargetRegistry;
140 
141  using ArchMatchFnTy = bool (*)(Triple::ArchType Arch);
142 
143  using MCAsmInfoCtorFnTy = MCAsmInfo *(*)(const MCRegisterInfo &MRI,
144  const Triple &TT,
147  bool PIC,
148  bool LargeCodeModel);
151  using MCRegInfoCtorFnTy = MCRegisterInfo *(*)(const Triple &TT);
152  using MCSubtargetInfoCtorFnTy = MCSubtargetInfo *(*)(const Triple &TT,
153  StringRef CPU,
154  StringRef Features);
156  *(*)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
159  // If it weren't for layering issues (this header is in llvm/Support, but
160  // depends on MC?) this should take the Streamer by value rather than rvalue
161  // reference.
162  using AsmPrinterCtorTy = AsmPrinter *(*)(
163  TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
164  using MCAsmBackendCtorTy = MCAsmBackend *(*)(const Target &T,
165  const MCSubtargetInfo &STI,
166  const MCRegisterInfo &MRI,
169  const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
171  using MCDisassemblerCtorTy = MCDisassembler *(*)(const Target &T,
172  const MCSubtargetInfo &STI,
173  MCContext &Ctx);
174  using MCInstPrinterCtorTy = MCInstPrinter *(*)(const Triple &T,
175  unsigned SyntaxVariant,
176  const MCAsmInfo &MAI,
177  const MCInstrInfo &MII,
179  using MCCodeEmitterCtorTy = MCCodeEmitter *(*)(const MCInstrInfo &II,
180  const MCRegisterInfo &MRI,
181  MCContext &Ctx);
182  using ELFStreamerCtorTy =
183  MCStreamer *(*)(const Triple &T, MCContext &Ctx,
184  std::unique_ptr<MCAsmBackend> &&TAB,
185  std::unique_ptr<MCObjectWriter> &&OW,
186  std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll);
187  using MachOStreamerCtorTy =
188  MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
189  std::unique_ptr<MCObjectWriter> &&OW,
190  std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll,
191  bool DWARFMustBeAtTheEnd);
192  using COFFStreamerCtorTy =
193  MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
194  std::unique_ptr<MCObjectWriter> &&OW,
195  std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll,
196  bool IncrementalLinkerCompatible);
197  using WasmStreamerCtorTy =
198  MCStreamer *(*)(const Triple &T, MCContext &Ctx,
199  std::unique_ptr<MCAsmBackend> &&TAB,
200  std::unique_ptr<MCObjectWriter> &&OW,
201  std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll);
202  using XCOFFStreamerCtorTy =
203  MCStreamer *(*)(const Triple &T, MCContext &Ctx,
204  std::unique_ptr<MCAsmBackend> &&TAB,
205  std::unique_ptr<MCObjectWriter> &&OW,
206  std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll);
207 
211  bool IsVerboseAsm);
213  MCStreamer &S, const MCSubtargetInfo &STI);
214  using MCRelocationInfoCtorTy = MCRelocationInfo *(*)(const Triple &TT,
215  MCContext &Ctx);
216  using MCSymbolizerCtorTy = MCSymbolizer *(*)(
217  const Triple &TT, LLVMOpInfoCallback GetOpInfo,
218  LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
219  std::unique_ptr<MCRelocationInfo> &&RelInfo);
220 
221  using CustomBehaviourCtorTy =
222  mca::CustomBehaviour *(*)(const MCSubtargetInfo &STI,
223  const mca::SourceMgr &SrcMgr,
224  const MCInstrInfo &MCII);
225 
226  using InstrPostProcessCtorTy =
227  mca::InstrPostProcess *(*)(const MCSubtargetInfo &STI,
228  const MCInstrInfo &MCII);
229 
230 private:
231  /// Next - The next registered target in the linked list, maintained by the
232  /// TargetRegistry.
233  Target *Next;
234 
235  /// The target function for checking if an architecture is supported.
236  ArchMatchFnTy ArchMatchFn;
237 
238  /// Name - The target name.
239  const char *Name;
240 
241  /// ShortDesc - A short description of the target.
242  const char *ShortDesc;
243 
244  /// BackendName - The name of the backend implementation. This must match the
245  /// name of the 'def X : Target ...' in TableGen.
246  const char *BackendName;
247 
248  /// HasJIT - Whether this target supports the JIT.
249  bool HasJIT;
250 
251  /// MCAsmInfoCtorFn - Constructor function for this target's MCAsmInfo, if
252  /// registered.
253  MCAsmInfoCtorFnTy MCAsmInfoCtorFn;
254 
255  /// Constructor function for this target's MCObjectFileInfo, if registered.
256  MCObjectFileInfoCtorFnTy MCObjectFileInfoCtorFn;
257 
258  /// MCInstrInfoCtorFn - Constructor function for this target's MCInstrInfo,
259  /// if registered.
260  MCInstrInfoCtorFnTy MCInstrInfoCtorFn;
261 
262  /// MCInstrAnalysisCtorFn - Constructor function for this target's
263  /// MCInstrAnalysis, if registered.
264  MCInstrAnalysisCtorFnTy MCInstrAnalysisCtorFn;
265 
266  /// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
267  /// if registered.
268  MCRegInfoCtorFnTy MCRegInfoCtorFn;
269 
270  /// MCSubtargetInfoCtorFn - Constructor function for this target's
271  /// MCSubtargetInfo, if registered.
272  MCSubtargetInfoCtorFnTy MCSubtargetInfoCtorFn;
273 
274  /// TargetMachineCtorFn - Construction function for this target's
275  /// TargetMachine, if registered.
276  TargetMachineCtorTy TargetMachineCtorFn;
277 
278  /// MCAsmBackendCtorFn - Construction function for this target's
279  /// MCAsmBackend, if registered.
280  MCAsmBackendCtorTy MCAsmBackendCtorFn;
281 
282  /// MCAsmParserCtorFn - Construction function for this target's
283  /// MCTargetAsmParser, if registered.
284  MCAsmParserCtorTy MCAsmParserCtorFn;
285 
286  /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
287  /// if registered.
288  AsmPrinterCtorTy AsmPrinterCtorFn;
289 
290  /// MCDisassemblerCtorFn - Construction function for this target's
291  /// MCDisassembler, if registered.
292  MCDisassemblerCtorTy MCDisassemblerCtorFn;
293 
294  /// MCInstPrinterCtorFn - Construction function for this target's
295  /// MCInstPrinter, if registered.
296  MCInstPrinterCtorTy MCInstPrinterCtorFn;
297 
298  /// MCCodeEmitterCtorFn - Construction function for this target's
299  /// CodeEmitter, if registered.
300  MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
301 
302  // Construction functions for the various object formats, if registered.
303  COFFStreamerCtorTy COFFStreamerCtorFn = nullptr;
304  MachOStreamerCtorTy MachOStreamerCtorFn = nullptr;
305  ELFStreamerCtorTy ELFStreamerCtorFn = nullptr;
306  WasmStreamerCtorTy WasmStreamerCtorFn = nullptr;
307  XCOFFStreamerCtorTy XCOFFStreamerCtorFn = nullptr;
308 
309  /// Construction function for this target's null TargetStreamer, if
310  /// registered (default = nullptr).
311  NullTargetStreamerCtorTy NullTargetStreamerCtorFn = nullptr;
312 
313  /// Construction function for this target's asm TargetStreamer, if
314  /// registered (default = nullptr).
315  AsmTargetStreamerCtorTy AsmTargetStreamerCtorFn = nullptr;
316 
317  /// Construction function for this target's obj TargetStreamer, if
318  /// registered (default = nullptr).
319  ObjectTargetStreamerCtorTy ObjectTargetStreamerCtorFn = nullptr;
320 
321  /// MCRelocationInfoCtorFn - Construction function for this target's
322  /// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
323  MCRelocationInfoCtorTy MCRelocationInfoCtorFn = nullptr;
324 
325  /// MCSymbolizerCtorFn - Construction function for this target's
326  /// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
327  MCSymbolizerCtorTy MCSymbolizerCtorFn = nullptr;
328 
329  /// CustomBehaviourCtorFn - Construction function for this target's
330  /// CustomBehaviour, if registered (default = nullptr).
331  CustomBehaviourCtorTy CustomBehaviourCtorFn = nullptr;
332 
333  /// InstrPostProcessCtorFn - Construction function for this target's
334  /// InstrPostProcess, if registered (default = nullptr).
335  InstrPostProcessCtorTy InstrPostProcessCtorFn = nullptr;
336 
337 public:
338  Target() = default;
339 
340  /// @name Target Information
341  /// @{
342 
343  // getNext - Return the next registered target.
344  const Target *getNext() const { return Next; }
345 
346  /// getName - Get the target name.
347  const char *getName() const { return Name; }
348 
349  /// getShortDescription - Get a short description of the target.
350  const char *getShortDescription() const { return ShortDesc; }
351 
352  /// getBackendName - Get the backend name.
353  const char *getBackendName() const { return BackendName; }
354 
355  /// @}
356  /// @name Feature Predicates
357  /// @{
358 
359  /// hasJIT - Check if this targets supports the just-in-time compilation.
360  bool hasJIT() const { return HasJIT; }
361 
362  /// hasTargetMachine - Check if this target supports code generation.
363  bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
364 
365  /// hasMCAsmBackend - Check if this target supports .o generation.
366  bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
367 
368  /// hasMCAsmParser - Check if this target supports assembly parsing.
369  bool hasMCAsmParser() const { return MCAsmParserCtorFn != nullptr; }
370 
371  /// @}
372  /// @name Feature Constructors
373  /// @{
374 
375  /// createMCAsmInfo - Create a MCAsmInfo implementation for the specified
376  /// target triple.
377  ///
378  /// \param TheTriple This argument is used to determine the target machine
379  /// feature set; it should always be provided. Generally this should be
380  /// either the target triple from the module, or the target triple of the
381  /// host if that does not exist.
383  const MCTargetOptions &Options) const {
384  if (!MCAsmInfoCtorFn)
385  return nullptr;
386  return MCAsmInfoCtorFn(MRI, Triple(TheTriple), Options);
387  }
388 
389  /// Create a MCObjectFileInfo implementation for the specified target
390  /// triple.
391  ///
393  bool LargeCodeModel = false) const {
394  if (!MCObjectFileInfoCtorFn) {
395  MCObjectFileInfo *MOFI = new MCObjectFileInfo();
396  MOFI->initMCObjectFileInfo(Ctx, PIC, LargeCodeModel);
397  return MOFI;
398  }
399  return MCObjectFileInfoCtorFn(Ctx, PIC, LargeCodeModel);
400  }
401 
402  /// createMCInstrInfo - Create a MCInstrInfo implementation.
403  ///
405  if (!MCInstrInfoCtorFn)
406  return nullptr;
407  return MCInstrInfoCtorFn();
408  }
409 
410  /// createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
411  ///
413  if (!MCInstrAnalysisCtorFn)
414  return nullptr;
415  return MCInstrAnalysisCtorFn(Info);
416  }
417 
418  /// createMCRegInfo - Create a MCRegisterInfo implementation.
419  ///
421  if (!MCRegInfoCtorFn)
422  return nullptr;
423  return MCRegInfoCtorFn(Triple(TT));
424  }
425 
426  /// createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
427  ///
428  /// \param TheTriple This argument is used to determine the target machine
429  /// feature set; it should always be provided. Generally this should be
430  /// either the target triple from the module, or the target triple of the
431  /// host if that does not exist.
432  /// \param CPU This specifies the name of the target CPU.
433  /// \param Features This specifies the string representation of the
434  /// additional target features.
436  StringRef Features) const {
437  if (!MCSubtargetInfoCtorFn)
438  return nullptr;
439  return MCSubtargetInfoCtorFn(Triple(TheTriple), CPU, Features);
440  }
441 
442  /// createTargetMachine - Create a target specific machine implementation
443  /// for the specified \p Triple.
444  ///
445  /// \param TT This argument is used to determine the target machine
446  /// feature set; it should always be provided. Generally this should be
447  /// either the target triple from the module, or the target triple of the
448  /// host if that does not exist.
450  StringRef Features,
451  const TargetOptions &Options,
455  bool JIT = false) const {
456  if (!TargetMachineCtorFn)
457  return nullptr;
458  return TargetMachineCtorFn(*this, Triple(TT), CPU, Features, Options, RM,
459  CM, OL, JIT);
460  }
461 
462  /// createMCAsmBackend - Create a target specific assembly parser.
464  const MCRegisterInfo &MRI,
465  const MCTargetOptions &Options) const {
466  if (!MCAsmBackendCtorFn)
467  return nullptr;
468  return MCAsmBackendCtorFn(*this, STI, MRI, Options);
469  }
470 
471  /// createMCAsmParser - Create a target specific assembly parser.
472  ///
473  /// \param Parser The target independent parser implementation to use for
474  /// parsing and lexing.
476  MCAsmParser &Parser,
477  const MCInstrInfo &MII,
478  const MCTargetOptions &Options) const {
479  if (!MCAsmParserCtorFn)
480  return nullptr;
481  return MCAsmParserCtorFn(STI, Parser, MII, Options);
482  }
483 
484  /// createAsmPrinter - Create a target specific assembly printer pass. This
485  /// takes ownership of the MCStreamer object.
487  std::unique_ptr<MCStreamer> &&Streamer) const {
488  if (!AsmPrinterCtorFn)
489  return nullptr;
490  return AsmPrinterCtorFn(TM, std::move(Streamer));
491  }
492 
494  MCContext &Ctx) const {
495  if (!MCDisassemblerCtorFn)
496  return nullptr;
497  return MCDisassemblerCtorFn(*this, STI, Ctx);
498  }
499 
500  MCInstPrinter *createMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
501  const MCAsmInfo &MAI,
502  const MCInstrInfo &MII,
503  const MCRegisterInfo &MRI) const {
504  if (!MCInstPrinterCtorFn)
505  return nullptr;
506  return MCInstPrinterCtorFn(T, SyntaxVariant, MAI, MII, MRI);
507  }
508 
509  /// createMCCodeEmitter - Create a target specific code emitter.
511  const MCRegisterInfo &MRI,
512  MCContext &Ctx) const {
513  if (!MCCodeEmitterCtorFn)
514  return nullptr;
515  return MCCodeEmitterCtorFn(II, MRI, Ctx);
516  }
517 
518  /// Create a target specific MCStreamer.
519  ///
520  /// \param T The target triple.
521  /// \param Ctx The target context.
522  /// \param TAB The target assembler backend object. Takes ownership.
523  /// \param OW The stream object.
524  /// \param Emitter The target independent assembler object.Takes ownership.
525  /// \param RelaxAll Relax all fixups?
527  std::unique_ptr<MCAsmBackend> &&TAB,
528  std::unique_ptr<MCObjectWriter> &&OW,
529  std::unique_ptr<MCCodeEmitter> &&Emitter,
530  const MCSubtargetInfo &STI, bool RelaxAll,
531  bool IncrementalLinkerCompatible,
532  bool DWARFMustBeAtTheEnd) const {
533  MCStreamer *S = nullptr;
534  switch (T.getObjectFormat()) {
536  llvm_unreachable("Unknown object format");
537  case Triple::COFF:
538  assert(T.isOSWindows() && "only Windows COFF is supported");
539  S = COFFStreamerCtorFn(Ctx, std::move(TAB), std::move(OW),
540  std::move(Emitter), RelaxAll,
541  IncrementalLinkerCompatible);
542  break;
543  case Triple::MachO:
544  if (MachOStreamerCtorFn)
545  S = MachOStreamerCtorFn(Ctx, std::move(TAB), std::move(OW),
546  std::move(Emitter), RelaxAll,
547  DWARFMustBeAtTheEnd);
548  else
549  S = createMachOStreamer(Ctx, std::move(TAB), std::move(OW),
550  std::move(Emitter), RelaxAll,
551  DWARFMustBeAtTheEnd);
552  break;
553  case Triple::ELF:
554  if (ELFStreamerCtorFn)
555  S = ELFStreamerCtorFn(T, Ctx, std::move(TAB), std::move(OW),
556  std::move(Emitter), RelaxAll);
557  else
558  S = createELFStreamer(Ctx, std::move(TAB), std::move(OW),
559  std::move(Emitter), RelaxAll);
560  break;
561  case Triple::Wasm:
562  if (WasmStreamerCtorFn)
563  S = WasmStreamerCtorFn(T, Ctx, std::move(TAB), std::move(OW),
564  std::move(Emitter), RelaxAll);
565  else
566  S = createWasmStreamer(Ctx, std::move(TAB), std::move(OW),
567  std::move(Emitter), RelaxAll);
568  break;
569  case Triple::GOFF:
570  report_fatal_error("GOFF MCObjectStreamer not implemented yet");
571  case Triple::XCOFF:
572  if (XCOFFStreamerCtorFn)
573  S = XCOFFStreamerCtorFn(T, Ctx, std::move(TAB), std::move(OW),
574  std::move(Emitter), RelaxAll);
575  else
576  S = createXCOFFStreamer(Ctx, std::move(TAB), std::move(OW),
577  std::move(Emitter), RelaxAll);
578  break;
579  }
580  if (ObjectTargetStreamerCtorFn)
581  ObjectTargetStreamerCtorFn(*S, STI);
582  return S;
583  }
584 
586  std::unique_ptr<formatted_raw_ostream> OS,
587  bool IsVerboseAsm, bool UseDwarfDirectory,
588  MCInstPrinter *InstPrint,
589  std::unique_ptr<MCCodeEmitter> &&CE,
590  std::unique_ptr<MCAsmBackend> &&TAB,
591  bool ShowInst) const {
592  formatted_raw_ostream &OSRef = *OS;
594  Ctx, std::move(OS), IsVerboseAsm, UseDwarfDirectory, InstPrint,
595  std::move(CE), std::move(TAB), ShowInst);
596  createAsmTargetStreamer(*S, OSRef, InstPrint, IsVerboseAsm);
597  return S;
598  }
599 
602  MCInstPrinter *InstPrint,
603  bool IsVerboseAsm) const {
604  if (AsmTargetStreamerCtorFn)
605  return AsmTargetStreamerCtorFn(S, OS, InstPrint, IsVerboseAsm);
606  return nullptr;
607  }
608 
612  return S;
613  }
614 
616  if (NullTargetStreamerCtorFn)
617  return NullTargetStreamerCtorFn(S);
618  return nullptr;
619  }
620 
621  /// createMCRelocationInfo - Create a target specific MCRelocationInfo.
622  ///
623  /// \param TT The target triple.
624  /// \param Ctx The target context.
626  MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn
627  ? MCRelocationInfoCtorFn
629  return Fn(Triple(TT), Ctx);
630  }
631 
632  /// createMCSymbolizer - Create a target specific MCSymbolizer.
633  ///
634  /// \param TT The target triple.
635  /// \param GetOpInfo The function to get the symbolic information for
636  /// operands.
637  /// \param SymbolLookUp The function to lookup a symbol name.
638  /// \param DisInfo The pointer to the block of symbolic information for above
639  /// call
640  /// back.
641  /// \param Ctx The target context.
642  /// \param RelInfo The relocation information for this target. Takes
643  /// ownership.
644  MCSymbolizer *
646  LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
647  MCContext *Ctx,
648  std::unique_ptr<MCRelocationInfo> &&RelInfo) const {
649  MCSymbolizerCtorTy Fn =
650  MCSymbolizerCtorFn ? MCSymbolizerCtorFn : llvm::createMCSymbolizer;
651  return Fn(Triple(TT), GetOpInfo, SymbolLookUp, DisInfo, Ctx,
652  std::move(RelInfo));
653  }
654 
655  /// createCustomBehaviour - Create a target specific CustomBehaviour.
656  /// This class is used by llvm-mca and requires backend functionality.
658  const mca::SourceMgr &SrcMgr,
659  const MCInstrInfo &MCII) const {
660  if (CustomBehaviourCtorFn)
661  return CustomBehaviourCtorFn(STI, SrcMgr, MCII);
662  return nullptr;
663  }
664 
665  /// createInstrPostProcess - Create a target specific InstrPostProcess.
666  /// This class is used by llvm-mca and requires backend functionality.
668  const MCInstrInfo &MCII) const {
669  if (InstrPostProcessCtorFn)
670  return InstrPostProcessCtorFn(STI, MCII);
671  return nullptr;
672  }
673 
674  /// @}
675 };
676 
677 /// TargetRegistry - Generic interface to target specific features.
679  // FIXME: Make this a namespace, probably just move all the Register*
680  // functions into Target (currently they all just set members on the Target
681  // anyway, and Target friends this class so those functions can...
682  // function).
683  TargetRegistry() = delete;
684 
685  class iterator {
686  friend struct TargetRegistry;
687 
688  const Target *Current = nullptr;
689 
690  explicit iterator(Target *T) : Current(T) {}
691 
692  public:
693  using iterator_category = std::forward_iterator_tag;
695  using difference_type = std::ptrdiff_t;
696  using pointer = value_type *;
698 
699  iterator() = default;
700 
701  bool operator==(const iterator &x) const { return Current == x.Current; }
702  bool operator!=(const iterator &x) const { return !operator==(x); }
703 
704  // Iterator traversal: forward iteration only
705  iterator &operator++() { // Preincrement
706  assert(Current && "Cannot increment end iterator!");
707  Current = Current->getNext();
708  return *this;
709  }
710  iterator operator++(int) { // Postincrement
711  iterator tmp = *this;
712  ++*this;
713  return tmp;
714  }
715 
716  const Target &operator*() const {
717  assert(Current && "Cannot dereference end iterator!");
718  return *Current;
719  }
720 
721  const Target *operator->() const { return &operator*(); }
722  };
723 
724  /// printRegisteredTargetsForVersion - Print the registered targets
725  /// appropriately for inclusion in a tool's version output.
727 
728  /// @name Registry Access
729  /// @{
730 
732 
733  /// lookupTarget - Lookup a target based on a target triple.
734  ///
735  /// \param Triple - The triple to use for finding a target.
736  /// \param Error - On failure, an error string describing why no target was
737  /// found.
738  static const Target *lookupTarget(const std::string &Triple,
739  std::string &Error);
740 
741  /// lookupTarget - Lookup a target based on an architecture name
742  /// and a target triple. If the architecture name is non-empty,
743  /// then the lookup is done by architecture. Otherwise, the target
744  /// triple is used.
745  ///
746  /// \param ArchName - The architecture to use for finding a target.
747  /// \param TheTriple - The triple to use for finding a target. The
748  /// triple is updated with canonical architecture name if a lookup
749  /// by architecture is done.
750  /// \param Error - On failure, an error string describing why no target was
751  /// found.
752  static const Target *lookupTarget(const std::string &ArchName,
753  Triple &TheTriple, std::string &Error);
754 
755  /// @}
756  /// @name Target Registration
757  /// @{
758 
759  /// RegisterTarget - Register the given target. Attempts to register a
760  /// target which has already been registered will be ignored.
761  ///
762  /// Clients are responsible for ensuring that registration doesn't occur
763  /// while another thread is attempting to access the registry. Typically
764  /// this is done by initializing all targets at program startup.
765  ///
766  /// @param T - The target being registered.
767  /// @param Name - The target name. This should be a static string.
768  /// @param ShortDesc - A short target description. This should be a static
769  /// string.
770  /// @param BackendName - The name of the backend. This should be a static
771  /// string that is the same for all targets that share a backend
772  /// implementation and must match the name used in the 'def X : Target ...' in
773  /// TableGen.
774  /// @param ArchMatchFn - The arch match checking function for this target.
775  /// @param HasJIT - Whether the target supports JIT code
776  /// generation.
777  static void RegisterTarget(Target &T, const char *Name, const char *ShortDesc,
778  const char *BackendName,
779  Target::ArchMatchFnTy ArchMatchFn,
780  bool HasJIT = false);
781 
782  /// RegisterMCAsmInfo - Register a MCAsmInfo implementation for the
783  /// given target.
784  ///
785  /// Clients are responsible for ensuring that registration doesn't occur
786  /// while another thread is attempting to access the registry. Typically
787  /// this is done by initializing all targets at program startup.
788  ///
789  /// @param T - The target being registered.
790  /// @param Fn - A function to construct a MCAsmInfo for the target.
792  T.MCAsmInfoCtorFn = Fn;
793  }
794 
795  /// Register a MCObjectFileInfo implementation for the given target.
796  ///
797  /// Clients are responsible for ensuring that registration doesn't occur
798  /// while another thread is attempting to access the registry. Typically
799  /// this is done by initializing all targets at program startup.
800  ///
801  /// @param T - The target being registered.
802  /// @param Fn - A function to construct a MCObjectFileInfo for the target.
805  T.MCObjectFileInfoCtorFn = Fn;
806  }
807 
808  /// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the
809  /// given target.
810  ///
811  /// Clients are responsible for ensuring that registration doesn't occur
812  /// while another thread is attempting to access the registry. Typically
813  /// this is done by initializing all targets at program startup.
814  ///
815  /// @param T - The target being registered.
816  /// @param Fn - A function to construct a MCInstrInfo for the target.
818  T.MCInstrInfoCtorFn = Fn;
819  }
820 
821  /// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for
822  /// the given target.
825  T.MCInstrAnalysisCtorFn = Fn;
826  }
827 
828  /// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
829  /// 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 a MCRegisterInfo for the target.
838  T.MCRegInfoCtorFn = Fn;
839  }
840 
841  /// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for
842  /// the given target.
843  ///
844  /// Clients are responsible for ensuring that registration doesn't occur
845  /// while another thread is attempting to access the registry. Typically
846  /// this is done by initializing all targets at program startup.
847  ///
848  /// @param T - The target being registered.
849  /// @param Fn - A function to construct a MCSubtargetInfo for the target.
852  T.MCSubtargetInfoCtorFn = Fn;
853  }
854 
855  /// RegisterTargetMachine - Register a TargetMachine implementation for the
856  /// given target.
857  ///
858  /// Clients are responsible for ensuring that registration doesn't occur
859  /// while another thread is attempting to access the registry. Typically
860  /// this is done by initializing all targets at program startup.
861  ///
862  /// @param T - The target being registered.
863  /// @param Fn - A function to construct a TargetMachine for the target.
865  T.TargetMachineCtorFn = Fn;
866  }
867 
868  /// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
869  /// given target.
870  ///
871  /// Clients are responsible for ensuring that registration doesn't occur
872  /// while another thread is attempting to access the registry. Typically
873  /// this is done by initializing all targets at program startup.
874  ///
875  /// @param T - The target being registered.
876  /// @param Fn - A function to construct an AsmBackend for the target.
878  T.MCAsmBackendCtorFn = Fn;
879  }
880 
881  /// RegisterMCAsmParser - Register a MCTargetAsmParser implementation for
882  /// the given target.
883  ///
884  /// Clients are responsible for ensuring that registration doesn't occur
885  /// while another thread is attempting to access the registry. Typically
886  /// this is done by initializing all targets at program startup.
887  ///
888  /// @param T - The target being registered.
889  /// @param Fn - A function to construct an MCTargetAsmParser for the target.
891  T.MCAsmParserCtorFn = Fn;
892  }
893 
894  /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
895  /// target.
896  ///
897  /// Clients are responsible for ensuring that registration doesn't occur
898  /// while another thread is attempting to access the registry. Typically
899  /// this is done by initializing all targets at program startup.
900  ///
901  /// @param T - The target being registered.
902  /// @param Fn - A function to construct an AsmPrinter for the target.
904  T.AsmPrinterCtorFn = Fn;
905  }
906 
907  /// RegisterMCDisassembler - Register a MCDisassembler implementation for
908  /// the given target.
909  ///
910  /// Clients are responsible for ensuring that registration doesn't occur
911  /// while another thread is attempting to access the registry. Typically
912  /// this is done by initializing all targets at program startup.
913  ///
914  /// @param T - The target being registered.
915  /// @param Fn - A function to construct an MCDisassembler for the target.
918  T.MCDisassemblerCtorFn = Fn;
919  }
920 
921  /// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the
922  /// given target.
923  ///
924  /// Clients are responsible for ensuring that registration doesn't occur
925  /// while another thread is attempting to access the registry. Typically
926  /// this is done by initializing all targets at program startup.
927  ///
928  /// @param T - The target being registered.
929  /// @param Fn - A function to construct an MCInstPrinter for the target.
931  T.MCInstPrinterCtorFn = Fn;
932  }
933 
934  /// RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the
935  /// given target.
936  ///
937  /// Clients are responsible for ensuring that registration doesn't occur
938  /// while another thread is attempting to access the registry. Typically
939  /// this is done by initializing all targets at program startup.
940  ///
941  /// @param T - The target being registered.
942  /// @param Fn - A function to construct an MCCodeEmitter for the target.
944  T.MCCodeEmitterCtorFn = Fn;
945  }
946 
948  T.COFFStreamerCtorFn = Fn;
949  }
950 
952  T.MachOStreamerCtorFn = Fn;
953  }
954 
956  T.ELFStreamerCtorFn = Fn;
957  }
958 
960  T.WasmStreamerCtorFn = Fn;
961  }
962 
964  T.XCOFFStreamerCtorFn = Fn;
965  }
966 
969  T.NullTargetStreamerCtorFn = Fn;
970  }
971 
974  T.AsmTargetStreamerCtorFn = Fn;
975  }
976 
977  static void
980  T.ObjectTargetStreamerCtorFn = Fn;
981  }
982 
983  /// RegisterMCRelocationInfo - Register an MCRelocationInfo
984  /// implementation for the given target.
985  ///
986  /// Clients are responsible for ensuring that registration doesn't occur
987  /// while another thread is attempting to access the registry. Typically
988  /// this is done by initializing all targets at program startup.
989  ///
990  /// @param T - The target being registered.
991  /// @param Fn - A function to construct an MCRelocationInfo for the target.
994  T.MCRelocationInfoCtorFn = Fn;
995  }
996 
997  /// RegisterMCSymbolizer - Register an MCSymbolizer
998  /// implementation for the given target.
999  ///
1000  /// Clients are responsible for ensuring that registration doesn't occur
1001  /// while another thread is attempting to access the registry. Typically
1002  /// this is done by initializing all targets at program startup.
1003  ///
1004  /// @param T - The target being registered.
1005  /// @param Fn - A function to construct an MCSymbolizer for the target.
1007  T.MCSymbolizerCtorFn = Fn;
1008  }
1009 
1010  /// RegisterCustomBehaviour - Register a CustomBehaviour
1011  /// implementation for the given target.
1012  ///
1013  /// Clients are responsible for ensuring that registration doesn't occur
1014  /// while another thread is attempting to access the registry. Typically
1015  /// this is done by initializing all targets at program startup.
1016  ///
1017  /// @param T - The target being registered.
1018  /// @param Fn - A function to construct a CustomBehaviour for the target.
1021  T.CustomBehaviourCtorFn = Fn;
1022  }
1023 
1024  /// RegisterInstrPostProcess - Register an InstrPostProcess
1025  /// implementation for the given target.
1026  ///
1027  /// Clients are responsible for ensuring that registration doesn't occur
1028  /// while another thread is attempting to access the registry. Typically
1029  /// this is done by initializing all targets at program startup.
1030  ///
1031  /// @param T - The target being registered.
1032  /// @param Fn - A function to construct an InstrPostProcess for the target.
1035  T.InstrPostProcessCtorFn = Fn;
1036  }
1037 
1038  /// @}
1039 };
1040 
1041 //===--------------------------------------------------------------------===//
1042 
1043 /// RegisterTarget - Helper template for registering a target, for use in the
1044 /// target's initialization function. Usage:
1045 ///
1046 ///
1047 /// Target &getTheFooTarget() { // The global target instance.
1048 /// static Target TheFooTarget;
1049 /// return TheFooTarget;
1050 /// }
1051 /// extern "C" void LLVMInitializeFooTargetInfo() {
1052 /// RegisterTarget<Triple::foo> X(getTheFooTarget(), "foo", "Foo
1053 /// description", "Foo" /* Backend Name */);
1054 /// }
1055 template <Triple::ArchType TargetArchType = Triple::UnknownArch,
1056  bool HasJIT = false>
1058  RegisterTarget(Target &T, const char *Name, const char *Desc,
1059  const char *BackendName) {
1060  TargetRegistry::RegisterTarget(T, Name, Desc, BackendName, &getArchMatch,
1061  HasJIT);
1062  }
1063 
1064  static bool getArchMatch(Triple::ArchType Arch) {
1065  return Arch == TargetArchType;
1066  }
1067 };
1068 
1069 /// RegisterMCAsmInfo - Helper template for registering a target assembly info
1070 /// implementation. This invokes the static "Create" method on the class to
1071 /// actually do the construction. Usage:
1072 ///
1073 /// extern "C" void LLVMInitializeFooTarget() {
1074 /// extern Target TheFooTarget;
1075 /// RegisterMCAsmInfo<FooMCAsmInfo> X(TheFooTarget);
1076 /// }
1077 template <class MCAsmInfoImpl> struct RegisterMCAsmInfo {
1079  TargetRegistry::RegisterMCAsmInfo(T, &Allocator);
1080  }
1081 
1082 private:
1083  static MCAsmInfo *Allocator(const MCRegisterInfo & /*MRI*/, const Triple &TT,
1084  const MCTargetOptions &Options) {
1085  return new MCAsmInfoImpl(TT, Options);
1086  }
1087 };
1088 
1089 /// RegisterMCAsmInfoFn - Helper template for registering a target assembly info
1090 /// implementation. This invokes the specified function to do the
1091 /// construction. Usage:
1092 ///
1093 /// extern "C" void LLVMInitializeFooTarget() {
1094 /// extern Target TheFooTarget;
1095 /// RegisterMCAsmInfoFn X(TheFooTarget, TheFunction);
1096 /// }
1100  }
1101 };
1102 
1103 /// Helper template for registering a target object file info implementation.
1104 /// This invokes the static "Create" method on the class to actually do the
1105 /// construction. Usage:
1106 ///
1107 /// extern "C" void LLVMInitializeFooTarget() {
1108 /// extern Target TheFooTarget;
1109 /// RegisterMCObjectFileInfo<FooMCObjectFileInfo> X(TheFooTarget);
1110 /// }
1111 template <class MCObjectFileInfoImpl> struct RegisterMCObjectFileInfo {
1114  }
1115 
1116 private:
1117  static MCObjectFileInfo *Allocator(MCContext &Ctx, bool PIC,
1118  bool LargeCodeModel = false) {
1119  return new MCObjectFileInfoImpl(Ctx, PIC, LargeCodeModel);
1120  }
1121 };
1122 
1123 /// Helper template for registering a target object file info implementation.
1124 /// This invokes the specified function to do the construction. Usage:
1125 ///
1126 /// extern "C" void LLVMInitializeFooTarget() {
1127 /// extern Target TheFooTarget;
1128 /// RegisterMCObjectFileInfoFn X(TheFooTarget, TheFunction);
1129 /// }
1133  }
1134 };
1135 
1136 /// RegisterMCInstrInfo - Helper template for registering a target instruction
1137 /// info implementation. This invokes the static "Create" method on the class
1138 /// to actually do the construction. Usage:
1139 ///
1140 /// extern "C" void LLVMInitializeFooTarget() {
1141 /// extern Target TheFooTarget;
1142 /// RegisterMCInstrInfo<FooMCInstrInfo> X(TheFooTarget);
1143 /// }
1144 template <class MCInstrInfoImpl> struct RegisterMCInstrInfo {
1147  }
1148 
1149 private:
1150  static MCInstrInfo *Allocator() { return new MCInstrInfoImpl(); }
1151 };
1152 
1153 /// RegisterMCInstrInfoFn - Helper template for registering a target
1154 /// instruction info implementation. This invokes the specified function to
1155 /// do the construction. Usage:
1156 ///
1157 /// extern "C" void LLVMInitializeFooTarget() {
1158 /// extern Target TheFooTarget;
1159 /// RegisterMCInstrInfoFn X(TheFooTarget, TheFunction);
1160 /// }
1164  }
1165 };
1166 
1167 /// RegisterMCInstrAnalysis - Helper template for registering a target
1168 /// instruction analyzer implementation. This invokes the static "Create"
1169 /// method on the class to actually do the construction. Usage:
1170 ///
1171 /// extern "C" void LLVMInitializeFooTarget() {
1172 /// extern Target TheFooTarget;
1173 /// RegisterMCInstrAnalysis<FooMCInstrAnalysis> X(TheFooTarget);
1174 /// }
1175 template <class MCInstrAnalysisImpl> struct RegisterMCInstrAnalysis {
1178  }
1179 
1180 private:
1181  static MCInstrAnalysis *Allocator(const MCInstrInfo *Info) {
1182  return new MCInstrAnalysisImpl(Info);
1183  }
1184 };
1185 
1186 /// RegisterMCInstrAnalysisFn - Helper template for registering a target
1187 /// instruction analyzer implementation. This invokes the specified function
1188 /// to do the construction. Usage:
1189 ///
1190 /// extern "C" void LLVMInitializeFooTarget() {
1191 /// extern Target TheFooTarget;
1192 /// RegisterMCInstrAnalysisFn X(TheFooTarget, TheFunction);
1193 /// }
1197  }
1198 };
1199 
1200 /// RegisterMCRegInfo - Helper template for registering a target register info
1201 /// implementation. This invokes the static "Create" method on the class to
1202 /// actually do the construction. Usage:
1203 ///
1204 /// extern "C" void LLVMInitializeFooTarget() {
1205 /// extern Target TheFooTarget;
1206 /// RegisterMCRegInfo<FooMCRegInfo> X(TheFooTarget);
1207 /// }
1208 template <class MCRegisterInfoImpl> struct RegisterMCRegInfo {
1210  TargetRegistry::RegisterMCRegInfo(T, &Allocator);
1211  }
1212 
1213 private:
1214  static MCRegisterInfo *Allocator(const Triple & /*TT*/) {
1215  return new MCRegisterInfoImpl();
1216  }
1217 };
1218 
1219 /// RegisterMCRegInfoFn - Helper template for registering a target register
1220 /// info implementation. This invokes the specified function to do the
1221 /// construction. Usage:
1222 ///
1223 /// extern "C" void LLVMInitializeFooTarget() {
1224 /// extern Target TheFooTarget;
1225 /// RegisterMCRegInfoFn X(TheFooTarget, TheFunction);
1226 /// }
1230  }
1231 };
1232 
1233 /// RegisterMCSubtargetInfo - Helper template for registering a target
1234 /// subtarget info implementation. This invokes the static "Create" method
1235 /// on the class to actually do the construction. Usage:
1236 ///
1237 /// extern "C" void LLVMInitializeFooTarget() {
1238 /// extern Target TheFooTarget;
1239 /// RegisterMCSubtargetInfo<FooMCSubtargetInfo> X(TheFooTarget);
1240 /// }
1241 template <class MCSubtargetInfoImpl> struct RegisterMCSubtargetInfo {
1244  }
1245 
1246 private:
1247  static MCSubtargetInfo *Allocator(const Triple & /*TT*/, StringRef /*CPU*/,
1248  StringRef /*FS*/) {
1249  return new MCSubtargetInfoImpl();
1250  }
1251 };
1252 
1253 /// RegisterMCSubtargetInfoFn - Helper template for registering a target
1254 /// subtarget info implementation. This invokes the specified function to
1255 /// do the construction. Usage:
1256 ///
1257 /// extern "C" void LLVMInitializeFooTarget() {
1258 /// extern Target TheFooTarget;
1259 /// RegisterMCSubtargetInfoFn X(TheFooTarget, TheFunction);
1260 /// }
1264  }
1265 };
1266 
1267 /// RegisterTargetMachine - Helper template for registering a target machine
1268 /// implementation, for use in the target machine initialization
1269 /// function. Usage:
1270 ///
1271 /// extern "C" void LLVMInitializeFooTarget() {
1272 /// extern Target TheFooTarget;
1273 /// RegisterTargetMachine<FooTargetMachine> X(TheFooTarget);
1274 /// }
1275 template <class TargetMachineImpl> struct RegisterTargetMachine {
1278  }
1279 
1280 private:
1281  static TargetMachine *
1282  Allocator(const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
1285  return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL, JIT);
1286  }
1287 };
1288 
1289 /// RegisterMCAsmBackend - Helper template for registering a target specific
1290 /// assembler backend. Usage:
1291 ///
1292 /// extern "C" void LLVMInitializeFooMCAsmBackend() {
1293 /// extern Target TheFooTarget;
1294 /// RegisterMCAsmBackend<FooAsmLexer> X(TheFooTarget);
1295 /// }
1296 template <class MCAsmBackendImpl> struct RegisterMCAsmBackend {
1299  }
1300 
1301 private:
1302  static MCAsmBackend *Allocator(const Target &T, const MCSubtargetInfo &STI,
1303  const MCRegisterInfo &MRI,
1304  const MCTargetOptions &Options) {
1305  return new MCAsmBackendImpl(T, STI, MRI);
1306  }
1307 };
1308 
1309 /// RegisterMCAsmParser - Helper template for registering a target specific
1310 /// assembly parser, for use in the target machine initialization
1311 /// function. Usage:
1312 ///
1313 /// extern "C" void LLVMInitializeFooMCAsmParser() {
1314 /// extern Target TheFooTarget;
1315 /// RegisterMCAsmParser<FooAsmParser> X(TheFooTarget);
1316 /// }
1317 template <class MCAsmParserImpl> struct RegisterMCAsmParser {
1320  }
1321 
1322 private:
1323  static MCTargetAsmParser *Allocator(const MCSubtargetInfo &STI,
1324  MCAsmParser &P, const MCInstrInfo &MII,
1325  const MCTargetOptions &Options) {
1326  return new MCAsmParserImpl(STI, P, MII, Options);
1327  }
1328 };
1329 
1330 /// RegisterAsmPrinter - Helper template for registering a target specific
1331 /// assembly printer, for use in the target machine initialization
1332 /// function. Usage:
1333 ///
1334 /// extern "C" void LLVMInitializeFooAsmPrinter() {
1335 /// extern Target TheFooTarget;
1336 /// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget);
1337 /// }
1338 template <class AsmPrinterImpl> struct RegisterAsmPrinter {
1341  }
1342 
1343 private:
1344  static AsmPrinter *Allocator(TargetMachine &TM,
1345  std::unique_ptr<MCStreamer> &&Streamer) {
1346  return new AsmPrinterImpl(TM, std::move(Streamer));
1347  }
1348 };
1349 
1350 /// RegisterMCCodeEmitter - Helper template for registering a target specific
1351 /// machine code emitter, for use in the target initialization
1352 /// function. Usage:
1353 ///
1354 /// extern "C" void LLVMInitializeFooMCCodeEmitter() {
1355 /// extern Target TheFooTarget;
1356 /// RegisterMCCodeEmitter<FooCodeEmitter> X(TheFooTarget);
1357 /// }
1358 template <class MCCodeEmitterImpl> struct RegisterMCCodeEmitter {
1361  }
1362 
1363 private:
1364  static MCCodeEmitter *Allocator(const MCInstrInfo & /*II*/,
1365  const MCRegisterInfo & /*MRI*/,
1366  MCContext & /*Ctx*/) {
1367  return new MCCodeEmitterImpl();
1368  }
1369 };
1370 
1371 } // end namespace llvm
1372 
1373 #endif // LLVM_SUPPORT_TARGETREGISTRY_H
llvm::Target::createMCObjectStreamer
MCStreamer * createMCObjectStreamer(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, const MCSubtargetInfo &STI, bool RelaxAll, bool IncrementalLinkerCompatible, bool DWARFMustBeAtTheEnd) const
Create a target specific MCStreamer.
Definition: TargetRegistry.h:526
llvm::MCAsmParser
Generic assembler parser interface, for use by target specific assembly parsers.
Definition: MCAsmParser.h:124
llvm::Triple::Wasm
@ Wasm
Definition: Triple.h:238
llvm::Target::AsmPrinterCtorTy
AsmPrinter *(*)(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) AsmPrinterCtorTy
Definition: TargetRegistry.h:163
llvm::RegisterMCAsmInfo::RegisterMCAsmInfo
RegisterMCAsmInfo(Target &T)
Definition: TargetRegistry.h:1078
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::TargetRegistry::iterator::difference_type
std::ptrdiff_t difference_type
Definition: TargetRegistry.h:695
Optional.h
llvm::RegisterMCCodeEmitter::RegisterMCCodeEmitter
RegisterMCCodeEmitter(Target &T)
Definition: TargetRegistry.h:1359
llvm::Triple::UnknownArch
@ UnknownArch
Definition: Triple.h:48
llvm::Target::MCAsmInfoCtorFnTy
MCAsmInfo *(*)(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options) MCAsmInfoCtorFnTy
Definition: TargetRegistry.h:145
llvm::RegisterMCAsmBackend
RegisterMCAsmBackend - Helper template for registering a target specific assembler backend.
Definition: TargetRegistry.h:1296
llvm::RegisterMCInstrInfoFn
RegisterMCInstrInfoFn - Helper template for registering a target instruction info implementation.
Definition: TargetRegistry.h:1161
llvm::Target::XCOFFStreamerCtorTy
MCStreamer *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll) XCOFFStreamerCtorTy
Definition: TargetRegistry.h:206
llvm::TargetOptions
Definition: TargetOptions.h:113
llvm::Target::WasmStreamerCtorTy
MCStreamer *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll) WasmStreamerCtorTy
Definition: TargetRegistry.h:201
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:72
StringRef.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::Target::MCInstrAnalysisCtorFnTy
MCInstrAnalysis *(*)(const MCInstrInfo *Info) MCInstrAnalysisCtorFnTy
Definition: TargetRegistry.h:150
llvm::Target::MCRelocationInfoCtorTy
MCRelocationInfo *(*)(const Triple &TT, MCContext &Ctx) MCRelocationInfoCtorTy
Definition: TargetRegistry.h:215
llvm::Target::createNullTargetStreamer
MCTargetStreamer * createNullTargetStreamer(MCStreamer &S) const
Definition: TargetRegistry.h:615
llvm::Target::createMCObjectFileInfo
MCObjectFileInfo * createMCObjectFileInfo(MCContext &Ctx, bool PIC, bool LargeCodeModel=false) const
Create a MCObjectFileInfo implementation for the specified target triple.
Definition: TargetRegistry.h:392
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::MCRelocationInfo
Create MCExprs from relocations found in an object file.
Definition: MCRelocationInfo.h:24
llvm::Target::createMCAsmInfo
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple, const MCTargetOptions &Options) const
createMCAsmInfo - Create a MCAsmInfo implementation for the specified target triple.
Definition: TargetRegistry.h:382
ErrorHandling.h
llvm::RegisterMCObjectFileInfo
Helper template for registering a target object file info implementation.
Definition: TargetRegistry.h:1111
llvm::Target::MCSubtargetInfoCtorFnTy
MCSubtargetInfo *(*)(const Triple &TT, StringRef CPU, StringRef Features) MCSubtargetInfoCtorFnTy
Definition: TargetRegistry.h:154
llvm::Target::MCSymbolizerCtorTy
MCSymbolizer *(*)(const Triple &TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo) MCSymbolizerCtorTy
Definition: TargetRegistry.h:219
llvm::TargetRegistry::RegisterAsmTargetStreamer
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
Definition: TargetRegistry.h:972
llvm::TargetRegistry::RegisterWasmStreamer
static void RegisterWasmStreamer(Target &T, Target::WasmStreamerCtorTy Fn)
Definition: TargetRegistry.h:959
llvm::TargetRegistry::RegisterMCInstrAnalysis
static void RegisterMCInstrAnalysis(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for the given target.
Definition: TargetRegistry.h:823
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::Target::COFFStreamerCtorTy
MCStreamer *(*)(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll, bool IncrementalLinkerCompatible) COFFStreamerCtorTy
Definition: TargetRegistry.h:196
llvm::RegisterMCInstrAnalysis::RegisterMCInstrAnalysis
RegisterMCInstrAnalysis(Target &T)
Definition: TargetRegistry.h:1176
MCObjectFileInfo.h
llvm::Target::CustomBehaviourCtorTy
mca::CustomBehaviour *(*)(const MCSubtargetInfo &STI, const mca::SourceMgr &SrcMgr, const MCInstrInfo &MCII) CustomBehaviourCtorTy
Definition: TargetRegistry.h:224
llvm::Target::createMCRelocationInfo
MCRelocationInfo * createMCRelocationInfo(StringRef TT, MCContext &Ctx) const
createMCRelocationInfo - Create a target specific MCRelocationInfo.
Definition: TargetRegistry.h:625
llvm::createMachOStreamer
MCStreamer * createMachOStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll, bool DWARFMustBeAtTheEnd, bool LabelSections=false)
Definition: MCMachOStreamer.cpp:509
llvm::RegisterMCInstrInfo::RegisterMCInstrInfo
RegisterMCInstrInfo(Target &T)
Definition: TargetRegistry.h:1145
llvm::Target::createMCCodeEmitter
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, const MCRegisterInfo &MRI, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
Definition: TargetRegistry.h:510
PIC
PassInstrumentationCallbacks PIC
Definition: PassBuilderBindings.cpp:55
llvm::TargetRegistry::iterator
Definition: TargetRegistry.h:685
llvm::RegisterMCRegInfoFn::RegisterMCRegInfoFn
RegisterMCRegInfoFn(Target &T, Target::MCRegInfoCtorFnTy Fn)
Definition: TargetRegistry.h:1228
llvm::TargetRegistry::RegisterMCDisassembler
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.
Definition: TargetRegistry.h:916
llvm::AMDGPU::Exp::Target
Target
Definition: SIDefines.h:732
llvm::Optional< Reloc::Model >
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::TargetRegistry::RegisterMCObjectFileInfo
static void RegisterMCObjectFileInfo(Target &T, Target::MCObjectFileInfoCtorFnTy Fn)
Register a MCObjectFileInfo implementation for the given target.
Definition: TargetRegistry.h:803
llvm::Triple::XCOFF
@ XCOFF
Definition: Triple.h:239
llvm::TargetRegistry
TargetRegistry - Generic interface to target specific features.
Definition: TargetRegistry.h:678
llvm::Target::createAsmStreamer
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool IsVerboseAsm, bool UseDwarfDirectory, MCInstPrinter *InstPrint, std::unique_ptr< MCCodeEmitter > &&CE, std::unique_ptr< MCAsmBackend > &&TAB, bool ShowInst) const
Definition: TargetRegistry.h:585
llvm::Target::createAsmTargetStreamer
MCTargetStreamer * createAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool IsVerboseAsm) const
Definition: TargetRegistry.h:600
tmp
alloca< 16 x float >, align 16 %tmp2=alloca< 16 x float >, align 16 store< 16 x float > %A,< 16 x float > *%tmp %s=bitcast< 16 x float > *%tmp to i8 *%s2=bitcast< 16 x float > *%tmp2 to i8 *call void @llvm.memcpy.i64(i8 *%s, i8 *%s2, i64 64, i32 16) %R=load< 16 x float > *%tmp2 ret< 16 x float > %R } declare void @llvm.memcpy.i64(i8 *nocapture, i8 *nocapture, i64, i32) nounwind which compiles to:_foo:subl $140, %esp movaps %xmm3, 112(%esp) movaps %xmm2, 96(%esp) movaps %xmm1, 80(%esp) movaps %xmm0, 64(%esp) movl 60(%esp), %eax movl %eax, 124(%esp) movl 56(%esp), %eax movl %eax, 120(%esp) movl 52(%esp), %eax< many many more 32-bit copies > movaps(%esp), %xmm0 movaps 16(%esp), %xmm1 movaps 32(%esp), %xmm2 movaps 48(%esp), %xmm3 addl $140, %esp ret On Nehalem, it may even be cheaper to just use movups when unaligned than to fall back to lower-granularity chunks. Implement processor-specific optimizations for parity with GCC on these processors. GCC does two optimizations:1. ix86_pad_returns inserts a noop before ret instructions if immediately preceded by a conditional branch or is the target of a jump. 2. ix86_avoid_jump_misspredicts inserts noops in cases where a 16-byte block of code contains more than 3 branches. The first one is done for all AMDs, Core2, and "Generic" The second one is done for:Atom, Pentium Pro, all AMDs, Pentium 4, Nocona, Core 2, and "Generic" Testcase:int x(int a) { return(a &0xf0)> >4 tmp
Definition: README.txt:1347
llvm::TargetRegistry::RegisterMCInstPrinter
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
Definition: TargetRegistry.h:930
llvm::TargetRegistry::lookupTarget
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
Definition: TargetRegistry.cpp:62
llvm::RegisterMCInstrInfo
RegisterMCInstrInfo - Helper template for registering a target instruction info implementation.
Definition: TargetRegistry.h:1144
llvm::TargetRegistry::RegisterCOFFStreamer
static void RegisterCOFFStreamer(Target &T, Target::COFFStreamerCtorTy Fn)
Definition: TargetRegistry.h:947
llvm::Target::MCAsmParserCtorTy
MCTargetAsmParser *(*)(const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII, const MCTargetOptions &Options) MCAsmParserCtorTy
Definition: TargetRegistry.h:170
llvm::Target::createMCInstrInfo
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
Definition: TargetRegistry.h:404
llvm::Target::MCInstrInfoCtorFnTy
MCInstrInfo *(*)() MCInstrInfoCtorFnTy
Definition: TargetRegistry.h:149
llvm::MCSymbolizer
Symbolize and annotate disassembled instructions.
Definition: MCSymbolizer.h:39
llvm::Target::MCAsmBackendCtorTy
MCAsmBackend *(*)(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) MCAsmBackendCtorTy
Definition: TargetRegistry.h:167
llvm::Target::createMCRegInfo
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
Definition: TargetRegistry.h:420
FormattedStream.h
llvm::RegisterMCObjectFileInfoFn::RegisterMCObjectFileInfoFn
RegisterMCObjectFileInfoFn(Target &T, Target::MCObjectFileInfoCtorFnTy Fn)
Definition: TargetRegistry.h:1131
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:199
llvm::Target::hasTargetMachine
bool hasTargetMachine() const
hasTargetMachine - Check if this target supports code generation.
Definition: TargetRegistry.h:363
llvm::RegisterMCInstrInfoFn::RegisterMCInstrInfoFn
RegisterMCInstrInfoFn(Target &T, Target::MCInstrInfoCtorFnTy Fn)
Definition: TargetRegistry.h:1162
llvm::MCAsmBackend
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:36
llvm::RegisterMCAsmParser
RegisterMCAsmParser - Helper template for registering a target specific assembly parser,...
Definition: TargetRegistry.h:1317
llvm::Triple::ArchType
ArchType
Definition: Triple.h:47
llvm::TargetRegistry::targets
static iterator_range< iterator > targets()
Definition: TargetRegistry.cpp:20
llvm::TargetRegistry::TargetRegistry
TargetRegistry()=delete
LLVMOpInfoCallback
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: DisassemblerTypes.h:42
llvm::createAsmStreamer
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool isVerboseAsm, bool useDwarfDirectory, MCInstPrinter *InstPrint, std::unique_ptr< MCCodeEmitter > &&CE, std::unique_ptr< MCAsmBackend > &&TAB, bool ShowInst)
Create a machine code streamer which will print out assembly for the native target,...
Definition: MCAsmStreamer.cpp:2482
llvm::RegisterMCSubtargetInfoFn
RegisterMCSubtargetInfoFn - Helper template for registering a target subtarget info implementation.
Definition: TargetRegistry.h:1261
llvm::TargetRegistry::iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: TargetRegistry.h:693
llvm::SrcMgr
SourceMgr SrcMgr
Definition: Error.cpp:24
llvm::TargetRegistry::iterator::operator==
bool operator==(const iterator &x) const
Definition: TargetRegistry.h:701
llvm::Target::TargetMachineCtorTy
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
Definition: TargetRegistry.h:158
llvm::TargetRegistry::iterator::operator->
const Target * operator->() const
Definition: TargetRegistry.h:721
llvm::RegisterMCObjectFileInfo::RegisterMCObjectFileInfo
RegisterMCObjectFileInfo(Target &T)
Definition: TargetRegistry.h:1112
llvm::MCInstrAnalysis
Definition: MCInstrAnalysis.h:27
llvm::TargetRegistry::iterator::operator!=
bool operator!=(const iterator &x) const
Definition: TargetRegistry.h:702
llvm::TargetRegistry::RegisterInstrPostProcess
static void RegisterInstrPostProcess(Target &T, Target::InstrPostProcessCtorTy Fn)
RegisterInstrPostProcess - Register an InstrPostProcess implementation for the given target.
Definition: TargetRegistry.h:1033
llvm::TargetRegistry::RegisterTargetMachine
static void RegisterTargetMachine(Target &T, Target::TargetMachineCtorTy Fn)
RegisterTargetMachine - Register a TargetMachine implementation for the given target.
Definition: TargetRegistry.h:864
llvm::RegisterTargetMachine
RegisterTargetMachine - Helper template for registering a target machine implementation,...
Definition: TargetRegistry.h:1275
llvm::Target::ObjectTargetStreamerCtorTy
MCTargetStreamer *(*)(MCStreamer &S, const MCSubtargetInfo &STI) ObjectTargetStreamerCtorTy
Definition: TargetRegistry.h:213
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::MCTargetStreamer
Target specific streamer interface.
Definition: MCStreamer.h:91
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::Triple::GOFF
@ GOFF
Definition: Triple.h:236
llvm::RegisterMCSubtargetInfo::RegisterMCSubtargetInfo
RegisterMCSubtargetInfo(Target &T)
Definition: TargetRegistry.h:1242
llvm::None
const NoneType None
Definition: None.h:23
llvm::RegisterMCInstrAnalysisFn
RegisterMCInstrAnalysisFn - Helper template for registering a target instruction analyzer implementat...
Definition: TargetRegistry.h:1194
llvm::RegisterMCAsmInfoFn
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
Definition: TargetRegistry.h:1097
llvm::Target::createMCAsmParser
MCTargetAsmParser * createMCAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser, const MCInstrInfo &MII, const MCTargetOptions &Options) const
createMCAsmParser - Create a target specific assembly parser.
Definition: TargetRegistry.h:475
llvm::Target::AsmTargetStreamerCtorTy
MCTargetStreamer *(*)(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool IsVerboseAsm) AsmTargetStreamerCtorTy
Definition: TargetRegistry.h:211
llvm::TargetRegistry::RegisterCustomBehaviour
static void RegisterCustomBehaviour(Target &T, Target::CustomBehaviourCtorTy Fn)
RegisterCustomBehaviour - Register a CustomBehaviour implementation for the given target.
Definition: TargetRegistry.h:1019
llvm::Target::MCObjectFileInfoCtorFnTy
MCObjectFileInfo *(*)(MCContext &Ctx, bool PIC, bool LargeCodeModel) MCObjectFileInfoCtorFnTy
Definition: TargetRegistry.h:148
llvm::Target::hasJIT
bool hasJIT() const
hasJIT - Check if this targets supports the just-in-time compilation.
Definition: TargetRegistry.h:360
llvm::Target::InstrPostProcessCtorTy
mca::InstrPostProcess *(*)(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) InstrPostProcessCtorTy
Definition: TargetRegistry.h:228
llvm::createWasmStreamer
MCStreamer * createWasmStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll)
Definition: MCWasmStreamer.cpp:188
llvm::Triple::ELF
@ ELF
Definition: Triple.h:235
llvm::TargetRegistry::RegisterMCAsmParser
static void RegisterMCAsmParser(Target &T, Target::MCAsmParserCtorTy Fn)
RegisterMCAsmParser - Register a MCTargetAsmParser implementation for the given target.
Definition: TargetRegistry.h:890
llvm::CodeGenOpt::Default
@ Default
Definition: CodeGen.h:55
llvm::TargetRegistry::RegisterMCAsmBackend
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
Definition: TargetRegistry.h:877
LLVMSymbolLookupCallback
const typedef char *(* LLVMSymbolLookupCallback)(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
The type for the symbol lookup function.
Definition: DisassemblerTypes.h:112
llvm::createXCOFFStreamer
MCStreamer * createXCOFFStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll)
Definition: MCXCOFFStreamer.cpp:119
llvm::RegisterMCAsmParser::RegisterMCAsmParser
RegisterMCAsmParser(Target &T)
Definition: TargetRegistry.h:1318
llvm::TargetRegistry::RegisterMachOStreamer
static void RegisterMachOStreamer(Target &T, Target::MachOStreamerCtorTy Fn)
Definition: TargetRegistry.h:951
llvm::TargetRegistry::iterator::operator++
iterator operator++(int)
Definition: TargetRegistry.h:710
llvm::RegisterMCInstrAnalysisFn::RegisterMCInstrAnalysisFn
RegisterMCInstrAnalysisFn(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
Definition: TargetRegistry.h:1195
llvm::RegisterMCSubtargetInfoFn::RegisterMCSubtargetInfoFn
RegisterMCSubtargetInfoFn(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
Definition: TargetRegistry.h:1262
llvm::MCInstPrinter
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:43
llvm::EngineKind::JIT
@ JIT
Definition: ExecutionEngine.h:525
llvm::mca::CustomBehaviour
Class which can be overriden by targets to enforce instruction dependencies and behaviours that aren'...
Definition: CustomBehaviour.h:55
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::MCDisassembler
Superclass for all disassemblers.
Definition: MCDisassembler.h:76
llvm::TargetRegistry::RegisterTarget
static void RegisterTarget(Target &T, const char *Name, const char *ShortDesc, const char *BackendName, Target::ArchMatchFnTy ArchMatchFn, bool HasJIT=false)
RegisterTarget - Register the given target.
Definition: TargetRegistry.cpp:88
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::Target::getNext
const Target * getNext() const
Definition: TargetRegistry.h:344
llvm::Target::createMCSymbolizer
MCSymbolizer * createMCSymbolizer(StringRef TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo) const
createMCSymbolizer - Create a target specific MCSymbolizer.
Definition: TargetRegistry.h:645
llvm::TargetRegistry::RegisterObjectTargetStreamer
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
Definition: TargetRegistry.h:978
llvm::createNullStreamer
MCStreamer * createNullStreamer(MCContext &Ctx)
Create a dummy machine code streamer, which does nothing.
Definition: MCNullStreamer.cpp:47
llvm::Target::createMCDisassembler
MCDisassembler * createMCDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) const
Definition: TargetRegistry.h:493
llvm::RegisterMCInstrAnalysis
RegisterMCInstrAnalysis - Helper template for registering a target instruction analyzer implementatio...
Definition: TargetRegistry.h:1175
llvm::Target::getName
const char * getName() const
getName - Get the target name.
Definition: TargetRegistry.h:347
llvm::formatted_raw_ostream
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Definition: FormattedStream.h:30
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
llvm::Target::createAsmPrinter
AsmPrinter * createAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) const
createAsmPrinter - Create a target specific assembly printer pass.
Definition: TargetRegistry.h:486
llvm::TargetRegistry::RegisterMCAsmInfo
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCAsmInfo - Register a MCAsmInfo implementation for the given target.
Definition: TargetRegistry.h:791
llvm::Target::MachOStreamerCtorTy
MCStreamer *(*)(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll, bool DWARFMustBeAtTheEnd) MachOStreamerCtorTy
Definition: TargetRegistry.h:191
iterator_range.h
llvm::createCustomBehaviour
mca::CustomBehaviour * createCustomBehaviour(const MCSubtargetInfo &STI, const mca::SourceMgr &SrcMgr, const MCInstrInfo &MCII)
llvm::createInstrPostProcess
mca::InstrPostProcess * createInstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
llvm::Target::MCInstPrinterCtorTy
MCInstPrinter *(*)(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) MCInstPrinterCtorTy
Definition: TargetRegistry.h:178
llvm::TargetRegistry::RegisterMCSubtargetInfo
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
Definition: TargetRegistry.h:850
llvm::MCTargetOptions
Definition: MCTargetOptions.h:36
llvm::MCObjectFileInfo::initMCObjectFileInfo
void initMCObjectFileInfo(MCContext &MCCtx, bool PIC, bool LargeCodeModel=false)
Definition: MCObjectFileInfo.cpp:971
llvm::Target::createNullStreamer
MCStreamer * createNullStreamer(MCContext &Ctx) const
Definition: TargetRegistry.h:609
Triple.h
llvm::Target::ArchMatchFnTy
bool(*)(Triple::ArchType Arch) ArchMatchFnTy
Definition: TargetRegistry.h:141
llvm::AArch64::RM
@ RM
Definition: AArch64ISelLowering.h:472
llvm::createMCRelocationInfo
MCRelocationInfo * createMCRelocationInfo(const Triple &TT, MCContext &Ctx)
Definition: MCRelocationInfo.cpp:27
llvm::RegisterMCRegInfo
RegisterMCRegInfo - Helper template for registering a target register info implementation.
Definition: TargetRegistry.h:1208
llvm::Target::createMCAsmBackend
MCAsmBackend * createMCAsmBackend(const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) const
createMCAsmBackend - Create a target specific assembly parser.
Definition: TargetRegistry.h:463
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::Target::hasMCAsmParser
bool hasMCAsmParser() const
hasMCAsmParser - Check if this target supports assembly parsing.
Definition: TargetRegistry.h:369
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::Target::MCDisassemblerCtorTy
MCDisassembler *(*)(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx) MCDisassemblerCtorTy
Definition: TargetRegistry.h:173
llvm::Target::createCustomBehaviour
mca::CustomBehaviour * createCustomBehaviour(const MCSubtargetInfo &STI, const mca::SourceMgr &SrcMgr, const MCInstrInfo &MCII) const
createCustomBehaviour - Create a target specific CustomBehaviour.
Definition: TargetRegistry.h:657
llvm::Target::hasMCAsmBackend
bool hasMCAsmBackend() const
hasMCAsmBackend - Check if this target supports .o generation.
Definition: TargetRegistry.h:366
llvm::RegisterMCAsmInfo
RegisterMCAsmInfo - Helper template for registering a target assembly info implementation.
Definition: TargetRegistry.h:1077
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::Target::createInstrPostProcess
mca::InstrPostProcess * createInstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) const
createInstrPostProcess - Create a target specific InstrPostProcess.
Definition: TargetRegistry.h:667
llvm::RegisterMCRegInfo::RegisterMCRegInfo
RegisterMCRegInfo(Target &T)
Definition: TargetRegistry.h:1209
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
llvm::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition: MCRegisterInfo.h:135
llvm::TargetRegistry::printRegisteredTargetsForVersion
static void printRegisteredTargetsForVersion(raw_ostream &OS)
printRegisteredTargetsForVersion - Print the registered targets appropriately for inclusion in a tool...
Definition: TargetRegistry.cpp:117
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::mca::InstrPostProcess
Class which can be overriden by targets to modify the mca::Instruction objects before the pipeline st...
Definition: CustomBehaviour.h:34
llvm::createELFStreamer
MCStreamer * createELFStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll)
Definition: MCELFStreamer.cpp:887
llvm::Target::createMCInstrAnalysis
MCInstrAnalysis * createMCInstrAnalysis(const MCInstrInfo *Info) const
createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
Definition: TargetRegistry.h:412
llvm::RegisterMCSubtargetInfo
RegisterMCSubtargetInfo - Helper template for registering a target subtarget info implementation.
Definition: TargetRegistry.h:1241
llvm::Target::createMCSubtargetInfo
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
Definition: TargetRegistry.h:435
llvm::TargetRegistry::RegisterMCInstrInfo
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
Definition: TargetRegistry.h:817
llvm::mca::SourceMgr
Definition: SourceMgr.h:28
llvm::TargetRegistry::RegisterMCCodeEmitter
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
Definition: TargetRegistry.h:943
llvm::MCInstrInfo
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:25
llvm::Target::createMCInstPrinter
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
Definition: TargetRegistry.h:500
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::MCCodeEmitter
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:21
llvm::TargetRegistry::RegisterMCRegInfo
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Definition: TargetRegistry.h:837
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::TargetRegistry::RegisterELFStreamer
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn)
Definition: TargetRegistry.h:955
llvm::RegisterMCAsmBackend::RegisterMCAsmBackend
RegisterMCAsmBackend(Target &T)
Definition: TargetRegistry.h:1297
llvm::Triple::MachO
@ MachO
Definition: Triple.h:237
llvm::RegisterTarget::getArchMatch
static bool getArchMatch(Triple::ArchType Arch)
Definition: TargetRegistry.h:1064
llvm::RegisterTarget
RegisterTarget - Helper template for registering a target, for use in the target's initialization fun...
Definition: TargetRegistry.h:1057
x
TODO unsigned x
Definition: README.txt:10
llvm::MCTargetAsmParser
MCTargetAsmParser - Generic interface to target specific assembly parsers.
Definition: MCTargetAsmParser.h:309
llvm::AsmPrinter
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:82
llvm::TargetRegistry::RegisterNullTargetStreamer
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
Definition: TargetRegistry.h:967
llvm::TargetRegistry::RegisterXCOFFStreamer
static void RegisterXCOFFStreamer(Target &T, Target::XCOFFStreamerCtorTy Fn)
Definition: TargetRegistry.h:963
llvm::Target::MCRegInfoCtorFnTy
MCRegisterInfo *(*)(const Triple &TT) MCRegInfoCtorFnTy
Definition: TargetRegistry.h:151
CodeGen.h
llvm::Target::getBackendName
const char * getBackendName() const
getBackendName - Get the backend name.
Definition: TargetRegistry.h:353
llvm::Triple::COFF
@ COFF
Definition: Triple.h:234
llvm::Target::getShortDescription
const char * getShortDescription() const
getShortDescription - Get a short description of the target.
Definition: TargetRegistry.h:350
llvm::TargetRegistry::iterator::operator*
const Target & operator*() const
Definition: TargetRegistry.h:716
llvm::TargetRegistry::iterator::iterator
iterator()=default
DisassemblerTypes.h
llvm::RegisterTarget::RegisterTarget
RegisterTarget(Target &T, const char *Name, const char *Desc, const char *BackendName)
Definition: TargetRegistry.h:1058
llvm::TargetRegistry::RegisterAsmPrinter
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn)
RegisterAsmPrinter - Register an AsmPrinter implementation for the given target.
Definition: TargetRegistry.h:903
llvm::TargetRegistry::iterator::operator++
iterator & operator++()
Definition: TargetRegistry.h:705
llvm::RegisterTargetMachine::RegisterTargetMachine
RegisterTargetMachine(Target &T)
Definition: TargetRegistry.h:1276
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::RegisterMCAsmInfoFn::RegisterMCAsmInfoFn
RegisterMCAsmInfoFn(Target &T, Target::MCAsmInfoCtorFnTy Fn)
Definition: TargetRegistry.h:1098
llvm::TargetRegistry::RegisterMCSymbolizer
static void RegisterMCSymbolizer(Target &T, Target::MCSymbolizerCtorTy Fn)
RegisterMCSymbolizer - Register an MCSymbolizer implementation for the given target.
Definition: TargetRegistry.h:1006
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::Target::ELFStreamerCtorTy
MCStreamer *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll) ELFStreamerCtorTy
Definition: TargetRegistry.h:186
llvm::Target::Target
Target()=default
llvm::RegisterAsmPrinter
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
Definition: TargetRegistry.h:1338
llvm::Target::MCCodeEmitterCtorTy
MCCodeEmitter *(*)(const MCInstrInfo &II, const MCRegisterInfo &MRI, MCContext &Ctx) MCCodeEmitterCtorTy
Definition: TargetRegistry.h:181
llvm::Target::NullTargetStreamerCtorTy
MCTargetStreamer *(*)(MCStreamer &S) NullTargetStreamerCtorTy
Definition: TargetRegistry.h:208
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75
llvm::RegisterMCRegInfoFn
RegisterMCRegInfoFn - Helper template for registering a target register info implementation.
Definition: TargetRegistry.h:1227
llvm::RegisterMCCodeEmitter
RegisterMCCodeEmitter - Helper template for registering a target specific machine code emitter,...
Definition: TargetRegistry.h:1358
llvm::createMCSymbolizer
MCSymbolizer * createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo)
Definition: MCExternalSymbolizer.cpp:190
llvm::TargetRegistry::RegisterMCRelocationInfo
static void RegisterMCRelocationInfo(Target &T, Target::MCRelocationInfoCtorTy Fn)
RegisterMCRelocationInfo - Register an MCRelocationInfo implementation for the given target.
Definition: TargetRegistry.h:992
llvm::MCObjectFileInfo
Definition: MCObjectFileInfo.h:26
llvm::RegisterMCObjectFileInfoFn
Helper template for registering a target object file info implementation.
Definition: TargetRegistry.h:1130
llvm::Target::createTargetMachine
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.
Definition: TargetRegistry.h:449
llvm::RegisterAsmPrinter::RegisterAsmPrinter
RegisterAsmPrinter(Target &T)
Definition: TargetRegistry.h:1339
llvm::Triple::UnknownObjectFormat
@ UnknownObjectFormat
Definition: Triple.h:232