LLVM: include/llvm/DebugInfo/DWARF/LowLevel/DWARFUnwindTable.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_DEBUGINFO_DWARF_LOWLEVEL_DWARFUNWINDTABLE_H
10#define LLVM_DEBUGINFO_DWARF_LOWLEVEL_DWARFUNWINDTABLE_H
11
17#include
18#include
19
20namespace llvm {
21
24
25
26
27
28class UnwindLocation {
29public:
31
33
35
36
37
39
40
41
43
44
45
46
48
49
50
51
53
54
56 };
57
58private:
59 Location Kind;
60 uint32_t RegNum;
61 int32_t Offset;
62 std::optional<uint32_t> AddrSpace;
63
64 std::optional Expr;
65
66 bool Dereference;
67
68
69
70
73 AddrSpace(std::nullopt), Dereference(false) {}
74
75 UnwindLocation(Location K, uint32_t Reg, int32_t Off,
76 std::optional<uint32_t> AS, bool Deref)
77 : Kind(K), RegNum(Reg), Offset(Off), AddrSpace(AS), Dereference(Deref) {}
78
79 UnwindLocation(DWARFExpression E, bool Deref)
81 Dereference(Deref) {}
82
83public:
84
85
86
88
89
91
93
94
95
96
97
98
99
102
103
104
105
106
107
108
109
110 LLVM_ABI static UnwindLocation
112 std::optional<uint32_t> AddrSpace = std::nullopt);
113 LLVM_ABI static UnwindLocation
115 std::optional<uint32_t> AddrSpace = std::nullopt);
116
117
118
122
127 if (AddrSpace)
128 return true;
129 return false;
130 }
133 return *AddrSpace;
134 }
137
138
139
140
142
143
144
145 void setOffset(int32_t NewOffset) { Offset = NewOffset; }
146
147
148
150
154
156};
157
158
159
160
161
162
163
164
165
167 std::map<uint32_t, UnwindLocation> Locations;
168
169public:
170
171
172
173
174
175
177 auto Pos = Locations.find(RegNum);
178 if (Pos == Locations.end())
179 return std::nullopt;
180 return Pos->second;
181 }
182
185 for (auto &&[Register, _] : Locations)
188 }
189
190
191
192
193
194
196 Locations.erase(RegNum);
197 Locations.insert(std::make_pair(RegNum, Location));
198 }
199
200
201
202
204
205
207
208 size_t size() const { return Locations.size(); }
209
211 return Locations == RHS.Locations;
212 }
213};
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
232
233
234 std::optional<uint64_t> Address;
235 UnwindLocation CFAValue;
236 RegisterLocations RegLocs;
237
238public:
240
241
242 bool hasAddress() const { return Address.has_value(); }
243
244
245
246
247
249
250
251
252
253
255
256
257
258
259
260
261
267};
268
269
270
271
272
273
275public:
279
281
282 size_t size() const { return Rows.size(); }
289 return Rows[Index];
290 }
291
292private:
294};
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
314parseRows(const CFIProgram &CFIP, UnwindRow &CurrRow,
315 const RegisterLocations *InitialLocs);
316
317}
318
319}
320
321#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
SI Pre allocate WWM Registers
This file defines the SmallVector class.
Tagged union holding either a T or a Error.
Wrapper class representing virtual and physical registers.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM Value Representation.
A class that can track all registers with locations in a UnwindRow object.
Definition DWARFUnwindTable.h:166
bool operator==(const RegisterLocations &RHS) const
Definition DWARFUnwindTable.h:210
std::optional< UnwindLocation > getRegisterLocation(uint32_t RegNum) const
Return the location for the register in RegNum if there is a location.
Definition DWARFUnwindTable.h:176
SmallVector< uint32_t, 4 > getRegisters() const
Definition DWARFUnwindTable.h:183
void setRegisterLocation(uint32_t RegNum, const UnwindLocation &Location)
Set the location for the register in RegNum to Location.
Definition DWARFUnwindTable.h:195
bool hasLocations() const
Returns true if we have any register locations in this object.
Definition DWARFUnwindTable.h:206
size_t size() const
Definition DWARFUnwindTable.h:208
void removeRegisterLocation(uint32_t RegNum)
Removes any rule for the register in RegNum.
Definition DWARFUnwindTable.h:203
A class that represents a location for the Call Frame Address (CFA) or a register.
Definition DWARFUnwindTable.h:28
static LLVM_ABI UnwindLocation createUndefined()
Create a location where the value is undefined and not available.
void setConstant(int32_t Value)
Some opcodes modify a constant value and we need to be able to update the constant value (DW_CFA_GNU_...
Definition DWARFUnwindTable.h:149
void setOffset(int32_t NewOffset)
Some opcodes will modify the CFA location's offset only, so we need to be able to modify the CFA offs...
Definition DWARFUnwindTable.h:145
uint32_t getRegister() const
Definition DWARFUnwindTable.h:124
static LLVM_ABI UnwindLocation createAtRegisterPlusOffset(uint32_t Reg, int32_t Off, std::optional< uint32_t > AddrSpace=std::nullopt)
static LLVM_ABI UnwindLocation createIsRegisterPlusOffset(uint32_t Reg, int32_t Off, std::optional< uint32_t > AddrSpace=std::nullopt)
Create a location where the saved value is in (Deref == false) or at (Deref == true) a regiser plus a...
int32_t getOffset() const
Definition DWARFUnwindTable.h:125
static LLVM_ABI UnwindLocation createAtDWARFExpression(DWARFExpression Expr)
static LLVM_ABI UnwindLocation createUnspecified()
Create a location whose rule is set to Unspecified.
LLVM_ABI bool operator==(const UnwindLocation &RHS) const
static LLVM_ABI UnwindLocation createIsDWARFExpression(DWARFExpression Expr)
Create a location whose value is the result of evaluating a DWARF expression.
Location
Definition DWARFUnwindTable.h:30
@ Undefined
Register is not available and can't be recovered.
Definition DWARFUnwindTable.h:34
@ Constant
Value is a constant value contained in "Offset": reg = Offset.
Definition DWARFUnwindTable.h:55
@ DWARFExpr
Register or CFA value is in or at a value found by evaluating a DWARF expression: reg = eval(dwarf_ex...
Definition DWARFUnwindTable.h:52
@ Same
Register value is in the register, nothing needs to be done to unwind it: reg = reg.
Definition DWARFUnwindTable.h:38
@ CFAPlusOffset
Register is in or at the CFA plus an offset: reg = CFA + offset reg = defef(CFA + offset)
Definition DWARFUnwindTable.h:42
@ Unspecified
Not specified.
Definition DWARFUnwindTable.h:32
@ RegPlusOffset
Register or CFA is in or at a register plus offset, optionally in an address space: reg = reg + offse...
Definition DWARFUnwindTable.h:47
Location getLocation() const
Definition DWARFUnwindTable.h:123
static LLVM_ABI UnwindLocation createIsConstant(int32_t Value)
uint32_t getAddressSpace() const
Definition DWARFUnwindTable.h:131
std::optional< DWARFExpression > getDWARFExpressionBytes() const
Definition DWARFUnwindTable.h:151
static LLVM_ABI UnwindLocation createAtCFAPlusOffset(int32_t Off)
static LLVM_ABI UnwindLocation createSame()
Create a location where the value is known to be in the register itself.
int32_t getConstant() const
Definition DWARFUnwindTable.h:135
bool getDereference() const
Definition DWARFUnwindTable.h:136
static LLVM_ABI UnwindLocation createIsCFAPlusOffset(int32_t Off)
Create a location that is in (Deref == false) or at (Deref == true) the CFA plus an offset.
void setRegister(uint32_t NewRegNum)
Some opcodes will modify the CFA location's register only, so we need to be able to modify the CFA re...
Definition DWARFUnwindTable.h:141
bool hasAddressSpace() const
Definition DWARFUnwindTable.h:126
A class that represents a single row in the unwind table that is decoded by parsing the DWARF Call Fr...
Definition DWARFUnwindTable.h:231
void setAddress(uint64_t Addr)
Set the address for this UnwindRow.
Definition DWARFUnwindTable.h:254
void slideAddress(uint64_t Offset)
Offset the address for this UnwindRow.
Definition DWARFUnwindTable.h:262
uint64_t getAddress() const
Get the address for this row.
Definition DWARFUnwindTable.h:248
UnwindRow()
Definition DWARFUnwindTable.h:239
const RegisterLocations & getRegisterLocations() const
Definition DWARFUnwindTable.h:266
UnwindLocation & getCFAValue()
Definition DWARFUnwindTable.h:263
const UnwindLocation & getCFAValue() const
Definition DWARFUnwindTable.h:264
RegisterLocations & getRegisterLocations()
Definition DWARFUnwindTable.h:265
bool hasAddress() const
Returns true if the address is valid in this object.
Definition DWARFUnwindTable.h:242
UnwindTable(RowContainer &&Rows)
Definition DWARFUnwindTable.h:280
const_iterator end() const
Definition DWARFUnwindTable.h:286
size_t size() const
Definition DWARFUnwindTable.h:282
iterator end()
Definition DWARFUnwindTable.h:285
iterator begin()
Definition DWARFUnwindTable.h:283
std::vector< UnwindRow > RowContainer
Definition DWARFUnwindTable.h:276
RowContainer::const_iterator const_iterator
Definition DWARFUnwindTable.h:278
const_iterator begin() const
Definition DWARFUnwindTable.h:284
RowContainer::iterator iterator
Definition DWARFUnwindTable.h:277
const UnwindRow & operator[](size_t Index) const
Definition DWARFUnwindTable.h:287
Calculates the starting offsets for various sections within the .debug_names section.
constexpr uint32_t InvalidRegisterNumber
Definition DWARFUnwindTable.h:23
LLVM_ABI Expected< UnwindTable::RowContainer > parseRows(const CFIProgram &CFIP, UnwindRow &CurrRow, const RegisterLocations *InitialLocs)
Parse the information in the CFIProgram and update the CurrRow object that the state machine describe...
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.