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