LLVM: include/llvm/CodeGen/AsmPrinter.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef LLVM_CODEGEN_ASMPRINTER_H
16#define LLVM_CODEGEN_ASMPRINTER_H
17
32#include
33#include
34#include
35#include
36
37namespace llvm {
38
85
89
90
92public:
93
95
96
98
99
100
102
103
104
105
107
108
110
111
113
114
116
117
119
120
122
123
125
126
127
129
130
131
133
134
135
136
138
139
140
141
142
145
146
148
149
151
152
153
157
159
160
161
164
165
171
172private:
173 MCSymbol *CurrentFnEnd = nullptr;
174
175
176
177
179
180
181
182 MCSymbol *CurrentSectionBeginSym = nullptr;
183
184
185
186 std::unique_ptr AddrLabelSymbols;
187
188
190
191
192 bool VerboseAsm;
193
194
195
196 struct FunctionCallGraphInfo {
197
198
200
201
203
205 };
206
207 enum CallGraphSectionFormatVersion : uint8_t {
208 V_0 = 0,
209 };
210
211
212 std::unique_ptr<raw_fd_ostream> StackUsageStream;
213
214
215 DenseMap<const MDNode *, SmallVector<const MCSymbol *>> PCSectionsSymbols;
216
217 static char ID;
218
219protected:
221
222
224
225
226
227
229
230
231
232
235
237
238private:
239
240 std::unique_ptr OwnedMDT;
241
242
243 std::unique_ptr OwnedMLI;
244
245
247
248
249
250 std::unique_ptr PP;
251
252
254
255
256
257
258 bool HasSplitStack = false;
259
260
261
262
263 bool HasNoSplitStack = false;
264
265
266 bool DbgInfoAvailable = false;
267
268protected:
270 char &ID = AsmPrinter::ID);
271
272public:
274
277
278 uint16_t getDwarfVersion() const;
280
281 bool isDwarf64() const;
282
283
284 unsigned int getDwarfOffsetByteSize() const;
285
286
287 unsigned int getUnitLengthFieldByteSize() const;
288
289
291
292 bool isPositionIndependent() const;
293
294
295 bool isVerbose() const { return VerboseAsm; }
296
297
298 unsigned getFunctionNumber() const;
299
300
301
303
306
307
308
310
311
312
313
317
318
319
320
322
323
324
326
327
328
329
330
331 void takeDeletedSymbolsForFunction(const Function *F,
332 std::vector<MCSymbol *> &Result);
333
334
336
337
338 const DataLayout &getDataLayout() const;
339
340
342
343
345
347
348
349 void emitInitialRawDwarfLocDirective(const MachineFunction &MF);
350
351
352 const MCSection *getCurrentSection() const;
353
356
358
359
360
361
363
365 return DwarfUsesRelocationsAcrossSections;
366 }
367
369 DwarfUsesRelocationsAcrossSections = Enable;
370 }
371
372
373
375
376
377
378
379 void handleCallsiteForCallgraph(
380 FunctionCallGraphInfo &FuncCGInfo,
383
384
385
386
387public:
388
397
398
399
400
401
412
413
415
416
419
420
422
424
425
426
427
428
429
431
432
433
435
436
437
439
440
446
447
448
449
450
451
452
454
455
456 void emitFunctionBody();
457
459
461
463
465
467
470
472 FunctionCallGraphInfo &FuncCGInfo);
473
475
477
478
480
481
483
484
485 CFISection getFunctionCFISectionType(const Function &F) const;
486
487
488 CFISection getFunctionCFISectionType(const MachineFunction &MF) const;
489
490
492
493
495
496 bool needsSEHMoves();
497
498
499
500
501
502 bool usesCFIWithoutEH() const;
503
504
505
506
508
509
510
511 virtual void emitJumpTableInfo();
512
513
514 virtual void emitGlobalVariable(const GlobalVariable *GV);
515
516
517
518 bool emitSpecialLLVMGlobal(const GlobalVariable *GV);
519
520
521
522
523
524
525
533
534
535
536
537
538
541
542
544 bool IsCtor);
545
546
547
548
549
551 unsigned MaxBytesToEmit = 0) const;
552
553
554
556 const Constant *BaseCV = nullptr,
558
559
560
561
565
566
567
568
569
570
571
572
573
575
576
577
578
580
581
583
584
585
586
587
589
590
591
592
593
594
596
597
598
600
601
602
604
605
606
608
609
610
611
612
614
615
617
618
622
623
624 virtual MCSymbol *GetCPISymbol(unsigned CPID) const;
625
626 virtual void emitFunctionEntryLabel();
627
631
633
634
635
639
643
644
645 virtual const MCExpr *lowerBlockAddressConstant(const BlockAddress &BA);
646
647
648
649
650 virtual bool
652
653
654
655 virtual void emitImplicitDef(const MachineInstr *MI) const;
656
657
658
659
660
662 return nullptr;
663 }
664
668 "Mach-O IFunc lowering is not yet supported on this target");
669 }
670
674 "Mach-O IFunc lowering is not yet supported on this target");
675 }
676
677
678 void emitNops(unsigned N);
679
680
681
682
683
684 MCSymbol *createTempSymbol(const Twine &Name) const;
685
686
687
690
691
692 MCSymbol *GetExternalSymbolSymbol(const Twine &Sym) const;
693
694
695 MCSymbol *GetJTISymbol(unsigned JTID, bool isLinkerPrivate = false) const;
696
697
698
699 MCSymbol *GetJTSetSymbol(unsigned UID, unsigned MBBID) const;
700
701
702
705
706
707
708
709
710
712
713
714 void emitInt8(int Value) const;
715
716
717 void emitInt16(int Value) const;
718
719
720 void emitInt32(int Value) const;
721
722
724
725
726 void emitSLEB128(int64_t Value, const char *Desc = nullptr) const;
727
728
730 unsigned PadTo = 0) const;
731
732
733
734
736 unsigned Size) const;
737
738
739 void emitLabelDifferenceAsULEB128(const MCSymbol *Hi,
741
742
743
744
746 unsigned Size, bool IsSectionRelative = false) const;
747
748
749
751 bool IsSectionRelative = false) const {
753 }
754
755
756
757
758
759
760
761
763
764
765 unsigned GetSizeOfEncodedValue(unsigned Encoding) const;
766
767
768 virtual void emitTTypeReference(const GlobalValue *GV, unsigned Encoding);
769
770
771
772
773 void emitDwarfSymbolReference(const MCSymbol *Label,
774 bool ForceOffset = false) const;
775
776
777
778
779
780
781
782
784
785
789
790
791
793
794
795 void emitDwarfLengthOrOffset(uint64_t Value) const;
796
797
798
800
801
802
803
804 MCSymbol *emitDwarfUnitLength(const Twine &Prefix,
805 const Twine &Comment) const;
806
807
809 unsigned Encoding) const;
810
811 void emitCallSiteValue(uint64_t Value, unsigned Encoding) const;
812
813
815
816
817
818
819
820 virtual void emitDebugValue(const MCExpr *Value, unsigned Size) const;
821
822
823
824
825
826
828
829
831
832 for (const auto &Abbrev : Abbrevs)
834
835
837 }
838
839 void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const;
840
841
842 void emitDwarfDIE(const DIE &Die) const;
843
844
845
846
847
848
849
850
853 getCodeViewJumpTableInfo(int JTI, const MachineInstr *BranchInstr,
854 const MCSymbol *BranchLabel) const;
855
856
857
858
859
860
861
862 void emitCOFFReplaceableFunctionData(Module &M);
863
864
865 void emitCOFFFeatureSymbol(Module &M);
866
867
868
869
870
871
872
873
874
875
876
877
878
879
882
883
884
886
887
888
889
890 virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
892
893
894
895
896
897 virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
899
900
901
902 virtual void emitInlineAsmStart() const;
903
904
905
906
907
908
909
910 virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
912
913
914
915 void emitVisibility(MCSymbol *Sym, unsigned Visibility,
916 bool IsDefinition = true) const;
917
918
919
921
922
925
926private:
927
928
929 mutable const MachineInstr *LastMI = nullptr;
930 mutable unsigned LastFn = 0;
931 mutable unsigned Counter = ~0U;
932
933 bool DwarfUsesRelocationsAcrossSections = false;
934
935
936 virtual void emitFunctionHeader();
937
938
939 virtual void emitFunctionHeaderComment();
940
941
943
944
945 void
948 const MDNode *LocMDNode = nullptr,
950
951
952
954
955
956
957 unsigned addInlineAsmDiagBuffer(StringRef AsmStr,
958 const MDNode *LocMDNode) const;
959
960
961
962
963
966
969
970 void emitLLVMUsedList(const ConstantArray *InitList);
971
972 void emitModuleIdents(Module &M);
973
974 virtual void emitModuleCommandLines(Module &M);
975
978
979
981
982protected:
985 unsigned uid) const;
986 virtual void emitGlobalAlias(const Module &M, const GlobalAlias &GA);
990};
991
992}
993
994#endif
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void emitConstantPool(MCStreamer &Streamer, MCSection *Section, ConstantPool &CP)
static std::optional< TypeSize > getPointerSize(const Value *V, const DataLayout &DL, const TargetLibraryInfo &TLI, const Function *F)
This file defines the DenseMap class.
This file contains constants used for implementing Dwarf debug support.
static void emitEncodingByte(MCObjectStreamer &Streamer, unsigned Encoding)
This file implements a map that provides insertion order iteration.
static void emitInlineAsm(LLVMContext &C, BasicBlock *BB, StringRef AsmText)
static SDValue lowerConstant(SDValue Op, SelectionDAG &DAG, const RISCVSubtarget &Subtarget)
This file implements a set that has insertion order iteration characteristics.
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),...
Collects and handles AsmPrinter objects required to build debug or EH information.
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
Definition AsmPrinter.h:619
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:414
MapVector< MBBSectionID, MBBSectionRange > MBBSectionRanges
Definition AsmPrinter.h:158
CFISection getModuleCFISectionType() const
Get the CFISection type for the module.
Definition AsmPrinter.h:491
MCSymbol * CurrentFnBegin
Definition AsmPrinter.h:220
MachineLoopInfo * MLI
This is a pointer to the current MachineLoopInfo.
Definition AsmPrinter.h:118
DwarfDebug * getDwarfDebug()
Definition AsmPrinter.h:275
virtual const MCExpr * lowerConstantPtrAuth(const ConstantPtrAuth &CPA)
Definition AsmPrinter.h:640
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...
TargetMachine & TM
Target machine description.
Definition AsmPrinter.h:94
void emitXRayTable()
Emit a table with all XRay instrumentation points.
DenseMap< const MachineBasicBlock *, SmallVector< MCSymbol *, 1 > > CurrentFnCallsiteEndSymbols
Vector of symbols marking the end of the callsites in the current function, keyed by their containing...
Definition AsmPrinter.h:144
DwarfDebug * getDwarfDebug() const
Definition AsmPrinter.h:276
MCSymbol * CurrentFnDescSym
The symbol for the current function descriptor on AIX.
Definition AsmPrinter.h:132
MCSymbol * CurrentFnBeginLocal
For dso_local functions, the current $local alias for the function.
Definition AsmPrinter.h:223
MapVector< const MCSymbol *, GOTEquivUsePair > GlobalGOTEquivs
Definition AsmPrinter.h:163
void emitDwarfStringOffset(DwarfStringPoolEntry S) const
Emit the 4- or 8-byte offset of a string from the start of its section.
void emitGlobalGOTEquivs()
Constant expressions using GOT equivalent globals may not be eligible for PC relative GOT entry conve...
MCSymbol * getFunctionBegin() const
Definition AsmPrinter.h:304
virtual void emitMachOIFuncStubHelperBody(Module &M, const GlobalIFunc &GI, MCSymbol *LazyPointer)
Definition AsmPrinter.h:671
MCSymbol * getAddrLabelSymbol(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
Definition AsmPrinter.h:314
const MCAsmInfo * MAI
Target Asm Printer information.
Definition AsmPrinter.h:97
SmallVector< std::unique_ptr< AsmPrinterHandler >, 2 > Handlers
Definition AsmPrinter.h:233
MachineFunction * MF
The current machine function.
Definition AsmPrinter.h:109
void computeGlobalGOTEquivs(Module &M)
Unnamed constant global variables solely contaning a pointer to another globals variable act like a g...
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.
MachineDominatorTree * MDT
This is a pointer to the current MachineDominatorTree.
Definition AsmPrinter.h:115
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:595
void emitStackMaps()
Emit the stack maps.
bool hasDebugInfo() const
Returns true if valid debug info is present.
Definition AsmPrinter.h:494
virtual void emitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
Definition AsmPrinter.h:603
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:162
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:599
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
virtual void emitMachOIFuncStubBody(Module &M, const GlobalIFunc &GI, MCSymbol *LazyPointer)
Definition AsmPrinter.h:665
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
MachineOptimizationRemarkEmitter * ORE
Optimization remark emitter.
Definition AsmPrinter.h:121
DenseMap< uint64_t, SmallVector< const GlobalAlias *, 1 > > AliasMapTy
Print a general LLVM constant to the .s file.
Definition AsmPrinter.h:562
virtual bool shouldEmitWeakSwiftAsyncExtendedFramePointerFlags() const
Definition AsmPrinter.h:987
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer, char &ID=AsmPrinter::ID)
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:302
void emitDwarfStringOffset(DwarfStringPoolEntryRef S) const
Emit the 4-or 8-byte offset of a string from the start of its section.
Definition AsmPrinter.h:786
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition AsmPrinter.h:128
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Definition AsmPrinter.h:112
void emitDwarfAbbrevs(const T &Abbrevs) const
Emit Dwarf abbreviation table.
Definition AsmPrinter.h:830
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:101
const StaticDataProfileInfo * SDPI
Provides the profile information for constants.
Definition AsmPrinter.h:147
bool doFinalization(Module &M) override
Shut down the asmprinter.
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:661
virtual void emitXXStructorList(const DataLayout &DL, const Constant *List, bool IsCtor)
This method emits llvm.global_ctors or llvm.global_dtors list.
MCSymbol * CurrentPatchableFunctionEntrySym
The symbol for the entry in __patchable_function_entires.
Definition AsmPrinter.h:124
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
Definition AsmPrinter.h:441
void emitDwarfAbbrev(const DIEAbbrev &Abbrev) const
void setDwarfUsesRelocationsAcrossSections(bool Enable)
Definition AsmPrinter.h:368
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition AsmPrinter.h:106
const ProfileSummaryInfo * PSI
The profile summary information.
Definition AsmPrinter.h:150
SledKind
Definition AsmPrinter.h:389
@ LOG_ARGS_ENTER
Definition AsmPrinter.h:393
@ TAIL_CALL
Definition AsmPrinter.h:392
@ CUSTOM_EVENT
Definition AsmPrinter.h:394
@ FUNCTION_EXIT
Definition AsmPrinter.h:391
@ FUNCTION_ENTER
Definition AsmPrinter.h:390
@ TYPED_EVENT
Definition AsmPrinter.h:395
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:750
virtual void emitFunctionDescriptor()
Definition AsmPrinter.h:628
size_t NumUserHandlers
Definition AsmPrinter.h:234
MCSymbol * CurrentFnSymForSize
The symbol used to represent the start of the current function for the purpose of calculating its siz...
Definition AsmPrinter.h:137
virtual unsigned getISAEncoding()
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
Definition AsmPrinter.h:814
bool isVerbose() const
Return true if assembly output should contain comments.
Definition AsmPrinter.h:295
MCSymbol * getFunctionEnd() const
Definition AsmPrinter.h:305
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:636
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.
SmallVector< std::unique_ptr< AsmPrinterHandler >, 1 > EHHandlers
A handle to the EH info emitter (if present).
Definition AsmPrinter.h:228
StackMaps SM
Definition AsmPrinter.h:236
ArrayRef< MCSymbol * > getAddrLabelSymbolToEmit(const BasicBlock *BB)
Return the symbol to be used for the specified basic block when its address is taken.
virtual void emitFunctionBodyEnd()
Targets can override this to emit stuff after the last basic block in the function.
Definition AsmPrinter.h:607
bool doesDwarfUseRelocationsAcrossSections() const
Definition AsmPrinter.h:364
CFISection
Definition AsmPrinter.h:166
@ EH
Emit .eh_frame.
Definition AsmPrinter.h:168
@ None
Do not emit either .eh_frame or .debug_frame.
Definition AsmPrinter.h:167
@ Debug
Emit .debug_frame.
Definition AsmPrinter.h:169
void addAsmPrinterHandler(std::unique_ptr< AsmPrinterHandler > Handler)
LLVM Basic Block Representation.
The address of a basic block.
ConstantArray - Constant Array Declarations.
A signed pointer, in the ptrauth sense.
This is an important base class in LLVM.
Dwarf abbreviation, describes the organization of a debug information object.
A structured debug information entry.
A parsed version of the target data layout string in and methods for querying it.
Base class for debug information backends.
Collects and handles dwarf debug information.
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
const DwarfStringPoolEntry & getEntry() const
Emits exception handling directives.
GCStrategy describes a garbage collector algorithm's code generation requirements,...
This class is intended to be used as a base class for asm properties and features specific to the tar...
Context object for machine code objects.
Base class for the full range of assembler expressions which are needed for parsing.
Instances of this class represent a single low-level machine instruction.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Streaming machine code generation interface.
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
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(char &ID)
DenseMap< const MachineInstr *, CallSiteInfo > CallSiteInfoMap
Representation of each machine instruction.
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.
A Module instance is used to store all the information related to an LLVM module.
Analysis providing profile information.
A SetVector that performs no allocations if smaller than a certain size.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A class that holds the constants that represent static data and their profile information and provide...
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Version
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
This struct is a compact representation of a valid (non-zero power of two) alignment.
Map a basic block section ID to the begin and end symbols of that section which determine the section...
Definition AsmPrinter.h:154
MCSymbol * BeginLabel
Definition AsmPrinter.h:155
MCSymbol * EndLabel
Definition AsmPrinter.h:155
Constant * Func
Definition AsmPrinter.h:528
GlobalValue * ComdatKey
Definition AsmPrinter.h:529
int Priority
Definition AsmPrinter.h:527
Definition AsmPrinter.h:402
const MCSymbol * Function
Definition AsmPrinter.h:404
SledKind Kind
Definition AsmPrinter.h:405
uint8_t Version
Definition AsmPrinter.h:408
const class Function * Fn
Definition AsmPrinter.h:407
LLVM_ABI void emit(int, MCStreamer *) const
bool AlwaysInstrument
Definition AsmPrinter.h:406
const MCSymbol * Sled
Definition AsmPrinter.h:403
Data for a string pool entry.
A helper struct providing information about the byte size of DW_FORM values that vary in size dependi...