26 std::vector<Desc> Descriptions;
27 Descriptions.resize(0xff);
70 for (
uint16_t LA = DW_OP_lit0; LA <= DW_OP_lit31; ++LA)
72 for (
uint16_t LA = DW_OP_reg0; LA <= DW_OP_reg31; ++LA)
74 for (
uint16_t LA = DW_OP_breg0; LA <= DW_OP_breg31; ++LA)
90 Descriptions[DW_OP_implicit_value] =
93 Descriptions[DW_OP_implicit_pointer] =
99 Descriptions[DW_OP_regval_type] =
101 Descriptions[DW_OP_WASM_location] =
116 if (Opcode >= Descriptions.
size())
118 return Descriptions[Opcode];
127 static constexpr unsigned LlvmUserDescriptionsSize = 1
128#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) +1
129#include "llvm/BinaryFormat/Dwarf.def"
131 std::vector<Desc> Descriptions;
132 Descriptions.resize(LlvmUserDescriptionsSize);
138 assert(Opcode == DW_OP_LLVM_user);
145 std::optional<DwarfFormat>
Format) {
147 Opcode = Data.getU8(&
Offset);
155 for (
unsigned Operand = 0; Operand <
Desc.
Op.
size(); ++Operand) {
161 assert(Operand == 0 &&
"SubOp operand must be the first operand");
162 Operands[Operand] = Data.getULEB128(&
Offset);
167 "SizeSubOpLEB Description must begin with SizeSubOpLEB operand");
170 Operands[Operand] = Data.getU8(&
Offset);
172 Operands[Operand] = (int8_t)Operands[Operand];
175 Operands[Operand] = Data.getU16(&
Offset);
177 Operands[Operand] = (int16_t)Operands[Operand];
180 Operands[Operand] = Data.getU32(&
Offset);
182 Operands[Operand] = (int32_t)Operands[Operand];
185 Operands[Operand] = Data.getU64(&
Offset);
188 Operands[Operand] = Data.getUnsigned(&
Offset, AddressSize);
198 Operands[Operand] = Data.getSLEB128(&
Offset);
200 Operands[Operand] = Data.getULEB128(&
Offset);
203 Operands[Operand] = Data.getULEB128(&
Offset);
207 switch (Operands[0]) {
212 Operands[Operand] = Data.getULEB128(&
Offset);
215 Operands[Operand] = Data.getU32(&
Offset);
226 Operands[Operand] =
Offset;
227 Offset += Operands[Operand - 1];
233 OperandEndOffsets[Operand] =
Offset;
249 auto Die = U->getDIEForOffset(U->getOffset() +
Operands[Operand]);
250 if (Die && Die.getTag() == dwarf::DW_TAG_base_type) {
256 OS <<
" \"" << *
Name <<
"\"";
272 if (Opcode == DW_OP_bregx || Opcode == DW_OP_regx ||
273 Opcode == DW_OP_regval_type)
275 else if (Opcode >= DW_OP_breg0 && Opcode < DW_OP_bregx)
276 DwarfRegNum = Opcode - DW_OP_breg0;
278 DwarfRegNum = Opcode - DW_OP_reg0;
282 if ((Opcode >= DW_OP_breg0 && Opcode <= DW_OP_breg31) ||
283 Opcode == DW_OP_bregx)
288 if (Opcode == DW_OP_regval_type)
306 OS <<
"<decoding error>";
311 assert(!
Name.empty() &&
"DW_OP has no name!");
314 if ((Opcode >= DW_OP_breg0 && Opcode <= DW_OP_breg31) ||
315 (Opcode >= DW_OP_reg0 && Opcode <= DW_OP_reg31) ||
316 Opcode == DW_OP_bregx || Opcode == DW_OP_regx ||
317 Opcode == DW_OP_regval_type)
321 for (
unsigned Operand = 0; Operand <
Desc.
Op.
size(); ++Operand) {
327 assert(!SubName.
empty() &&
"DW_OP SubOp has no name!");
328 OS <<
" " << SubName;
333 if (Opcode == DW_OP_convert &&
Operands[Operand] == 0)
351 for (
unsigned i = 0; i <
Operands[Operand - 1]; ++i)
356 else if (Opcode != DW_OP_entry_value &&
357 Opcode != DW_OP_GNU_entry_value)
368 if (Data.getData().empty())
371 for (
auto &
Op : *
this) {
372 DumpOpts.
IsEH = IsEH;
375 while (FailOffset < Data.getData().size())
376 OS <<
format(
" %02x", Data.getU8(&FailOffset));
388 if (EntryValExprSize) {
390 if (EntryValExprSize == 0)
400 for (
unsigned Operand = 0; Operand <
Op.Desc.
Op.
size(); ++Operand) {
401 unsigned Size =
Op.Desc.
Op[Operand];
408 if (
Op.Opcode == DW_OP_convert &&
Op.Operands[Operand] == 0)
410 auto Die = U->getDIEForOffset(U->getOffset() +
Op.Operands[Operand]);
411 if (!Die || Die.getTag() != dwarf::DW_TAG_base_type)
420 for (
auto &
Op : *
this)
452 case dwarf::DW_OP_regx: {
456 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
463 case dwarf::DW_OP_bregx: {
466 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
475 case dwarf::DW_OP_entry_value:
476 case dwarf::DW_OP_GNU_entry_value: {
489 case dwarf::DW_OP_stack_value: {
496 case dwarf::DW_OP_nop: {
499 case dwarf::DW_OP_LLVM_user: {
504 if (Opcode >= dwarf::DW_OP_reg0 && Opcode <= dwarf::DW_OP_reg31) {
507 uint64_t DwarfRegNum = Opcode - dwarf::DW_OP_reg0;
508 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
513 }
else if (Opcode >= dwarf::DW_OP_breg0 &&
514 Opcode <= dwarf::DW_OP_breg31) {
515 int DwarfRegNum = Opcode - dwarf::DW_OP_breg0;
517 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
528 << (int)Opcode <<
")>";
536 if (Stack.size() != 1) {
537 OS <<
"<stack of size " << Stack.size() <<
", expected 1>";
542 OS <<
"[" << Stack.front().String <<
"]";
544 OS << Stack.front().String;
556 if (AddressSize !=
RHS.AddressSize || Format !=
RHS.Format)
558 return Data.getData() ==
RHS.Data.getData();
mir Rename Register Operands
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
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.
std::optional< unsigned > getSubCode() const
@ DwarfNA
Serves as a marker for unused entries.
static bool verify(const Operation &Op, DWARFUnit *U)
Verify Op. Does not affect the return of isError().
bool print(raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, DWARFUnit *U) const
uint64_t getEndOffset() const
@ SizeSubOpLEB
The operand is a ULEB128 encoded SubOpcode.
@ SizeBlock
Preceding operand contains block size.
uint64_t getRawOperand(unsigned Idx) const
An iterator to go through the expression operations.
bool verify(DWARFUnit *U)
bool printCompact(raw_ostream &OS, std::function< StringRef(uint64_t RegNum, bool IsEH)> GetNameForDWARFReg=nullptr)
Print the expression in a format intended to be compact and useful to a user, but not perfectly unamb...
bool operator==(const DWARFExpression &RHS) const
void print(raw_ostream &OS, DIDumpOptions DumpOpts, DWARFUnit *U, bool IsEH=false) const
static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS, DIDumpOptions DumpOpts, uint8_t Opcode, const ArrayRef< uint64_t > Operands)
Lightweight error class with error context and mandatory checking.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an SmallVector or SmallString.
StringRef SubOperationEncodingString(unsigned OpEncoding, unsigned SubOpEncoding)
StringRef OperationEncodingString(unsigned Encoding)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
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)
static std::vector< Desc > getOpDescriptions()
static bool printCompactDWARFExpr(raw_ostream &OS, DWARFExpression::iterator I, const DWARFExpression::iterator E, std::function< StringRef(uint64_t RegNum, bool IsEH)> GetNameForDWARFReg=nullptr)
static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS, DIDumpOptions DumpOpts, ArrayRef< uint64_t > Operands, unsigned Operand)
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
static Desc getDescImpl(ArrayRef< Desc > Descriptions, unsigned Opcode)
DWARFExpression::Operation Op
static Desc getOpDesc(unsigned Opcode)
static std::vector< Desc > getSubOpDescriptions()
Container for dump options that control which debug information will be dumped.
std::function< llvm::StringRef(uint64_t DwarfRegNum, bool IsEH)> GetNameForDWARFReg
Description of the encoding of one expression Op.
DwarfVersion Version
Dwarf version where the Op was introduced.
SmallVector< Encoding > Op
Encoding for Op operands.
A user-facing string representation of a DWARF expression.
PrintedExpr(ExprKind K=Address)