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"
24#include "llvm/MC/MCAsmInfo.h"
31#include <cassert>
32#include <cstddef>
33#include <iterator>
34#include <memory>
35#include <optional>
36#include <string>
37
38namespace llvm {
39
40class AsmPrinter;
41class MCAsmBackend;
42class MCAsmInfo;
43class MCAsmParser;
44class MCCodeEmitter;
45class MCContext;
46class MCDisassembler;
47class MCInstPrinter;
48class MCInstrAnalysis;
49class MCInstrInfo;
50class MCLFIRewriter;
51class MCObjectWriter;
52class MCRegisterInfo;
54class MCStreamer;
55class MCSubtargetInfo;
56class MCSymbolizer;
58class MCTargetOptions;
60class raw_ostream;
61class TargetMachine;
62class TargetOptions;
63namespace mca {
64class CustomBehaviour;
67struct SourceMgr;
68} // namespace mca
69
71// Takes ownership of \p TAB and \p CE.
72
73/// Create a machine code streamer which will print out assembly for the native
74/// target, suitable for compiling with a native assembler.
75///
76/// \param InstPrint - If given, the instruction printer to use. If not given
77/// the MCInst representation will be printed. This method takes ownership of
78/// InstPrint.
79///
80/// \param CE - If given, a code emitter to use to show the instruction
81/// encoding inline with the assembly. This method takes ownership of \p CE.
82///
83/// \param TAB - If given, a target asm backend to use to show the fixup
84/// information in conjunction with encoding information. This method takes
85/// ownership of \p TAB.
86///
87/// \param ShowInst - Whether to show the MCInst representation inline with
88/// the assembly.
90createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS,
91 std::unique_ptr<MCInstPrinter> InstPrint,
92 std::unique_ptr<MCCodeEmitter> CE,
93 std::unique_ptr<MCAsmBackend> TAB);
94
96 std::unique_ptr<MCAsmBackend> &&TAB,
97 std::unique_ptr<MCObjectWriter> &&OW,
98 std::unique_ptr<MCCodeEmitter> &&CE);
100 std::unique_ptr<MCAsmBackend> &&TAB,
101 std::unique_ptr<MCObjectWriter> &&OW,
102 std::unique_ptr<MCCodeEmitter> &&CE);
104 std::unique_ptr<MCAsmBackend> &&TAB,
105 std::unique_ptr<MCObjectWriter> &&OW,
106 std::unique_ptr<MCCodeEmitter> &&CE,
107 bool DWARFMustBeAtTheEnd,
108 bool LabelSections = false);
110 std::unique_ptr<MCAsmBackend> &&TAB,
111 std::unique_ptr<MCObjectWriter> &&OW,
112 std::unique_ptr<MCCodeEmitter> &&CE);
114 std::unique_ptr<MCAsmBackend> &&TAB,
115 std::unique_ptr<MCObjectWriter> &&OW,
116 std::unique_ptr<MCCodeEmitter> &&CE);
118createDXContainerStreamer(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
119 std::unique_ptr<MCObjectWriter> &&OW,
120 std::unique_ptr<MCCodeEmitter> &&CE);
121
123 MCContext &Ctx);
124
126createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
127 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
128 MCContext *Ctx, std::unique_ptr<MCRelocationInfo> &&RelInfo);
129
132 const MCInstrInfo &MCII);
133
136
139
140/// Target - Wrapper for Target specific information.
141///
142/// For registration purposes, this is a POD type so that targets can be
143/// registered without the use of static constructors.
144///
145/// Targets should implement a single global instance of this class (which
146/// will be zero initialized), and pass that instance to the TargetRegistry as
147/// part of their initialization.
148class Target {
149public:
150 friend struct TargetRegistry;
151
153
155 const Triple &TT,
156 const MCTargetOptions &Options);
158 bool PIC,
159 bool LargeCodeModel);
162 using MCRegInfoCtorFnTy = MCRegisterInfo *(*)(const Triple &TT);
164 StringRef CPU,
165 StringRef Features);
167 *(*)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
168 const TargetOptions &Options, std::optional<Reloc::Model> RM,
169 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, bool JIT);
170 // If it weren't for layering issues (this header is in llvm/Support, but
171 // depends on MC?) this should take the Streamer by value rather than rvalue
172 // reference.
174 TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
176 const MCSubtargetInfo &STI,
177 const MCRegisterInfo &MRI,
178 const MCTargetOptions &Options);
180 MCAsmParser &P,
181 const MCInstrInfo &MII);
183 const MCSubtargetInfo &STI,
184 MCContext &Ctx);
186 unsigned SyntaxVariant,
187 const MCAsmInfo &MAI,
188 const MCInstrInfo &MII,
189 const MCRegisterInfo &MRI);
191 MCContext &Ctx);
193 MCStreamer *(*)(const Triple &T, MCContext &Ctx,
194 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 *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
203 std::unique_ptr<MCObjectWriter> &&OW,
204 std::unique_ptr<MCCodeEmitter> &&Emitter);
206 MCStreamer *(*)(const Triple &T, MCContext &Ctx,
207 std::unique_ptr<MCAsmBackend> &&TAB,
208 std::unique_ptr<MCObjectWriter> &&OW,
209 std::unique_ptr<MCCodeEmitter> &&Emitter);
210
214 MCInstPrinter *InstPrint);
216 *(*)(MCContext & Ctx, std::unique_ptr<formatted_raw_ostream> OS,
217 std::unique_ptr<MCInstPrinter> IP, std::unique_ptr<MCCodeEmitter> CE,
218 std::unique_ptr<MCAsmBackend> TAB);
220 MCTargetStreamer *(*)(MCStreamer &S, const MCSubtargetInfo &STI);
222 MCContext &Ctx);
224 MCSymbolizer *(*)(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
225 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
226 MCContext *Ctx,
227 std::unique_ptr<MCRelocationInfo> &&RelInfo);
228
231 const mca::SourceMgr &SrcMgr,
232 const MCInstrInfo &MCII);
233
236 const MCInstrInfo &MCII);
237
240 const MCInstrInfo &MCII);
241
243 MCLFIRewriter *(*)(MCContext & Ctx,
244 std::unique_ptr<MCRegisterInfo> &&RegInfo,
245 std::unique_ptr<MCInstrInfo> &&InstInfo);
246
247private:
248 /// Next - The next registered target in the linked list, maintained by the
249 /// TargetRegistry.
250 Target *Next;
251
252 /// The target function for checking if an architecture is supported.
253 ArchMatchFnTy ArchMatchFn;
254
255 /// Name - The target name.
256 const char *Name;
257
258 /// ShortDesc - A short description of the target.
259 const char *ShortDesc;
260
261 /// BackendName - The name of the backend implementation. This must match the
262 /// name of the 'def X : Target ...' in TableGen.
263 const char *BackendName;
264
265 /// HasJIT - Whether this target supports the JIT.
266 bool HasJIT;
267
268 /// MCAsmInfoCtorFn - Constructor function for this target's MCAsmInfo, if
269 /// registered.
270 MCAsmInfoCtorFnTy MCAsmInfoCtorFn;
271
272 /// Constructor function for this target's MCObjectFileInfo, if registered.
273 MCObjectFileInfoCtorFnTy MCObjectFileInfoCtorFn;
274
275 /// MCInstrInfoCtorFn - Constructor function for this target's MCInstrInfo,
276 /// if registered.
277 MCInstrInfoCtorFnTy MCInstrInfoCtorFn;
278
279 /// MCInstrAnalysisCtorFn - Constructor function for this target's
280 /// MCInstrAnalysis, if registered.
281 MCInstrAnalysisCtorFnTy MCInstrAnalysisCtorFn;
282
283 /// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
284 /// if registered.
285 MCRegInfoCtorFnTy MCRegInfoCtorFn;
286
287 /// MCSubtargetInfoCtorFn - Constructor function for this target's
288 /// MCSubtargetInfo, if registered.
289 MCSubtargetInfoCtorFnTy MCSubtargetInfoCtorFn;
290
291 /// TargetMachineCtorFn - Construction function for this target's
292 /// TargetMachine, if registered.
293 TargetMachineCtorTy TargetMachineCtorFn;
294
295 /// MCAsmBackendCtorFn - Construction function for this target's
296 /// MCAsmBackend, if registered.
297 MCAsmBackendCtorTy MCAsmBackendCtorFn;
298
299 /// MCAsmParserCtorFn - Construction function for this target's
300 /// MCTargetAsmParser, if registered.
301 MCAsmParserCtorTy MCAsmParserCtorFn;
302
303 /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
304 /// if registered.
305 AsmPrinterCtorTy AsmPrinterCtorFn;
306
307 /// MCDisassemblerCtorFn - Construction function for this target's
308 /// MCDisassembler, if registered.
309 MCDisassemblerCtorTy MCDisassemblerCtorFn;
310
311 /// MCInstPrinterCtorFn - Construction function for this target's
312 /// MCInstPrinter, if registered.
313 MCInstPrinterCtorTy MCInstPrinterCtorFn;
314
315 /// MCCodeEmitterCtorFn - Construction function for this target's
316 /// CodeEmitter, if registered.
317 MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
318
319 // Construction functions for the various object formats, if registered.
320 COFFStreamerCtorTy COFFStreamerCtorFn = nullptr;
321 MachOStreamerCtorTy MachOStreamerCtorFn = nullptr;
322 ELFStreamerCtorTy ELFStreamerCtorFn = nullptr;
323 XCOFFStreamerCtorTy XCOFFStreamerCtorFn = nullptr;
324
325 /// Construction function for this target's null TargetStreamer, if
326 /// registered (default = nullptr).
327 NullTargetStreamerCtorTy NullTargetStreamerCtorFn = nullptr;
328
329 /// Construction function for this target's asm TargetStreamer, if
330 /// registered (default = nullptr).
331 AsmTargetStreamerCtorTy AsmTargetStreamerCtorFn = nullptr;
332
333 /// Construction function for this target's AsmStreamer, if
334 /// registered (default = nullptr).
335 AsmStreamerCtorTy AsmStreamerCtorFn = nullptr;
336
337 /// Construction function for this target's obj TargetStreamer, if
338 /// registered (default = nullptr).
339 ObjectTargetStreamerCtorTy ObjectTargetStreamerCtorFn = nullptr;
340
341 /// MCRelocationInfoCtorFn - Construction function for this target's
342 /// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
343 MCRelocationInfoCtorTy MCRelocationInfoCtorFn = nullptr;
344
345 /// MCSymbolizerCtorFn - Construction function for this target's
346 /// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
347 MCSymbolizerCtorTy MCSymbolizerCtorFn = nullptr;
348
349 /// CustomBehaviourCtorFn - Construction function for this target's
350 /// CustomBehaviour, if registered (default = nullptr).
351 CustomBehaviourCtorTy CustomBehaviourCtorFn = nullptr;
352
353 /// InstrPostProcessCtorFn - Construction function for this target's
354 /// InstrPostProcess, if registered (default = nullptr).
355 InstrPostProcessCtorTy InstrPostProcessCtorFn = nullptr;
356
357 /// InstrumentManagerCtorFn - Construction function for this target's
358 /// InstrumentManager, if registered (default = nullptr).
359 InstrumentManagerCtorTy InstrumentManagerCtorFn = nullptr;
360
361 // MCLFIRewriterCtorFn - Construction function for this target's
362 // MCLFIRewriter, if registered (default = nullptr).
363 MCLFIRewriterCtorTy MCLFIRewriterCtorFn = nullptr;
364
365public:
366 Target() = default;
367
368 /// @name Target Information
369 /// @{
370
371 // getNext - Return the next registered target.
372 const Target *getNext() const { return Next; }
373
374 /// getName - Get the target name.
375 const char *getName() const { return Name; }
376
377 /// getShortDescription - Get a short description of the target.
378 const char *getShortDescription() const { return ShortDesc; }
379
380 /// getBackendName - Get the backend name.
381 const char *getBackendName() const { return BackendName; }
382
383 /// @}
384 /// @name Feature Predicates
385 /// @{
386
387 /// hasJIT - Check if this targets supports the just-in-time compilation.
388 bool hasJIT() const { return HasJIT; }
389
390 /// hasTargetMachine - Check if this target supports code generation.
391 bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
392
393 /// hasMCAsmBackend - Check if this target supports .o generation.
394 bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
395
396 /// hasMCAsmParser - Check if this target supports assembly parsing.
397 bool hasMCAsmParser() const { return MCAsmParserCtorFn != nullptr; }
398
399 /// @}
400 /// @name Feature Constructors
401 /// @{
402
403 /// Create a MCAsmInfo implementation for the specified
404 /// target triple.
405 ///
406 /// \param TheTriple This argument is used to determine the target machine
407 /// feature set; it should always be provided. Generally this should be
408 /// either the target triple from the module, or the target triple of the
409 /// host if that does not exist.
410 MCAsmInfo *createMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TheTriple,
411 const MCTargetOptions &Options) const {
412 if (!MCAsmInfoCtorFn)
413 return nullptr;
414 return MCAsmInfoCtorFn(MRI, TheTriple, Options);
415 }
416
417 /// Create a MCObjectFileInfo implementation for the specified target
418 /// triple.
419 ///
421 bool LargeCodeModel = false) const {
422 if (!MCObjectFileInfoCtorFn) {
424 MOFI->initMCObjectFileInfo(Ctx, PIC, LargeCodeModel);
425 return MOFI;
426 }
427 return MCObjectFileInfoCtorFn(Ctx, PIC, LargeCodeModel);
428 }
429
430 /// createMCInstrInfo - Create a MCInstrInfo implementation.
431 ///
433 if (!MCInstrInfoCtorFn)
434 return nullptr;
435 return MCInstrInfoCtorFn();
436 }
437
438 /// createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
439 ///
441 if (!MCInstrAnalysisCtorFn)
442 return nullptr;
443 return MCInstrAnalysisCtorFn(Info);
444 }
445
446 /// Create a MCRegisterInfo implementation.
448 if (!MCRegInfoCtorFn)
449 return nullptr;
450 return MCRegInfoCtorFn(TT);
451 }
452
453 /// createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
454 ///
455 /// \param TheTriple This argument is used to determine the target machine
456 /// feature set; it should always be provided. Generally this should be
457 /// either the target triple from the module, or the target triple of the
458 /// host if that does not exist.
459 /// \param CPU This specifies the name of the target CPU.
460 /// \param Features This specifies the string representation of the
461 /// additional target features.
463 StringRef Features) const {
464 if (!MCSubtargetInfoCtorFn)
465 return nullptr;
466 if (!isValidFeatureListFormat(Features))
467 return nullptr;
468 return MCSubtargetInfoCtorFn(TheTriple, CPU, Features);
469 }
470
471 /// createTargetMachine - Create a target specific machine implementation
472 /// for the specified \p Triple.
473 ///
474 /// \param TT This argument is used to determine the target machine
475 /// feature set; it should always be provided. Generally this should be
476 /// either the target triple from the module, or the target triple of the
477 /// host if that does not exist.
479 const Triple &TT, StringRef CPU, StringRef Features,
480 const TargetOptions &Options, std::optional<Reloc::Model> RM,
481 std::optional<CodeModel::Model> CM = std::nullopt,
482 CodeGenOptLevel OL = CodeGenOptLevel::Default, bool JIT = false) const {
483 if (!TargetMachineCtorFn)
484 return nullptr;
485 return TargetMachineCtorFn(*this, TT, CPU, Features, Options, RM, CM, OL,
486 JIT);
487 }
488
489 /// createMCAsmBackend - Create a target specific assembly parser.
491 const MCRegisterInfo &MRI,
492 const MCTargetOptions &Options) const {
493 if (!MCAsmBackendCtorFn)
494 return nullptr;
495 return MCAsmBackendCtorFn(*this, STI, MRI, Options);
496 }
497
498 /// createMCAsmParser - Create a target specific assembly parser.
499 ///
500 /// \param Parser The target independent parser implementation to use for
501 /// parsing and lexing.
503 MCAsmParser &Parser,
504 const MCInstrInfo &MII) const {
505 if (!MCAsmParserCtorFn)
506 return nullptr;
507 return MCAsmParserCtorFn(STI, Parser, MII);
508 }
509
510 /// createAsmPrinter - Create a target specific assembly printer pass. This
511 /// takes ownership of the MCStreamer object.
513 std::unique_ptr<MCStreamer> &&Streamer) const {
514 if (!AsmPrinterCtorFn)
515 return nullptr;
516 return AsmPrinterCtorFn(TM, std::move(Streamer));
517 }
518
520 MCContext &Ctx) const {
521 if (!MCDisassemblerCtorFn)
522 return nullptr;
523 return MCDisassemblerCtorFn(*this, STI, Ctx);
524 }
525
526 MCInstPrinter *createMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
527 const MCAsmInfo &MAI,
528 const MCInstrInfo &MII,
529 const MCRegisterInfo &MRI) const {
530 if (!MCInstPrinterCtorFn)
531 return nullptr;
532 return MCInstPrinterCtorFn(T, SyntaxVariant, MAI, MII, MRI);
533 }
534
535 /// createMCCodeEmitter - Create a target specific code emitter.
537 MCContext &Ctx) const {
538 if (!MCCodeEmitterCtorFn)
539 return nullptr;
540 return MCCodeEmitterCtorFn(II, Ctx);
541 }
542
543 /// Create a target specific MCStreamer.
544 ///
545 /// \param T The target triple.
546 /// \param Ctx The target context.
547 /// \param TAB The target assembler backend object. Takes ownership.
548 /// \param OW The stream object.
549 /// \param Emitter The target independent assembler object.Takes ownership.
551 const Triple &T, MCContext &Ctx, std::unique_ptr<MCAsmBackend> TAB,
552 std::unique_ptr<MCObjectWriter> OW,
553 std::unique_ptr<MCCodeEmitter> Emitter, const MCSubtargetInfo &STI) const;
554
556 createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS,
557 std::unique_ptr<MCInstPrinter> IP,
558 std::unique_ptr<MCCodeEmitter> CE,
559 std::unique_ptr<MCAsmBackend> TAB) const;
560
563 MCInstPrinter *InstPrint) const {
564 if (AsmTargetStreamerCtorFn)
565 return AsmTargetStreamerCtorFn(S, OS, InstPrint);
566 return nullptr;
567 }
568
572 return S;
573 }
574
576 if (NullTargetStreamerCtorFn)
577 return NullTargetStreamerCtorFn(S);
578 return nullptr;
579 }
580
582 createMCLFIRewriter(MCContext &Ctx, std::unique_ptr<MCRegisterInfo> &&RegInfo,
583 std::unique_ptr<MCInstrInfo> &&InstInfo) const {
584 if (MCLFIRewriterCtorFn)
585 return MCLFIRewriterCtorFn(Ctx, std::move(RegInfo), std::move(InstInfo));
586 return nullptr;
587 }
588
589 /// createMCRelocationInfo - Create a target specific MCRelocationInfo.
590 ///
591 /// \param TT The target triple.
592 /// \param Ctx The target context.
594 MCContext &Ctx) const {
595 MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn
596 ? MCRelocationInfoCtorFn
598 return Fn(TT, Ctx);
599 }
600
601 /// createMCSymbolizer - Create a target specific MCSymbolizer.
602 ///
603 /// \param TT The target triple.
604 /// \param GetOpInfo The function to get the symbolic information for
605 /// operands.
606 /// \param SymbolLookUp The function to lookup a symbol name.
607 /// \param DisInfo The pointer to the block of symbolic information for above
608 /// call
609 /// back.
610 /// \param Ctx The target context.
611 /// \param RelInfo The relocation information for this target. Takes
612 /// ownership.
615 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
616 MCContext *Ctx,
617 std::unique_ptr<MCRelocationInfo> &&RelInfo) const {
619 MCSymbolizerCtorFn ? MCSymbolizerCtorFn : llvm::createMCSymbolizer;
620 return Fn(TT, GetOpInfo, SymbolLookUp, DisInfo, Ctx, std::move(RelInfo));
621 }
622
623 /// createCustomBehaviour - Create a target specific CustomBehaviour.
624 /// This class is used by llvm-mca and requires backend functionality.
626 const mca::SourceMgr &SrcMgr,
627 const MCInstrInfo &MCII) const {
628 if (CustomBehaviourCtorFn)
629 return CustomBehaviourCtorFn(STI, SrcMgr, MCII);
630 return nullptr;
631 }
632
633 /// createInstrPostProcess - Create a target specific InstrPostProcess.
634 /// This class is used by llvm-mca and requires backend functionality.
636 const MCInstrInfo &MCII) const {
637 if (InstrPostProcessCtorFn)
638 return InstrPostProcessCtorFn(STI, MCII);
639 return nullptr;
640 }
641
642 /// createInstrumentManager - Create a target specific
643 /// InstrumentManager. This class is used by llvm-mca and requires
644 /// backend functionality.
647 const MCInstrInfo &MCII) const {
648 if (InstrumentManagerCtorFn)
649 return InstrumentManagerCtorFn(STI, MCII);
650 return nullptr;
651 }
652
653 /// isValidFeatureListFormat - check that FeatureString
654 /// has the format:
655 /// "+attr1,+attr2,-attr3,...,+attrN"
656 /// A comma separates each feature from the next (all lowercase).
657 /// Each of the remaining features is prefixed with '+' or '-' indicating
658 /// whether that feature should be enabled or disabled contrary to the cpu
659 /// specification.
660 /// The string must match exactly that format otherwise
661 /// MCSubtargetInfo::ApplyFeatureFlag will fail.
662 /// For example feature string "+a,+m,c" is accepted, and results in feature
663 /// list {"+a", "+m", "c"}. Later in ApplyFeatureFlag, it asserts
664 /// that all features must start with '+' or '-' and assert is failed.
665 static bool isValidFeatureListFormat(StringRef FeaturesString);
666
667 /// @}
668};
669
670/// TargetRegistry - Generic interface to target specific features.
672 // FIXME: Make this a namespace, probably just move all the Register*
673 // functions into Target (currently they all just set members on the Target
674 // anyway, and Target friends this class so those functions can...
675 // function).
676 TargetRegistry() = delete;
677
678 class iterator {
679 friend struct TargetRegistry;
680
681 const Target *Current = nullptr;
682
683 explicit iterator(Target *T) : Current(T) {}
684
685 public:
686 using iterator_category = std::forward_iterator_tag;
688 using difference_type = std::ptrdiff_t;
691
692 iterator() = default;
693
694 bool operator==(const iterator &x) const { return Current == x.Current; }
695 bool operator!=(const iterator &x) const { return !operator==(x); }
696
697 // Iterator traversal: forward iteration only
698 iterator &operator++() { // Preincrement
699 assert(Current && "Cannot increment end iterator!");
700 Current = Current->getNext();
701 return *this;
702 }
703 iterator operator++(int) { // Postincrement
704 iterator tmp = *this;
705 ++*this;
706 return tmp;
707 }
708
709 const Target &operator*() const {
710 assert(Current && "Cannot dereference end iterator!");
711 return *Current;
712 }
713
714 const Target *operator->() const { return &operator*(); }
715 };
716
717 /// printRegisteredTargetsForVersion - Print the registered targets
718 /// appropriately for inclusion in a tool's version output.
720
721 /// @name Registry Access
722 /// @{
723
725
726 /// lookupTarget - Lookup a target based on a target triple.
727 ///
728 /// \param Triple - The triple to use for finding a target.
729 /// \param Error - On failure, an error string describing why no target was
730 /// found.
731 LLVM_ABI static const Target *lookupTarget(const Triple &TheTriple,
732 std::string &Error);
733
734 /// lookupTarget - Lookup a target based on an architecture name
735 /// and a target triple. If the architecture name is non-empty,
736 /// then the lookup is done by architecture. Otherwise, the target
737 /// triple is used.
738 ///
739 /// \param ArchName - The architecture to use for finding a target.
740 /// \param TheTriple - The triple to use for finding a target. The
741 /// triple is updated with canonical architecture name if a lookup
742 /// by architecture is done.
743 /// \param Error - On failure, an error string describing why no target was
744 /// found.
745 LLVM_ABI static const Target *
746 lookupTarget(StringRef ArchName, Triple &TheTriple, std::string &Error);
747
748 /// @}
749 /// @name Target Registration
750 /// @{
751
752 /// RegisterTarget - Register the given target. Attempts to register a
753 /// target which has already been registered will be ignored.
754 ///
755 /// Clients are responsible for ensuring that registration doesn't occur
756 /// while another thread is attempting to access the registry. Typically
757 /// this is done by initializing all targets at program startup.
758 ///
759 /// @param T - The target being registered.
760 /// @param Name - The target name. This should be a static string.
761 /// @param ShortDesc - A short target description. This should be a static
762 /// string.
763 /// @param BackendName - The name of the backend. This should be a static
764 /// string that is the same for all targets that share a backend
765 /// implementation and must match the name used in the 'def X : Target ...' in
766 /// TableGen.
767 /// @param ArchMatchFn - The arch match checking function for this target.
768 /// @param HasJIT - Whether the target supports JIT code
769 /// generation.
770 LLVM_ABI static void RegisterTarget(Target &T, const char *Name,
771 const char *ShortDesc,
772 const char *BackendName,
773 Target::ArchMatchFnTy ArchMatchFn,
774 bool HasJIT = false);
775
776 /// RegisterMCAsmInfo - Register a MCAsmInfo implementation for the
777 /// given target.
778 ///
779 /// Clients are responsible for ensuring that registration doesn't occur
780 /// while another thread is attempting to access the registry. Typically
781 /// this is done by initializing all targets at program startup.
782 ///
783 /// @param T - The target being registered.
784 /// @param Fn - A function to construct a MCAsmInfo for the target.
786 T.MCAsmInfoCtorFn = Fn;
787 }
788
789 /// Register a MCObjectFileInfo implementation for the given target.
790 ///
791 /// Clients are responsible for ensuring that registration doesn't occur
792 /// while another thread is attempting to access the registry. Typically
793 /// this is done by initializing all targets at program startup.
794 ///
795 /// @param T - The target being registered.
796 /// @param Fn - A function to construct a MCObjectFileInfo for the target.
799 T.MCObjectFileInfoCtorFn = Fn;
800 }
801
802 /// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the
803 /// given target.
804 ///
805 /// Clients are responsible for ensuring that registration doesn't occur
806 /// while another thread is attempting to access the registry. Typically
807 /// this is done by initializing all targets at program startup.
808 ///
809 /// @param T - The target being registered.
810 /// @param Fn - A function to construct a MCInstrInfo for the target.
812 T.MCInstrInfoCtorFn = Fn;
813 }
814
815 /// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for
816 /// the given target.
819 T.MCInstrAnalysisCtorFn = Fn;
820 }
821
822 /// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
823 /// given target.
824 ///
825 /// Clients are responsible for ensuring that registration doesn't occur
826 /// while another thread is attempting to access the registry. Typically
827 /// this is done by initializing all targets at program startup.
828 ///
829 /// @param T - The target being registered.
830 /// @param Fn - A function to construct a MCRegisterInfo for the target.
832 T.MCRegInfoCtorFn = Fn;
833 }
834
835 /// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for
836 /// the given target.
837 ///
838 /// Clients are responsible for ensuring that registration doesn't occur
839 /// while another thread is attempting to access the registry. Typically
840 /// this is done by initializing all targets at program startup.
841 ///
842 /// @param T - The target being registered.
843 /// @param Fn - A function to construct a MCSubtargetInfo for the target.
846 T.MCSubtargetInfoCtorFn = Fn;
847 }
848
849 /// RegisterTargetMachine - Register a TargetMachine implementation for the
850 /// given target.
851 ///
852 /// Clients are responsible for ensuring that registration doesn't occur
853 /// while another thread is attempting to access the registry. Typically
854 /// this is done by initializing all targets at program startup.
855 ///
856 /// @param T - The target being registered.
857 /// @param Fn - A function to construct a TargetMachine for the target.
859 T.TargetMachineCtorFn = Fn;
860 }
861
862 /// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
863 /// given target.
864 ///
865 /// Clients are responsible for ensuring that registration doesn't occur
866 /// while another thread is attempting to access the registry. Typically
867 /// this is done by initializing all targets at program startup.
868 ///
869 /// @param T - The target being registered.
870 /// @param Fn - A function to construct an AsmBackend for the target.
872 T.MCAsmBackendCtorFn = Fn;
873 }
874
875 /// RegisterMCAsmParser - Register a MCTargetAsmParser implementation for
876 /// the given target.
877 ///
878 /// Clients are responsible for ensuring that registration doesn't occur
879 /// while another thread is attempting to access the registry. Typically
880 /// this is done by initializing all targets at program startup.
881 ///
882 /// @param T - The target being registered.
883 /// @param Fn - A function to construct an MCTargetAsmParser for the target.
885 T.MCAsmParserCtorFn = Fn;
886 }
887
888 /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
889 /// target.
890 ///
891 /// Clients are responsible for ensuring that registration doesn't occur
892 /// while another thread is attempting to access the registry. Typically
893 /// this is done by initializing all targets at program startup.
894 ///
895 /// @param T - The target being registered.
896 /// @param Fn - A function to construct an AsmPrinter for the target.
898 T.AsmPrinterCtorFn = Fn;
899 }
900
901 /// RegisterMCDisassembler - Register a MCDisassembler implementation for
902 /// the given target.
903 ///
904 /// Clients are responsible for ensuring that registration doesn't occur
905 /// while another thread is attempting to access the registry. Typically
906 /// this is done by initializing all targets at program startup.
907 ///
908 /// @param T - The target being registered.
909 /// @param Fn - A function to construct an MCDisassembler for the target.
912 T.MCDisassemblerCtorFn = Fn;
913 }
914
915 /// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the
916 /// given target.
917 ///
918 /// Clients are responsible for ensuring that registration doesn't occur
919 /// while another thread is attempting to access the registry. Typically
920 /// this is done by initializing all targets at program startup.
921 ///
922 /// @param T - The target being registered.
923 /// @param Fn - A function to construct an MCInstPrinter for the target.
925 T.MCInstPrinterCtorFn = Fn;
926 }
927
928 /// RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the
929 /// given target.
930 ///
931 /// Clients are responsible for ensuring that registration doesn't occur
932 /// while another thread is attempting to access the registry. Typically
933 /// this is done by initializing all targets at program startup.
934 ///
935 /// @param T - The target being registered.
936 /// @param Fn - A function to construct an MCCodeEmitter for the target.
938 T.MCCodeEmitterCtorFn = Fn;
939 }
940
942 T.COFFStreamerCtorFn = Fn;
943 }
944
946 T.MachOStreamerCtorFn = Fn;
947 }
948
950 T.ELFStreamerCtorFn = Fn;
951 }
952
954 T.XCOFFStreamerCtorFn = Fn;
955 }
956
959 T.NullTargetStreamerCtorFn = Fn;
960 }
961
963 T.AsmStreamerCtorFn = Fn;
964 }
965
968 T.AsmTargetStreamerCtorFn = Fn;
969 }
970
971 static void
974 T.ObjectTargetStreamerCtorFn = Fn;
975 }
976
977 /// RegisterMCRelocationInfo - Register an MCRelocationInfo
978 /// implementation for the given target.
979 ///
980 /// Clients are responsible for ensuring that registration doesn't occur
981 /// while another thread is attempting to access the registry. Typically
982 /// this is done by initializing all targets at program startup.
983 ///
984 /// @param T - The target being registered.
985 /// @param Fn - A function to construct an MCRelocationInfo for the target.
988 T.MCRelocationInfoCtorFn = Fn;
989 }
990
991 /// RegisterMCSymbolizer - Register an MCSymbolizer
992 /// implementation for the given target.
993 ///
994 /// Clients are responsible for ensuring that registration doesn't occur
995 /// while another thread is attempting to access the registry. Typically
996 /// this is done by initializing all targets at program startup.
997 ///
998 /// @param T - The target being registered.
999 /// @param Fn - A function to construct an MCSymbolizer for the target.
1001 T.MCSymbolizerCtorFn = Fn;
1002 }
1003
1004 /// RegisterCustomBehaviour - Register a CustomBehaviour
1005 /// implementation for the given target.
1006 ///
1007 /// Clients are responsible for ensuring that registration doesn't occur
1008 /// while another thread is attempting to access the registry. Typically
1009 /// this is done by initializing all targets at program startup.
1010 ///
1011 /// @param T - The target being registered.
1012 /// @param Fn - A function to construct a CustomBehaviour for the target.
1015 T.CustomBehaviourCtorFn = Fn;
1016 }
1017
1018 /// RegisterInstrPostProcess - Register an InstrPostProcess
1019 /// implementation for the given target.
1020 ///
1021 /// Clients are responsible for ensuring that registration doesn't occur
1022 /// while another thread is attempting to access the registry. Typically
1023 /// this is done by initializing all targets at program startup.
1024 ///
1025 /// @param T - The target being registered.
1026 /// @param Fn - A function to construct an InstrPostProcess for the target.
1029 T.InstrPostProcessCtorFn = Fn;
1030 }
1031
1032 /// RegisterInstrumentManager - Register an InstrumentManager
1033 /// implementation for the given target.
1034 ///
1035 /// Clients are responsible for ensuring that registration doesn't occur
1036 /// while another thread is attempting to access the registry. Typically
1037 /// this is done by initializing all targets at program startup.
1038 ///
1039 /// @param T - The target being registered.
1040 /// @param Fn - A function to construct an InstrumentManager for the
1041 /// target.
1044 T.InstrumentManagerCtorFn = Fn;
1045 }
1046
1048 T.MCLFIRewriterCtorFn = Fn;
1049 }
1050
1051 /// @}
1052};
1053
1054//===--------------------------------------------------------------------===//
1055
1056/// RegisterTarget - Helper template for registering a target, for use in the
1057/// target's initialization function. Usage:
1058///
1059///
1060/// Target &getTheFooTarget() { // The global target instance.
1061/// static Target TheFooTarget;
1062/// return TheFooTarget;
1063/// }
1064/// extern "C" void LLVMInitializeFooTargetInfo() {
1065/// RegisterTarget<Triple::foo> X(getTheFooTarget(), "foo", "Foo
1066/// description", "Foo" /* Backend Name */);
1067/// }
1068template <Triple::ArchType TargetArchType = Triple::UnknownArch,
1069 bool HasJIT = false>
1071 RegisterTarget(Target &T, const char *Name, const char *Desc,
1072 const char *BackendName) {
1073 TargetRegistry::RegisterTarget(T, Name, Desc, BackendName, &getArchMatch,
1074 HasJIT);
1075 }
1076
1077 static bool getArchMatch(Triple::ArchType Arch) {
1078 return Arch == TargetArchType;
1079 }
1080};
1081
1082/// RegisterMCAsmInfo - Helper template for registering a target assembly info
1083/// implementation. This invokes the static "Create" method on the class to
1084/// actually do the construction. Usage:
1085///
1086/// extern "C" void LLVMInitializeFooTarget() {
1087/// extern Target TheFooTarget;
1088/// RegisterMCAsmInfo<FooMCAsmInfo> X(TheFooTarget);
1089/// }
1090template <class MCAsmInfoImpl> struct RegisterMCAsmInfo {
1094
1095private:
1096 static MCAsmInfo *Allocator(const MCRegisterInfo & /*MRI*/, const Triple &TT,
1097 const MCTargetOptions &Options) {
1098 return new MCAsmInfoImpl(TT, Options);
1099 }
1100};
1101
1102/// RegisterMCAsmInfoFn - Helper template for registering a target assembly info
1103/// implementation. This invokes the specified function to do the
1104/// construction. Usage:
1105///
1106/// extern "C" void LLVMInitializeFooTarget() {
1107/// extern Target TheFooTarget;
1108/// RegisterMCAsmInfoFn X(TheFooTarget, TheFunction);
1109/// }
1115
1116/// Helper template for registering a target object file info implementation.
1117/// This invokes the static "Create" method on the class to actually do the
1118/// construction. Usage:
1119///
1120/// extern "C" void LLVMInitializeFooTarget() {
1121/// extern Target TheFooTarget;
1122/// RegisterMCObjectFileInfo<FooMCObjectFileInfo> X(TheFooTarget);
1123/// }
1124template <class MCObjectFileInfoImpl> struct RegisterMCObjectFileInfo {
1128
1129private:
1130 static MCObjectFileInfo *Allocator(MCContext &Ctx, bool PIC,
1131 bool LargeCodeModel = false) {
1132 return new MCObjectFileInfoImpl(Ctx, PIC, LargeCodeModel);
1133 }
1134};
1135
1136/// Helper template for registering a target object file info implementation.
1137/// This invokes the specified function to do the construction. Usage:
1138///
1139/// extern "C" void LLVMInitializeFooTarget() {
1140/// extern Target TheFooTarget;
1141/// RegisterMCObjectFileInfoFn X(TheFooTarget, TheFunction);
1142/// }
1148
1149/// RegisterMCInstrInfo - Helper template for registering a target instruction
1150/// info implementation. This invokes the static "Create" method on the class
1151/// to actually do the construction. Usage:
1152///
1153/// extern "C" void LLVMInitializeFooTarget() {
1154/// extern Target TheFooTarget;
1155/// RegisterMCInstrInfo<FooMCInstrInfo> X(TheFooTarget);
1156/// }
1157template <class MCInstrInfoImpl> struct RegisterMCInstrInfo {
1161
1162private:
1163 static MCInstrInfo *Allocator() { return new MCInstrInfoImpl(); }
1164};
1165
1166/// RegisterMCInstrInfoFn - Helper template for registering a target
1167/// instruction info implementation. This invokes the specified function to
1168/// do the construction. Usage:
1169///
1170/// extern "C" void LLVMInitializeFooTarget() {
1171/// extern Target TheFooTarget;
1172/// RegisterMCInstrInfoFn X(TheFooTarget, TheFunction);
1173/// }
1179
1180/// RegisterMCInstrAnalysis - Helper template for registering a target
1181/// instruction analyzer implementation. This invokes the static "Create"
1182/// method on the class to actually do the construction. Usage:
1183///
1184/// extern "C" void LLVMInitializeFooTarget() {
1185/// extern Target TheFooTarget;
1186/// RegisterMCInstrAnalysis<FooMCInstrAnalysis> X(TheFooTarget);
1187/// }
1188template <class MCInstrAnalysisImpl> struct RegisterMCInstrAnalysis {
1192
1193private:
1194 static MCInstrAnalysis *Allocator(const MCInstrInfo *Info) {
1195 return new MCInstrAnalysisImpl(Info);
1196 }
1197};
1198
1199/// RegisterMCInstrAnalysisFn - Helper template for registering a target
1200/// instruction analyzer implementation. This invokes the specified function
1201/// to do the construction. Usage:
1202///
1203/// extern "C" void LLVMInitializeFooTarget() {
1204/// extern Target TheFooTarget;
1205/// RegisterMCInstrAnalysisFn X(TheFooTarget, TheFunction);
1206/// }
1212
1213/// RegisterMCRegInfo - Helper template for registering a target register info
1214/// implementation. This invokes the static "Create" method on the class to
1215/// actually do the construction. Usage:
1216///
1217/// extern "C" void LLVMInitializeFooTarget() {
1218/// extern Target TheFooTarget;
1219/// RegisterMCRegInfo<FooMCRegInfo> X(TheFooTarget);
1220/// }
1221template <class MCRegisterInfoImpl> struct RegisterMCRegInfo {
1225
1226private:
1227 static MCRegisterInfo *Allocator(const Triple & /*TT*/) {
1228 return new MCRegisterInfoImpl();
1229 }
1230};
1231
1232/// RegisterMCRegInfoFn - Helper template for registering a target register
1233/// info implementation. This invokes the specified function to do the
1234/// construction. Usage:
1235///
1236/// extern "C" void LLVMInitializeFooTarget() {
1237/// extern Target TheFooTarget;
1238/// RegisterMCRegInfoFn X(TheFooTarget, TheFunction);
1239/// }
1245
1246/// RegisterMCSubtargetInfo - Helper template for registering a target
1247/// subtarget info implementation. This invokes the static "Create" method
1248/// on the class to actually do the construction. Usage:
1249///
1250/// extern "C" void LLVMInitializeFooTarget() {
1251/// extern Target TheFooTarget;
1252/// RegisterMCSubtargetInfo<FooMCSubtargetInfo> X(TheFooTarget);
1253/// }
1254template <class MCSubtargetInfoImpl> struct RegisterMCSubtargetInfo {
1258
1259private:
1260 static MCSubtargetInfo *Allocator(const Triple & /*TT*/, StringRef /*CPU*/,
1261 StringRef /*FS*/) {
1262 return new MCSubtargetInfoImpl();
1263 }
1264};
1265
1266/// RegisterMCSubtargetInfoFn - Helper template for registering a target
1267/// subtarget info implementation. This invokes the specified function to
1268/// do the construction. Usage:
1269///
1270/// extern "C" void LLVMInitializeFooTarget() {
1271/// extern Target TheFooTarget;
1272/// RegisterMCSubtargetInfoFn X(TheFooTarget, TheFunction);
1273/// }
1279
1280/// RegisterTargetMachine - Helper template for registering a target machine
1281/// implementation, for use in the target machine initialization
1282/// function. Usage:
1283///
1284/// extern "C" void LLVMInitializeFooTarget() {
1285/// extern Target TheFooTarget;
1286/// RegisterTargetMachine<FooTargetMachine> X(TheFooTarget);
1287/// }
1288template <class TargetMachineImpl> struct RegisterTargetMachine {
1292
1293private:
1294 static TargetMachine *
1295 Allocator(const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
1296 const TargetOptions &Options, std::optional<Reloc::Model> RM,
1297 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, bool JIT) {
1298 return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL, JIT);
1299 }
1300};
1301
1302/// RegisterMCAsmBackend - Helper template for registering a target specific
1303/// assembler backend. Usage:
1304///
1305/// extern "C" void LLVMInitializeFooMCAsmBackend() {
1306/// extern Target TheFooTarget;
1307/// RegisterMCAsmBackend<FooAsmLexer> X(TheFooTarget);
1308/// }
1309template <class MCAsmBackendImpl> struct RegisterMCAsmBackend {
1313
1314private:
1315 static MCAsmBackend *Allocator(const Target &T, const MCSubtargetInfo &STI,
1316 const MCRegisterInfo &MRI,
1317 const MCTargetOptions &Options) {
1318 return new MCAsmBackendImpl(T, STI, MRI);
1319 }
1320};
1321
1322/// RegisterMCAsmParser - Helper template for registering a target specific
1323/// assembly parser, for use in the target machine initialization
1324/// function. Usage:
1325///
1326/// extern "C" void LLVMInitializeFooMCAsmParser() {
1327/// extern Target TheFooTarget;
1328/// RegisterMCAsmParser<FooAsmParser> X(TheFooTarget);
1329/// }
1330template <class MCAsmParserImpl> struct RegisterMCAsmParser {
1334
1335private:
1336 static MCTargetAsmParser *Allocator(const MCSubtargetInfo &STI,
1337 MCAsmParser &P, const MCInstrInfo &MII) {
1338 return new MCAsmParserImpl(STI, P, MII);
1339 }
1340};
1341
1342/// RegisterAsmPrinter - Helper template for registering a target specific
1343/// assembly printer, for use in the target machine initialization
1344/// function. Usage:
1345///
1346/// extern "C" void LLVMInitializeFooAsmPrinter() {
1347/// extern Target TheFooTarget;
1348/// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget);
1349/// }
1350template <class AsmPrinterImpl> struct RegisterAsmPrinter {
1354
1355private:
1357 std::unique_ptr<MCStreamer> &&Streamer) {
1358 return new AsmPrinterImpl(TM, std::move(Streamer));
1359 }
1360};
1361
1362/// RegisterMCCodeEmitter - Helper template for registering a target specific
1363/// machine code emitter, for use in the target initialization
1364/// function. Usage:
1365///
1366/// extern "C" void LLVMInitializeFooMCCodeEmitter() {
1367/// extern Target TheFooTarget;
1368/// RegisterMCCodeEmitter<FooCodeEmitter> X(TheFooTarget);
1369/// }
1370template <class MCCodeEmitterImpl> struct RegisterMCCodeEmitter {
1374
1375private:
1376 static MCCodeEmitter *Allocator(const MCInstrInfo & /*II*/,
1377 MCContext & /*Ctx*/) {
1378 return new MCCodeEmitterImpl();
1379 }
1380};
1381
1382} // end namespace llvm
1383
1384#endif // LLVM_MC_TARGETREGISTRY_H
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:66
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:222
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:95
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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 *(*)(MCContext &Ctx, 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.
MCLFIRewriter * createMCLFIRewriter(MCContext &Ctx, std::unique_ptr< MCRegisterInfo > &&RegInfo, std::unique_ptr< MCInstrInfo > &&InstInfo) const
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.
MCInstrAnalysis * createMCInstrAnalysis(const MCInstrInfo *Info) const
createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
MCTargetAsmParser * createMCAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser, const MCInstrInfo &MII) const
createMCAsmParser - Create a target specific assembly parser.
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
MCTargetAsmParser *(*)(const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII) MCAsmParserCtorTy
static bool isValidFeatureListFormat(StringRef FeaturesString)
isValidFeatureListFormat - check that FeatureString has the format: "+attr1,+attr2,...
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.
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.
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 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 LLVM_ABI const Target * lookupTarget(const Triple &TheTriple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
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