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