LLVM 19.0.0git
AsmPrinter.h
Go to the documentation of this file.
1//===- llvm/CodeGen/AsmPrinter.h - AsmPrinter Framework ---------*- 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 contains a class to be used as the base class for target specific
10// asm writers. This class primarily handles common functionality used by
11// all asm writers.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_ASMPRINTER_H
16#define LLVM_CODEGEN_ASMPRINTER_H
17
18#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/MapVector.h"
27#include "llvm/IR/InlineAsm.h"
29#include <cstdint>
30#include <memory>
31#include <utility>
32#include <vector>
33
34namespace llvm {
35
36class AddrLabelMap;
37class BasicBlock;
38class BlockAddress;
39class Constant;
40class ConstantArray;
41class ConstantPtrAuth;
42class DataLayout;
43class DIE;
44class DIEAbbrev;
45class DwarfDebug;
46class GCMetadataPrinter;
47class GCStrategy;
48class GlobalAlias;
49class GlobalObject;
50class GlobalValue;
51class GlobalVariable;
52class MachineBasicBlock;
53class MachineConstantPoolValue;
54class MachineDominatorTree;
55class MachineFunction;
56class MachineInstr;
57class MachineJumpTableInfo;
58class MachineLoopInfo;
59class MachineModuleInfo;
60class MachineOptimizationRemarkEmitter;
61class MCAsmInfo;
62class MCCFIInstruction;
63class MCContext;
64class MCExpr;
65class MCInst;
66class MCSection;
67class MCStreamer;
68class MCSubtargetInfo;
69class MCSymbol;
70class MCTargetOptions;
71class MDNode;
72class Module;
73class PseudoProbeHandler;
74class raw_ostream;
75class StringRef;
76class TargetLoweringObjectFile;
77class TargetMachine;
78class Twine;
79
80namespace remarks {
81class RemarkStreamer;
82}
83
84/// This class is intended to be used as a driving class for all asm writers.
86public:
87 /// Target machine description.
89
90 /// Target Asm Printer information.
91 const MCAsmInfo *MAI = nullptr;
92
93 /// This is the context for the output file that we are streaming. This owns
94 /// all of the global MC-related objects for the generated translation unit.
96
97 /// This is the MCStreamer object for the file we are generating. This
98 /// contains the transient state for the current translation unit that we are
99 /// generating (such as the current section etc).
100 std::unique_ptr<MCStreamer> OutStreamer;
101
102 /// The current machine function.
103 MachineFunction *MF = nullptr;
104
105 /// This is a pointer to the current MachineModuleInfo.
107
108 /// This is a pointer to the current MachineDominatorTree.
110
111 /// This is a pointer to the current MachineLoopInfo.
113
114 /// Optimization remark emitter.
116
117 /// The symbol for the entry in __patchable_function_entires.
119
120 /// The symbol for the current function. This is recalculated at the beginning
121 /// of each call to runOnMachineFunction().
123
124 /// The symbol for the current function descriptor on AIX. This is created
125 /// at the beginning of each call to SetupMachineFunction().
127
128 /// The symbol used to represent the start of the current function for the
129 /// purpose of calculating its size (e.g. using the .size directive). By
130 /// default, this is equal to CurrentFnSym.
132
133 /// Map a basic block section ID to the begin and end symbols of that section
134 /// which determine the section's range.
137 };
138
140
141 /// Map global GOT equivalent MCSymbols to GlobalVariables and keep track of
142 /// its number of uses by other globals.
143 using GOTEquivUsePair = std::pair<const GlobalVariable *, unsigned>;
145
146 /// struct HandlerInfo and Handlers permit users or target extended
147 /// AsmPrinter to add their own handlers.
148 struct HandlerInfo {
149 std::unique_ptr<AsmPrinterHandler> Handler;
154
155 HandlerInfo(std::unique_ptr<AsmPrinterHandler> Handler, StringRef TimerName,
161 };
162
163 // Flags representing which CFI section is required for a function/module.
164 enum class CFISection : unsigned {
165 None = 0, ///< Do not emit either .eh_frame or .debug_frame
166 EH = 1, ///< Emit .eh_frame
167 Debug = 2 ///< Emit .debug_frame
168 };
169
170private:
171 MCSymbol *CurrentFnEnd = nullptr;
172
173 /// Map a basic block section ID to the exception symbol associated with that
174 /// section. Map entries are assigned and looked up via
175 /// AsmPrinter::getMBBExceptionSym.
176 DenseMap<unsigned, MCSymbol *> MBBSectionExceptionSyms;
177
178 // The symbol used to represent the start of the current BB section of the
179 // function. This is used to calculate the size of the BB section.
180 MCSymbol *CurrentSectionBeginSym = nullptr;
181
182 /// This map keeps track of which symbol is being used for the specified basic
183 /// block's address of label.
184 std::unique_ptr<AddrLabelMap> AddrLabelSymbols;
185
186 /// The garbage collection metadata printer table.
188
189 /// Emit comments in assembly output if this is true.
190 bool VerboseAsm;
191
192 /// Output stream for the stack usage file (i.e., .su file).
193 std::unique_ptr<raw_fd_ostream> StackUsageStream;
194
195 /// List of symbols to be inserted into PC sections.
197
198 static char ID;
199
200protected:
202
203 /// For dso_local functions, the current $local alias for the function.
205
206 /// A vector of all debug/EH info emitters we should use. This vector
207 /// maintains ownership of the emitters.
208 std::vector<HandlerInfo> Handlers;
209 size_t NumUserHandlers = 0;
210
212
213private:
214 /// If generated on the fly this own the instance.
215 std::unique_ptr<MachineDominatorTree> OwnedMDT;
216
217 /// If generated on the fly this own the instance.
218 std::unique_ptr<MachineLoopInfo> OwnedMLI;
219
220 /// If the target supports dwarf debug info, this pointer is non-null.
221 DwarfDebug *DD = nullptr;
222
223 /// A handler that supports pseudo probe emission with embedded inline
224 /// context.
225 PseudoProbeHandler *PP = nullptr;
226
227 /// CFISection type the module needs i.e. either .eh_frame or .debug_frame.
228 CFISection ModuleCFISection = CFISection::None;
229
230 /// True if the module contains split-stack functions. This is used to
231 /// emit .note.GNU-split-stack section as required by the linker for
232 /// special handling split-stack function calling no-split-stack function.
233 bool HasSplitStack = false;
234
235 /// True if the module contains no-split-stack functions. This is used to emit
236 /// .note.GNU-no-split-stack section when it also contains functions without a
237 /// split stack prologue.
238 bool HasNoSplitStack = false;
239
240protected:
241 explicit AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer);
242
243public:
244 ~AsmPrinter() override;
245
246 DwarfDebug *getDwarfDebug() { return DD; }
247 DwarfDebug *getDwarfDebug() const { return DD; }
248
251
252 bool isDwarf64() const;
253
254 /// Returns 4 for DWARF32 and 8 for DWARF64.
255 unsigned int getDwarfOffsetByteSize() const;
256
257 /// Returns 4 for DWARF32 and 12 for DWARF64.
258 unsigned int getUnitLengthFieldByteSize() const;
259
260 /// Returns information about the byte size of DW_FORM values.
262
263 bool isPositionIndependent() const;
264
265 /// Return true if assembly output should contain comments.
266 bool isVerbose() const { return VerboseAsm; }
267
268 /// Return a unique ID for the current function.
269 unsigned getFunctionNumber() const;
270
271 /// Return symbol for the function pseudo stack if the stack frame is not a
272 /// register based.
273 virtual const MCSymbol *getFunctionFrameSymbol() const { return nullptr; }
274
276 MCSymbol *getFunctionEnd() const { return CurrentFnEnd; }
277
278 // Return the exception symbol associated with the MBB section containing a
279 // given basic block.
281
282 /// Return the symbol to be used for the specified basic block when its
283 /// address is taken. This cannot be its normal LBB label because the block
284 /// may be accessed outside its containing function.
286 return getAddrLabelSymbolToEmit(BB).front();
287 }
288
289 /// Return the symbol to be used for the specified basic block when its
290 /// address is taken. If other blocks were RAUW'd to this one, we may have
291 /// to emit them as well, return the whole set.
293
294 /// If the specified function has had any references to address-taken blocks
295 /// generated, but the block got deleted, return the symbol now so we can
296 /// emit it. This prevents emitting a reference to a symbol that has no
297 /// definition.
299 std::vector<MCSymbol *> &Result);
300
301 /// Return information about object file lowering.
303
304 /// Return information about data layout.
305 const DataLayout &getDataLayout() const;
306
307 /// Return the pointer size from the TargetMachine
308 unsigned getPointerSize() const;
309
310 /// Return information about subtarget.
311 const MCSubtargetInfo &getSubtargetInfo() const;
312
313 void EmitToStreamer(MCStreamer &S, const MCInst &Inst);
314
315 /// Emits inital debug location directive.
317
318 /// Return the current section we are emitting to.
319 const MCSection *getCurrentSection() const;
320
322 const GlobalValue *GV) const;
323
324 MCSymbol *getSymbol(const GlobalValue *GV) const;
325
326 /// Similar to getSymbol() but preferred for references. On ELF, this uses a
327 /// local symbol if a reference to GV is guaranteed to be resolved to the
328 /// definition in the same module.
329 MCSymbol *getSymbolPreferLocal(const GlobalValue &GV) const;
330
332 return DwarfUsesRelocationsAcrossSections;
333 }
334
336 DwarfUsesRelocationsAcrossSections = Enable;
337 }
338
339 //===------------------------------------------------------------------===//
340 // XRay instrumentation implementation.
341 //===------------------------------------------------------------------===//
342public:
343 // This describes the kind of sled we're storing in the XRay table.
344 enum class SledKind : uint8_t {
345 FUNCTION_ENTER = 0,
346 FUNCTION_EXIT = 1,
347 TAIL_CALL = 2,
348 LOG_ARGS_ENTER = 3,
349 CUSTOM_EVENT = 4,
350 TYPED_EVENT = 5,
351 };
352
353 // The table will contain these structs that point to the sled, the function
354 // containing the sled, and what kind of sled (and whether they should always
355 // be instrumented). We also use a version identifier that the runtime can use
356 // to decide what to do with the sled, depending on the version of the sled.
362 const class Function *Fn;
363 uint8_t Version;
364
365 void emit(int, MCStreamer *) const;
366 };
367
368 // All the sleds to be emitted.
370
371 // Helper function to record a given XRay sled.
372 void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind,
373 uint8_t Version = 0);
374
375 /// Emit a table with all XRay instrumentation points.
376 void emitXRayTable();
377
379
380 //===------------------------------------------------------------------===//
381 // MachineFunctionPass Implementation.
382 //===------------------------------------------------------------------===//
383
384 /// Record analysis usage.
385 void getAnalysisUsage(AnalysisUsage &AU) const override;
386
387 /// Set up the AsmPrinter when we are working on a new module. If your pass
388 /// overrides this, it must make sure to explicitly call this implementation.
389 bool doInitialization(Module &M) override;
390
391 /// Shut down the asmprinter. If you override this in your pass, you must make
392 /// sure to call it explicitly.
393 bool doFinalization(Module &M) override;
394
395 /// Emit the specified function out to the OutStreamer.
399 return false;
400 }
401
402 //===------------------------------------------------------------------===//
403 // Coarse grained IR lowering routines.
404 //===------------------------------------------------------------------===//
405
406 /// This should be called when a new MachineFunction is being processed from
407 /// runOnMachineFunction.
409
410 /// This method emits the body and trailer for a function.
411 void emitFunctionBody();
412
414
415 void emitFrameAlloc(const MachineInstr &MI);
416
418
419 void emitStackUsage(const MachineFunction &MF);
420
422
423 void emitKCFITrapEntry(const MachineFunction &MF, const MCSymbol *Symbol);
424 virtual void emitKCFITypeId(const MachineFunction &MF);
425
426 void emitPseudoProbe(const MachineInstr &MI);
427
429
430 /// Emits a label as reference for PC sections.
431 void emitPCSectionsLabel(const MachineFunction &MF, const MDNode &MD);
432
433 /// Emits the PC sections collected from instructions.
434 void emitPCSections(const MachineFunction &MF);
435
436 /// Get the CFISection type for a function.
438
439 /// Get the CFISection type for a function.
441
442 /// Get the CFISection type for the module.
443 CFISection getModuleCFISectionType() const { return ModuleCFISection; }
444
445 bool needsSEHMoves();
446
447 /// Since emitting CFI unwind information is entangled with supporting the
448 /// exceptions, this returns true for platforms which use CFI unwind
449 /// information for other purposes (debugging, sanitizers, ...) when
450 /// `MCAsmInfo::ExceptionsType == ExceptionHandling::None`.
451 bool usesCFIWithoutEH() const;
452
453 /// Print to the current output stream assembly representations of the
454 /// constants in the constant pool MCP. This is used to print out constants
455 /// which have been "spilled to memory" by the code generator.
456 virtual void emitConstantPool();
457
458 /// Print assembly representations of the jump tables used by the current
459 /// function to the current output stream.
460 virtual void emitJumpTableInfo();
461
462 /// Emit the specified global variable to the .s file.
463 virtual void emitGlobalVariable(const GlobalVariable *GV);
464
465 /// Check to see if the specified global is a special global used by LLVM. If
466 /// so, emit it and return true, otherwise do nothing and return false.
468
469 /// `llvm.global_ctors` and `llvm.global_dtors` are arrays of Structor
470 /// structs.
471 ///
472 /// Priority - init priority
473 /// Func - global initialization or global clean-up function
474 /// ComdatKey - associated data
475 struct Structor {
476 int Priority = 0;
477 Constant *Func = nullptr;
479
480 Structor() = default;
481 };
482
483 /// This method gathers an array of Structors and then sorts them out by
484 /// Priority.
485 /// @param List The initializer of `llvm.global_ctors` or `llvm.global_dtors`
486 /// array.
487 /// @param[out] Structors Sorted Structor structs by Priority.
489 SmallVector<Structor, 8> &Structors);
490
491 /// This method emits `llvm.global_ctors` or `llvm.global_dtors` list.
492 virtual void emitXXStructorList(const DataLayout &DL, const Constant *List,
493 bool IsCtor);
494
495 /// Emit an alignment directive to the specified power of two boundary. If a
496 /// global value is specified, and if that global has an explicit alignment
497 /// requested, it will override the alignment request if required for
498 /// correctness.
499 void emitAlignment(Align Alignment, const GlobalObject *GV = nullptr,
500 unsigned MaxBytesToEmit = 0) const;
501
502 /// Lower the specified LLVM Constant to an MCExpr.
503 virtual const MCExpr *lowerConstant(const Constant *CV);
504
505 /// Print a general LLVM constant to the .s file.
506 /// On AIX, when an alias refers to a sub-element of a global variable, the
507 /// label of that alias needs to be emitted before the corresponding element.
509 void emitGlobalConstant(const DataLayout &DL, const Constant *CV,
510 AliasMapTy *AliasList = nullptr);
511
512 /// Unnamed constant global variables solely contaning a pointer to
513 /// another globals variable act like a global variable "proxy", or GOT
514 /// equivalents, i.e., it's only used to hold the address of the latter. One
515 /// optimization is to replace accesses to these proxies by using the GOT
516 /// entry for the final global instead. Hence, we select GOT equivalent
517 /// candidates among all the module global variables, avoid emitting them
518 /// unnecessarily and finally replace references to them by pc relative
519 /// accesses to GOT entries.
521
522 /// Constant expressions using GOT equivalent globals may not be
523 /// eligible for PC relative GOT entry conversion, in such cases we need to
524 /// emit the proxies we previously omitted in EmitGlobalVariable.
525 void emitGlobalGOTEquivs();
526
527 /// Emit the stack maps.
528 void emitStackMaps();
529
530 //===------------------------------------------------------------------===//
531 // Overridable Hooks
532 //===------------------------------------------------------------------===//
533
535 Handlers.insert(Handlers.begin(), std::move(Handler));
537 }
538
539 // Targets can, or in the case of EmitInstruction, must implement these to
540 // customize output.
541
542 /// This virtual method can be overridden by targets that want to emit
543 /// something at the start of their file.
544 virtual void emitStartOfAsmFile(Module &) {}
545
546 /// This virtual method can be overridden by targets that want to emit
547 /// something at the end of their file.
548 virtual void emitEndOfAsmFile(Module &) {}
549
550 /// Targets can override this to emit stuff before the first basic block in
551 /// the function.
552 virtual void emitFunctionBodyStart() {}
553
554 /// Targets can override this to emit stuff after the last basic block in the
555 /// function.
556 virtual void emitFunctionBodyEnd() {}
557
558 /// Targets can override this to emit stuff at the start of a basic block.
559 /// By default, this method prints the label for the specified
560 /// MachineBasicBlock, an alignment (if present) and a comment describing it
561 /// if appropriate.
562 virtual void emitBasicBlockStart(const MachineBasicBlock &MBB);
563
564 /// Targets can override this to emit stuff at the end of a basic block.
565 virtual void emitBasicBlockEnd(const MachineBasicBlock &MBB);
566
567 /// Targets should implement this to emit instructions.
568 virtual void emitInstruction(const MachineInstr *) {
569 llvm_unreachable("EmitInstruction not implemented");
570 }
571
572 /// Return the symbol for the specified constant pool entry.
573 virtual MCSymbol *GetCPISymbol(unsigned CPID) const;
574
575 virtual void emitFunctionEntryLabel();
576
577 virtual void emitFunctionDescriptor() {
578 llvm_unreachable("Function descriptor is target-specific.");
579 }
580
582
583 /// Targets can override this to change how global constants that are part of
584 /// a C++ static/global constructor list are emitted.
585 virtual void emitXXStructor(const DataLayout &DL, const Constant *CV) {
587 }
588
589 virtual const MCExpr *lowerConstantPtrAuth(const ConstantPtrAuth &CPA) {
590 report_fatal_error("ptrauth constant lowering not implemented");
591 }
592
593 /// Return true if the basic block has exactly one predecessor and the control
594 /// transfer mechanism between the predecessor and this block is a
595 /// fall-through.
596 virtual bool
598
599 /// Targets can override this to customize the output of IMPLICIT_DEF
600 /// instructions in verbose mode.
601 virtual void emitImplicitDef(const MachineInstr *MI) const;
602
603 /// getSubtargetInfo() cannot be used where this is needed because we don't
604 /// have a MachineFunction when we're lowering a GlobalIFunc, and
605 /// getSubtargetInfo requires one. Override the implementation in targets
606 /// that support the Mach-O IFunc lowering.
608 return nullptr;
609 }
610
611 virtual void emitMachOIFuncStubBody(Module &M, const GlobalIFunc &GI,
612 MCSymbol *LazyPointer) {
614 "Mach-O IFunc lowering is not yet supported on this target");
615 }
616
618 MCSymbol *LazyPointer) {
620 "Mach-O IFunc lowering is not yet supported on this target");
621 }
622
623 /// Emit N NOP instructions.
624 void emitNops(unsigned N);
625
626 //===------------------------------------------------------------------===//
627 // Symbol Lowering Routines.
628 //===------------------------------------------------------------------===//
629
630 MCSymbol *createTempSymbol(const Twine &Name) const;
631
632 /// Return the MCSymbol for a private symbol with global value name as its
633 /// base, with the specified suffix.
635 StringRef Suffix) const;
636
637 /// Return the MCSymbol for the specified ExternalSymbol.
639
640 /// Return the symbol for the specified jump table entry.
641 MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
642
643 /// Return the symbol for the specified jump table .set
644 /// FIXME: privatize to AsmPrinter.
645 MCSymbol *GetJTSetSymbol(unsigned UID, unsigned MBBID) const;
646
647 /// Return the MCSymbol used to satisfy BlockAddress uses of the specified
648 /// basic block.
650 MCSymbol *GetBlockAddressSymbol(const BasicBlock *BB) const;
651
652 //===------------------------------------------------------------------===//
653 // Emission Helper Routines.
654 //===------------------------------------------------------------------===//
655
656 /// This is just convenient handler for printing offsets.
657 void printOffset(int64_t Offset, raw_ostream &OS) const;
658
659 /// Emit a byte directive and value.
660 void emitInt8(int Value) const;
661
662 /// Emit a short directive and value.
663 void emitInt16(int Value) const;
664
665 /// Emit a long directive and value.
666 void emitInt32(int Value) const;
667
668 /// Emit a long long directive and value.
669 void emitInt64(uint64_t Value) const;
670
671 /// Emit the specified signed leb128 value.
672 void emitSLEB128(int64_t Value, const char *Desc = nullptr) const;
673
674 /// Emit the specified unsigned leb128 value.
675 void emitULEB128(uint64_t Value, const char *Desc = nullptr,
676 unsigned PadTo = 0) const;
677
678 /// Emit something like ".long Hi-Lo" where the size in bytes of the directive
679 /// is specified by Size and Hi/Lo specify the labels. This implicitly uses
680 /// .set if it is available.
681 void emitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo,
682 unsigned Size) const;
683
684 /// Emit something like ".uleb128 Hi-Lo".
686 const MCSymbol *Lo) const;
687
688 /// Emit something like ".long Label+Offset" where the size in bytes of the
689 /// directive is specified by Size and Label specifies the label. This
690 /// implicitly uses .set if it is available.
691 void emitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
692 unsigned Size, bool IsSectionRelative = false) const;
693
694 /// Emit something like ".long Label" where the size in bytes of the directive
695 /// is specified by Size and Label specifies the label.
696 void emitLabelReference(const MCSymbol *Label, unsigned Size,
697 bool IsSectionRelative = false) const {
698 emitLabelPlusOffset(Label, 0, Size, IsSectionRelative);
699 }
700
701 //===------------------------------------------------------------------===//
702 // Dwarf Emission Helper Routines
703 //===------------------------------------------------------------------===//
704
705 /// Emit a .byte 42 directive that corresponds to an encoding. If verbose
706 /// assembly output is enabled, we output comments describing the encoding.
707 /// Desc is a string saying what the encoding is specifying (e.g. "LSDA").
708 void emitEncodingByte(unsigned Val, const char *Desc = nullptr) const;
709
710 /// Return the size of the encoding in bytes.
711 unsigned GetSizeOfEncodedValue(unsigned Encoding) const;
712
713 /// Emit reference to a ttype global with a specified encoding.
714 virtual void emitTTypeReference(const GlobalValue *GV, unsigned Encoding);
715
716 /// Emit a reference to a symbol for use in dwarf. Different object formats
717 /// represent this in different ways. Some use a relocation others encode
718 /// the label offset in its section.
719 void emitDwarfSymbolReference(const MCSymbol *Label,
720 bool ForceOffset = false) const;
721
722 /// Emit the 4- or 8-byte offset of a string from the start of its section.
723 ///
724 /// When possible, emit a DwarfStringPool section offset without any
725 /// relocations, and without using the symbol. Otherwise, defers to \a
726 /// emitDwarfSymbolReference().
727 ///
728 /// The length of the emitted value depends on the DWARF format.
730
731 /// Emit the 4-or 8-byte offset of a string from the start of its section.
734 }
735
736 /// Emit something like ".long Label + Offset" or ".quad Label + Offset"
737 /// depending on the DWARF format.
738 void emitDwarfOffset(const MCSymbol *Label, uint64_t Offset) const;
739
740 /// Emit 32- or 64-bit value depending on the DWARF format.
742
743 /// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
744 /// according to the settings.
745 void emitDwarfUnitLength(uint64_t Length, const Twine &Comment) const;
746
747 /// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
748 /// according to the settings.
749 /// Return the end symbol generated inside, the caller needs to emit it.
750 MCSymbol *emitDwarfUnitLength(const Twine &Prefix,
751 const Twine &Comment) const;
752
753 /// Emit reference to a call site with a specified encoding
754 void emitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo,
755 unsigned Encoding) const;
756 /// Emit an integer value corresponding to the call site encoding
757 void emitCallSiteValue(uint64_t Value, unsigned Encoding) const;
758
759 /// Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
760 virtual unsigned getISAEncoding() { return 0; }
761
762 /// Emit the directive and value for debug thread local expression
763 ///
764 /// \p Value - The value to emit.
765 /// \p Size - The size of the integer (in bytes) to emit.
766 virtual void emitDebugValue(const MCExpr *Value, unsigned Size) const;
767
768 //===------------------------------------------------------------------===//
769 // Dwarf Lowering Routines
770 //===------------------------------------------------------------------===//
771
772 /// Emit frame instruction to describe the layout of the frame.
773 void emitCFIInstruction(const MCCFIInstruction &Inst) const;
774
775 /// Emit Dwarf abbreviation table.
776 template <typename T> void emitDwarfAbbrevs(const T &Abbrevs) const {
777 // For each abbreviation.
778 for (const auto &Abbrev : Abbrevs)
779 emitDwarfAbbrev(*Abbrev);
780
781 // Mark end of abbreviations.
782 emitULEB128(0, "EOM(3)");
783 }
784
785 void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const;
786
787 /// Recursively emit Dwarf DIE tree.
788 void emitDwarfDIE(const DIE &Die) const;
789
790 //===------------------------------------------------------------------===//
791 // CodeView Helper Routines
792 //===------------------------------------------------------------------===//
793
794 /// Gets information required to create a CodeView debug symbol for a jump
795 /// table.
796 /// Return value is <Base Address, Base Offset, Branch Address, Entry Size>
797 virtual std::tuple<const MCSymbol *, uint64_t, const MCSymbol *,
799 getCodeViewJumpTableInfo(int JTI, const MachineInstr *BranchInstr,
800 const MCSymbol *BranchLabel) const;
801
802 //===------------------------------------------------------------------===//
803 // Inline Asm Support
804 //===------------------------------------------------------------------===//
805
806 // These are hooks that targets can override to implement inline asm
807 // support. These should probably be moved out of AsmPrinter someday.
808
809 /// Print information related to the specified machine instr that is
810 /// independent of the operand, and may be independent of the instr itself.
811 /// This can be useful for portably encoding the comment character or other
812 /// bits of target-specific knowledge into the asmstrings. The syntax used is
813 /// ${:comment}. Targets can override this to add support for their own
814 /// strange codes.
815 virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
816 StringRef Code) const;
817
818 /// Print the MachineOperand as a symbol. Targets with complex handling of
819 /// symbol references should override the base implementation.
820 virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS);
821
822 /// Print the specified operand of MI, an INLINEASM instruction, using the
823 /// specified assembler variant. Targets should override this to format as
824 /// appropriate. This method can return true if the operand is erroneous.
825 virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
826 const char *ExtraCode, raw_ostream &OS);
827
828 /// Print the specified operand of MI, an INLINEASM instruction, using the
829 /// specified assembler variant as an address. Targets should override this to
830 /// format as appropriate. This method can return true if the operand is
831 /// erroneous.
832 virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
833 const char *ExtraCode, raw_ostream &OS);
834
835 /// Let the target do anything it needs to do before emitting inlineasm.
836 /// \p StartInfo - the subtarget info before parsing inline asm
837 virtual void emitInlineAsmStart() const;
838
839 /// Let the target do anything it needs to do after emitting inlineasm.
840 /// This callback can be used restore the original mode in case the
841 /// inlineasm contains directives to switch modes.
842 /// \p StartInfo - the original subtarget info before inline asm
843 /// \p EndInfo - the final subtarget info after parsing the inline asm,
844 /// or NULL if the value is unknown.
845 virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
846 const MCSubtargetInfo *EndInfo) const;
847
848 /// This emits visibility information about symbol, if this is supported by
849 /// the target.
850 void emitVisibility(MCSymbol *Sym, unsigned Visibility,
851 bool IsDefinition = true) const;
852
853 /// This emits linkage information about \p GVSym based on \p GV, if this is
854 /// supported by the target.
855 virtual void emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const;
856
857 /// Return the alignment for the specified \p GV.
858 static Align getGVAlignment(const GlobalObject *GV, const DataLayout &DL,
859 Align InAlign = Align(1));
860
861private:
862 /// Private state for PrintSpecial()
863 // Assign a unique ID to this machine instruction.
864 mutable const MachineInstr *LastMI = nullptr;
865 mutable unsigned LastFn = 0;
866 mutable unsigned Counter = ~0U;
867
868 bool DwarfUsesRelocationsAcrossSections = false;
869
870 /// This method emits the header for the current function.
871 virtual void emitFunctionHeader();
872
873 /// This method emits a comment next to header for the current function.
874 virtual void emitFunctionHeaderComment();
875
876 /// This method emits prefix-like data before the current function.
877 void emitFunctionPrefix(ArrayRef<const Constant *> Prefix);
878
879 /// Emit a blob of inline asm to the output streamer.
880 void
881 emitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
882 const MCTargetOptions &MCOptions,
883 const MDNode *LocMDNode = nullptr,
884 InlineAsm::AsmDialect AsmDialect = InlineAsm::AD_ATT) const;
885
886 /// This method formats and emits the specified machine instruction that is an
887 /// inline asm.
888 void emitInlineAsm(const MachineInstr *MI) const;
889
890 /// Add inline assembly info to the diagnostics machinery, so we can
891 /// emit file and position info. Returns SrcMgr memory buffer position.
892 unsigned addInlineAsmDiagBuffer(StringRef AsmStr,
893 const MDNode *LocMDNode) const;
894
895 //===------------------------------------------------------------------===//
896 // Internal Implementation Details
897 //===------------------------------------------------------------------===//
898
899 void emitJumpTableEntry(const MachineJumpTableInfo *MJTI,
900 const MachineBasicBlock *MBB, unsigned uid) const;
901 void emitLLVMUsedList(const ConstantArray *InitList);
902 /// Emit llvm.ident metadata in an '.ident' directive.
903 void emitModuleIdents(Module &M);
904 /// Emit bytes for llvm.commandline metadata.
905 virtual void emitModuleCommandLines(Module &M);
906
907 GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy &S);
908 virtual void emitGlobalAlias(const Module &M, const GlobalAlias &GA);
909 void emitGlobalIFunc(Module &M, const GlobalIFunc &GI);
910
911private:
912 /// This method decides whether the specified basic block requires a label.
913 bool shouldEmitLabelForBasicBlock(const MachineBasicBlock &MBB) const;
914
915protected:
917 return false;
918 }
919};
920
921} // end namespace llvm
922
923#endif // LLVM_CODEGEN_ASMPRINTER_H
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
dxil metadata emit
This file defines the DenseMap class.
This file contains constants used for implementing Dwarf debug support.
std::string Name
uint64_t Size
Symbol * Sym
Definition: ELF_riscv.cpp:479
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition: MD5.cpp:55
Machine Check Debug Module
This file implements a map that provides insertion order iteration.
raw_pwrite_stream & OS
This file defines the SmallVector class.
Represent the analysis usage information of a pass.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:85
virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, const MCSubtargetInfo *EndInfo) const
Let the target do anything it needs to do after emitting inlineasm.
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
Definition: AsmPrinter.h:568
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Definition: AsmPrinter.cpp:399
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: AsmPrinter.cpp:706
void emitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
SmallVector< XRayFunctionEntry, 4 > Sleds
Definition: AsmPrinter.h:369
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
void addAsmPrinterHandler(HandlerInfo Handler)
Definition: AsmPrinter.h:534
bool isDwarf64() const
CFISection getModuleCFISectionType() const
Get the CFISection type for the module.
Definition: AsmPrinter.h:443
void emitNops(unsigned N)
Emit N NOP instructions.
MCSymbol * CurrentFnBegin
Definition: AsmPrinter.h:201
unsigned GetSizeOfEncodedValue(unsigned Encoding) const
Return the size of the encoding in bytes.
MachineLoopInfo * MLI
This is a pointer to the current MachineLoopInfo.
Definition: AsmPrinter.h:112
virtual void emitDebugValue(const MCExpr *Value, unsigned Size) const
Emit the directive and value for debug thread local expression.
Definition: AsmPrinter.cpp:930
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
Definition: AsmPrinter.cpp:419
virtual void emitConstantPool()
Print to the current output stream assembly representations of the constants in the constant pool MCP...
void emitDwarfDIE(const DIE &Die) const
Recursively emit Dwarf DIE tree.
DwarfDebug * getDwarfDebug()
Definition: AsmPrinter.h:246
virtual void emitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
Definition: AsmPrinter.cpp:728
virtual const MCExpr * lowerConstantPtrAuth(const ConstantPtrAuth &CPA)
Definition: AsmPrinter.h:589
void emitDwarfLengthOrOffset(uint64_t Value) const
Emit 32- or 64-bit value depending on the DWARF format.
unsigned int getUnitLengthFieldByteSize() const
Returns 4 for DWARF32 and 12 for DWARF64.
void emitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label+Offset" where the size in bytes of the directive is specified by Siz...
~AsmPrinter() override
Definition: AsmPrinter.cpp:385
TargetMachine & TM
Target machine description.
Definition: AsmPrinter.h:88
void emitXRayTable()
Emit a table with all XRay instrumentation points.
virtual void emitBasicBlockEnd(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the end of a basic block.
DwarfDebug * getDwarfDebug() const
Definition: AsmPrinter.h:247
MCSymbol * CurrentFnDescSym
The symbol for the current function descriptor on AIX.
Definition: AsmPrinter.h:126
MCSymbol * CurrentFnBeginLocal
For dso_local functions, the current $local alias for the function.
Definition: AsmPrinter.h:204
MapVector< const MCSymbol *, GOTEquivUsePair > GlobalGOTEquivs
Definition: AsmPrinter.h:144
void emitDwarfStringOffset(DwarfStringPoolEntry S) const
Emit the 4- or 8-byte offset of a string from the start of its section.
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
void emitGlobalGOTEquivs()
Constant expressions using GOT equivalent globals may not be eligible for PC relative GOT entry conve...
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
MCSymbol * getFunctionBegin() const
Definition: AsmPrinter.h:275
void emitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
Emit something like ".long Hi-Lo" where the size in bytes of the directive is specified by Size and H...
void emitKCFITrapEntry(const MachineFunction &MF, const MCSymbol *Symbol)
virtual void emitMachOIFuncStubHelperBody(Module &M, const GlobalIFunc &GI, MCSymbol *LazyPointer)
Definition: AsmPrinter.h:617
MCSymbol * getMBBExceptionSym(const MachineBasicBlock &MBB)
MCSymbol * getAddrLabelSymbol(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
Definition: AsmPrinter.h:285
virtual void emitTTypeReference(const GlobalValue *GV, unsigned Encoding)
Emit reference to a ttype global with a specified encoding.
const MCAsmInfo * MAI
Target Asm Printer information.
Definition: AsmPrinter.h:91
bool emitSpecialLLVMGlobal(const GlobalVariable *GV)
Check to see if the specified global is a special global used by LLVM.
MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:103
void emitDwarfOffset(const MCSymbol *Label, uint64_t Offset) const
Emit something like ".long Label + Offset" or ".quad Label + Offset" depending on the DWARF format.
virtual void PrintSpecial(const MachineInstr *MI, raw_ostream &OS, StringRef Code) const
Print information related to the specified machine instr that is independent of the operand,...
virtual void emitJumpTableInfo()
Print assembly representations of the jump tables used by the current function to the current output ...
void computeGlobalGOTEquivs(Module &M)
Unnamed constant global variables solely contaning a pointer to another globals variable act like a g...
static Align getGVAlignment(const GlobalObject *GV, const DataLayout &DL, Align InAlign=Align(1))
Return the alignment for the specified GV.
Definition: AsmPrinter.cpp:352
void emitInt8(int Value) const
Emit a byte directive and value.
CFISection getFunctionCFISectionType(const Function &F) const
Get the CFISection type for a function.
virtual void SetupMachineFunction(MachineFunction &MF)
This should be called when a new MachineFunction is being processed from runOnMachineFunction.
void emitFunctionBody()
This method emits the body and trailer for a function.
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
void emitBBAddrMapSection(const MachineFunction &MF)
void emitPCSections(const MachineFunction &MF)
Emits the PC sections collected from instructions.
MapVector< unsigned, MBBSectionRange > MBBSectionRanges
Definition: AsmPrinter.h:139
MachineDominatorTree * MDT
This is a pointer to the current MachineDominatorTree.
Definition: AsmPrinter.h:109
virtual void emitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
Definition: AsmPrinter.h:544
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
virtual void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV)
void emitStackMaps()
Emit the stack maps.
void emitDwarfUnitLength(uint64_t Length, const Twine &Comment) const
Emit a unit length field.
virtual void emitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
Definition: AsmPrinter.h:552
std::pair< const GlobalVariable *, unsigned > GOTEquivUsePair
Map global GOT equivalent MCSymbols to GlobalVariables and keep track of its number of uses by other ...
Definition: AsmPrinter.h:143
void emitPatchableFunctionEntries()
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind, uint8_t Version=0)
virtual void emitEndOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the end of their file...
Definition: AsmPrinter.h:548
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
Definition: AsmPrinter.cpp:450
MCSymbol * GetJTSetSymbol(unsigned UID, unsigned MBBID) const
Return the symbol for the specified jump table .set FIXME: privatize to AsmPrinter.
virtual void emitMachOIFuncStubBody(Module &M, const GlobalIFunc &GI, MCSymbol *LazyPointer)
Definition: AsmPrinter.h:611
void emitEncodingByte(unsigned Val, const char *Desc=nullptr) const
Emit a .byte 42 directive that corresponds to an encoding.
virtual void emitImplicitDef(const MachineInstr *MI) const
Targets can override this to customize the output of IMPLICIT_DEF instructions in verbose mode.
virtual void emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const
This emits linkage information about GVSym based on GV, if this is supported by the target.
Definition: AsmPrinter.cpp:661
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
Definition: AsmPrinter.cpp:441
unsigned getFunctionNumber() const
Return a unique ID for the current function.
Definition: AsmPrinter.cpp:395
MachineOptimizationRemarkEmitter * ORE
Optimization remark emitter.
Definition: AsmPrinter.h:115
virtual bool shouldEmitWeakSwiftAsyncExtendedFramePointerFlags() const
Definition: AsmPrinter.h:916
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
void emitGlobalConstant(const DataLayout &DL, const Constant *CV, AliasMapTy *AliasList=nullptr)
EmitGlobalConstant - Print a general LLVM constant to the .s file.
virtual const MCSymbol * getFunctionFrameSymbol() const
Return symbol for the function pseudo stack if the stack frame is not a register based.
Definition: AsmPrinter.h:273
void emitFrameAlloc(const MachineInstr &MI)
void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const
Emit the 4-or 8-byte offset of a string from the start of its section.
Definition: AsmPrinter.h:732
void emitStackSizeSection(const MachineFunction &MF)
MCSymbol * getSymbolPreferLocal(const GlobalValue &GV) const
Similar to getSymbol() but preferred for references.
Definition: AsmPrinter.cpp:710
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition: AsmPrinter.h:122
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Definition: AsmPrinter.h:106
void emitDwarfAbbrevs(const T &Abbrevs) const
Emit Dwarf abbreviation table.
Definition: AsmPrinter.h:776
void emitSLEB128(int64_t Value, const char *Desc=nullptr) const
Emit the specified signed leb128 value.
void emitAlignment(Align Alignment, const GlobalObject *GV=nullptr, unsigned MaxBytesToEmit=0) const
Emit an alignment directive to the specified power of two boundary.
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition: AsmPrinter.h:95
void emitCFIInstruction(const MachineInstr &MI)
MCSymbol * createTempSymbol(const Twine &Name) const
bool doFinalization(Module &M) override
Shut down the asmprinter.
MCSymbol * GetExternalSymbolSymbol(Twine Sym) const
Return the MCSymbol for the specified ExternalSymbol.
virtual const MCSubtargetInfo * getIFuncMCSubtargetInfo() const
getSubtargetInfo() cannot be used where this is needed because we don't have a MachineFunction when w...
Definition: AsmPrinter.h:607
void emitStackUsage(const MachineFunction &MF)
virtual void emitKCFITypeId(const MachineFunction &MF)
bool isPositionIndependent() const
Definition: AsmPrinter.cpp:390
virtual void emitXXStructorList(const DataLayout &DL, const Constant *List, bool IsCtor)
This method emits llvm.global_ctors or llvm.global_dtors list.
void emitPCSectionsLabel(const MachineFunction &MF, const MDNode &MD)
Emits a label as reference for PC sections.
void emitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Encoding) const
Emit reference to a call site with a specified encoding.
MCSymbol * CurrentPatchableFunctionEntrySym
The symbol for the entry in __patchable_function_entires.
Definition: AsmPrinter.h:118
virtual void emitBasicBlockStart(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the start of a basic block.
void takeDeletedSymbolsForFunction(const Function *F, std::vector< MCSymbol * > &Result)
If the specified function has had any references to address-taken blocks generated,...
Definition: AsmPrinter.cpp:285
void emitVisibility(MCSymbol *Sym, unsigned Visibility, bool IsDefinition=true) const
This emits visibility information about symbol, if this is supported by the target.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
Definition: AsmPrinter.h:396
void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const
void setDwarfUsesRelocationsAcrossSections(bool Enable)
Definition: AsmPrinter.h:335
void emitInt32(int Value) const
Emit a long directive and value.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:100
virtual const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
void emitLabelReference(const MCSymbol *Label, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label" where the size in bytes of the directive is specified by Size and L...
Definition: AsmPrinter.h:696
virtual void emitFunctionDescriptor()
Definition: AsmPrinter.h:577
const MCSection * getCurrentSection() const
Return the current section we are emitting to.
Definition: AsmPrinter.cpp:437
unsigned int getDwarfOffsetByteSize() const
Returns 4 for DWARF32 and 8 for DWARF64.
virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
size_t NumUserHandlers
Definition: AsmPrinter.h:209
MCSymbol * CurrentFnSymForSize
The symbol used to represent the start of the current function for the purpose of calculating its siz...
Definition: AsmPrinter.h:131
virtual unsigned getISAEncoding()
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
Definition: AsmPrinter.h:760
bool isVerbose() const
Return true if assembly output should contain comments.
Definition: AsmPrinter.h:266
MCSymbol * getFunctionEnd() const
Definition: AsmPrinter.h:276
virtual void emitXXStructor(const DataLayout &DL, const Constant *CV)
Targets can override this to change how global constants that are part of a C++ static/global constru...
Definition: AsmPrinter.h:585
void preprocessXXStructorList(const DataLayout &DL, const Constant *List, SmallVector< Structor, 8 > &Structors)
This method gathers an array of Structors and then sorts them out by Priority.
void emitInt16(int Value) const
Emit a short directive and value.
void setDwarfVersion(uint16_t Version)
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
Definition: AsmPrinter.cpp:701
void emitPseudoProbe(const MachineInstr &MI)
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
Definition: AsmPrinter.cpp:410
void emitRemarksSection(remarks::RemarkStreamer &RS)
StackMaps SM
Definition: AsmPrinter.h:211
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.
ArrayRef< MCSymbol * > getAddrLabelSymbolToEmit(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
Definition: AsmPrinter.cpp:277
virtual void emitFunctionBodyEnd()
Targets can override this to emit stuff after the last basic block in the function.
Definition: AsmPrinter.h:556
const DataLayout & getDataLayout() const
Return information about data layout.
Definition: AsmPrinter.cpp:403
virtual void emitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
void emitInitialRawDwarfLocDirective(const MachineFunction &MF)
Emits inital debug location directive.
Definition: AsmPrinter.cpp:423
void emitInt64(uint64_t Value) const
Emit a long long directive and value.
uint16_t getDwarfVersion() const
dwarf::FormParams getDwarfFormParams() const
Returns information about the byte size of DW_FORM values.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
Definition: AsmPrinter.cpp:414
bool usesCFIWithoutEH() const
Since emitting CFI unwind information is entangled with supporting the exceptions,...
bool doesDwarfUseRelocationsAcrossSections() const
Definition: AsmPrinter.h:331
virtual void emitInlineAsmStart() const
Let the target do anything it needs to do before emitting inlineasm.
@ None
Do not emit either .eh_frame or .debug_frame.
@ Debug
Emit .debug_frame.
virtual std::tuple< const MCSymbol *, uint64_t, const MCSymbol *, codeview::JumpTableEntrySize > getCodeViewJumpTableInfo(int JTI, const MachineInstr *BranchInstr, const MCSymbol *BranchLabel) const
Gets information required to create a CodeView debug symbol for a jump table.
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
void emitCallSiteValue(uint64_t Value, unsigned Encoding) const
Emit an integer value corresponding to the call site encoding.
void emitLabelDifferenceAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo) const
Emit something like ".uleb128 Hi-Lo".
std::vector< HandlerInfo > Handlers
A vector of all debug/EH info emitters we should use.
Definition: AsmPrinter.h:208
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
The address of a basic block.
Definition: Constants.h:890
ConstantArray - Constant Array Declarations.
Definition: Constants.h:424
A signed pointer, in the ptrauth sense.
Definition: Constants.h:1012
This is an important base class in LLVM.
Definition: Constant.h:41
Dwarf abbreviation, describes the organization of a debug information object.
Definition: DIE.h:79
A structured debug information entry.
Definition: DIE.h:819
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
Collects and handles dwarf debug information.
Definition: DwarfDebug.h:351
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
const DwarfStringPoolEntry & getEntry() const
GCMetadataPrinter - Emits GC metadata as assembly code.
GCStrategy describes a garbage collector algorithm's code generation requirements,...
Definition: GCStrategy.h:63
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
Context object for machine code objects.
Definition: MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:36
Streaming machine code generation interface.
Definition: MCStreamer.h:213
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
Metadata node.
Definition: Metadata.h:1067
Abstract base class for all machine specific constantpool value subclasses.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Representation of each machine instruction.
Definition: MachineInstr.h:69
This class contains meta information specific to a module.
MachineOperand class - Representation of each machine instruction operand.
This class implements a map that also provides access to all stored values in a deterministic order.
Definition: MapVector.h:36
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
LLVM Value Representation.
Definition: Value.h:74
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
@ BlockAddress
Definition: ISDOpcodes.h:84
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
@ Length
Definition: DWP.cpp:480
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:167
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1849
@ Enable
Enable colors.
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
struct HandlerInfo and Handlers permit users or target extended AsmPrinter to add their own handlers.
Definition: AsmPrinter.h:148
HandlerInfo(std::unique_ptr< AsmPrinterHandler > Handler, StringRef TimerName, StringRef TimerDescription, StringRef TimerGroupName, StringRef TimerGroupDescription)
Definition: AsmPrinter.h:155
std::unique_ptr< AsmPrinterHandler > Handler
Definition: AsmPrinter.h:149
Map a basic block section ID to the begin and end symbols of that section which determine the section...
Definition: AsmPrinter.h:135
llvm.global_ctors and llvm.global_dtors are arrays of Structor structs.
Definition: AsmPrinter.h:475
const class Function * Fn
Definition: AsmPrinter.h:362
Description of the encoding of one expression Op.
Data for a string pool entry.
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...
Definition: Dwarf.h:1077