LLVM 20.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/StringRef.h"
30#include <cassert>
31#include <cstddef>
32#include <iterator>
33#include <memory>
34#include <optional>
35#include <string>
36
37namespace llvm {
38
39class AsmPrinter;
40class MCAsmBackend;
41class MCAsmInfo;
42class MCAsmParser;
43class MCCodeEmitter;
44class MCContext;
45class MCDisassembler;
46class MCInstPrinter;
47class MCInstrAnalysis;
48class MCInstrInfo;
49class MCObjectWriter;
50class MCRegisterInfo;
51class MCRelocationInfo;
52class MCStreamer;
53class MCSubtargetInfo;
54class MCSymbolizer;
55class MCTargetAsmParser;
56class MCTargetOptions;
57class MCTargetStreamer;
58class raw_ostream;
59class TargetMachine;
60class TargetOptions;
61namespace mca {
62class CustomBehaviour;
65struct SourceMgr;
66} // namespace mca
67
69// Takes ownership of \p TAB and \p CE.
70
71/// Create a machine code streamer which will print out assembly for the native
72/// target, suitable for compiling with a native assembler.
73///
74/// \param InstPrint - If given, the instruction printer to use. If not given
75/// the MCInst representation will be printed. This method takes ownership of
76/// InstPrint.
77///
78/// \param CE - If given, a code emitter to use to show the instruction
79/// encoding inline with the assembly. This method takes ownership of \p CE.
80///
81/// \param TAB - If given, a target asm backend to use to show the fixup
82/// information in conjunction with encoding information. This method takes
83/// ownership of \p TAB.
84///
85/// \param ShowInst - Whether to show the MCInst representation inline with
86/// the assembly.
88createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS,
89 MCInstPrinter *InstPrint, std::unique_ptr<MCCodeEmitter> &&CE,
90 std::unique_ptr<MCAsmBackend> &&TAB);
91
93 std::unique_ptr<MCAsmBackend> &&TAB,
94 std::unique_ptr<MCObjectWriter> &&OW,
95 std::unique_ptr<MCCodeEmitter> &&CE);
97 std::unique_ptr<MCAsmBackend> &&TAB,
98 std::unique_ptr<MCObjectWriter> &&OW,
99 std::unique_ptr<MCCodeEmitter> &&CE);
101 std::unique_ptr<MCAsmBackend> &&TAB,
102 std::unique_ptr<MCObjectWriter> &&OW,
103 std::unique_ptr<MCCodeEmitter> &&CE,
104 bool DWARFMustBeAtTheEnd,
105 bool LabelSections = false);
107 std::unique_ptr<MCAsmBackend> &&TAB,
108 std::unique_ptr<MCObjectWriter> &&OW,
109 std::unique_ptr<MCCodeEmitter> &&CE);
111 std::unique_ptr<MCAsmBackend> &&TAB,
112 std::unique_ptr<MCObjectWriter> &&OW,
113 std::unique_ptr<MCCodeEmitter> &&CE);
115 std::unique_ptr<MCAsmBackend> &&TAB,
116 std::unique_ptr<MCObjectWriter> &&OW,
117 std::unique_ptr<MCCodeEmitter> &&CE);
118
120
122 LLVMSymbolLookupCallback SymbolLookUp,
123 void *DisInfo, MCContext *Ctx,
124 std::unique_ptr<MCRelocationInfo> &&RelInfo);
125
127 const mca::SourceMgr &SrcMgr,
128 const MCInstrInfo &MCII);
129
131 const MCInstrInfo &MCII);
132
134 const MCInstrInfo &MCII);
135
136/// Target - Wrapper for Target specific information.
137///
138/// For registration purposes, this is a POD type so that targets can be
139/// registered without the use of static constructors.
140///
141/// Targets should implement a single global instance of this class (which
142/// will be zero initialized), and pass that instance to the TargetRegistry as
143/// part of their initialization.
144class Target {
145public:
146 friend struct TargetRegistry;
147
149
151 const Triple &TT,
152 const MCTargetOptions &Options);
154 bool PIC,
155 bool LargeCodeModel);
158 using MCRegInfoCtorFnTy = MCRegisterInfo *(*)(const Triple &TT);
160 StringRef CPU,
161 StringRef Features);
163 *(*)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
164 const TargetOptions &Options, std::optional<Reloc::Model> RM,
165 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, bool JIT);
166 // If it weren't for layering issues (this header is in llvm/Support, but
167 // depends on MC?) this should take the Streamer by value rather than rvalue
168 // reference.
170 TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
172 const MCSubtargetInfo &STI,
173 const MCRegisterInfo &MRI,
174 const MCTargetOptions &Options);
176 const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
177 const MCTargetOptions &Options);
179 const MCSubtargetInfo &STI,
180 MCContext &Ctx);
182 unsigned SyntaxVariant,
183 const MCAsmInfo &MAI,
184 const MCInstrInfo &MII,
185 const MCRegisterInfo &MRI);
187 MCContext &Ctx);
189 MCStreamer *(*)(const Triple &T, MCContext &Ctx,
190 std::unique_ptr<MCAsmBackend> &&TAB,
191 std::unique_ptr<MCObjectWriter> &&OW,
192 std::unique_ptr<MCCodeEmitter> &&Emitter);
194 MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
195 std::unique_ptr<MCObjectWriter> &&OW,
196 std::unique_ptr<MCCodeEmitter> &&Emitter);
198 MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
199 std::unique_ptr<MCObjectWriter> &&OW,
200 std::unique_ptr<MCCodeEmitter> &&Emitter);
202 MCStreamer *(*)(const Triple &T, MCContext &Ctx,
203 std::unique_ptr<MCAsmBackend> &&TAB,
204 std::unique_ptr<MCObjectWriter> &&OW,
205 std::unique_ptr<MCCodeEmitter> &&Emitter);
206
210 MCInstPrinter *InstPrint);
212 MCStreamer &S, const MCSubtargetInfo &STI);
214 MCContext &Ctx);
216 const Triple &TT, LLVMOpInfoCallback GetOpInfo,
217 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
218 std::unique_ptr<MCRelocationInfo> &&RelInfo);
219
222 const mca::SourceMgr &SrcMgr,
223 const MCInstrInfo &MCII);
224
227 const MCInstrInfo &MCII);
228
231 const MCInstrInfo &MCII);
232
233private:
234 /// Next - The next registered target in the linked list, maintained by the
235 /// TargetRegistry.
236 Target *Next;
237
238 /// The target function for checking if an architecture is supported.
239 ArchMatchFnTy ArchMatchFn;
240
241 /// Name - The target name.
242 const char *Name;
243
244 /// ShortDesc - A short description of the target.
245 const char *ShortDesc;
246
247 /// BackendName - The name of the backend implementation. This must match the
248 /// name of the 'def X : Target ...' in TableGen.
249 const char *BackendName;
250
251 /// HasJIT - Whether this target supports the JIT.
252 bool HasJIT;
253
254 /// MCAsmInfoCtorFn - Constructor function for this target's MCAsmInfo, if
255 /// registered.
256 MCAsmInfoCtorFnTy MCAsmInfoCtorFn;
257
258 /// Constructor function for this target's MCObjectFileInfo, if registered.
259 MCObjectFileInfoCtorFnTy MCObjectFileInfoCtorFn;
260
261 /// MCInstrInfoCtorFn - Constructor function for this target's MCInstrInfo,
262 /// if registered.
263 MCInstrInfoCtorFnTy MCInstrInfoCtorFn;
264
265 /// MCInstrAnalysisCtorFn - Constructor function for this target's
266 /// MCInstrAnalysis, if registered.
267 MCInstrAnalysisCtorFnTy MCInstrAnalysisCtorFn;
268
269 /// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
270 /// if registered.
271 MCRegInfoCtorFnTy MCRegInfoCtorFn;
272
273 /// MCSubtargetInfoCtorFn - Constructor function for this target's
274 /// MCSubtargetInfo, if registered.
275 MCSubtargetInfoCtorFnTy MCSubtargetInfoCtorFn;
276
277 /// TargetMachineCtorFn - Construction function for this target's
278 /// TargetMachine, if registered.
279 TargetMachineCtorTy TargetMachineCtorFn;
280
281 /// MCAsmBackendCtorFn - Construction function for this target's
282 /// MCAsmBackend, if registered.
283 MCAsmBackendCtorTy MCAsmBackendCtorFn;
284
285 /// MCAsmParserCtorFn - Construction function for this target's
286 /// MCTargetAsmParser, if registered.
287 MCAsmParserCtorTy MCAsmParserCtorFn;
288
289 /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
290 /// if registered.
291 AsmPrinterCtorTy AsmPrinterCtorFn;
292
293 /// MCDisassemblerCtorFn - Construction function for this target's
294 /// MCDisassembler, if registered.
295 MCDisassemblerCtorTy MCDisassemblerCtorFn;
296
297 /// MCInstPrinterCtorFn - Construction function for this target's
298 /// MCInstPrinter, if registered.
299 MCInstPrinterCtorTy MCInstPrinterCtorFn;
300
301 /// MCCodeEmitterCtorFn - Construction function for this target's
302 /// CodeEmitter, if registered.
303 MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
304
305 // Construction functions for the various object formats, if registered.
306 COFFStreamerCtorTy COFFStreamerCtorFn = nullptr;
307 MachOStreamerCtorTy MachOStreamerCtorFn = nullptr;
308 ELFStreamerCtorTy ELFStreamerCtorFn = nullptr;
309 XCOFFStreamerCtorTy XCOFFStreamerCtorFn = nullptr;
310
311 /// Construction function for this target's null TargetStreamer, if
312 /// registered (default = nullptr).
313 NullTargetStreamerCtorTy NullTargetStreamerCtorFn = nullptr;
314
315 /// Construction function for this target's asm TargetStreamer, if
316 /// registered (default = nullptr).
317 AsmTargetStreamerCtorTy AsmTargetStreamerCtorFn = nullptr;
318
319 /// Construction function for this target's obj TargetStreamer, if
320 /// registered (default = nullptr).
321 ObjectTargetStreamerCtorTy ObjectTargetStreamerCtorFn = nullptr;
322
323 /// MCRelocationInfoCtorFn - Construction function for this target's
324 /// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
325 MCRelocationInfoCtorTy MCRelocationInfoCtorFn = nullptr;
326
327 /// MCSymbolizerCtorFn - Construction function for this target's
328 /// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
329 MCSymbolizerCtorTy MCSymbolizerCtorFn = nullptr;
330
331 /// CustomBehaviourCtorFn - Construction function for this target's
332 /// CustomBehaviour, if registered (default = nullptr).
333 CustomBehaviourCtorTy CustomBehaviourCtorFn = nullptr;
334
335 /// InstrPostProcessCtorFn - Construction function for this target's
336 /// InstrPostProcess, if registered (default = nullptr).
337 InstrPostProcessCtorTy InstrPostProcessCtorFn = nullptr;
338
339 /// InstrumentManagerCtorFn - Construction function for this target's
340 /// InstrumentManager, if registered (default = nullptr).
341 InstrumentManagerCtorTy InstrumentManagerCtorFn = nullptr;
342
343public:
344 Target() = default;
345
346 /// @name Target Information
347 /// @{
348
349 // getNext - Return the next registered target.
350 const Target *getNext() const { return Next; }
351
352 /// getName - Get the target name.
353 const char *getName() const { return Name; }
354
355 /// getShortDescription - Get a short description of the target.
356 const char *getShortDescription() const { return ShortDesc; }
357
358 /// getBackendName - Get the backend name.
359 const char *getBackendName() const { return BackendName; }
360
361 /// @}
362 /// @name Feature Predicates
363 /// @{
364
365 /// hasJIT - Check if this targets supports the just-in-time compilation.
366 bool hasJIT() const { return HasJIT; }
367
368 /// hasTargetMachine - Check if this target supports code generation.
369 bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
370
371 /// hasMCAsmBackend - Check if this target supports .o generation.
372 bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
373
374 /// hasMCAsmParser - Check if this target supports assembly parsing.
375 bool hasMCAsmParser() const { return MCAsmParserCtorFn != nullptr; }
376
377 /// @}
378 /// @name Feature Constructors
379 /// @{
380
381 /// createMCAsmInfo - Create a MCAsmInfo implementation for the specified
382 /// target triple.
383 ///
384 /// \param TheTriple This argument is used to determine the target machine
385 /// feature set; it should always be provided. Generally this should be
386 /// either the target triple from the module, or the target triple of the
387 /// host if that does not exist.
389 const MCTargetOptions &Options) const {
390 if (!MCAsmInfoCtorFn)
391 return nullptr;
392 return MCAsmInfoCtorFn(MRI, Triple(TheTriple), Options);
393 }
394
395 /// Create a MCObjectFileInfo implementation for the specified target
396 /// triple.
397 ///
399 bool LargeCodeModel = false) const {
400 if (!MCObjectFileInfoCtorFn) {
402 MOFI->initMCObjectFileInfo(Ctx, PIC, LargeCodeModel);
403 return MOFI;
404 }
405 return MCObjectFileInfoCtorFn(Ctx, PIC, LargeCodeModel);
406 }
407
408 /// createMCInstrInfo - Create a MCInstrInfo implementation.
409 ///
411 if (!MCInstrInfoCtorFn)
412 return nullptr;
413 return MCInstrInfoCtorFn();
414 }
415
416 /// createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
417 ///
419 if (!MCInstrAnalysisCtorFn)
420 return nullptr;
421 return MCInstrAnalysisCtorFn(Info);
422 }
423
424 /// createMCRegInfo - Create a MCRegisterInfo implementation.
425 ///
427 if (!MCRegInfoCtorFn)
428 return nullptr;
429 return MCRegInfoCtorFn(Triple(TT));
430 }
431
432 /// createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
433 ///
434 /// \param TheTriple This argument is used to determine the target machine
435 /// feature set; it should always be provided. Generally this should be
436 /// either the target triple from the module, or the target triple of the
437 /// host if that does not exist.
438 /// \param CPU This specifies the name of the target CPU.
439 /// \param Features This specifies the string representation of the
440 /// additional target features.
442 StringRef Features) const {
443 if (!MCSubtargetInfoCtorFn)
444 return nullptr;
445 return MCSubtargetInfoCtorFn(Triple(TheTriple), CPU, Features);
446 }
447
448 /// createTargetMachine - Create a target specific machine implementation
449 /// for the specified \p Triple.
450 ///
451 /// \param TT This argument is used to determine the target machine
452 /// feature set; it should always be provided. Generally this should be
453 /// either the target triple from the module, or the target triple of the
454 /// host if that does not exist.
456 StringRef TT, StringRef CPU, StringRef Features,
457 const TargetOptions &Options, std::optional<Reloc::Model> RM,
458 std::optional<CodeModel::Model> CM = std::nullopt,
459 CodeGenOptLevel OL = CodeGenOptLevel::Default, bool JIT = false) const {
460 if (!TargetMachineCtorFn)
461 return nullptr;
462 return TargetMachineCtorFn(*this, Triple(TT), CPU, Features, Options, RM,
463 CM, OL, JIT);
464 }
465
466 /// createMCAsmBackend - Create a target specific assembly parser.
468 const MCRegisterInfo &MRI,
469 const MCTargetOptions &Options) const {
470 if (!MCAsmBackendCtorFn)
471 return nullptr;
472 return MCAsmBackendCtorFn(*this, STI, MRI, Options);
473 }
474
475 /// createMCAsmParser - Create a target specific assembly parser.
476 ///
477 /// \param Parser The target independent parser implementation to use for
478 /// parsing and lexing.
480 MCAsmParser &Parser,
481 const MCInstrInfo &MII,
482 const MCTargetOptions &Options) const {
483 if (!MCAsmParserCtorFn)
484 return nullptr;
485 return MCAsmParserCtorFn(STI, Parser, MII, Options);
486 }
487
488 /// createAsmPrinter - Create a target specific assembly printer pass. This
489 /// takes ownership of the MCStreamer object.
491 std::unique_ptr<MCStreamer> &&Streamer) const {
492 if (!AsmPrinterCtorFn)
493 return nullptr;
494 return AsmPrinterCtorFn(TM, std::move(Streamer));
495 }
496
498 MCContext &Ctx) const {
499 if (!MCDisassemblerCtorFn)
500 return nullptr;
501 return MCDisassemblerCtorFn(*this, STI, Ctx);
502 }
503
504 MCInstPrinter *createMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
505 const MCAsmInfo &MAI,
506 const MCInstrInfo &MII,
507 const MCRegisterInfo &MRI) const {
508 if (!MCInstPrinterCtorFn)
509 return nullptr;
510 return MCInstPrinterCtorFn(T, SyntaxVariant, MAI, MII, MRI);
511 }
512
513 /// createMCCodeEmitter - Create a target specific code emitter.
515 MCContext &Ctx) const {
516 if (!MCCodeEmitterCtorFn)
517 return nullptr;
518 return MCCodeEmitterCtorFn(II, Ctx);
519 }
520
521 /// Create a target specific MCStreamer.
522 ///
523 /// \param T The target triple.
524 /// \param Ctx The target context.
525 /// \param TAB The target assembler backend object. Takes ownership.
526 /// \param OW The stream object.
527 /// \param Emitter The target independent assembler object.Takes ownership.
529 std::unique_ptr<MCAsmBackend> TAB,
530 std::unique_ptr<MCObjectWriter> OW,
531 std::unique_ptr<MCCodeEmitter> Emitter,
532 const MCSubtargetInfo &STI) const;
533 LLVM_DEPRECATED("Use the overload without the 3 trailing bool", "")
535 std::unique_ptr<MCAsmBackend> &&TAB,
536 std::unique_ptr<MCObjectWriter> &&OW,
537 std::unique_ptr<MCCodeEmitter> &&Emitter,
538 const MCSubtargetInfo &STI, bool, bool,
539 bool) const;
540
542 std::unique_ptr<formatted_raw_ostream> OS,
543 MCInstPrinter *IP,
544 std::unique_ptr<MCCodeEmitter> CE,
545 std::unique_ptr<MCAsmBackend> TAB) const;
546 LLVM_DEPRECATED("Use the overload without the 3 unused bool", "")
547 MCStreamer *
549 bool IsVerboseAsm, bool UseDwarfDirectory,
550 MCInstPrinter *IP, std::unique_ptr<MCCodeEmitter> &&CE,
551 std::unique_ptr<MCAsmBackend> &&TAB, bool ShowInst) const;
552
555 MCInstPrinter *InstPrint) const {
556 if (AsmTargetStreamerCtorFn)
557 return AsmTargetStreamerCtorFn(S, OS, InstPrint);
558 return nullptr;
559 }
560
564 return S;
565 }
566
568 if (NullTargetStreamerCtorFn)
569 return NullTargetStreamerCtorFn(S);
570 return nullptr;
571 }
572
573 /// createMCRelocationInfo - Create a target specific MCRelocationInfo.
574 ///
575 /// \param TT The target triple.
576 /// \param Ctx The target context.
578 MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn
579 ? MCRelocationInfoCtorFn
581 return Fn(Triple(TT), Ctx);
582 }
583
584 /// createMCSymbolizer - Create a target specific MCSymbolizer.
585 ///
586 /// \param TT The target triple.
587 /// \param GetOpInfo The function to get the symbolic information for
588 /// operands.
589 /// \param SymbolLookUp The function to lookup a symbol name.
590 /// \param DisInfo The pointer to the block of symbolic information for above
591 /// call
592 /// back.
593 /// \param Ctx The target context.
594 /// \param RelInfo The relocation information for this target. Takes
595 /// ownership.
598 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
599 MCContext *Ctx,
600 std::unique_ptr<MCRelocationInfo> &&RelInfo) const {
602 MCSymbolizerCtorFn ? MCSymbolizerCtorFn : llvm::createMCSymbolizer;
603 return Fn(Triple(TT), GetOpInfo, SymbolLookUp, DisInfo, Ctx,
604 std::move(RelInfo));
605 }
606
607 /// createCustomBehaviour - Create a target specific CustomBehaviour.
608 /// This class is used by llvm-mca and requires backend functionality.
610 const mca::SourceMgr &SrcMgr,
611 const MCInstrInfo &MCII) const {
612 if (CustomBehaviourCtorFn)
613 return CustomBehaviourCtorFn(STI, SrcMgr, MCII);
614 return nullptr;
615 }
616
617 /// createInstrPostProcess - Create a target specific InstrPostProcess.
618 /// This class is used by llvm-mca and requires backend functionality.
620 const MCInstrInfo &MCII) const {
621 if (InstrPostProcessCtorFn)
622 return InstrPostProcessCtorFn(STI, MCII);
623 return nullptr;
624 }
625
626 /// createInstrumentManager - Create a target specific
627 /// InstrumentManager. This class is used by llvm-mca and requires
628 /// backend functionality.
631 const MCInstrInfo &MCII) const {
632 if (InstrumentManagerCtorFn)
633 return InstrumentManagerCtorFn(STI, MCII);
634 return nullptr;
635 }
636
637 /// @}
638};
639
640/// TargetRegistry - Generic interface to target specific features.
642 // FIXME: Make this a namespace, probably just move all the Register*
643 // functions into Target (currently they all just set members on the Target
644 // anyway, and Target friends this class so those functions can...
645 // function).
646 TargetRegistry() = delete;
647
648 class iterator {
649 friend struct TargetRegistry;
650
651 const Target *Current = nullptr;
652
653 explicit iterator(Target *T) : Current(T) {}
654
655 public:
656 using iterator_category = std::forward_iterator_tag;
658 using difference_type = std::ptrdiff_t;
661
662 iterator() = default;
663
664 bool operator==(const iterator &x) const { return Current == x.Current; }
665 bool operator!=(const iterator &x) const { return !operator==(x); }
666
667 // Iterator traversal: forward iteration only
668 iterator &operator++() { // Preincrement
669 assert(Current && "Cannot increment end iterator!");
670 Current = Current->getNext();
671 return *this;
672 }
673 iterator operator++(int) { // Postincrement
674 iterator tmp = *this;
675 ++*this;
676 return tmp;
677 }
678
679 const Target &operator*() const {
680 assert(Current && "Cannot dereference end iterator!");
681 return *Current;
682 }
683
684 const Target *operator->() const { return &operator*(); }
685 };
686
687 /// printRegisteredTargetsForVersion - Print the registered targets
688 /// appropriately for inclusion in a tool's version output.
690
691 /// @name Registry Access
692 /// @{
693
695
696 /// lookupTarget - Lookup a target based on a target triple.
697 ///
698 /// \param Triple - The triple to use for finding a target.
699 /// \param Error - On failure, an error string describing why no target was
700 /// found.
701 static const Target *lookupTarget(StringRef Triple, std::string &Error);
702
703 /// lookupTarget - Lookup a target based on an architecture name
704 /// and a target triple. If the architecture name is non-empty,
705 /// then the lookup is done by architecture. Otherwise, the target
706 /// triple is used.
707 ///
708 /// \param ArchName - The architecture to use for finding a target.
709 /// \param TheTriple - The triple to use for finding a target. The
710 /// triple is updated with canonical architecture name if a lookup
711 /// by architecture is done.
712 /// \param Error - On failure, an error string describing why no target was
713 /// found.
714 static const Target *lookupTarget(StringRef ArchName, Triple &TheTriple,
715 std::string &Error);
716
717 /// @}
718 /// @name Target Registration
719 /// @{
720
721 /// RegisterTarget - Register the given target. Attempts to register a
722 /// target which has already been registered will be ignored.
723 ///
724 /// Clients are responsible for ensuring that registration doesn't occur
725 /// while another thread is attempting to access the registry. Typically
726 /// this is done by initializing all targets at program startup.
727 ///
728 /// @param T - The target being registered.
729 /// @param Name - The target name. This should be a static string.
730 /// @param ShortDesc - A short target description. This should be a static
731 /// string.
732 /// @param BackendName - The name of the backend. This should be a static
733 /// string that is the same for all targets that share a backend
734 /// implementation and must match the name used in the 'def X : Target ...' in
735 /// TableGen.
736 /// @param ArchMatchFn - The arch match checking function for this target.
737 /// @param HasJIT - Whether the target supports JIT code
738 /// generation.
739 static void RegisterTarget(Target &T, const char *Name, const char *ShortDesc,
740 const char *BackendName,
741 Target::ArchMatchFnTy ArchMatchFn,
742 bool HasJIT = false);
743
744 /// RegisterMCAsmInfo - Register a MCAsmInfo implementation for the
745 /// given target.
746 ///
747 /// Clients are responsible for ensuring that registration doesn't occur
748 /// while another thread is attempting to access the registry. Typically
749 /// this is done by initializing all targets at program startup.
750 ///
751 /// @param T - The target being registered.
752 /// @param Fn - A function to construct a MCAsmInfo for the target.
754 T.MCAsmInfoCtorFn = Fn;
755 }
756
757 /// Register a MCObjectFileInfo implementation for the given target.
758 ///
759 /// Clients are responsible for ensuring that registration doesn't occur
760 /// while another thread is attempting to access the registry. Typically
761 /// this is done by initializing all targets at program startup.
762 ///
763 /// @param T - The target being registered.
764 /// @param Fn - A function to construct a MCObjectFileInfo for the target.
767 T.MCObjectFileInfoCtorFn = Fn;
768 }
769
770 /// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the
771 /// given target.
772 ///
773 /// Clients are responsible for ensuring that registration doesn't occur
774 /// while another thread is attempting to access the registry. Typically
775 /// this is done by initializing all targets at program startup.
776 ///
777 /// @param T - The target being registered.
778 /// @param Fn - A function to construct a MCInstrInfo for the target.
780 T.MCInstrInfoCtorFn = Fn;
781 }
782
783 /// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for
784 /// the given target.
787 T.MCInstrAnalysisCtorFn = Fn;
788 }
789
790 /// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
791 /// given target.
792 ///
793 /// Clients are responsible for ensuring that registration doesn't occur
794 /// while another thread is attempting to access the registry. Typically
795 /// this is done by initializing all targets at program startup.
796 ///
797 /// @param T - The target being registered.
798 /// @param Fn - A function to construct a MCRegisterInfo for the target.
800 T.MCRegInfoCtorFn = Fn;
801 }
802
803 /// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for
804 /// the given target.
805 ///
806 /// Clients are responsible for ensuring that registration doesn't occur
807 /// while another thread is attempting to access the registry. Typically
808 /// this is done by initializing all targets at program startup.
809 ///
810 /// @param T - The target being registered.
811 /// @param Fn - A function to construct a MCSubtargetInfo for the target.
814 T.MCSubtargetInfoCtorFn = Fn;
815 }
816
817 /// RegisterTargetMachine - Register a TargetMachine 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 TargetMachine for the target.
827 T.TargetMachineCtorFn = Fn;
828 }
829
830 /// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
831 /// given target.
832 ///
833 /// Clients are responsible for ensuring that registration doesn't occur
834 /// while another thread is attempting to access the registry. Typically
835 /// this is done by initializing all targets at program startup.
836 ///
837 /// @param T - The target being registered.
838 /// @param Fn - A function to construct an AsmBackend for the target.
840 T.MCAsmBackendCtorFn = Fn;
841 }
842
843 /// RegisterMCAsmParser - Register a MCTargetAsmParser implementation for
844 /// the 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 an MCTargetAsmParser for the target.
853 T.MCAsmParserCtorFn = Fn;
854 }
855
856 /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
857 /// target.
858 ///
859 /// Clients are responsible for ensuring that registration doesn't occur
860 /// while another thread is attempting to access the registry. Typically
861 /// this is done by initializing all targets at program startup.
862 ///
863 /// @param T - The target being registered.
864 /// @param Fn - A function to construct an AsmPrinter for the target.
866 T.AsmPrinterCtorFn = Fn;
867 }
868
869 /// RegisterMCDisassembler - Register a MCDisassembler implementation for
870 /// the given target.
871 ///
872 /// Clients are responsible for ensuring that registration doesn't occur
873 /// while another thread is attempting to access the registry. Typically
874 /// this is done by initializing all targets at program startup.
875 ///
876 /// @param T - The target being registered.
877 /// @param Fn - A function to construct an MCDisassembler for the target.
880 T.MCDisassemblerCtorFn = Fn;
881 }
882
883 /// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the
884 /// given target.
885 ///
886 /// Clients are responsible for ensuring that registration doesn't occur
887 /// while another thread is attempting to access the registry. Typically
888 /// this is done by initializing all targets at program startup.
889 ///
890 /// @param T - The target being registered.
891 /// @param Fn - A function to construct an MCInstPrinter for the target.
893 T.MCInstPrinterCtorFn = Fn;
894 }
895
896 /// RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the
897 /// given target.
898 ///
899 /// Clients are responsible for ensuring that registration doesn't occur
900 /// while another thread is attempting to access the registry. Typically
901 /// this is done by initializing all targets at program startup.
902 ///
903 /// @param T - The target being registered.
904 /// @param Fn - A function to construct an MCCodeEmitter for the target.
906 T.MCCodeEmitterCtorFn = Fn;
907 }
908
910 T.COFFStreamerCtorFn = Fn;
911 }
912
914 T.MachOStreamerCtorFn = Fn;
915 }
916
918 T.ELFStreamerCtorFn = Fn;
919 }
920
922 T.XCOFFStreamerCtorFn = Fn;
923 }
924
927 T.NullTargetStreamerCtorFn = Fn;
928 }
929
932 T.AsmTargetStreamerCtorFn = Fn;
933 }
934
935 static void
938 T.ObjectTargetStreamerCtorFn = Fn;
939 }
940
941 /// RegisterMCRelocationInfo - Register an MCRelocationInfo
942 /// implementation for the given target.
943 ///
944 /// Clients are responsible for ensuring that registration doesn't occur
945 /// while another thread is attempting to access the registry. Typically
946 /// this is done by initializing all targets at program startup.
947 ///
948 /// @param T - The target being registered.
949 /// @param Fn - A function to construct an MCRelocationInfo for the target.
952 T.MCRelocationInfoCtorFn = Fn;
953 }
954
955 /// RegisterMCSymbolizer - Register an MCSymbolizer
956 /// implementation for the given target.
957 ///
958 /// Clients are responsible for ensuring that registration doesn't occur
959 /// while another thread is attempting to access the registry. Typically
960 /// this is done by initializing all targets at program startup.
961 ///
962 /// @param T - The target being registered.
963 /// @param Fn - A function to construct an MCSymbolizer for the target.
965 T.MCSymbolizerCtorFn = Fn;
966 }
967
968 /// RegisterCustomBehaviour - Register a CustomBehaviour
969 /// implementation for the given target.
970 ///
971 /// Clients are responsible for ensuring that registration doesn't occur
972 /// while another thread is attempting to access the registry. Typically
973 /// this is done by initializing all targets at program startup.
974 ///
975 /// @param T - The target being registered.
976 /// @param Fn - A function to construct a CustomBehaviour for the target.
979 T.CustomBehaviourCtorFn = Fn;
980 }
981
982 /// RegisterInstrPostProcess - Register an InstrPostProcess
983 /// implementation for the given target.
984 ///
985 /// Clients are responsible for ensuring that registration doesn't occur
986 /// while another thread is attempting to access the registry. Typically
987 /// this is done by initializing all targets at program startup.
988 ///
989 /// @param T - The target being registered.
990 /// @param Fn - A function to construct an InstrPostProcess for the target.
993 T.InstrPostProcessCtorFn = Fn;
994 }
995
996 /// RegisterInstrumentManager - Register an InstrumentManager
997 /// implementation for the given target.
998 ///
999 /// Clients are responsible for ensuring that registration doesn't occur
1000 /// while another thread is attempting to access the registry. Typically
1001 /// this is done by initializing all targets at program startup.
1002 ///
1003 /// @param T - The target being registered.
1004 /// @param Fn - A function to construct an InstrumentManager for the
1005 /// target.
1008 T.InstrumentManagerCtorFn = Fn;
1009 }
1010
1011 /// @}
1012};
1013
1014//===--------------------------------------------------------------------===//
1015
1016/// RegisterTarget - Helper template for registering a target, for use in the
1017/// target's initialization function. Usage:
1018///
1019///
1020/// Target &getTheFooTarget() { // The global target instance.
1021/// static Target TheFooTarget;
1022/// return TheFooTarget;
1023/// }
1024/// extern "C" void LLVMInitializeFooTargetInfo() {
1025/// RegisterTarget<Triple::foo> X(getTheFooTarget(), "foo", "Foo
1026/// description", "Foo" /* Backend Name */);
1027/// }
1028template <Triple::ArchType TargetArchType = Triple::UnknownArch,
1029 bool HasJIT = false>
1031 RegisterTarget(Target &T, const char *Name, const char *Desc,
1032 const char *BackendName) {
1034 HasJIT);
1035 }
1036
1037 static bool getArchMatch(Triple::ArchType Arch) {
1038 return Arch == TargetArchType;
1039 }
1040};
1041
1042/// RegisterMCAsmInfo - Helper template for registering a target assembly info
1043/// implementation. This invokes the static "Create" method on the class to
1044/// actually do the construction. Usage:
1045///
1046/// extern "C" void LLVMInitializeFooTarget() {
1047/// extern Target TheFooTarget;
1048/// RegisterMCAsmInfo<FooMCAsmInfo> X(TheFooTarget);
1049/// }
1050template <class MCAsmInfoImpl> struct RegisterMCAsmInfo {
1053 }
1054
1055private:
1056 static MCAsmInfo *Allocator(const MCRegisterInfo & /*MRI*/, const Triple &TT,
1057 const MCTargetOptions &Options) {
1058 return new MCAsmInfoImpl(TT, Options);
1059 }
1060};
1061
1062/// RegisterMCAsmInfoFn - Helper template for registering a target assembly info
1063/// implementation. This invokes the specified function to do the
1064/// construction. Usage:
1065///
1066/// extern "C" void LLVMInitializeFooTarget() {
1067/// extern Target TheFooTarget;
1068/// RegisterMCAsmInfoFn X(TheFooTarget, TheFunction);
1069/// }
1073 }
1074};
1075
1076/// Helper template for registering a target object file info implementation.
1077/// This invokes the static "Create" method on the class to actually do the
1078/// construction. Usage:
1079///
1080/// extern "C" void LLVMInitializeFooTarget() {
1081/// extern Target TheFooTarget;
1082/// RegisterMCObjectFileInfo<FooMCObjectFileInfo> X(TheFooTarget);
1083/// }
1084template <class MCObjectFileInfoImpl> struct RegisterMCObjectFileInfo {
1087 }
1088
1089private:
1090 static MCObjectFileInfo *Allocator(MCContext &Ctx, bool PIC,
1091 bool LargeCodeModel = false) {
1092 return new MCObjectFileInfoImpl(Ctx, PIC, LargeCodeModel);
1093 }
1094};
1095
1096/// Helper template for registering a target object file info implementation.
1097/// This invokes the specified function to do the construction. Usage:
1098///
1099/// extern "C" void LLVMInitializeFooTarget() {
1100/// extern Target TheFooTarget;
1101/// RegisterMCObjectFileInfoFn X(TheFooTarget, TheFunction);
1102/// }
1106 }
1107};
1108
1109/// RegisterMCInstrInfo - Helper template for registering a target instruction
1110/// info implementation. This invokes the static "Create" method on the class
1111/// to actually do the construction. Usage:
1112///
1113/// extern "C" void LLVMInitializeFooTarget() {
1114/// extern Target TheFooTarget;
1115/// RegisterMCInstrInfo<FooMCInstrInfo> X(TheFooTarget);
1116/// }
1117template <class MCInstrInfoImpl> struct RegisterMCInstrInfo {
1120 }
1121
1122private:
1123 static MCInstrInfo *Allocator() { return new MCInstrInfoImpl(); }
1124};
1125
1126/// RegisterMCInstrInfoFn - Helper template for registering a target
1127/// instruction info implementation. This invokes the specified function to
1128/// do the construction. Usage:
1129///
1130/// extern "C" void LLVMInitializeFooTarget() {
1131/// extern Target TheFooTarget;
1132/// RegisterMCInstrInfoFn X(TheFooTarget, TheFunction);
1133/// }
1137 }
1138};
1139
1140/// RegisterMCInstrAnalysis - Helper template for registering a target
1141/// instruction analyzer implementation. This invokes the static "Create"
1142/// method on the class to actually do the construction. Usage:
1143///
1144/// extern "C" void LLVMInitializeFooTarget() {
1145/// extern Target TheFooTarget;
1146/// RegisterMCInstrAnalysis<FooMCInstrAnalysis> X(TheFooTarget);
1147/// }
1148template <class MCInstrAnalysisImpl> struct RegisterMCInstrAnalysis {
1151 }
1152
1153private:
1154 static MCInstrAnalysis *Allocator(const MCInstrInfo *Info) {
1155 return new MCInstrAnalysisImpl(Info);
1156 }
1157};
1158
1159/// RegisterMCInstrAnalysisFn - Helper template for registering a target
1160/// instruction analyzer implementation. This invokes the specified function
1161/// to do the construction. Usage:
1162///
1163/// extern "C" void LLVMInitializeFooTarget() {
1164/// extern Target TheFooTarget;
1165/// RegisterMCInstrAnalysisFn X(TheFooTarget, TheFunction);
1166/// }
1170 }
1171};
1172
1173/// RegisterMCRegInfo - Helper template for registering a target register info
1174/// implementation. This invokes the static "Create" method on the class to
1175/// actually do the construction. Usage:
1176///
1177/// extern "C" void LLVMInitializeFooTarget() {
1178/// extern Target TheFooTarget;
1179/// RegisterMCRegInfo<FooMCRegInfo> X(TheFooTarget);
1180/// }
1181template <class MCRegisterInfoImpl> struct RegisterMCRegInfo {
1184 }
1185
1186private:
1187 static MCRegisterInfo *Allocator(const Triple & /*TT*/) {
1188 return new MCRegisterInfoImpl();
1189 }
1190};
1191
1192/// RegisterMCRegInfoFn - Helper template for registering a target register
1193/// info implementation. This invokes the specified function to do the
1194/// construction. Usage:
1195///
1196/// extern "C" void LLVMInitializeFooTarget() {
1197/// extern Target TheFooTarget;
1198/// RegisterMCRegInfoFn X(TheFooTarget, TheFunction);
1199/// }
1203 }
1204};
1205
1206/// RegisterMCSubtargetInfo - Helper template for registering a target
1207/// subtarget info implementation. This invokes the static "Create" method
1208/// on the class to actually do the construction. Usage:
1209///
1210/// extern "C" void LLVMInitializeFooTarget() {
1211/// extern Target TheFooTarget;
1212/// RegisterMCSubtargetInfo<FooMCSubtargetInfo> X(TheFooTarget);
1213/// }
1214template <class MCSubtargetInfoImpl> struct RegisterMCSubtargetInfo {
1217 }
1218
1219private:
1220 static MCSubtargetInfo *Allocator(const Triple & /*TT*/, StringRef /*CPU*/,
1221 StringRef /*FS*/) {
1222 return new MCSubtargetInfoImpl();
1223 }
1224};
1225
1226/// RegisterMCSubtargetInfoFn - Helper template for registering a target
1227/// subtarget info implementation. This invokes the specified function to
1228/// do the construction. Usage:
1229///
1230/// extern "C" void LLVMInitializeFooTarget() {
1231/// extern Target TheFooTarget;
1232/// RegisterMCSubtargetInfoFn X(TheFooTarget, TheFunction);
1233/// }
1237 }
1238};
1239
1240/// RegisterTargetMachine - Helper template for registering a target machine
1241/// implementation, for use in the target machine initialization
1242/// function. Usage:
1243///
1244/// extern "C" void LLVMInitializeFooTarget() {
1245/// extern Target TheFooTarget;
1246/// RegisterTargetMachine<FooTargetMachine> X(TheFooTarget);
1247/// }
1248template <class TargetMachineImpl> struct RegisterTargetMachine {
1251 }
1252
1253private:
1254 static TargetMachine *
1255 Allocator(const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
1256 const TargetOptions &Options, std::optional<Reloc::Model> RM,
1257 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, bool JIT) {
1258 return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL, JIT);
1259 }
1260};
1261
1262/// RegisterMCAsmBackend - Helper template for registering a target specific
1263/// assembler backend. Usage:
1264///
1265/// extern "C" void LLVMInitializeFooMCAsmBackend() {
1266/// extern Target TheFooTarget;
1267/// RegisterMCAsmBackend<FooAsmLexer> X(TheFooTarget);
1268/// }
1269template <class MCAsmBackendImpl> struct RegisterMCAsmBackend {
1272 }
1273
1274private:
1275 static MCAsmBackend *Allocator(const Target &T, const MCSubtargetInfo &STI,
1276 const MCRegisterInfo &MRI,
1277 const MCTargetOptions &Options) {
1278 return new MCAsmBackendImpl(T, STI, MRI);
1279 }
1280};
1281
1282/// RegisterMCAsmParser - Helper template for registering a target specific
1283/// assembly parser, for use in the target machine initialization
1284/// function. Usage:
1285///
1286/// extern "C" void LLVMInitializeFooMCAsmParser() {
1287/// extern Target TheFooTarget;
1288/// RegisterMCAsmParser<FooAsmParser> X(TheFooTarget);
1289/// }
1290template <class MCAsmParserImpl> struct RegisterMCAsmParser {
1293 }
1294
1295private:
1296 static MCTargetAsmParser *Allocator(const MCSubtargetInfo &STI,
1297 MCAsmParser &P, const MCInstrInfo &MII,
1298 const MCTargetOptions &Options) {
1299 return new MCAsmParserImpl(STI, P, MII, Options);
1300 }
1301};
1302
1303/// RegisterAsmPrinter - Helper template for registering a target specific
1304/// assembly printer, for use in the target machine initialization
1305/// function. Usage:
1306///
1307/// extern "C" void LLVMInitializeFooAsmPrinter() {
1308/// extern Target TheFooTarget;
1309/// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget);
1310/// }
1311template <class AsmPrinterImpl> struct RegisterAsmPrinter {
1314 }
1315
1316private:
1318 std::unique_ptr<MCStreamer> &&Streamer) {
1319 return new AsmPrinterImpl(TM, std::move(Streamer));
1320 }
1321};
1322
1323/// RegisterMCCodeEmitter - Helper template for registering a target specific
1324/// machine code emitter, for use in the target initialization
1325/// function. Usage:
1326///
1327/// extern "C" void LLVMInitializeFooMCCodeEmitter() {
1328/// extern Target TheFooTarget;
1329/// RegisterMCCodeEmitter<FooCodeEmitter> X(TheFooTarget);
1330/// }
1331template <class MCCodeEmitterImpl> struct RegisterMCCodeEmitter {
1334 }
1335
1336private:
1337 static MCCodeEmitter *Allocator(const MCInstrInfo & /*II*/,
1338 MCContext & /*Ctx*/) {
1339 return new MCCodeEmitterImpl();
1340 }
1341};
1342
1343} // end namespace llvm
1344
1345#endif // LLVM_MC_TARGETREGISTRY_H
unsigned const MachineRegisterInfo * MRI
aarch64 promote const
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
#define LLVM_DEPRECATED(MSG, FIX)
Definition: Compiler.h:153
dxil DXContainer Global Emitter
std::string Name
static LVOptions Options
Definition: LVOptions.cpp:25
uint64_t IntrinsicInst * II
#define P(N)
PassInstrumentationCallbacks PIC
Basic Register Allocator
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:86
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:42
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
Generic assembler parser interface, for use by target specific assembly parsers.
Definition: MCAsmParser.h:123
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:21
Context object for machine code objects.
Definition: MCContext.h:83
Superclass for all disassemblers.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:45
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
void initMCObjectFileInfo(MCContext &MCCtx, bool PIC, bool LargeCodeModel=false)
Defines the object file and target independent interfaces used by the assembler backend to write nati...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Create MCExprs from relocations found in an object file.
Streaming machine code generation interface.
Definition: MCStreamer.h:213
Generic base class for all target subtargets.
Symbolize and annotate disassembled instructions.
Definition: MCSymbolizer.h:39
MCTargetAsmParser - Generic interface to target specific assembly parsers.
Target specific streamer interface.
Definition: MCStreamer.h:94
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
bool operator!=(const iterator &x) const
const Target * operator->() const
bool operator==(const iterator &x) const
const Target & operator*() const
std::forward_iterator_tag iterator_category
Target - Wrapper for Target specific information.
MCTargetStreamer *(*)(MCStreamer &S) NullTargetStreamerCtorTy
MCStreamer *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) XCOFFStreamerCtorTy
MCDisassembler *(*)(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx) MCDisassemblerCtorTy
Target()=default
mca::InstrPostProcess *(*)(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) InstrPostProcessCtorTy
MCAsmInfo *(*)(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options) MCAsmInfoCtorFnTy
bool hasTargetMachine() const
hasTargetMachine - Check if this target supports code generation.
TargetMachine *(*)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT) TargetMachineCtorTy
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
const char * getName() const
getName - Get the target name.
MCObjectFileInfo * createMCObjectFileInfo(MCContext &Ctx, bool PIC, bool LargeCodeModel=false) const
Create a MCObjectFileInfo implementation for the specified target triple.
const Target * getNext() const
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
AsmPrinter *(*)(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) AsmPrinterCtorTy
MCSymbolizer * createMCSymbolizer(StringRef TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo) const
createMCSymbolizer - Create a target specific MCSymbolizer.
MCAsmBackend * createMCAsmBackend(const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) const
createMCAsmBackend - Create a target specific assembly parser.
MCObjectFileInfo *(*)(MCContext &Ctx, bool PIC, bool LargeCodeModel) MCObjectFileInfoCtorFnTy
bool hasMCAsmParser() const
hasMCAsmParser - Check if this target supports assembly parsing.
MCStreamer * createNullStreamer(MCContext &Ctx) const
MCRelocationInfo * createMCRelocationInfo(StringRef TT, MCContext &Ctx) const
createMCRelocationInfo - Create a target specific MCRelocationInfo.
MCStreamer *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) ELFStreamerCtorTy
MCTargetStreamer * createAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint) const
MCInstrAnalysis *(*)(const MCInstrInfo *Info) MCInstrAnalysisCtorFnTy
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
MCTargetStreamer *(*)(MCStreamer &S, const MCSubtargetInfo &STI) ObjectTargetStreamerCtorTy
MCRegisterInfo *(*)(const Triple &TT) MCRegInfoCtorFnTy
MCInstrInfo *(*)() MCInstrInfoCtorFnTy
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) const
Create a target specific MCStreamer.
mca::CustomBehaviour * createCustomBehaviour(const MCSubtargetInfo &STI, const mca::SourceMgr &SrcMgr, const MCInstrInfo &MCII) const
createCustomBehaviour - Create a target specific CustomBehaviour.
bool(*)(Triple::ArchType Arch) ArchMatchFnTy
MCInstPrinter *(*)(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) MCInstPrinterCtorTy
MCDisassembler * createMCDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) const
mca::CustomBehaviour *(*)(const MCSubtargetInfo &STI, const mca::SourceMgr &SrcMgr, const MCInstrInfo &MCII) CustomBehaviourCtorTy
TargetMachine * createTargetMachine(StringRef TT, StringRef CPU, StringRef Features, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM=std::nullopt, CodeGenOptLevel OL=CodeGenOptLevel::Default, bool JIT=false) const
createTargetMachine - Create a target specific machine implementation for the specified Triple.
bool hasMCAsmBackend() const
hasMCAsmBackend - Check if this target supports .o generation.
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple, const MCTargetOptions &Options) const
createMCAsmInfo - Create a MCAsmInfo implementation for the specified target triple.
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
MCSymbolizer *(*)(const Triple &TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo) MCSymbolizerCtorTy
MCSubtargetInfo *(*)(const Triple &TT, StringRef CPU, StringRef Features) MCSubtargetInfoCtorFnTy
mca::InstrPostProcess * createInstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) const
createInstrPostProcess - Create a target specific InstrPostProcess.
const char * getBackendName() const
getBackendName - Get the backend name.
MCTargetStreamer *(*)(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint) AsmTargetStreamerCtorTy
MCAsmBackend *(*)(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) MCAsmBackendCtorTy
MCTargetAsmParser * createMCAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser, const MCInstrInfo &MII, const MCTargetOptions &Options) const
createMCAsmParser - Create a target specific assembly parser.
MCInstrAnalysis * createMCInstrAnalysis(const MCInstrInfo *Info) const
createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
const char * getShortDescription() const
getShortDescription - Get a short description of the target.
bool hasJIT() const
hasJIT - Check if this targets supports the just-in-time compilation.
MCCodeEmitter *(*)(const MCInstrInfo &II, MCContext &Ctx) MCCodeEmitterCtorTy
mca::InstrumentManager *(*)(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) InstrumentManagerCtorTy
MCStreamer *(*)(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) COFFStreamerCtorTy
MCTargetStreamer * createNullTargetStreamer(MCStreamer &S) const
MCRelocationInfo *(*)(const Triple &TT, MCContext &Ctx) MCRelocationInfoCtorTy
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, MCInstPrinter *IP, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCAsmBackend > TAB) const
MCTargetAsmParser *(*)(const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII, const MCTargetOptions &Options) MCAsmParserCtorTy
MCStreamer *(*)(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) MachOStreamerCtorTy
AsmPrinter * createAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) const
createAsmPrinter - Create a target specific assembly printer pass.
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
mca::InstrumentManager * createInstrumentManager(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) const
createInstrumentManager - Create a target specific InstrumentManager.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
@ UnknownArch
Definition: Triple.h:47
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
A range adaptor for a pair of iterators.
Class which can be overriden by targets to enforce instruction dependencies and behaviours that aren'...
Class which can be overriden by targets to modify the mca::Instruction objects before the pipeline st...
This class allows targets to optionally customize the logic that resolves scheduling class IDs.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
const char *(* LLVMSymbolLookupCallback)(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
The type for the symbol lookup function.
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.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
mca::CustomBehaviour * createCustomBehaviour(const MCSubtargetInfo &STI, const mca::SourceMgr &SrcMgr, const MCInstrInfo &MCII)
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, MCInstPrinter *InstPrint, std::unique_ptr< MCCodeEmitter > &&CE, std::unique_ptr< MCAsmBackend > &&TAB)
Create a machine code streamer which will print out assembly for the native target,...
MCStreamer * createELFStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
MCStreamer * createNullStreamer(MCContext &Ctx)
Create a dummy machine code streamer, which does nothing.
MCSymbolizer * createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo)
MCStreamer * createMachOStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool DWARFMustBeAtTheEnd, bool LabelSections=false)
SourceMgr SrcMgr
Definition: Error.cpp:24
MCRelocationInfo * createMCRelocationInfo(const Triple &TT, MCContext &Ctx)
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:54
MCStreamer * createDXContainerStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
mca::InstrumentManager * createInstrumentManager(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
MCStreamer * createWasmStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
MCStreamer * createGOFFStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
MCStreamer * createSPIRVStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
mca::InstrPostProcess * createInstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
Description of the encoding of one expression Op.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
RegisterMCAsmBackend - Helper template for registering a target specific assembler backend.
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
RegisterMCAsmInfoFn(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCAsmInfo - Helper template for registering a target assembly info implementation.
RegisterMCAsmParser - Helper template for registering a target specific assembly parser,...
RegisterMCCodeEmitter - Helper template for registering a target specific machine code emitter,...
RegisterMCInstrAnalysisFn - Helper template for registering a target instruction analyzer implementat...
RegisterMCInstrAnalysisFn(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
RegisterMCInstrAnalysis - Helper template for registering a target instruction analyzer implementatio...
RegisterMCInstrInfoFn - Helper template for registering a target instruction info implementation.
RegisterMCInstrInfoFn(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Helper template for registering a target instruction info implementation.
Helper template for registering a target object file info implementation.
RegisterMCObjectFileInfoFn(Target &T, Target::MCObjectFileInfoCtorFnTy Fn)
Helper template for registering a target object file info implementation.
RegisterMCRegInfoFn - Helper template for registering a target register info implementation.
RegisterMCRegInfoFn(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Helper template for registering a target register info implementation.
RegisterMCSubtargetInfoFn - Helper template for registering a target subtarget info implementation.
RegisterMCSubtargetInfoFn(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Helper template for registering a target subtarget info implementation.
RegisterTargetMachine - Helper template for registering a target machine implementation,...
RegisterTarget - Helper template for registering a target, for use in the target's initialization fun...
static bool getArchMatch(Triple::ArchType Arch)
RegisterTarget(Target &T, const char *Name, const char *Desc, const char *BackendName)
TargetRegistry - Generic interface to target specific features.
static void RegisterMCSymbolizer(Target &T, Target::MCSymbolizerCtorTy Fn)
RegisterMCSymbolizer - Register an MCSymbolizer implementation for the given target.
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn)
RegisterAsmPrinter - Register an AsmPrinter implementation for the given target.
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
static void RegisterXCOFFStreamer(Target &T, Target::XCOFFStreamerCtorTy Fn)
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCAsmInfo - Register a MCAsmInfo implementation for the given target.
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
static void RegisterMCInstrAnalysis(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for the given target.
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn)
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
static void RegisterInstrPostProcess(Target &T, Target::InstrPostProcessCtorTy Fn)
RegisterInstrPostProcess - Register an InstrPostProcess implementation for the given target.
static const Target * lookupTarget(StringRef Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.
static void RegisterMCAsmParser(Target &T, Target::MCAsmParserCtorTy Fn)
RegisterMCAsmParser - Register a MCTargetAsmParser implementation for the given target.
static void printRegisteredTargetsForVersion(raw_ostream &OS)
printRegisteredTargetsForVersion - Print the registered targets appropriately for inclusion in a tool...
static void RegisterTargetMachine(Target &T, Target::TargetMachineCtorTy Fn)
RegisterTargetMachine - Register a TargetMachine implementation for the given target.
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterCOFFStreamer(Target &T, Target::COFFStreamerCtorTy Fn)
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.
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
static iterator_range< iterator > targets()
static void RegisterInstrumentManager(Target &T, Target::InstrumentManagerCtorTy Fn)
RegisterInstrumentManager - Register an InstrumentManager implementation for the given target.
static void RegisterCustomBehaviour(Target &T, Target::CustomBehaviourCtorTy Fn)
RegisterCustomBehaviour - Register a CustomBehaviour implementation for the given target.
static void RegisterMachOStreamer(Target &T, Target::MachOStreamerCtorTy Fn)
static void RegisterMCObjectFileInfo(Target &T, Target::MCObjectFileInfoCtorFnTy Fn)
Register a MCObjectFileInfo implementation for the given target.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
static void RegisterMCRelocationInfo(Target &T, Target::MCRelocationInfoCtorTy Fn)
RegisterMCRelocationInfo - Register an MCRelocationInfo implementation for the given target.
Abstracting the input code sequence (a sequence of MCInst) and assigning unique identifiers to every ...
Definition: SourceMgr.h:29