LLVM: lib/DebugInfo/DWARF/LowLevel/DWARFExpression.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
10#include
11#include
12#include
13
14using namespace llvm;
15using namespace dwarf;
16
17namespace llvm {
18
21
23 std::vector Descriptions;
24 Descriptions.resize(0xff);
67 for (uint16_t LA = DW_OP_lit0; LA <= DW_OP_lit31; ++LA)
69 for (uint16_t LA = DW_OP_reg0; LA <= DW_OP_reg31; ++LA)
71 for (uint16_t LA = DW_OP_breg0; LA <= DW_OP_breg31; ++LA)
80 Descriptions[DW_OP_push_object_address] = Desc(Op::Dwarf3);
84 Descriptions[DW_OP_form_tls_address] = Desc(Op::Dwarf3);
85 Descriptions[DW_OP_call_frame_cfa] = Desc(Op::Dwarf3);
87 Descriptions[DW_OP_implicit_value] =
90 Descriptions[DW_OP_implicit_pointer] =
96 Descriptions[DW_OP_regval_type] =
98 Descriptions[DW_OP_WASM_location] =
100 Descriptions[DW_OP_GNU_push_tls_address] = Desc(Op::Dwarf3);
104 Descriptions[DW_OP_GNU_implicit_pointer] =
106
107
108
110 return Descriptions;
111}
112
114
115 if (Opcode >= Descriptions.size())
116 return {};
117 return Descriptions[Opcode];
118}
119
124
126 static constexpr unsigned LlvmUserDescriptionsSize = 1
127#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) +1
128#include "llvm/BinaryFormat/Dwarf.def"
129 ;
130 std::vector Descriptions;
131 Descriptions.resize(LlvmUserDescriptionsSize);
133 Descriptions[DW_OP_LLVM_form_aspace_address] =
137 Descriptions[DW_OP_LLVM_offset_uconst] =
140 Descriptions[DW_OP_LLVM_call_frame_entry_reg] =
143 Descriptions[DW_OP_LLVM_aspace_bregx] =
146 Descriptions[DW_OP_LLVM_extend] =
148 Descriptions[DW_OP_LLVM_select_bit_piece] =
150 return Descriptions;
151}
152
154 assert(Opcode == DW_OP_LLVM_user);
156 return getDescImpl(Descriptions, SubOpcode);
157}
158
161 std::optional Format) {
164
167 return false;
168
170 OperandEndOffsets.resize(Desc.Op.size());
171 for (unsigned Operand = 0; Operand < Desc.Op.size(); ++Operand) {
172 unsigned Size = Desc.Op[Operand];
174
177 assert(Operand == 0 && "SubOp operand must be the first operand");
178 Operands[Operand] = Data.getULEB128(&Offset);
181 return false;
183 "SizeSubOpLEB Description must begin with SizeSubOpLEB operand");
185 OperandEndOffsets.resize(Desc.Op.size());
186 break;
188 Operands[Operand] = Data.getU8(&Offset);
190 Operands[Operand] = (int8_t)Operands[Operand];
191 break;
193 Operands[Operand] = Data.getU16(&Offset);
195 Operands[Operand] = (int16_t)Operands[Operand];
196 break;
198 Operands[Operand] = Data.getU32(&Offset);
200 Operands[Operand] = (int32_t)Operands[Operand];
201 break;
203 Operands[Operand] = Data.getU64(&Offset);
204 break;
206 Operands[Operand] = Data.getUnsigned(&Offset, AddressSize);
207 break;
209 if (!Format)
210 return false;
211 Operands[Operand] =
213 break;
216 Operands[Operand] = Data.getSLEB128(&Offset);
217 else
218 Operands[Operand] = Data.getULEB128(&Offset);
219 break;
221 Operands[Operand] = Data.getULEB128(&Offset);
222 break;
224 assert(Operand == 1);
225 switch (Operands[0]) {
226 case 0:
227 case 1:
228 case 2:
229 case 4:
230 Operands[Operand] = Data.getULEB128(&Offset);
231 break;
232 case 3:
233 Operands[Operand] = Data.getU32(&Offset);
234 break;
235 default:
236 return false;
237 }
238 break;
240
241 if (Operand == 0)
242 return false;
243
244 Operands[Operand] = Offset;
245 Offset += Operands[Operand - 1];
246 break;
247 default:
249 }
250
251 OperandEndOffsets[Operand] = Offset;
252 }
253
255 return true;
256}
257
260 return std::nullopt;
261 return Operands[0];
262}
263
265 if (AddressSize != RHS.AddressSize || Format != RHS.Format)
266 return false;
267 return Data.getData() == RHS.Data.getData();
268}
269
270}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
This class represents an Operation in the Expression.
LLVM_ABI std::optional< unsigned > getSubCode() const
Definition DWARFExpression.cpp:258
@ DwarfNA
Serves as a marker for unused entries.
@ SizeSubOpLEB
The operand is a ULEB128 encoded SubOpcode.
@ SizeBlock
Preceding operand contains block size.
DWARFExpression(DataExtractor Data, uint8_t AddressSize, std::optional< dwarf::DwarfFormat > Format=std::nullopt)
LLVM_ABI bool operator==(const DWARFExpression &RHS) const
Definition DWARFExpression.cpp:264
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Calculates the starting offsets for various sections within the .debug_names section.
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
This is an optimization pass for GlobalISel generic memory operations.
static Desc getSubOpDesc(unsigned Opcode, unsigned SubOpcode)
Definition DWARFExpression.cpp:153
static std::vector< Desc > getOpDescriptions()
Definition DWARFExpression.cpp:22
static Desc getDescImpl(ArrayRef< Desc > Descriptions, unsigned Opcode)
Definition DWARFExpression.cpp:113
FunctionAddr VTableAddr uintptr_t uintptr_t Data
DWARFExpression::Operation Op
static Desc getOpDesc(unsigned Opcode)
Definition DWARFExpression.cpp:120
static std::vector< Desc > getSubOpDescriptions()
Definition DWARFExpression.cpp:125
Description of the encoding of one expression Op.