LLVM 23.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 MCLFIRewriter;
50class MCObjectWriter;
51class MCRegisterInfo;
53class MCStreamer;
54class MCSubtargetInfo;
55class MCSymbolizer;
57class MCTargetOptions;
59class raw_ostream;
60class TargetMachine;
61class TargetOptions;
62namespace mca {
63class CustomBehaviour;
66struct SourceMgr;
67} // namespace mca
68
70// Takes ownership of \p TAB and \p CE.
71
72/// Create a machine code streamer which will print out assembly for the native
73/// target, suitable for compiling with a native assembler.
74///
75/// \param InstPrint - If given, the instruction printer to use. If not given
76/// the MCInst representation will be printed. This method takes ownership of
77/// InstPrint.
78///
79/// \param CE - If given, a code emitter to use to show the instruction
80/// encoding inline with the assembly. This method takes ownership of \p CE.
81///
82/// \param TAB - If given, a target asm backend to use to show the fixup
83/// information in conjunction with encoding information. This method takes
84/// ownership of \p TAB.
85///
86/// \param ShowInst - Whether to show the MCInst representation inline with
87/// the assembly.
89createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS,
90 std::unique_ptr<MCInstPrinter> InstPrint,
91 std::unique_ptr<MCCodeEmitter> CE,
92 std::unique_ptr<MCAsmBackend> TAB);
93
95 std::unique_ptr<MCAsmBackend> &&TAB,
96 std::unique_ptr<MCObjectWriter> &&OW,
97 std::unique_ptr<MCCodeEmitter> &&CE);
99 std::unique_ptr<MCAsmBackend> &&TAB,
100 std::unique_ptr<MCObjectWriter> &&OW,
101 std::unique_ptr<MCCodeEmitter> &&CE);
103 std::unique_ptr<MCAsmBackend> &&TAB,
104 std::unique_ptr<MCObjectWriter> &&OW,
105 std::unique_ptr<MCCodeEmitter> &&CE,
106 bool DWARFMustBeAtTheEnd,
107 bool LabelSections = false);
109 std::unique_ptr<MCAsmBackend> &&TAB,
110 std::unique_ptr<MCObjectWriter> &&OW,
111 std::unique_ptr<MCCodeEmitter> &&CE);
113 std::unique_ptr<MCAsmBackend> &&TAB,
114 std::unique_ptr<MCObjectWriter> &&OW,
115 std::unique_ptr<MCCodeEmitter> &&CE);
117createDXContainerStreamer(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
118 std::unique_ptr<MCObjectWriter> &&OW,
119 std::unique_ptr<MCCodeEmitter> &&CE);
120
122 MCContext &Ctx);
123
125createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
126 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
127 MCContext *Ctx, std::unique_ptr<MCRelocationInfo> &&RelInfo);
128
131 const MCInstrInfo &MCII);
132
135
138
139/// Target - Wrapper for Target specific information.
140///
141/// For registration purposes, this is a POD type so that targets can be
142/// registered without the use of static constructors.
143///
144/// Targets should implement a single global instance of this class (which
145/// will be zero initialized), and pass that instance to the TargetRegistry as
146/// part of their initialization.
147class Target {
148public:
149 friend struct TargetRegistry;
150
152
154 const Triple &TT,
155 const MCTargetOptions &Options);
157 bool PIC,
158 bool LargeCodeModel);
161 using MCRegInfoCtorFnTy = MCRegisterInfo *(*)(const Triple &TT);
163 StringRef CPU,
164 StringRef Features);
166 *(*)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
167 const TargetOptions &Options, std::optional<Reloc::Model> RM,
168 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, bool JIT);
169 // If it weren't for layering issues (this header is in llvm/Support, but
170 // depends on MC?) this should take the Streamer by value rather than rvalue
171 // reference.
173 TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
175 const MCSubtargetInfo &STI,
176 const MCRegisterInfo &MRI,
177 const MCTargetOptions &Options);
179 const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
180 const MCTargetOptions &Options);
182 const MCSubtargetInfo &STI,
183 MCContext &Ctx);
185 unsigned SyntaxVariant,
186 const MCAsmInfo &MAI,
187 const MCInstrInfo &MII,
188 const MCRegisterInfo &MRI);
190 MCContext &Ctx);
192 MCStreamer *(*)(const Triple &T, MCContext &Ctx,
193 std::unique_ptr<MCAsmBackend> &&TAB,
194 std::unique_ptr<MCObjectWriter> &&OW,
195 std::unique_ptr<MCCodeEmitter> &&Emitter);
197 MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
198 std::unique_ptr<MCObjectWriter> &&OW,
199 std::unique_ptr<MCCodeEmitter> &&Emitter);
201 MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
202 std::unique_ptr<MCObjectWriter> &&OW,
203 std::unique_ptr<MCCodeEmitter> &&Emitter);
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);
209
213 MCInstPrinter *InstPrint);
215 *(*)(MCContext & Ctx, std::unique_ptr<formatted_raw_ostream> OS,
216 std::unique_ptr<MCInstPrinter> IP, std::unique_ptr<MCCodeEmitter> CE,
217 std::unique_ptr<MCAsmBackend> TAB);
219 MCTargetStreamer *(*)(MCStreamer &S, const MCSubtargetInfo &STI);
221 MCContext &Ctx);
223 MCSymbolizer *(*)(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
224 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
225 MCContext *Ctx,
226 std::unique_ptr<MCRelocationInfo> &&RelInfo);
227
230 const mca::SourceMgr &SrcMgr,
231 const MCInstrInfo &MCII);
232
235 const MCInstrInfo &MCII);
236
239 const MCInstrInfo &MCII);
240
242 MCLFIRewriter *(*)(MCStreamer & S,
243 std::unique_ptr<MCRegisterInfo> &&RegInfo,
244 std::unique_ptr<MCInstrInfo> &&InstInfo);
245
246private:
247 /// Next - The next registered target in the linked list, maintained by the
248 /// TargetRegistry.
249 Target *Next;
250
251 /// The target function for checking if an architecture is supported.
252 ArchMatchFnTy ArchMatchFn;
253
254 /// Name - The target name.
255 const char *Name;
256
257 /// ShortDesc - A short description of the target.
258 const char *ShortDesc;
259
260 /// BackendName - The name of the backend implementation. This must match the
261 /// name of the 'def X : Target ...' in TableGen.
262 const char *BackendName;
263
264 /// HasJIT - Whether this target supports the JIT.
265 bool HasJIT;
266
267 /// MCAsmInfoCtorFn - Constructor function for this target's MCAsmInfo, if
268 /// registered.
269 MCAsmInfoCtorFnTy MCAsmInfoCtorFn;
270
271 /// Constructor function for this target's MCObjectFileInfo, if registered.
272 MCObjectFileInfoCtorFnTy MCObjectFileInfoCtorFn;
273
274 /// MCInstrInfoCtorFn - Constructor function for this target's MCInstrInfo,
275 /// if registered.
276 MCInstrInfoCtorFnTy MCInstrInfoCtorFn;
277
278 /// MCInstrAnalysisCtorFn - Constructor function for this target's
279 /// MCInstrAnalysis, if registered.
280 MCInstrAnalysisCtorFnTy MCInstrAnalysisCtorFn;
281
282 /// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
283 /// if registered.
284 MCRegInfoCtorFnTy MCRegInfoCtorFn;
285
286 /// MCSubtargetInfoCtorFn - Constructor function for this target's
287 /// MCSubtargetInfo, if registered.
288 MCSubtargetInfoCtorFnTy MCSubtargetInfoCtorFn;
289
290 /// TargetMachineCtorFn - Construction function for this target's
291 /// TargetMachine, if registered.
292 TargetMachineCtorTy TargetMachineCtorFn;
293
294 /// MCAsmBackendCtorFn - Construction function for this target's
295 /// MCAsmBackend, if registered.
296 MCAsmBackendCtorTy MCAsmBackendCtorFn;
297
298 /// MCAsmParserCtorFn - Construction function for this target's
299 /// MCTargetAsmParser, if registered.
300 MCAsmParserCtorTy MCAsmParserCtorFn;
301
302 /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
303 /// if registered.
304 AsmPrinterCtorTy AsmPrinterCtorFn;
305
306 /// MCDisassemblerCtorFn - Construction function for this target's
307 /// MCDisassembler, if registered.
308 MCDisassemblerCtorTy MCDisassemblerCtorFn;
309
310 /// MCInstPrinterCtorFn - Construction function for this target's
311 /// MCInstPrinter, if registered.
312 MCInstPrinterCtorTy MCInstPrinterCtorFn;
313
314 /// MCCodeEmitterCtorFn - Construction function for this target's
315 /// CodeEmitter, if registered.
316 MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
317
318 // Construction functions for the various object formats, if registered.
319 COFFStreamerCtorTy COFFStreamerCtorFn = nullptr;
320 MachOStreamerCtorTy MachOStreamerCtorFn = nullptr;
321 ELFStreamerCtorTy ELFStreamerCtorFn = nullptr;
322 XCOFFStreamerCtorTy XCOFFStreamerCtorFn = nullptr;
323
324 /// Construction function for this target's null TargetStreamer, if
325 /// registered (default = nullptr).
326 NullTargetStreamerCtorTy NullTargetStreamerCtorFn = nullptr;
327
328 /// Construction function for this target's asm TargetStreamer, if
329 /// registered (default = nullptr).
330 AsmTargetStreamerCtorTy AsmTargetStreamerCtorFn = nullptr;
331
332 /// Construction function for this target's AsmStreamer, if
333 /// registered (default = nullptr).
334 AsmStreamerCtorTy AsmStreamerCtorFn = nullptr;
335
336 /// Construction function for this target's obj TargetStreamer, if
337 /// registered (default = nullptr).
338 ObjectTargetStreamerCtorTy ObjectTargetStreamerCtorFn = nullptr;
339
340 /// MCRelocationInfoCtorFn - Construction function for this target's
341 /// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
342 MCRelocationInfoCtorTy MCRelocationInfoCtorFn = nullptr;
343
344 /// MCSymbolizerCtorFn - Construction function for this target's
345 /// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
346 MCSymbolizerCtorTy MCSymbolizerCtorFn = nullptr;
347
348 /// CustomBehaviourCtorFn - Construction function for this target's
349 /// CustomBehaviour, if registered (default = nullptr).
350 CustomBehaviourCtorTy CustomBehaviourCtorFn = nullptr;
351
352 /// InstrPostProcessCtorFn - Construction function for this target's
353 /// InstrPostProcess, if registered (default = nullptr).
354 InstrPostProcessCtorTy InstrPostProcessCtorFn = nullptr;
355
356 /// InstrumentManagerCtorFn - Construction function for this target's
357 /// InstrumentManager, if registered (default = nullptr).
358 InstrumentManagerCtorTy InstrumentManagerCtorFn = nullptr;
359
360 // MCLFIRewriterCtorFn - Construction function for this target's
361 // MCLFIRewriter, if registered (default = nullptr).
362 MCLFIRewriterCtorTy MCLFIRewriterCtorFn = nullptr;
363
364public:
365 Target() = default;
366
367 /// @name Target Information
368 /// @{
369
370 // getNext - Return the next registered target.
371 const Target *getNext() const { return Next; }
372
373 /// getName - Get the target name.
374 const char *getName() const { return Name; }
375
376 /// getShortDescription - Get a short description of the target.
377 const char *getShortDescription() const { return ShortDesc; }
378
379 /// getBackendName - Get the backend name.
380 const char *getBackendName() const { return BackendName; }
381
382 /// @}
383 /// @name Feature Predicates
384 /// @{
385
386 /// hasJIT - Check if this targets supports the just-in-time compilation.
387 bool hasJIT() const { return HasJIT; }
388
389 /// hasTargetMachine - Check if this target supports code generation.
390 bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
391
392 /// hasMCAsmBackend - Check if this target supports .o generation.
393 bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
394
395 /// hasMCAsmParser - Check if this target supports assembly parsing.
396 bool hasMCAsmParser() const { return MCAsmParserCtorFn != nullptr; }
397
398 /// @}
399 /// @name Feature Constructors
400 /// @{
401
402 /// Create a MCAsmInfo implementation for the specified
403 /// target triple.
404 ///
405 /// \param TheTriple This argument is used to determine the target machine
406 /// feature set; it should always be provided. Generally this should be
407 /// either the target triple from the module, or the target triple of the
408 /// host if that does not exist.
410 const MCTargetOptions &Options) const {
411 if (!MCAsmInfoCtorFn)
412 return nullptr;
413 return MCAsmInfoCtorFn(MRI, TheTriple, Options);
414 }
415
416 /// Create a MCObjectFileInfo implementation for the specified target
417 /// triple.
418 ///
420 bool LargeCodeModel = false) const {
421 if (!MCObjectFileInfoCtorFn) {
423 MOFI->initMCObjectFileInfo(Ctx, PIC, LargeCodeModel);
424 return MOFI;
425 }
426 return MCObjectFileInfoCtorFn(Ctx, PIC, LargeCodeModel);
427 }
428
429 /// createMCInstrInfo - Create a MCInstrInfo implementation.
430 ///
432 if (!MCInstrInfoCtorFn)
433 return nullptr;
434 return MCInstrInfoCtorFn();
435 }
436
437 /// createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
438 ///
440 if (!MCInstrAnalysisCtorFn)
441 return nullptr;
442 return MCInstrAnalysisCtorFn(Info);
443 }
444
445 /// Create a MCRegisterInfo implementation.
447 if (!MCRegInfoCtorFn)
448 return nullptr;
449 return MCRegInfoCtorFn(TT);
450 }
451
452 /// createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
453 ///
454 /// \param TheTriple This argument is used to determine the target machine
455 /// feature set; it should always be provided. Generally this should be
456 /// either the target triple from the module, or the target triple of the
457 /// host if that does not exist.
458 /// \param CPU This specifies the name of the target CPU.
459 /// \param Features This specifies the string representation of the
460 /// additional target features.
462 StringRef Features) const {
463 if (!MCSubtargetInfoCtorFn)
464 return nullptr;
465 return MCSubtargetInfoCtorFn(TheTriple, CPU, Features);
466 }
467
468 /// createTargetMachine - Create a target specific machine implementation
469 /// for the specified \p Triple.
470 ///
471 /// \param TT This argument is used to determine the target machine
472 /// feature set; it should always be provided. Generally this should be
473 /// either the target triple from the module, or the target triple of the
474 /// host if that does not exist.
476 const Triple &TT, StringRef CPU, StringRef Features,
477 const TargetOptions &Options, std::optional<Reloc::Model> RM,
478 std::optional<CodeModel::Model> CM = std::nullopt,
479 CodeGenOptLevel OL = CodeGenOptLevel::Default, bool JIT = false) const {
480 if (!TargetMachineCtorFn)
481 return nullptr;
482 return TargetMachineCtorFn(*this, TT, CPU, Features, Options, RM, CM, OL,
483 JIT);
484 }
485
486 /// createMCAsmBackend - Create a target specific assembly parser.
488 const MCRegisterInfo &MRI,
489 const MCTargetOptions &Options) const {
490 if (!MCAsmBackendCtorFn)
491 return nullptr;
492 return MCAsmBackendCtorFn(*this, STI, MRI, Options);
493 }
494
495 /// createMCAsmParser - Create a target specific assembly parser.
496 ///
497 /// \param Parser The target independent parser implementation to use for
498 /// parsing and lexing.
500 MCAsmParser &Parser,
501 const MCInstrInfo &MII,
502 const MCTargetOptions &Options) const {
503 if (!MCAsmParserCtorFn)
504 return nullptr;
505 return MCAsmParserCtorFn(STI, Parser, MII, Options);
506 }
507
508 /// createAsmPrinter - Create a target specific assembly printer pass. This
509 /// takes ownership of the MCStreamer object.
511 std::unique_ptr<MCStreamer> &&Streamer) const {
512 if (!AsmPrinterCtorFn)
513 return nullptr;
514 return AsmPrinterCtorFn(TM, std::move(Streamer));
515 }
516
518 MCContext &Ctx) const {
519 if (!MCDisassemblerCtorFn)
520 return nullptr;
521 return MCDisassemblerCtorFn(*this, STI, Ctx);
522 }
523
524 MCInstPrinter *createMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
525 const MCAsmInfo &MAI,
526 const MCInstrInfo &MII,
527 const MCRegisterInfo &MRI) const {
528 if (!MCInstPrinterCtorFn)
529 return nullptr;
530 return MCInstPrinterCtorFn(T, SyntaxVariant, MAI, MII, MRI);
531 }
532
533 /// createMCCodeEmitter - Create a target specific code emitter.
535 MCContext &Ctx) const {
536 if (!MCCodeEmitterCtorFn)
537 return nullptr;
538 return MCCodeEmitterCtorFn(II, Ctx);
539 }
540
541 /// Create a target specific MCStreamer.
542 ///
543 /// \param T The target triple.
544 /// \param Ctx The target context.
545 /// \param TAB The target assembler backend object. Takes ownership.
546 /// \param OW The stream object.
547 /// \param Emitter The target independent assembler object.Takes ownership.
549 const Triple &T, MCContext &Ctx, std::unique_ptr<MCAsmBackend> TAB,
550 std::unique_ptr<MCObjectWriter> OW,
551 std::unique_ptr<MCCodeEmitter> Emitter, const MCSubtargetInfo &STI) const;
552
554 createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS,
555 std::unique_ptr<MCInstPrinter> IP,
556 std::unique_ptr<MCCodeEmitter> CE,
557 std::unique_ptr<MCAsmBackend> TAB) const;
558
561 MCInstPrinter *InstPrint) const {
562 if (AsmTargetStreamerCtorFn)
563 return AsmTargetStreamerCtorFn(S, OS, InstPrint);
564 return nullptr;
565 }
566
570 return S;
571 }
572
574 if (NullTargetStreamerCtorFn)
575 return NullTargetStreamerCtorFn(S);
576 return nullptr;
577 }
578
580 std::unique_ptr<MCRegisterInfo> &&RegInfo,
581 std::unique_ptr<MCInstrInfo> &&InstInfo) const {
582 if (MCLFIRewriterCtorFn)
583 MCLFIRewriterCtorFn(S, std::move(RegInfo), std::move(InstInfo));
584 }
585
586 /// createMCRelocationInfo - Create a target specific MCRelocationInfo.
587 ///
588 /// \param TT The target triple.
589 /// \param Ctx The target context.
591 MCContext &Ctx) const {
592 MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn
593 ? MCRelocationInfoCtorFn
595 return Fn(TT, Ctx);
596 }
597
598 /// createMCSymbolizer - Create a target specific MCSymbolizer.
599 ///
600 /// \param TT The target triple.
601 /// \param GetOpInfo The function to get the symbolic information for
602 /// operands.
603 /// \param SymbolLookUp The function to lookup a symbol name.
604 /// \param DisInfo The pointer to the block of symbolic information for above
605 /// call
606 /// back.
607 /// \param Ctx The target context.
608 /// \param RelInfo The relocation information for this target. Takes
609 /// ownership.
612 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
613 MCContext *Ctx,
614 std::unique_ptr<MCRelocationInfo> &&RelInfo) const {
616 MCSymbolizerCtorFn ? MCSymbolizerCtorFn : llvm::createMCSymbolizer;
617 return Fn(TT, GetOpInfo, SymbolLookUp, DisInfo, Ctx, std::move(RelInfo));
618 }
619
620 /// createCustomBehaviour - Create a target specific CustomBehaviour.
621 /// This class is used by llvm-mca and requires backend functionality.
623 const mca::SourceMgr &SrcMgr,
624 const MCInstrInfo &MCII) const {
625 if (CustomBehaviourCtorFn)
626 return CustomBehaviourCtorFn(STI, SrcMgr, MCII);
627 return nullptr;
628 }
629
630 /// createInstrPostProcess - Create a target specific InstrPostProcess.
631 /// This class is used by llvm-mca and requires backend functionality.
633 const MCInstrInfo &MCII) const {
634 if (InstrPostProcessCtorFn)
635 return InstrPostProcessCtorFn(STI, MCII);
636 return nullptr;
637 }
638
639 /// createInstrumentManager - Create a target specific
640 /// InstrumentManager. This class is used by llvm-mca and requires
641 /// backend functionality.
644 const MCInstrInfo &MCII) const {
645 if (InstrumentManagerCtorFn)
646 return InstrumentManagerCtorFn(STI, MCII);
647 return nullptr;
648 }
649
650 /// @}
651};
652
653/// TargetRegistry - Generic interface to target specific features.
655 // FIXME: Make this a namespace, probably just move all the Register*
656 // functions into Target (currently they all just set members on the Target
657 // anyway, and Target friends this class so those functions can...
658 // function).
659 TargetRegistry() = delete;
660
661 class iterator {
662 friend struct TargetRegistry;
663
664 const Target *Current = nullptr;
665
666 explicit iterator(Target *T) : Current(T) {}
667
668 public:
669 using iterator_category = std::forward_iterator_tag;
671 using difference_type = std::ptrdiff_t;
674
675 iterator() = default;
676
677 bool operator==(const iterator &x) const { return Current == x.Current; }
678 bool operator!=(const iterator &x) const { return !operator==(x); }
679
680 // Iterator traversal: forward iteration only
681 iterator &operator++() { // Preincrement
682 assert(Current && "Cannot increment end iterator!");
683 Current = Current->getNext();
684 return *this;
685 }
686 iterator operator++(int) { // Postincrement
687 iterator tmp = *this;
688 ++*this;
689 return tmp;
690 }
691
692 const Target &operator*() const {
693 assert(Current && "Cannot dereference end iterator!");
694 return *Current;
695 }
696
697 const Target *operator->() const { return &operator*(); }
698 };
699
700 /// printRegisteredTargetsForVersion - Print the registered targets
701 /// appropriately for inclusion in a tool's version output.
703
704 /// @name Registry Access
705 /// @{
706
708
709 /// lookupTarget - Lookup a target based on a target triple.
710 ///
711 /// \param TripleStr - The triple to use for finding a target.
712 /// \param Error - On failure, an error string describing why no target was
713 /// found.
714 // TODO(boomanaiden154): Remove this function after LLVM 22 branches.
715 [[deprecated("Use overload accepting Triple instead")]]
716 static const Target *lookupTarget(StringRef TripleStr, std::string &Error) {
717 return lookupTarget(Triple(TripleStr), Error);
718 }
719
720 /// lookupTarget - Lookup a target based on a target triple.
721 ///
722 /// \param Triple - The triple to use for finding a target.
723 /// \param Error - On failure, an error string describing why no target was
724 /// found.
725 LLVM_ABI static const Target *lookupTarget(const Triple &TheTriple,
726 std::string &Error);
727
728 /// lookupTarget - Lookup a target based on an architecture name
729 /// and a target triple. If the architecture name is non-empty,
730 /// then the lookup is done by architecture. Otherwise, the target
731 /// triple is used.
732 ///
733 /// \param ArchName - The architecture to use for finding a target.
734 /// \param TheTriple - The triple to use for finding a target. The
735 /// triple is updated with canonical architecture name if a lookup
736 /// by architecture is done.
737 /// \param Error - On failure, an error string describing why no target was
738 /// found.
739 LLVM_ABI static const Target *
740 lookupTarget(StringRef ArchName, Triple &TheTriple, std::string &Error);
741
742 /// @}
743 /// @name Target Registration
744 /// @{
745
746 /// RegisterTarget - Register the given target. Attempts to register a
747 /// target which has already been registered will be ignored.
748 ///
749 /// Clients are responsible for ensuring that registration doesn't occur
750 /// while another thread is attempting to access the registry. Typically
751 /// this is done by initializing all targets at program startup.
752 ///
753 /// @param T - The target being registered.
754 /// @param Name - The target name. This should be a static string.
755 /// @param ShortDesc - A short target description. This should be a static
756 /// string.
757 /// @param BackendName - The name of the backend. This should be a static
758 /// string that is the same for all targets that share a backend
759 /// implementation and must match the name used in the 'def X : Target ...' in
760 /// TableGen.
761 /// @param ArchMatchFn - The arch match checking function for this target.
762 /// @param HasJIT - Whether the target supports JIT code
763 /// generation.
764 LLVM_ABI static void RegisterTarget(Target &T, const char *Name,
765 const char *ShortDesc,
766 const char *BackendName,
767 Target::ArchMatchFnTy ArchMatchFn,
768 bool HasJIT = false);
769
770 /// RegisterMCAsmInfo - Register a MCAsmInfo 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 MCAsmInfo for the target.
780 T.MCAsmInfoCtorFn = Fn;
781 }
782
783 /// Register a MCObjectFileInfo implementation for the given target.
784 ///
785 /// Clients are responsible for ensuring that registration doesn't occur
786 /// while another thread is attempting to access the registry. Typically
787 /// this is done by initializing all targets at program startup.
788 ///
789 /// @param T - The target being registered.
790 /// @param Fn - A function to construct a MCObjectFileInfo for the target.
793 T.MCObjectFileInfoCtorFn = Fn;
794 }
795
796 /// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the
797 /// given target.
798 ///
799 /// Clients are responsible for ensuring that registration doesn't occur
800 /// while another thread is attempting to access the registry. Typically
801 /// this is done by initializing all targets at program startup.
802 ///
803 /// @param T - The target being registered.
804 /// @param Fn - A function to construct a MCInstrInfo for the target.
806 T.MCInstrInfoCtorFn = Fn;
807 }
808
809 /// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for
810 /// the given target.
813 T.MCInstrAnalysisCtorFn = Fn;
814 }
815
816 /// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
817 /// given target.
818 ///
819 /// Clients are responsible for ensuring that registration doesn't occur
820 /// while another thread is attempting to access the registry. Typically
821 /// this is done by initializing all targets at program startup.
822 ///
823 /// @param T - The target being registered.
824 /// @param Fn - A function to construct a MCRegisterInfo for the target.
826 T.MCRegInfoCtorFn = Fn;
827 }
828
829 /// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for
830 /// the given target.
831 ///
832 /// Clients are responsible for ensuring that registration doesn't occur
833 /// while another thread is attempting to access the registry. Typically
834 /// this is done by initializing all targets at program startup.
835 ///
836 /// @param T - The target being registered.
837 /// @param Fn - A function to construct a MCSubtargetInfo for the target.
840 T.MCSubtargetInfoCtorFn = Fn;
841 }
842
843 /// RegisterTargetMachine - Register a TargetMachine implementation for the
844 /// given target.
845 ///
846 /// Clients are responsible for ensuring that registration doesn't occur
847 /// while another thread is attempting to access the registry. Typically
848 /// this is done by initializing all targets at program startup.
849 ///
850 /// @param T - The target being registered.
851 /// @param Fn - A function to construct a TargetMachine for the target.
853 T.TargetMachineCtorFn = Fn;
854 }
855
856 /// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
857 /// given 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 AsmBackend for the target.
866 T.MCAsmBackendCtorFn = Fn;
867 }
868
869 /// RegisterMCAsmParser - Register a MCTargetAsmParser 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 MCTargetAsmParser for the target.
879 T.MCAsmParserCtorFn = Fn;
880 }
881
882 /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
883 /// target.
884 ///
885 /// Clients are responsible for ensuring that registration doesn't occur
886 /// while another thread is attempting to access the registry. Typically
887 /// this is done by initializing all targets at program startup.
888 ///
889 /// @param T - The target being registered.
890 /// @param Fn - A function to construct an AsmPrinter for the target.
892 T.AsmPrinterCtorFn = Fn;
893 }
894
895 /// RegisterMCDisassembler - Register a MCDisassembler implementation for
896 /// the given target.
897 ///
898 /// Clients are responsible for ensuring that registration doesn't occur
899 /// while another thread is attempting to access the registry. Typically
900 /// this is done by initializing all targets at program startup.
901 ///
902 /// @param T - The target being registered.
903 /// @param Fn - A function to construct an MCDisassembler for the target.
906 T.MCDisassemblerCtorFn = Fn;
907 }
908
909 /// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the
910 /// given target.
911 ///
912 /// Clients are responsible for ensuring that registration doesn't occur
913 /// while another thread is attempting to access the registry. Typically
914 /// this is done by initializing all targets at program startup.
915 ///
916 /// @param T - The target being registered.
917 /// @param Fn - A function to construct an MCInstPrinter for the target.
919 T.MCInstPrinterCtorFn = Fn;
920 }
921
922 /// RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the
923 /// given target.
924 ///
925 /// Clients are responsible for ensuring that registration doesn't occur
926 /// while another thread is attempting to access the registry. Typically
927 /// this is done by initializing all targets at program startup.
928 ///
929 /// @param T - The target being registered.
930 /// @param Fn - A function to construct an MCCodeEmitter for the target.
932 T.MCCodeEmitterCtorFn = Fn;
933 }
934
936 T.COFFStreamerCtorFn = Fn;
937 }
938
940 T.MachOStreamerCtorFn = Fn;
941 }
942
944 T.ELFStreamerCtorFn = Fn;
945 }
946
948 T.XCOFFStreamerCtorFn = Fn;
949 }
950
953 T.NullTargetStreamerCtorFn = Fn;
954 }
955
957 T.AsmStreamerCtorFn = Fn;
958 }
959
962 T.AsmTargetStreamerCtorFn = Fn;
963 }
964
965 static void
968 T.ObjectTargetStreamerCtorFn = Fn;
969 }
970
971 /// RegisterMCRelocationInfo - Register an MCRelocationInfo
972 /// implementation for the given target.
973 ///
974 /// Clients are responsible for ensuring that registration doesn't occur
975 /// while another thread is attempting to access the registry. Typically
976 /// this is done by initializing all targets at program startup.
977 ///
978 /// @param T - The target being registered.
979 /// @param Fn - A function to construct an MCRelocationInfo for the target.
982 T.MCRelocationInfoCtorFn = Fn;
983 }
984
985 /// RegisterMCSymbolizer - Register an MCSymbolizer
986 /// implementation for the given target.
987 ///
988 /// Clients are responsible for ensuring that registration doesn't occur
989 /// while another thread is attempting to access the registry. Typically
990 /// this is done by initializing all targets at program startup.
991 ///
992 /// @param T - The target being registered.
993 /// @param Fn - A function to construct an MCSymbolizer for the target.
995 T.MCSymbolizerCtorFn = Fn;
996 }
997
998 /// RegisterCustomBehaviour - Register a CustomBehaviour
999 /// implementation for the given target.
1000 ///
1001 /// Clients are responsible for ensuring that registration doesn't occur
1002 /// while another thread is attempting to access the registry. Typically
1003 /// this is done by initializing all targets at program startup.
1004 ///
1005 /// @param T - The target being registered.
1006 /// @param Fn - A function to construct a CustomBehaviour for the target.
1009 T.CustomBehaviourCtorFn = Fn;
1010 }
1011
1012 /// RegisterInstrPostProcess - Register an InstrPostProcess
1013 /// implementation for the given target.
1014 ///
1015 /// Clients are responsible for ensuring that registration doesn't occur
1016 /// while another thread is attempting to access the registry. Typically
1017 /// this is done by initializing all targets at program startup.
1018 ///
1019 /// @param T - The target being registered.
1020 /// @param Fn - A function to construct an InstrPostProcess for the target.
1023 T.InstrPostProcessCtorFn = Fn;
1024 }
1025
1026 /// RegisterInstrumentManager - Register an InstrumentManager
1027 /// implementation for the given target.
1028 ///
1029 /// Clients are responsible for ensuring that registration doesn't occur
1030 /// while another thread is attempting to access the registry. Typically
1031 /// this is done by initializing all targets at program startup.
1032 ///
1033 /// @param T - The target being registered.
1034 /// @param Fn - A function to construct an InstrumentManager for the
1035 /// target.
1038 T.InstrumentManagerCtorFn = Fn;
1039 }
1040
1042 T.MCLFIRewriterCtorFn = Fn;
1043 }
1044
1045 /// @}
1046};
1047
1048//===--------------------------------------------------------------------===//
1049
1050/// RegisterTarget - Helper template for registering a target, for use in the
1051/// target's initialization function. Usage:
1052///
1053///
1054/// Target &getTheFooTarget() { // The global target instance.
1055/// static Target TheFooTarget;
1056/// return TheFooTarget;
1057/// }
1058/// extern "C" void LLVMInitializeFooTargetInfo() {
1059/// RegisterTarget<Triple::foo> X(getTheFooTarget(), "foo", "Foo
1060/// description", "Foo" /* Backend Name */);
1061/// }
1062template <Triple::ArchType TargetArchType = Triple::UnknownArch,
1063 bool HasJIT = false>
1065 RegisterTarget(Target &T, const char *Name, const char *Desc,
1066 const char *BackendName) {
1067 TargetRegistry::RegisterTarget(T, Name, Desc, BackendName, &getArchMatch,
1068 HasJIT);
1069 }
1070
1071 static bool getArchMatch(Triple::ArchType Arch) {
1072 return Arch == TargetArchType;
1073 }
1074};
1075
1076/// RegisterMCAsmInfo - Helper template for registering a target assembly info
1077/// implementation. This invokes the static "Create" method on the class to
1078/// actually do the construction. Usage:
1079///
1080/// extern "C" void LLVMInitializeFooTarget() {
1081/// extern Target TheFooTarget;
1082/// RegisterMCAsmInfo<FooMCAsmInfo> X(TheFooTarget);
1083/// }
1084template <class MCAsmInfoImpl> struct RegisterMCAsmInfo {
1088
1089private:
1090 static MCAsmInfo *Allocator(const MCRegisterInfo & /*MRI*/, const Triple &TT,
1091 const MCTargetOptions &Options) {
1092 return new MCAsmInfoImpl(TT, Options);
1093 }
1094};
1095
1096/// RegisterMCAsmInfoFn - Helper template for registering a target assembly info
1097/// implementation. This invokes the specified function to do the
1098/// construction. Usage:
1099///
1100/// extern "C" void LLVMInitializeFooTarget() {
1101/// extern Target TheFooTarget;
1102/// RegisterMCAsmInfoFn X(TheFooTarget, TheFunction);
1103/// }
1109
1110/// Helper template for registering a target object file info implementation.
1111/// This invokes the static "Create" method on the class to actually do the
1112/// construction. Usage:
1113///
1114/// extern "C" void LLVMInitializeFooTarget() {
1115/// extern Target TheFooTarget;
1116/// RegisterMCObjectFileInfo<FooMCObjectFileInfo> X(TheFooTarget);
1117/// }
1118template <class MCObjectFileInfoImpl> struct RegisterMCObjectFileInfo {
1122
1123private:
1124 static MCObjectFileInfo *Allocator(MCContext &Ctx, bool PIC,
1125 bool LargeCodeModel = false) {
1126 return new MCObjectFileInfoImpl(Ctx, PIC, LargeCodeModel);
1127 }
1128};
1129
1130/// Helper template for registering a target object file info implementation.
1131/// This invokes the specified function to do the construction. Usage:
1132///
1133/// extern "C" void LLVMInitializeFooTarget() {
1134/// extern Target TheFooTarget;
1135/// RegisterMCObjectFileInfoFn X(TheFooTarget, TheFunction);
1136/// }
1142
1143/// RegisterMCInstrInfo - Helper template for registering a target instruction
1144/// info implementation. This invokes the static "Create" method on the class
1145/// to actually do the construction. Usage:
1146///
1147/// extern "C" void LLVMInitializeFooTarget() {
1148/// extern Target TheFooTarget;
1149/// RegisterMCInstrInfo<FooMCInstrInfo> X(TheFooTarget);
1150/// }
1151template <class MCInstrInfoImpl> struct RegisterMCInstrInfo {
1155
1156private:
1157 static MCInstrInfo *Allocator() { return new MCInstrInfoImpl(); }
1158};
1159
1160/// RegisterMCInstrInfoFn - Helper template for registering a target
1161/// instruction info implementation. This invokes the specified function to
1162/// do the construction. Usage:
1163///
1164/// extern "C" void LLVMInitializeFooTarget() {
1165/// extern Target TheFooTarget;
1166/// RegisterMCInstrInfoFn X(TheFooTarget, TheFunction);
1167/// }
1173
1174/// RegisterMCInstrAnalysis - Helper template for registering a target
1175/// instruction analyzer implementation. This invokes the static "Create"
1176/// method on the class to actually do the construction. Usage:
1177///
1178/// extern "C" void LLVMInitializeFooTarget() {
1179/// extern Target TheFooTarget;
1180/// RegisterMCInstrAnalysis<FooMCInstrAnalysis> X(TheFooTarget);
1181/// }
1182template <class MCInstrAnalysisImpl> struct RegisterMCInstrAnalysis {
1186
1187private:
1188 static MCInstrAnalysis *Allocator(const MCInstrInfo *Info) {
1189 return new MCInstrAnalysisImpl(Info);
1190 }
1191};
1192
1193/// RegisterMCInstrAnalysisFn - Helper template for registering a target
1194/// instruction analyzer implementation. This invokes the specified function
1195/// to do the construction. Usage:
1196///
1197/// extern "C" void LLVMInitializeFooTarget() {
1198/// extern Target TheFooTarget;
1199/// RegisterMCInstrAnalysisFn X(TheFooTarget, TheFunction);
1200/// }
1206
1207/// RegisterMCRegInfo - Helper template for registering a target register info
1208/// implementation. This invokes the static "Create" method on the class to
1209/// actually do the construction. Usage:
1210///
1211/// extern "C" void LLVMInitializeFooTarget() {
1212/// extern Target TheFooTarget;
1213/// RegisterMCRegInfo<FooMCRegInfo> X(TheFooTarget);
1214/// }
1215template <class MCRegisterInfoImpl> struct RegisterMCRegInfo {
1219
1220private:
1221 static MCRegisterInfo *Allocator(const Triple & /*TT*/) {
1222 return new MCRegisterInfoImpl();
1223 }
1224};
1225
1226/// RegisterMCRegInfoFn - Helper template for registering a target register
1227/// info implementation. This invokes the specified function to do the
1228/// construction. Usage:
1229///
1230/// extern "C" void LLVMInitializeFooTarget() {
1231/// extern Target TheFooTarget;
1232/// RegisterMCRegInfoFn X(TheFooTarget, TheFunction);
1233/// }
1239
1240/// RegisterMCSubtargetInfo - Helper template for registering a target
1241/// subtarget info implementation. This invokes the static "Create" method
1242/// on the class to actually do the construction. Usage:
1243///
1244/// extern "C" void LLVMInitializeFooTarget() {
1245/// extern Target TheFooTarget;
1246/// RegisterMCSubtargetInfo<FooMCSubtargetInfo> X(TheFooTarget);
1247/// }
1248template <class MCSubtargetInfoImpl> struct RegisterMCSubtargetInfo {
1252
1253private:
1254 static MCSubtargetInfo *Allocator(const Triple & /*TT*/, StringRef /*CPU*/,
1255 StringRef /*FS*/) {
1256 return new MCSubtargetInfoImpl();
1257 }
1258};
1259
1260/// RegisterMCSubtargetInfoFn - Helper template for registering a target
1261/// subtarget info implementation. This invokes the specified function to
1262/// do the construction. Usage:
1263///
1264/// extern "C" void LLVMInitializeFooTarget() {
1265/// extern Target TheFooTarget;
1266/// RegisterMCSubtargetInfoFn X(TheFooTarget, TheFunction);
1267/// }
1273
1274/// RegisterTargetMachine - Helper template for registering a target machine
1275/// implementation, for use in the target machine initialization
1276/// function. Usage:
1277///
1278/// extern "C" void LLVMInitializeFooTarget() {
1279/// extern Target TheFooTarget;
1280/// RegisterTargetMachine<FooTargetMachine> X(TheFooTarget);
1281/// }
1282template <class TargetMachineImpl> struct RegisterTargetMachine {
1286
1287private:
1288 static TargetMachine *
1289 Allocator(const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
1290 const TargetOptions &Options, std::optional<Reloc::Model> RM,
1291 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, bool JIT) {
1292 return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL, JIT);
1293 }
1294};
1295
1296/// RegisterMCAsmBackend - Helper template for registering a target specific
1297/// assembler backend. Usage:
1298///
1299/// extern "C" void LLVMInitializeFooMCAsmBackend() {
1300/// extern Target TheFooTarget;
1301/// RegisterMCAsmBackend<FooAsmLexer> X(TheFooTarget);
1302/// }
1303template <class MCAsmBackendImpl> struct RegisterMCAsmBackend {
1307
1308private:
1309 static MCAsmBackend *Allocator(const Target &T, const MCSubtargetInfo &STI,
1310 const MCRegisterInfo &MRI,
1311 const MCTargetOptions &Options) {
1312 return new MCAsmBackendImpl(T, STI, MRI);
1313 }
1314};
1315
1316/// RegisterMCAsmParser - Helper template for registering a target specific
1317/// assembly parser, for use in the target machine initialization
1318/// function. Usage:
1319///
1320/// extern "C" void LLVMInitializeFooMCAsmParser() {
1321/// extern Target TheFooTarget;
1322/// RegisterMCAsmParser<FooAsmParser> X(TheFooTarget);
1323/// }
1324template <class MCAsmParserImpl> struct RegisterMCAsmParser {
1328
1329private:
1330 static MCTargetAsmParser *Allocator(const MCSubtargetInfo &STI,
1331 MCAsmParser &P, const MCInstrInfo &MII,
1332 const MCTargetOptions &Options) {
1333 return new MCAsmParserImpl(STI, P, MII, Options);
1334 }
1335};
1336
1337/// RegisterAsmPrinter - Helper template for registering a target specific
1338/// assembly printer, for use in the target machine initialization
1339/// function. Usage:
1340///
1341/// extern "C" void LLVMInitializeFooAsmPrinter() {
1342/// extern Target TheFooTarget;
1343/// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget);
1344/// }
1345template <class AsmPrinterImpl> struct RegisterAsmPrinter {
1349
1350private:
1352 std::unique_ptr<MCStreamer> &&Streamer) {
1353 return new AsmPrinterImpl(TM, std::move(Streamer));
1354 }
1355};
1356
1357/// RegisterMCCodeEmitter - Helper template for registering a target specific
1358/// machine code emitter, for use in the target initialization
1359/// function. Usage:
1360///
1361/// extern "C" void LLVMInitializeFooMCCodeEmitter() {
1362/// extern Target TheFooTarget;
1363/// RegisterMCCodeEmitter<FooCodeEmitter> X(TheFooTarget);
1364/// }
1365template <class MCCodeEmitterImpl> struct RegisterMCCodeEmitter {
1369
1370private:
1371 static MCCodeEmitter *Allocator(const MCInstrInfo & /*II*/,
1372 MCContext & /*Ctx*/) {
1373 return new MCCodeEmitterImpl();
1374 }
1375};
1376
1377} // end namespace llvm
1378
1379#endif // LLVM_MC_TARGETREGISTRY_H
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:213
dxil DXContainer Global Emitter
static LVOptions Options
Definition LVOptions.cpp:25
#define T
uint64_t IntrinsicInst * II
#define P(N)
PassInstrumentationCallbacks PIC
Basic Register Allocator
This class is intended to be used as a driving class for all asm writers.
Definition AsmPrinter.h:91
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Generic interface to target specific assembler backends.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:64
Generic assembler parser interface, for use by target specific assembly parsers.
MCCodeEmitter - Generic instruction encoding interface.
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...
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
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:221
Generic base class for all target subtargets.
Symbolize and annotate disassembled instructions.
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:55
Primary interface to the complete machine description for the target machine.
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.
TargetMachine * createTargetMachine(const Triple &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.
MCRelocationInfo *(*)(const Triple &TT, MCContext &Ctx) MCRelocationInfoCtorTy
MCStreamer *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) XCOFFStreamerCtorTy
MCRegisterInfo * createMCRegInfo(const Triple &TT) const
Create a MCRegisterInfo implementation.
MCTargetStreamer *(*)(MCStreamer &S) NullTargetStreamerCtorTy
MCAsmInfo *(*)(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options) MCAsmInfoCtorFnTy
mca::InstrPostProcess *(*)(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) InstrPostProcessCtorTy
mca::InstrumentManager *(*)(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) InstrumentManagerCtorTy
MCSubtargetInfo *(*)(const Triple &TT, StringRef CPU, StringRef Features) MCSubtargetInfoCtorFnTy
Target()=default
MCCodeEmitter *(*)(const MCInstrInfo &II, MCContext &Ctx) MCCodeEmitterCtorTy
MCTargetStreamer *(*)(MCStreamer &S, const MCSubtargetInfo &STI) ObjectTargetStreamerCtorTy
bool hasTargetMachine() const
hasTargetMachine - Check if this target supports code generation.
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
MCObjectFileInfo *(*)(MCContext &Ctx, bool PIC, bool LargeCodeModel) MCObjectFileInfoCtorFnTy
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TheTriple, const MCTargetOptions &Options) const
Create a MCAsmInfo implementation for the specified target triple.
MCDisassembler *(*)(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx) MCDisassemblerCtorTy
MCAsmBackend *(*)(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) MCAsmBackendCtorTy
MCAsmBackend * createMCAsmBackend(const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) const
createMCAsmBackend - Create a target specific assembly parser.
MCStreamer *(*)(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) COFFStreamerCtorTy
MCTargetStreamer *(*)(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint) AsmTargetStreamerCtorTy
bool hasMCAsmParser() const
hasMCAsmParser - Check if this target supports assembly parsing.
MCStreamer * createNullStreamer(MCContext &Ctx) const
LLVM_ABI MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, std::unique_ptr< MCInstPrinter > IP, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCAsmBackend > TAB) const
MCStreamer *(*)(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) MachOStreamerCtorTy
MCLFIRewriter *(*)(MCStreamer &S, std::unique_ptr< MCRegisterInfo > &&RegInfo, std::unique_ptr< MCInstrInfo > &&InstInfo) MCLFIRewriterCtorTy
MCTargetStreamer * createAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint) const
MCInstrAnalysis *(*)(const MCInstrInfo *Info) MCInstrAnalysisCtorFnTy
MCRegisterInfo *(*)(const Triple &TT) MCRegInfoCtorFnTy
MCInstrInfo *(*)() MCInstrInfoCtorFnTy
LLVM_ABI 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.
friend struct TargetRegistry
mca::CustomBehaviour *(*)(const MCSubtargetInfo &STI, const mca::SourceMgr &SrcMgr, const MCInstrInfo &MCII) CustomBehaviourCtorTy
bool(*)(Triple::ArchType Arch) ArchMatchFnTy
MCSymbolizer * createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo) const
createMCSymbolizer - Create a target specific MCSymbolizer.
MCDisassembler * createMCDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) const
bool hasMCAsmBackend() const
hasMCAsmBackend - Check if this target supports .o generation.
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
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.
MCRelocationInfo * createMCRelocationInfo(const Triple &TT, MCContext &Ctx) const
createMCRelocationInfo - Create a target specific MCRelocationInfo.
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.
void createMCLFIRewriter(MCStreamer &S, std::unique_ptr< MCRegisterInfo > &&RegInfo, std::unique_ptr< MCInstrInfo > &&InstInfo) const
MCSubtargetInfo * createMCSubtargetInfo(const Triple &TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
const char * getShortDescription() const
getShortDescription - Get a short description of the target.
MCStreamer *(*)(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, std::unique_ptr< MCInstPrinter > IP, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCAsmBackend > TAB) AsmStreamerCtorTy
MCSymbolizer *(*)(const Triple &TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo) MCSymbolizerCtorTy
bool hasJIT() const
hasJIT - Check if this targets supports the just-in-time compilation.
AsmPrinter *(*)( TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) AsmPrinterCtorTy
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
MCTargetStreamer * createNullTargetStreamer(MCStreamer &S) const
MCInstPrinter *(*)(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) MCInstPrinterCtorTy
AsmPrinter * createAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) const
createAsmPrinter - Create a target specific assembly printer pass.
MCTargetAsmParser *(*)( const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII, const MCTargetOptions &Options) MCAsmParserCtorTy
MCStreamer *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) ELFStreamerCtorTy
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:47
@ UnknownArch
Definition Triple.h:50
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:53
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 Types.h:26
LLVM_ABI mca::InstrumentManager * createInstrumentManager(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
LLVM_ABI MCStreamer * createELFStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
LLVM_ABI MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, std::unique_ptr< 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,...
Op::Description Desc
LLVM_ABI MCStreamer * createNullStreamer(MCContext &Ctx)
Create a dummy machine code streamer, which does nothing.
LLVM_ABI MCSymbolizer * createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo)
LLVM_ABI 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
LLVM_ABI MCRelocationInfo * createMCRelocationInfo(const Triple &TT, MCContext &Ctx)
LLVM_ABI mca::CustomBehaviour * createCustomBehaviour(const MCSubtargetInfo &STI, const mca::SourceMgr &SrcMgr, const MCInstrInfo &MCII)
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
@ Default
-O2, -Os, -Oz
Definition CodeGen.h:85
LLVM_ABI MCStreamer * createDXContainerStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
LLVM_ABI MCStreamer * createWasmStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
LLVM_ABI MCStreamer * createGOFFStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
LLVM_ABI MCStreamer * createSPIRVStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
LLVM_ABI mca::InstrPostProcess * createInstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
RegisterMCAsmInfoFn(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCInstrAnalysisFn(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
RegisterMCInstrInfoFn(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCObjectFileInfoFn(Target &T, Target::MCObjectFileInfoCtorFnTy Fn)
RegisterMCRegInfoFn(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCSubtargetInfoFn(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
static bool getArchMatch(Triple::ArchType Arch)
RegisterTarget(Target &T, const char *Name, const char *Desc, const char *BackendName)
static const Target * lookupTarget(StringRef TripleStr, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
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 RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn)
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 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 LLVM_ABI void printRegisteredTargetsForVersion(raw_ostream &OS)
printRegisteredTargetsForVersion - Print the registered targets appropriately for inclusion in a tool...
static void RegisterMCLFIRewriter(Target &T, Target::MCLFIRewriterCtorTy Fn)
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 LLVM_ABI 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 LLVM_ABI 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