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