LLVM: lib/CodeGen/AsmPrinter/DebugLocStream.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGLOCSTREAM_H
10#define LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGLOCSTREAM_H
11
15
16namespace llvm {
17
22
23
24
25
26
27
28
29
31public:
45
46private:
50 std::vectorstd::string Comments;
52
53
54
55 bool GenerateComments;
56
57public:
58 DebugLocStream(bool GenerateComments) : GenerateComments(GenerateComments) { }
59 size_t getNumLists() const { return Lists.size(); }
60 const List &getList(size_t LI) const { return Lists[LI]; }
68
69 class ListBuilder;
70 class EntryBuilder;
71
72private:
73
74
75
76
77
78
80 size_t LI = Lists.size();
82 return LI;
83 }
84
85
86
87
88
89
90
91 bool finalizeList(AsmPrinter &Asm);
92
93
94
95
96
97 void startEntry(const MCSymbol *BeginSym, const MCSymbol *EndSym) {
98 Entries.push_back({BeginSym, EndSym, DWARFBytes.size(), Comments.size()});
99 }
100
101
102 void finalizeEntry();
103
104public:
108
110 size_t LI = getIndex(L);
111 return ArrayRef(Entries).slice(Lists[LI].EntryOffset, getNumEntries(LI));
112 }
113
115 size_t EI = getIndex(E);
116 return ArrayRef(DWARFBytes.begin(), DWARFBytes.end())
117 .slice(Entries[EI].ByteOffset, getNumBytes(EI));
118 }
120 size_t EI = getIndex(E);
121 return ArrayRef(Comments).slice(Entries[EI].CommentOffset,
122 getNumComments(EI));
123 }
124
125private:
126 size_t getIndex(const List &L) const {
128 "Expected valid list");
129 return &L - &Lists.front();
130 }
131 size_t getIndex(const Entry &E) const {
133 "Expected valid entry");
134 return &E - &Entries.front();
135 }
136 size_t getNumEntries(size_t LI) const {
137 if (LI + 1 == Lists.size())
138 return Entries.size() - Lists[LI].EntryOffset;
139 return Lists[LI + 1].EntryOffset - Lists[LI].EntryOffset;
140 }
142 if (EI + 1 == Entries.size())
143 return DWARFBytes.size() - Entries[EI].ByteOffset;
144 return Entries[EI + 1].ByteOffset - Entries[EI].ByteOffset;
145 }
146 size_t getNumComments(size_t EI) const {
147 if (EI + 1 == Entries.size())
148 return Comments.size() - Entries[EI].CommentOffset;
149 return Entries[EI + 1].CommentOffset - Entries[EI].CommentOffset;
150 }
151};
152
153
158 size_t ListIndex;
159 std::optional<uint8_t> TagOffset;
160
161public:
164 : Locs(Locs), Asm(Asm), V(V), ListIndex(Locs.startList(&CU)),
165 TagOffset(std::nullopt) {}
166
168 TagOffset = TO;
169 }
170
171
172
173
174
176
178};
179
180
183
184public:
186 : Locs(List.getLocs()) {
187 Locs.startEntry(Begin, End);
188 }
189
190
192
194};
195
196}
197
198#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static const SCEV * getNumBytes(const SCEV *BECount, Type *IntPtr, const SCEV *StoreSizeSCEV, Loop *CurLoop, const DataLayout *DL, ScalarEvolution *SE)
Compute the number of bytes as a SCEV from the backedge taken count.
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class is intended to be used as a driving class for all asm writers.
This class is used to track local variable information.
Builder for DebugLocStream entries.
Definition DebugLocStream.h:181
EntryBuilder(ListBuilder &List, const MCSymbol *Begin, const MCSymbol *End)
Definition DebugLocStream.h:185
BufferByteStreamer getStreamer()
Definition DebugLocStream.h:193
~EntryBuilder()
Finalize the entry, deleting it if it's empty.
Definition DebugLocStream.h:191
Builder for DebugLocStream lists.
Definition DebugLocStream.h:154
DebugLocStream & getLocs()
Definition DebugLocStream.h:177
ListBuilder(DebugLocStream &Locs, DwarfCompileUnit &CU, AsmPrinter &Asm, DbgVariable &V)
Definition DebugLocStream.h:162
void setTagOffset(uint8_t TO)
Definition DebugLocStream.h:167
~ListBuilder()
Finalize the list.
const List & getList(size_t LI) const
Definition DebugLocStream.h:60
ArrayRef< std::string > getComments(const Entry &E) const
Definition DebugLocStream.h:119
BufferByteStreamer getStreamer()
Definition DebugLocStream.h:105
ArrayRef< Entry > getEntries(const List &L) const
Definition DebugLocStream.h:109
ArrayRef< char > getBytes(const Entry &E) const
Definition DebugLocStream.h:114
MCSymbol * getSym() const
Definition DebugLocStream.h:62
DebugLocStream(bool GenerateComments)
Definition DebugLocStream.h:58
size_t getNumLists() const
Definition DebugLocStream.h:59
void setSym(MCSymbol *Sym)
Definition DebugLocStream.h:65
ArrayRef< List > getLists() const
Definition DebugLocStream.h:61
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This is an optimization pass for GlobalISel generic memory operations.
ArrayRef(const T &OneElt) -> ArrayRef< T >
Implement std::hash so that hash_code can be used in STL containers.
Definition DebugLocStream.h:39
size_t ByteOffset
Definition DebugLocStream.h:42
size_t CommentOffset
Definition DebugLocStream.h:43
const MCSymbol * End
Definition DebugLocStream.h:41
const MCSymbol * Begin
Definition DebugLocStream.h:40
Definition DebugLocStream.h:32
List(DwarfCompileUnit *CU, size_t EntryOffset)
Definition DebugLocStream.h:36
MCSymbol * Label
Definition DebugLocStream.h:34
size_t EntryOffset
Definition DebugLocStream.h:35