LLVM 22.0.0git
TargetRegistry.h
Go to the documentation of this file.
1//===- MC/TargetRegistry.h - Target Registration ----------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file exposes the TargetRegistry interface, which tools can use to access
10// the appropriate target specific classes (TargetMachine, AsmPrinter, etc.)
11// which have been registered.
12//
13// Target specific class implementations should register themselves using the
14// appropriate TargetRegistry interfaces.
15//
16//===----------------------------------------------------------------------===//
17
18#ifndef LLVM_MC_TARGETREGISTRY_H
19#define LLVM_MC_TARGETREGISTRY_H
20
22#include "llvm/ADT/StringRef.h"
30#include <cassert>
31#include <cstddef>
32#include <iterator>
33#include <memory>
34#include <optional>
35#include <string>
36
37namespace llvm {
38
39class AsmPrinter;
40class MCAsmBackend;
41class MCAsmInfo;
42class MCAsmParser;
43class MCCodeEmitter;
44class MCContext;
45class MCDisassembler;
46class MCInstPrinter;
47class MCInstrAnalysis;
48class MCInstrInfo;
49class MCObjectWriter;
50class MCRegisterInfo;
51class MCRelocationInfo;
52class MCStreamer;
53class MCSubtargetInfo;
54class MCSymbolizer;
55class MCTargetAsmParser;
56class MCTargetOptions;
57class MCTargetStreamer;
58class raw_ostream;
59class TargetMachine;
60class TargetOptions;
61namespace mca {
62class CustomBehaviour;
65struct SourceMgr;
66} // namespace mca
67
69// Takes ownership of \p TAB and \p CE.
70
71/// Create a machine code streamer which will print out assembly for the native
72/// target, suitable for compiling with a native assembler.
73///
74/// \param InstPrint - If given, the instruction printer to use. If not given
75/// the MCInst representation will be printed. This method takes ownership of
76/// InstPrint.
77///
78/// \param CE - If given, a code emitter to use to show the instruction
79/// encoding inline with the assembly. This method takes ownership of \p CE.
80///
81/// \param TAB - If given, a target asm backend to use to show the fixup
82/// information in conjunction with encoding information. This method takes
83/// ownership of \p TAB.
84///
85/// \param ShowInst - Whether to show the MCInst representation inline with
86/// the assembly.
88createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS,
89 std::unique_ptr<MCInstPrinter> InstPrint,
90 std::unique_ptr<MCCodeEmitter> CE,
91 std::unique_ptr<MCAsmBackend> TAB);
92
94 std::unique_ptr<MCAsmBackend> &&TAB,
95 std::unique_ptr<MCObjectWriter> &&OW,
96 std::unique_ptr<MCCodeEmitter> &&CE);
98 std::unique_ptr<MCAsmBackend> &&TAB,
99 std::unique_ptr<MCObjectWriter> &&OW,
100 std::unique_ptr<MCCodeEmitter> &&CE);
102 std::unique_ptr<MCAsmBackend> &&TAB,
103 std::unique_ptr<MCObjectWriter> &&OW,
104 std::unique_ptr<MCCodeEmitter> &&CE,
105 bool DWARFMustBeAtTheEnd,
106 bool LabelSections = false);
108 std::unique_ptr<MCAsmBackend> &&TAB,
109 std::unique_ptr<MCObjectWriter> &&OW,
110 std::unique_ptr<MCCodeEmitter> &&CE);
112 std::unique_ptr<MCAsmBackend> &&TAB,
113 std::unique_ptr<MCObjectWriter> &&OW,
114 std::unique_ptr<MCCodeEmitter> &&CE);
116createDXContainerStreamer(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
117 std::unique_ptr<MCObjectWriter> &&OW,
118 std::unique_ptr<MCCodeEmitter> &&CE);
119
121 MCContext &Ctx);
122
124createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
125 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
126 MCContext *Ctx, std::unique_ptr<MCRelocationInfo> &&RelInfo);
127
130 const MCInstrInfo &MCII);
131
134
137
138/// Target - Wrapper for Target specific information.
139///
140/// For registration purposes, this is a POD type so that targets can be
141/// registered without the use of static constructors.
142///
143/// Targets should implement a single global instance of this class (which
144/// will be zero initialized), and pass that instance to the TargetRegistry as
145/// part of their initialization.
146class Target {
147public:
148 friend struct TargetRegistry;
149
151
153 const Triple &TT,
154 const MCTargetOptions &Options);
156 bool PIC,
157 bool LargeCodeModel);
160 using MCRegInfoCtorFnTy = MCRegisterInfo *(*)(const Triple &TT);
162 StringRef CPU,
163 StringRef Features);
165 *(*)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
166 const TargetOptions &Options, std::optional<Reloc::Model> RM,
167 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, bool JIT);
168 // If it weren't for layering issues (this header is in llvm/Support, but
169 // depends on MC?) this should take the Streamer by value rather than rvalue
170 // reference.
172 TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
174 const MCSubtargetInfo &STI,
175 const MCRegisterInfo &MRI,
176 const MCTargetOptions &Options);
178 const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
179 const MCTargetOptions &Options);
181 const MCSubtargetInfo &STI,
182 MCContext &Ctx);
184 unsigned SyntaxVariant,
185 const MCAsmInfo &MAI,
186 const MCInstrInfo &MII,
187 const MCRegisterInfo &MRI);
189 MCContext &Ctx);
191 MCStreamer *(*)(const Triple &T, MCContext &Ctx,
192 std::unique_ptr<MCAsmBackend> &&TAB,
193 std::unique_ptr<MCObjectWriter> &&OW,
194 std::unique_ptr<MCCodeEmitter> &&Emitter);
196 MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
197 std::unique_ptr<MCObjectWriter> &&OW,
198 std::unique_ptr<MCCodeEmitter> &&Emitter);
200 MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB,
201 std::unique_ptr<MCObjectWriter> &&OW,
202 std::unique_ptr<MCCodeEmitter> &&Emitter);
204 MCStreamer *(*)(const Triple &T, MCContext &Ctx,
205 std::unique_ptr<MCAsmBackend> &&TAB,
206 std::unique_ptr<MCObjectWriter> &&OW,
207 std::unique_ptr<MCCodeEmitter> &&Emitter);
208
212 MCInstPrinter *InstPrint);
214 *(*)(MCContext & Ctx, std::unique_ptr<formatted_raw_ostream> OS,
215 std::unique_ptr<MCInstPrinter> IP, std::unique_ptr<MCCodeEmitter> CE,
216 std::unique_ptr<MCAsmBackend> TAB);
218 MCTargetStreamer *(*)(MCStreamer &S, const MCSubtargetInfo &STI);
220 MCContext &Ctx);
222 MCSymbolizer *(*)(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
223 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo,
224 MCContext *Ctx,
225 std::unique_ptr<MCRelocationInfo> &&RelInfo);
226
229 const mca::SourceMgr &SrcMgr,
230 const MCInstrInfo &MCII);
231
234 const MCInstrInfo &MCII);
235
238 const MCInstrInfo &MCII);
239
240private:
241 /// Next - The next registered target in the linked list, maintained by the
242 /// TargetRegistry.
243 Target *Next;
244
245 /// The target function for checking if an architecture is supported.
246 ArchMatchFnTy ArchMatchFn;
247
248 /// Name - The target name.
249 const char *Name;
250
251 /// ShortDesc - A short description of the target.
252 const char *ShortDesc;
253
254 /// BackendName - The name of the backend implementation. This must match the
255 /// name of the 'def X : Target ...' in TableGen.
256 const char *BackendName;
257
258 /// HasJIT - Whether this target supports the JIT.
259 bool HasJIT;
260
261 /// MCAsmInfoCtorFn - Constructor function for this target's MCAsmInfo, if
262 /// registered.
263 MCAsmInfoCtorFnTy MCAsmInfoCtorFn;
264
265 /// Constructor function for this target's MCObjectFileInfo, if registered.
266 MCObjectFileInfoCtorFnTy MCObjectFileInfoCtorFn;
267
268 /// MCInstrInfoCtorFn - Constructor function for this target's MCInstrInfo,
269 /// if registered.
270 MCInstrInfoCtorFnTy MCInstrInfoCtorFn;
271
272 /// MCInstrAnalysisCtorFn - Constructor function for this target's
273 /// MCInstrAnalysis, if registered.
274 MCInstrAnalysisCtorFnTy MCInstrAnalysisCtorFn;
275
276 /// MCRegInfoCtorFn - Constructor function for this target's MCRegisterInfo,
277 /// if registered.
278 MCRegInfoCtorFnTy MCRegInfoCtorFn;
279
280 /// MCSubtargetInfoCtorFn - Constructor function for this target's
281 /// MCSubtargetInfo, if registered.
282 MCSubtargetInfoCtorFnTy MCSubtargetInfoCtorFn;
283
284 /// TargetMachineCtorFn - Construction function for this target's
285 /// TargetMachine, if registered.
286 TargetMachineCtorTy TargetMachineCtorFn;
287
288 /// MCAsmBackendCtorFn - Construction function for this target's
289 /// MCAsmBackend, if registered.
290 MCAsmBackendCtorTy MCAsmBackendCtorFn;
291
292 /// MCAsmParserCtorFn - Construction function for this target's
293 /// MCTargetAsmParser, if registered.
294 MCAsmParserCtorTy MCAsmParserCtorFn;
295
296 /// AsmPrinterCtorFn - Construction function for this target's AsmPrinter,
297 /// if registered.
298 AsmPrinterCtorTy AsmPrinterCtorFn;
299
300 /// MCDisassemblerCtorFn - Construction function for this target's
301 /// MCDisassembler, if registered.
302 MCDisassemblerCtorTy MCDisassemblerCtorFn;
303
304 /// MCInstPrinterCtorFn - Construction function for this target's
305 /// MCInstPrinter, if registered.
306 MCInstPrinterCtorTy MCInstPrinterCtorFn;
307
308 /// MCCodeEmitterCtorFn - Construction function for this target's
309 /// CodeEmitter, if registered.
310 MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
311
312 // Construction functions for the various object formats, if registered.
313 COFFStreamerCtorTy COFFStreamerCtorFn = nullptr;
314 MachOStreamerCtorTy MachOStreamerCtorFn = nullptr;
315 ELFStreamerCtorTy ELFStreamerCtorFn = nullptr;
316 XCOFFStreamerCtorTy XCOFFStreamerCtorFn = nullptr;
317
318 /// Construction function for this target's null TargetStreamer, if
319 /// registered (default = nullptr).
320 NullTargetStreamerCtorTy NullTargetStreamerCtorFn = nullptr;
321
322 /// Construction function for this target's asm TargetStreamer, if
323 /// registered (default = nullptr).
324 AsmTargetStreamerCtorTy AsmTargetStreamerCtorFn = nullptr;
325
326 /// Construction function for this target's AsmStreamer, if
327 /// registered (default = nullptr).
328 AsmStreamerCtorTy AsmStreamerCtorFn = nullptr;
329
330 /// Construction function for this target's obj TargetStreamer, if
331 /// registered (default = nullptr).
332 ObjectTargetStreamerCtorTy ObjectTargetStreamerCtorFn = nullptr;
333
334 /// MCRelocationInfoCtorFn - Construction function for this target's
335 /// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
336 MCRelocationInfoCtorTy MCRelocationInfoCtorFn = nullptr;
337
338 /// MCSymbolizerCtorFn - Construction function for this target's
339 /// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
340 MCSymbolizerCtorTy MCSymbolizerCtorFn = nullptr;
341
342 /// CustomBehaviourCtorFn - Construction function for this target's
343 /// CustomBehaviour, if registered (default = nullptr).
344 CustomBehaviourCtorTy CustomBehaviourCtorFn = nullptr;
345
346 /// InstrPostProcessCtorFn - Construction function for this target's
347 /// InstrPostProcess, if registered (default = nullptr).
348 InstrPostProcessCtorTy InstrPostProcessCtorFn = nullptr;
349
350 /// InstrumentManagerCtorFn - Construction function for this target's
351 /// InstrumentManager, if registered (default = nullptr).
352 InstrumentManagerCtorTy InstrumentManagerCtorFn = nullptr;
353
354public:
355 Target() = default;
356
357 /// @name Target Information
358 /// @{
359
360 // getNext - Return the next registered target.
361 const Target *getNext() const { return Next; }
362
363 /// getName - Get the target name.
364 const char *getName() const { return Name; }
365
366 /// getShortDescription - Get a short description of the target.
367 const char *getShortDescription() const { return ShortDesc; }
368
369 /// getBackendName - Get the backend name.
370 const char *getBackendName() const { return BackendName; }
371
372 /// @}
373 /// @name Feature Predicates
374 /// @{
375
376 /// hasJIT - Check if this targets supports the just-in-time compilation.
377 bool hasJIT() const { return HasJIT; }
378
379 /// hasTargetMachine - Check if this target supports code generation.
380 bool hasTargetMachine() const { return TargetMachineCtorFn != nullptr; }
381
382 /// hasMCAsmBackend - Check if this target supports .o generation.
383 bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != nullptr; }
384
385 /// hasMCAsmParser - Check if this target supports assembly parsing.
386 bool hasMCAsmParser() const { return MCAsmParserCtorFn != nullptr; }
387
388 /// @}
389 /// @name Feature Constructors
390 /// @{
391
392 /// createMCAsmInfo - Create a MCAsmInfo implementation for the specified
393 /// target triple.
394 ///
395 /// \param TheTriple This argument is used to determine the target machine
396 /// feature set; it should always be provided. Generally this should be
397 /// either the target triple from the module, or the target triple of the
398 /// host if that does not exist.
400 const MCTargetOptions &Options) const {
401 if (!MCAsmInfoCtorFn)
402 return nullptr;
403 return MCAsmInfoCtorFn(MRI, Triple(TheTriple), Options);
404 }
405
406 /// Create a MCObjectFileInfo implementation for the specified target
407 /// triple.
408 ///
410 bool LargeCodeModel = false) const {
411 if (!MCObjectFileInfoCtorFn) {
413 MOFI->initMCObjectFileInfo(Ctx, PIC, LargeCodeModel);
414 return MOFI;
415 }
416 return MCObjectFileInfoCtorFn(Ctx, PIC, LargeCodeModel);
417 }
418
419 /// createMCInstrInfo - Create a MCInstrInfo implementation.
420 ///
422 if (!MCInstrInfoCtorFn)
423 return nullptr;
424 return MCInstrInfoCtorFn();
425 }
426
427 /// createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
428 ///
430 if (!MCInstrAnalysisCtorFn)
431 return nullptr;
432 return MCInstrAnalysisCtorFn(Info);
433 }
434
435 /// createMCRegInfo - Create a MCRegisterInfo implementation.
436 ///
438 if (!MCRegInfoCtorFn)
439 return nullptr;
440 return MCRegInfoCtorFn(Triple(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 return MCSubtargetInfoCtorFn(Triple(TheTriple), CPU, Features);
457 }
458
459 /// createTargetMachine - Create a target specific machine implementation
460 /// for the specified \p Triple.
461 ///
462 /// \param TT This argument is used to determine the target machine
463 /// feature set; it should always be provided. Generally this should be
464 /// either the target triple from the module, or the target triple of the
465 /// host if that does not exist.
467 const Triple &TT, StringRef CPU, StringRef Features,
468 const TargetOptions &Options, std::optional<Reloc::Model> RM,
469 std::optional<CodeModel::Model> CM = std::nullopt,
470 CodeGenOptLevel OL = CodeGenOptLevel::Default, bool JIT = false) const {
471 if (!TargetMachineCtorFn)
472 return nullptr;
473 return TargetMachineCtorFn(*this, TT, CPU, Features, Options, RM, CM, OL,
474 JIT);
475 }
476
477 [[deprecated("Use overload accepting Triple instead")]]
479 StringRef 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 return createTargetMachine(Triple(TT), CPU, Features, Options, RM, CM, OL,
484 JIT);
485 }
486
487 /// createMCAsmBackend - Create a target specific assembly parser.
489 const MCRegisterInfo &MRI,
490 const MCTargetOptions &Options) const {
491 if (!MCAsmBackendCtorFn)
492 return nullptr;
493 return MCAsmBackendCtorFn(*this, STI, MRI, Options);
494 }
495
496 /// createMCAsmParser - Create a target specific assembly parser.
497 ///
498 /// \param Parser The target independent parser implementation to use for
499 /// parsing and lexing.
501 MCAsmParser &Parser,
502 const MCInstrInfo &MII,
503 const MCTargetOptions &Options) const {
504 if (!MCAsmParserCtorFn)
505 return nullptr;
506 return MCAsmParserCtorFn(STI, Parser, MII, Options);
507 }
508
509 /// createAsmPrinter - Create a target specific assembly printer pass. This
510 /// takes ownership of the MCStreamer object.
512 std::unique_ptr<MCStreamer> &&Streamer) const {
513 if (!AsmPrinterCtorFn)
514 return nullptr;
515 return AsmPrinterCtorFn(TM, std::move(Streamer));
516 }
517
519 MCContext &Ctx) const {
520 if (!MCDisassemblerCtorFn)
521 return nullptr;
522 return MCDisassemblerCtorFn(*this, STI, Ctx);
523 }
524
525 MCInstPrinter *createMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
526 const MCAsmInfo &MAI,
527 const MCInstrInfo &MII,
528 const MCRegisterInfo &MRI) const {
529 if (!MCInstPrinterCtorFn)
530 return nullptr;
531 return MCInstPrinterCtorFn(T, SyntaxVariant, MAI, MII, MRI);
532 }
533
534 /// createMCCodeEmitter - Create a target specific code emitter.
536 MCContext &Ctx) const {
537 if (!MCCodeEmitterCtorFn)
538 return nullptr;
539 return MCCodeEmitterCtorFn(II, Ctx);
540 }
541
542 /// Create a target specific MCStreamer.
543 ///
544 /// \param T The target triple.
545 /// \param Ctx The target context.
546 /// \param TAB The target assembler backend object. Takes ownership.
547 /// \param OW The stream object.
548 /// \param Emitter The target independent assembler object.Takes ownership.
550 const Triple &T, MCContext &Ctx, std::unique_ptr<MCAsmBackend> TAB,
551 std::unique_ptr<MCObjectWriter> OW,
552 std::unique_ptr<MCCodeEmitter> Emitter, const MCSubtargetInfo &STI) const;
553
555 createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS,
556 std::unique_ptr<MCInstPrinter> IP,
557 std::unique_ptr<MCCodeEmitter> CE,
558 std::unique_ptr<MCAsmBackend> TAB) const;
559
562 MCInstPrinter *InstPrint) const {
563 if (AsmTargetStreamerCtorFn)
564 return AsmTargetStreamerCtorFn(S, OS, InstPrint);
565 return nullptr;
566 }
567
571 return S;
572 }
573
575 if (NullTargetStreamerCtorFn)
576 return NullTargetStreamerCtorFn(S);
577 return nullptr;
578 }
579
580 /// createMCRelocationInfo - Create a target specific MCRelocationInfo.
581 ///
582 /// \param TT The target triple.
583 /// \param Ctx The target context.
585 MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn
586 ? MCRelocationInfoCtorFn
588 return Fn(Triple(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(Triple(TT), GetOpInfo, SymbolLookUp, DisInfo, Ctx,
611 std::move(RelInfo));
612 }
613
614 /// createCustomBehaviour - Create a target specific CustomBehaviour.
615 /// This class is used by llvm-mca and requires backend functionality.
617 const mca::SourceMgr &SrcMgr,
618 const MCInstrInfo &MCII) const {
619 if (CustomBehaviourCtorFn)
620 return CustomBehaviourCtorFn(STI, SrcMgr, MCII);
621 return nullptr;
622 }
623
624 /// createInstrPostProcess - Create a target specific InstrPostProcess.
625 /// This class is used by llvm-mca and requires backend functionality.
627 const MCInstrInfo &MCII) const {
628 if (InstrPostProcessCtorFn)
629 return InstrPostProcessCtorFn(STI, MCII);
630 return nullptr;
631 }
632
633 /// createInstrumentManager - Create a target specific
634 /// InstrumentManager. This class is used by llvm-mca and requires
635 /// backend functionality.
638 const MCInstrInfo &MCII) const {
639 if (InstrumentManagerCtorFn)
640 return InstrumentManagerCtorFn(STI, MCII);
641 return nullptr;
642 }
643
644 /// @}
645};
646
647/// TargetRegistry - Generic interface to target specific features.
649 // FIXME: Make this a namespace, probably just move all the Register*
650 // functions into Target (currently they all just set members on the Target
651 // anyway, and Target friends this class so those functions can...
652 // function).
653 TargetRegistry() = delete;
654
655 class iterator {
656 friend struct TargetRegistry;
657
658 const Target *Current = nullptr;
659
660 explicit iterator(Target *T) : Current(T) {}
661
662 public:
663 using iterator_category = std::forward_iterator_tag;
665 using difference_type = std::ptrdiff_t;
668
669 iterator() = default;
670
671 bool operator==(const iterator &x) const { return Current == x.Current; }
672 bool operator!=(const iterator &x) const { return !operator==(x); }
673
674 // Iterator traversal: forward iteration only
675 iterator &operator++() { // Preincrement
676 assert(Current && "Cannot increment end iterator!");
677 Current = Current->getNext();
678 return *this;
679 }
680 iterator operator++(int) { // Postincrement
681 iterator tmp = *this;
682 ++*this;
683 return tmp;
684 }
685
686 const Target &operator*() const {
687 assert(Current && "Cannot dereference end iterator!");
688 return *Current;
689 }
690
691 const Target *operator->() const { return &operator*(); }
692 };
693
694 /// printRegisteredTargetsForVersion - Print the registered targets
695 /// appropriately for inclusion in a tool's version output.
697
698 /// @name Registry Access
699 /// @{
700
702
703 /// lookupTarget - Lookup a target based on a target triple.
704 ///
705 /// \param TripleStr - The triple to use for finding a target.
706 /// \param Error - On failure, an error string describing why no target was
707 /// found.
708 // TODO: Drop this in favor of the method accepting Triple.
709 static const Target *lookupTarget(StringRef TripleStr, std::string &Error) {
710 return lookupTarget(Triple(TripleStr), Error);
711 }
712
713 /// lookupTarget - Lookup a target based on a target triple.
714 ///
715 /// \param Triple - The triple to use for finding a target.
716 /// \param Error - On failure, an error string describing why no target was
717 /// found.
718 LLVM_ABI static const Target *lookupTarget(const Triple &TheTriple,
719 std::string &Error);
720
721 /// lookupTarget - Lookup a target based on an architecture name
722 /// and a target triple. If the architecture name is non-empty,
723 /// then the lookup is done by architecture. Otherwise, the target
724 /// triple is used.
725 ///
726 /// \param ArchName - The architecture to use for finding a target.
727 /// \param TheTriple - The triple to use for finding a target. The
728 /// triple is updated with canonical architecture name if a lookup
729 /// by architecture is done.
730 /// \param Error - On failure, an error string describing why no target was
731 /// found.
732 LLVM_ABI static const Target *
733 lookupTarget(StringRef ArchName, Triple &TheTriple, std::string &Error);
734
735 /// @}
736 /// @name Target Registration
737 /// @{
738
739 /// RegisterTarget - Register the given target. Attempts to register a
740 /// target which has already been registered will be ignored.
741 ///
742 /// Clients are responsible for ensuring that registration doesn't occur
743 /// while another thread is attempting to access the registry. Typically
744 /// this is done by initializing all targets at program startup.
745 ///
746 /// @param T - The target being registered.
747 /// @param Name - The target name. This should be a static string.
748 /// @param ShortDesc - A short target description. This should be a static
749 /// string.
750 /// @param BackendName - The name of the backend. This should be a static
751 /// string that is the same for all targets that share a backend
752 /// implementation and must match the name used in the 'def X : Target ...' in
753 /// TableGen.
754 /// @param ArchMatchFn - The arch match checking function for this target.
755 /// @param HasJIT - Whether the target supports JIT code
756 /// generation.
757 LLVM_ABI static void RegisterTarget(Target &T, const char *Name,
758 const char *ShortDesc,
759 const char *BackendName,
760 Target::ArchMatchFnTy ArchMatchFn,
761 bool HasJIT = false);
762
763 /// RegisterMCAsmInfo - Register a MCAsmInfo implementation for the
764 /// given target.
765 ///
766 /// Clients are responsible for ensuring that registration doesn't occur
767 /// while another thread is attempting to access the registry. Typically
768 /// this is done by initializing all targets at program startup.
769 ///
770 /// @param T - The target being registered.
771 /// @param Fn - A function to construct a MCAsmInfo for the target.
773 T.MCAsmInfoCtorFn = Fn;
774 }
775
776 /// Register a MCObjectFileInfo implementation for the given target.
777 ///
778 /// Clients are responsible for ensuring that registration doesn't occur
779 /// while another thread is attempting to access the registry. Typically
780 /// this is done by initializing all targets at program startup.
781 ///
782 /// @param T - The target being registered.
783 /// @param Fn - A function to construct a MCObjectFileInfo for the target.
786 T.MCObjectFileInfoCtorFn = Fn;
787 }
788
789 /// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the
790 /// given target.
791 ///
792 /// Clients are responsible for ensuring that registration doesn't occur
793 /// while another thread is attempting to access the registry. Typically
794 /// this is done by initializing all targets at program startup.
795 ///
796 /// @param T - The target being registered.
797 /// @param Fn - A function to construct a MCInstrInfo for the target.
799 T.MCInstrInfoCtorFn = Fn;
800 }
801
802 /// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for
803 /// the given target.
806 T.MCInstrAnalysisCtorFn = Fn;
807 }
808
809 /// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the
810 /// given target.
811 ///
812 /// Clients are responsible for ensuring that registration doesn't occur
813 /// while another thread is attempting to access the registry. Typically
814 /// this is done by initializing all targets at program startup.
815 ///
816 /// @param T - The target being registered.
817 /// @param Fn - A function to construct a MCRegisterInfo for the target.
819 T.MCRegInfoCtorFn = Fn;
820 }
821
822 /// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for
823 /// the 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 MCSubtargetInfo for the target.
833 T.MCSubtargetInfoCtorFn = Fn;
834 }
835
836 /// RegisterTargetMachine - Register a TargetMachine implementation for the
837 /// given target.
838 ///
839 /// Clients are responsible for ensuring that registration doesn't occur
840 /// while another thread is attempting to access the registry. Typically
841 /// this is done by initializing all targets at program startup.
842 ///
843 /// @param T - The target being registered.
844 /// @param Fn - A function to construct a TargetMachine for the target.
846 T.TargetMachineCtorFn = Fn;
847 }
848
849 /// RegisterMCAsmBackend - Register a MCAsmBackend 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 an AsmBackend for the target.
859 T.MCAsmBackendCtorFn = Fn;
860 }
861
862 /// RegisterMCAsmParser - Register a MCTargetAsmParser implementation for
863 /// the 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 MCTargetAsmParser for the target.
872 T.MCAsmParserCtorFn = Fn;
873 }
874
875 /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given
876 /// 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 AsmPrinter for the target.
885 T.AsmPrinterCtorFn = Fn;
886 }
887
888 /// RegisterMCDisassembler - Register a MCDisassembler implementation for
889 /// the given 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 MCDisassembler for the target.
899 T.MCDisassemblerCtorFn = Fn;
900 }
901
902 /// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the
903 /// given target.
904 ///
905 /// Clients are responsible for ensuring that registration doesn't occur
906 /// while another thread is attempting to access the registry. Typically
907 /// this is done by initializing all targets at program startup.
908 ///
909 /// @param T - The target being registered.
910 /// @param Fn - A function to construct an MCInstPrinter for the target.
912 T.MCInstPrinterCtorFn = Fn;
913 }
914
915 /// RegisterMCCodeEmitter - Register a MCCodeEmitter 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 MCCodeEmitter for the target.
925 T.MCCodeEmitterCtorFn = Fn;
926 }
927
929 T.COFFStreamerCtorFn = Fn;
930 }
931
933 T.MachOStreamerCtorFn = Fn;
934 }
935
937 T.ELFStreamerCtorFn = Fn;
938 }
939
941 T.XCOFFStreamerCtorFn = Fn;
942 }
943
946 T.NullTargetStreamerCtorFn = Fn;
947 }
948
950 T.AsmStreamerCtorFn = Fn;
951 }
952
955 T.AsmTargetStreamerCtorFn = Fn;
956 }
957
958 static void
961 T.ObjectTargetStreamerCtorFn = Fn;
962 }
963
964 /// RegisterMCRelocationInfo - Register an MCRelocationInfo
965 /// implementation for the given target.
966 ///
967 /// Clients are responsible for ensuring that registration doesn't occur
968 /// while another thread is attempting to access the registry. Typically
969 /// this is done by initializing all targets at program startup.
970 ///
971 /// @param T - The target being registered.
972 /// @param Fn - A function to construct an MCRelocationInfo for the target.
975 T.MCRelocationInfoCtorFn = Fn;
976 }
977
978 /// RegisterMCSymbolizer - Register an MCSymbolizer
979 /// implementation for the given target.
980 ///
981 /// Clients are responsible for ensuring that registration doesn't occur
982 /// while another thread is attempting to access the registry. Typically
983 /// this is done by initializing all targets at program startup.
984 ///
985 /// @param T - The target being registered.
986 /// @param Fn - A function to construct an MCSymbolizer for the target.
988 T.MCSymbolizerCtorFn = Fn;
989 }
990
991 /// RegisterCustomBehaviour - Register a CustomBehaviour
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 a CustomBehaviour for the target.
1002 T.CustomBehaviourCtorFn = Fn;
1003 }
1004
1005 /// RegisterInstrPostProcess - Register an InstrPostProcess
1006 /// implementation for the given target.
1007 ///
1008 /// Clients are responsible for ensuring that registration doesn't occur
1009 /// while another thread is attempting to access the registry. Typically
1010 /// this is done by initializing all targets at program startup.
1011 ///
1012 /// @param T - The target being registered.
1013 /// @param Fn - A function to construct an InstrPostProcess for the target.
1016 T.InstrPostProcessCtorFn = Fn;
1017 }
1018
1019 /// RegisterInstrumentManager - Register an InstrumentManager
1020 /// implementation for the given target.
1021 ///
1022 /// Clients are responsible for ensuring that registration doesn't occur
1023 /// while another thread is attempting to access the registry. Typically
1024 /// this is done by initializing all targets at program startup.
1025 ///
1026 /// @param T - The target being registered.
1027 /// @param Fn - A function to construct an InstrumentManager for the
1028 /// target.
1031 T.InstrumentManagerCtorFn = Fn;
1032 }
1033
1034 /// @}
1035};
1036
1037//===--------------------------------------------------------------------===//
1038
1039/// RegisterTarget - Helper template for registering a target, for use in the
1040/// target's initialization function. Usage:
1041///
1042///
1043/// Target &getTheFooTarget() { // The global target instance.
1044/// static Target TheFooTarget;
1045/// return TheFooTarget;
1046/// }
1047/// extern "C" void LLVMInitializeFooTargetInfo() {
1048/// RegisterTarget<Triple::foo> X(getTheFooTarget(), "foo", "Foo
1049/// description", "Foo" /* Backend Name */);
1050/// }
1051template <Triple::ArchType TargetArchType = Triple::UnknownArch,
1052 bool HasJIT = false>
1054 RegisterTarget(Target &T, const char *Name, const char *Desc,
1055 const char *BackendName) {
1057 HasJIT);
1058 }
1059
1060 static bool getArchMatch(Triple::ArchType Arch) {
1061 return Arch == TargetArchType;
1062 }
1063};
1064
1065/// RegisterMCAsmInfo - Helper template for registering a target assembly info
1066/// implementation. This invokes the static "Create" method on the class to
1067/// actually do the construction. Usage:
1068///
1069/// extern "C" void LLVMInitializeFooTarget() {
1070/// extern Target TheFooTarget;
1071/// RegisterMCAsmInfo<FooMCAsmInfo> X(TheFooTarget);
1072/// }
1073template <class MCAsmInfoImpl> struct RegisterMCAsmInfo {
1076 }
1077
1078private:
1079 static MCAsmInfo *Allocator(const MCRegisterInfo & /*MRI*/, const Triple &TT,
1080 const MCTargetOptions &Options) {
1081 return new MCAsmInfoImpl(TT, Options);
1082 }
1083};
1084
1085/// RegisterMCAsmInfoFn - Helper template for registering a target assembly info
1086/// implementation. This invokes the specified function to do the
1087/// construction. Usage:
1088///
1089/// extern "C" void LLVMInitializeFooTarget() {
1090/// extern Target TheFooTarget;
1091/// RegisterMCAsmInfoFn X(TheFooTarget, TheFunction);
1092/// }
1096 }
1097};
1098
1099/// Helper template for registering a target object file info implementation.
1100/// This invokes the static "Create" method on the class to actually do the
1101/// construction. Usage:
1102///
1103/// extern "C" void LLVMInitializeFooTarget() {
1104/// extern Target TheFooTarget;
1105/// RegisterMCObjectFileInfo<FooMCObjectFileInfo> X(TheFooTarget);
1106/// }
1107template <class MCObjectFileInfoImpl> struct RegisterMCObjectFileInfo {
1110 }
1111
1112private:
1113 static MCObjectFileInfo *Allocator(MCContext &Ctx, bool PIC,
1114 bool LargeCodeModel = false) {
1115 return new MCObjectFileInfoImpl(Ctx, PIC, LargeCodeModel);
1116 }
1117};
1118
1119/// Helper template for registering a target object file info implementation.
1120/// This invokes the specified function to do the construction. Usage:
1121///
1122/// extern "C" void LLVMInitializeFooTarget() {
1123/// extern Target TheFooTarget;
1124/// RegisterMCObjectFileInfoFn X(TheFooTarget, TheFunction);
1125/// }
1129 }
1130};
1131
1132/// RegisterMCInstrInfo - Helper template for registering a target instruction
1133/// info implementation. This invokes the static "Create" method on the class
1134/// to actually do the construction. Usage:
1135///
1136/// extern "C" void LLVMInitializeFooTarget() {
1137/// extern Target TheFooTarget;
1138/// RegisterMCInstrInfo<FooMCInstrInfo> X(TheFooTarget);
1139/// }
1140template <class MCInstrInfoImpl> struct RegisterMCInstrInfo {
1143 }
1144
1145private:
1146 static MCInstrInfo *Allocator() { return new MCInstrInfoImpl(); }
1147};
1148
1149/// RegisterMCInstrInfoFn - Helper template for registering a target
1150/// instruction info implementation. This invokes the specified function to
1151/// do the construction. Usage:
1152///
1153/// extern "C" void LLVMInitializeFooTarget() {
1154/// extern Target TheFooTarget;
1155/// RegisterMCInstrInfoFn X(TheFooTarget, TheFunction);
1156/// }
1160 }
1161};
1162
1163/// RegisterMCInstrAnalysis - Helper template for registering a target
1164/// instruction analyzer implementation. This invokes the static "Create"
1165/// method on the class to actually do the construction. Usage:
1166///
1167/// extern "C" void LLVMInitializeFooTarget() {
1168/// extern Target TheFooTarget;
1169/// RegisterMCInstrAnalysis<FooMCInstrAnalysis> X(TheFooTarget);
1170/// }
1171template <class MCInstrAnalysisImpl> struct RegisterMCInstrAnalysis {
1174 }
1175
1176private:
1177 static MCInstrAnalysis *Allocator(const MCInstrInfo *Info) {
1178 return new MCInstrAnalysisImpl(Info);
1179 }
1180};
1181
1182/// RegisterMCInstrAnalysisFn - Helper template for registering a target
1183/// instruction analyzer implementation. This invokes the specified function
1184/// to do the construction. Usage:
1185///
1186/// extern "C" void LLVMInitializeFooTarget() {
1187/// extern Target TheFooTarget;
1188/// RegisterMCInstrAnalysisFn X(TheFooTarget, TheFunction);
1189/// }
1193 }
1194};
1195
1196/// RegisterMCRegInfo - Helper template for registering a target register info
1197/// implementation. This invokes the static "Create" method on the class to
1198/// actually do the construction. Usage:
1199///
1200/// extern "C" void LLVMInitializeFooTarget() {
1201/// extern Target TheFooTarget;
1202/// RegisterMCRegInfo<FooMCRegInfo> X(TheFooTarget);
1203/// }
1204template <class MCRegisterInfoImpl> struct RegisterMCRegInfo {
1207 }
1208
1209private:
1210 static MCRegisterInfo *Allocator(const Triple & /*TT*/) {
1211 return new MCRegisterInfoImpl();
1212 }
1213};
1214
1215/// RegisterMCRegInfoFn - Helper template for registering a target register
1216/// info implementation. This invokes the specified function to do the
1217/// construction. Usage:
1218///
1219/// extern "C" void LLVMInitializeFooTarget() {
1220/// extern Target TheFooTarget;
1221/// RegisterMCRegInfoFn X(TheFooTarget, TheFunction);
1222/// }
1226 }
1227};
1228
1229/// RegisterMCSubtargetInfo - Helper template for registering a target
1230/// subtarget info implementation. This invokes the static "Create" method
1231/// on the class to actually do the construction. Usage:
1232///
1233/// extern "C" void LLVMInitializeFooTarget() {
1234/// extern Target TheFooTarget;
1235/// RegisterMCSubtargetInfo<FooMCSubtargetInfo> X(TheFooTarget);
1236/// }
1237template <class MCSubtargetInfoImpl> struct RegisterMCSubtargetInfo {
1240 }
1241
1242private:
1243 static MCSubtargetInfo *Allocator(const Triple & /*TT*/, StringRef /*CPU*/,
1244 StringRef /*FS*/) {
1245 return new MCSubtargetInfoImpl();
1246 }
1247};
1248
1249/// RegisterMCSubtargetInfoFn - Helper template for registering a target
1250/// subtarget info implementation. This invokes the specified function to
1251/// do the construction. Usage:
1252///
1253/// extern "C" void LLVMInitializeFooTarget() {
1254/// extern Target TheFooTarget;
1255/// RegisterMCSubtargetInfoFn X(TheFooTarget, TheFunction);
1256/// }
1260 }
1261};
1262
1263/// RegisterTargetMachine - Helper template for registering a target machine
1264/// implementation, for use in the target machine initialization
1265/// function. Usage:
1266///
1267/// extern "C" void LLVMInitializeFooTarget() {
1268/// extern Target TheFooTarget;
1269/// RegisterTargetMachine<FooTargetMachine> X(TheFooTarget);
1270/// }
1271template <class TargetMachineImpl> struct RegisterTargetMachine {
1274 }
1275
1276private:
1277 static TargetMachine *
1278 Allocator(const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
1279 const TargetOptions &Options, std::optional<Reloc::Model> RM,
1280 std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, bool JIT) {
1281 return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL, JIT);
1282 }
1283};
1284
1285/// RegisterMCAsmBackend - Helper template for registering a target specific
1286/// assembler backend. Usage:
1287///
1288/// extern "C" void LLVMInitializeFooMCAsmBackend() {
1289/// extern Target TheFooTarget;
1290/// RegisterMCAsmBackend<FooAsmLexer> X(TheFooTarget);
1291/// }
1292template <class MCAsmBackendImpl> struct RegisterMCAsmBackend {
1295 }
1296
1297private:
1298 static MCAsmBackend *Allocator(const Target &T, const MCSubtargetInfo &STI,
1299 const MCRegisterInfo &MRI,
1300 const MCTargetOptions &Options) {
1301 return new MCAsmBackendImpl(T, STI, MRI);
1302 }
1303};
1304
1305/// RegisterMCAsmParser - Helper template for registering a target specific
1306/// assembly parser, for use in the target machine initialization
1307/// function. Usage:
1308///
1309/// extern "C" void LLVMInitializeFooMCAsmParser() {
1310/// extern Target TheFooTarget;
1311/// RegisterMCAsmParser<FooAsmParser> X(TheFooTarget);
1312/// }
1313template <class MCAsmParserImpl> struct RegisterMCAsmParser {
1316 }
1317
1318private:
1319 static MCTargetAsmParser *Allocator(const MCSubtargetInfo &STI,
1320 MCAsmParser &P, const MCInstrInfo &MII,
1321 const MCTargetOptions &Options) {
1322 return new MCAsmParserImpl(STI, P, MII, Options);
1323 }
1324};
1325
1326/// RegisterAsmPrinter - Helper template for registering a target specific
1327/// assembly printer, for use in the target machine initialization
1328/// function. Usage:
1329///
1330/// extern "C" void LLVMInitializeFooAsmPrinter() {
1331/// extern Target TheFooTarget;
1332/// RegisterAsmPrinter<FooAsmPrinter> X(TheFooTarget);
1333/// }
1334template <class AsmPrinterImpl> struct RegisterAsmPrinter {
1337 }
1338
1339private:
1341 std::unique_ptr<MCStreamer> &&Streamer) {
1342 return new AsmPrinterImpl(TM, std::move(Streamer));
1343 }
1344};
1345
1346/// RegisterMCCodeEmitter - Helper template for registering a target specific
1347/// machine code emitter, for use in the target initialization
1348/// function. Usage:
1349///
1350/// extern "C" void LLVMInitializeFooMCCodeEmitter() {
1351/// extern Target TheFooTarget;
1352/// RegisterMCCodeEmitter<FooCodeEmitter> X(TheFooTarget);
1353/// }
1354template <class MCCodeEmitterImpl> struct RegisterMCCodeEmitter {
1357 }
1358
1359private:
1360 static MCCodeEmitter *Allocator(const MCInstrInfo & /*II*/,
1361 MCContext & /*Ctx*/) {
1362 return new MCCodeEmitterImpl();
1363 }
1364};
1365
1366} // end namespace llvm
1367
1368#endif // LLVM_MC_TARGETREGISTRY_H
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
#define LLVM_ABI
Definition: Compiler.h:213
dxil DXContainer Global Emitter
std::string Name
static LVOptions Options
Definition: LVOptions.cpp:25
uint64_t IntrinsicInst * II
#define P(N)
PassInstrumentationCallbacks PIC
Basic Register Allocator
raw_pwrite_stream & OS
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:90
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:55
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:64
Generic assembler parser interface, for use by target specific assembly parsers.
Definition: MCAsmParser.h:124
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:23
Context object for machine code objects.
Definition: MCContext.h:83
Superclass for all disassemblers.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:46
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:27
void initMCObjectFileInfo(MCContext &MCCtx, bool PIC, bool LargeCodeModel=false)
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:220
Generic base class for all target subtargets.
Symbolize and annotate disassembled instructions.
Definition: MCSymbolizer.h:40
MCTargetAsmParser - Generic interface to target specific assembly parsers.
Target specific streamer interface.
Definition: MCStreamer.h:93
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:83
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.
MCTargetStreamer *(*)(MCStreamer &S) NullTargetStreamerCtorTy
MCStreamer *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) XCOFFStreamerCtorTy
MCDisassembler *(*)(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx) MCDisassemblerCtorTy
Target()=default
mca::InstrPostProcess *(*)(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) InstrPostProcessCtorTy
MCAsmInfo *(*)(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options) MCAsmInfoCtorFnTy
bool hasTargetMachine() const
hasTargetMachine - Check if this target supports code generation.
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
TargetMachine *(*)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT) TargetMachineCtorTy
MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, MCContext &Ctx) const
createMCCodeEmitter - Create a target specific code emitter.
const char * getName() const
getName - Get the target name.
MCObjectFileInfo * createMCObjectFileInfo(MCContext &Ctx, bool PIC, bool LargeCodeModel=false) const
Create a MCObjectFileInfo implementation for the specified target triple.
const Target * getNext() const
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
AsmPrinter *(*)(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) AsmPrinterCtorTy
MCSymbolizer * createMCSymbolizer(StringRef TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo) const
createMCSymbolizer - Create a target specific MCSymbolizer.
MCAsmBackend * createMCAsmBackend(const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) const
createMCAsmBackend - Create a target specific assembly parser.
MCObjectFileInfo *(*)(MCContext &Ctx, bool PIC, bool LargeCodeModel) MCObjectFileInfoCtorFnTy
bool hasMCAsmParser() const
hasMCAsmParser - Check if this target supports assembly parsing.
MCStreamer * createNullStreamer(MCContext &Ctx) const
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
MCRelocationInfo * createMCRelocationInfo(StringRef TT, MCContext &Ctx) const
createMCRelocationInfo - Create a target specific MCRelocationInfo.
MCStreamer *(*)(const Triple &T, MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) ELFStreamerCtorTy
MCTargetStreamer * createAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint) const
MCInstrAnalysis *(*)(const MCInstrInfo *Info) MCInstrAnalysisCtorFnTy
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
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.
bool(*)(Triple::ArchType Arch) ArchMatchFnTy
MCTargetStreamer *(*)(MCStreamer &S, const MCSubtargetInfo &STI) ObjectTargetStreamerCtorTy
MCInstPrinter *(*)(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) MCInstPrinterCtorTy
MCDisassembler * createMCDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) const
mca::CustomBehaviour *(*)(const MCSubtargetInfo &STI, const mca::SourceMgr &SrcMgr, const MCInstrInfo &MCII) CustomBehaviourCtorTy
TargetMachine * createTargetMachine(StringRef TT, StringRef CPU, StringRef Features, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM=std::nullopt, CodeGenOptLevel OL=CodeGenOptLevel::Default, bool JIT=false) const
bool hasMCAsmBackend() const
hasMCAsmBackend - Check if this target supports .o generation.
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple, const MCTargetOptions &Options) const
createMCAsmInfo - Create a MCAsmInfo implementation for the specified target triple.
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
MCSubtargetInfo *(*)(const Triple &TT, StringRef CPU, StringRef Features) MCSubtargetInfoCtorFnTy
mca::InstrPostProcess * createInstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) const
createInstrPostProcess - Create a target specific InstrPostProcess.
const char * getBackendName() const
getBackendName - Get the backend name.
MCTargetStreamer *(*)(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint) AsmTargetStreamerCtorTy
MCAsmBackend *(*)(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) MCAsmBackendCtorTy
MCSymbolizer *(*)(const Triple &TT, LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, std::unique_ptr< MCRelocationInfo > &&RelInfo) MCSymbolizerCtorTy
MCTargetAsmParser * createMCAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser, const MCInstrInfo &MII, const MCTargetOptions &Options) const
createMCAsmParser - Create a target specific assembly parser.
MCInstrAnalysis * createMCInstrAnalysis(const MCInstrInfo *Info) const
createMCInstrAnalysis - Create a MCInstrAnalysis implementation.
const char * getShortDescription() const
getShortDescription - Get a short description of the target.
bool hasJIT() const
hasJIT - Check if this targets supports the just-in-time compilation.
MCCodeEmitter *(*)(const MCInstrInfo &II, MCContext &Ctx) MCCodeEmitterCtorTy
mca::InstrumentManager *(*)(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) InstrumentManagerCtorTy
MCStreamer *(*)(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) COFFStreamerCtorTy
MCTargetStreamer * createNullTargetStreamer(MCStreamer &S) const
MCRelocationInfo *(*)(const Triple &TT, MCContext &Ctx) MCRelocationInfoCtorTy
MCTargetAsmParser *(*)(const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII, const MCTargetOptions &Options) MCAsmParserCtorTy
MCStreamer *(*)(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter) MachOStreamerCtorTy
AsmPrinter * createAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) const
createAsmPrinter - Create a target specific assembly printer pass.
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
mca::InstrumentManager * createInstrumentManager(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) const
createInstrumentManager - Create a target specific InstrumentManager.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:47
@ UnknownArch
Definition: Triple.h:50
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
A range adaptor for a pair of iterators.
Class which can be overriden by targets to enforce instruction dependencies and behaviours that aren'...
Class which can be overriden by targets to modify the mca::Instruction objects before the pipeline st...
This class allows targets to optionally customize the logic that resolves scheduling class IDs.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
const char *(* LLVMSymbolLookupCallback)(void *DisInfo, uint64_t ReferenceValue, uint64_t *ReferenceType, uint64_t ReferencePC, const char **ReferenceName)
The type for the symbol lookup function.
int(* LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, uint64_t Offset, uint64_t OpSize, uint64_t InstSize, int TagType, void *TagBuf)
The type for the operand information call back function.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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,...
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
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)
Description of the encoding of one expression Op.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
RegisterMCAsmBackend - Helper template for registering a target specific assembler backend.
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
RegisterMCAsmInfoFn(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCAsmInfo - Helper template for registering a target assembly info implementation.
RegisterMCAsmParser - Helper template for registering a target specific assembly parser,...
RegisterMCCodeEmitter - Helper template for registering a target specific machine code emitter,...
RegisterMCInstrAnalysisFn - Helper template for registering a target instruction analyzer implementat...
RegisterMCInstrAnalysisFn(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
RegisterMCInstrAnalysis - Helper template for registering a target instruction analyzer implementatio...
RegisterMCInstrInfoFn - Helper template for registering a target instruction info implementation.
RegisterMCInstrInfoFn(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Helper template for registering a target instruction info implementation.
Helper template for registering a target object file info implementation.
RegisterMCObjectFileInfoFn(Target &T, Target::MCObjectFileInfoCtorFnTy Fn)
Helper template for registering a target object file info implementation.
RegisterMCRegInfoFn - Helper template for registering a target register info implementation.
RegisterMCRegInfoFn(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Helper template for registering a target register info implementation.
RegisterMCSubtargetInfoFn - Helper template for registering a target subtarget info implementation.
RegisterMCSubtargetInfoFn(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Helper template for registering a target subtarget info implementation.
RegisterTargetMachine - Helper template for registering a target machine implementation,...
RegisterTarget - Helper template for registering a target, for use in the target's initialization fun...
static bool getArchMatch(Triple::ArchType Arch)
RegisterTarget(Target &T, const char *Name, const char *Desc, const char *BackendName)
TargetRegistry - Generic interface to target specific features.
static const Target * lookupTarget(StringRef TripleStr, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
static void RegisterMCSymbolizer(Target &T, Target::MCSymbolizerCtorTy Fn)
RegisterMCSymbolizer - Register an MCSymbolizer implementation for the given target.
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn)
RegisterAsmPrinter - Register an AsmPrinter implementation for the given target.
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
static void RegisterXCOFFStreamer(Target &T, Target::XCOFFStreamerCtorTy Fn)
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCAsmInfo - Register a MCAsmInfo implementation for the given target.
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
static void RegisterMCInstrAnalysis(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for the given target.
static void RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn)
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn)
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
static void RegisterInstrPostProcess(Target &T, Target::InstrPostProcessCtorTy Fn)
RegisterInstrPostProcess - Register an InstrPostProcess implementation for the given target.
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.
static void RegisterMCAsmParser(Target &T, Target::MCAsmParserCtorTy Fn)
RegisterMCAsmParser - Register a MCTargetAsmParser implementation for the given target.
static LLVM_ABI void printRegisteredTargetsForVersion(raw_ostream &OS)
printRegisteredTargetsForVersion - Print the registered targets appropriately for inclusion in a tool...
static void 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