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] =
97 Descriptions[DW_OP_regval_type] =
99 Descriptions[DW_OP_WASM_location] =
114 if (Opcode >= Descriptions.
size())
116 return Descriptions[Opcode];
125 static constexpr unsigned LlvmUserDescriptionsSize = 1
126#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) +1
127#include "llvm/BinaryFormat/Dwarf.def"
129 std::vector<Desc> Descriptions;
130 Descriptions.resize(LlvmUserDescriptionsSize);
136 assert(Opcode == DW_OP_LLVM_user);
143 std::optional<DwarfFormat>
Format) {
145 Opcode = Data.getU8(&
Offset);
153 for (
unsigned Operand = 0; Operand <
Desc.
Op.
size(); ++Operand) {
159 assert(Operand == 0 &&
"SubOp operand must be the first operand");
160 Operands[Operand] = Data.getULEB128(&
Offset);
165 "SizeSubOpLEB Description must begin with SizeSubOpLEB operand");
168 Operands[Operand] = Data.getU8(&
Offset);
170 Operands[Operand] = (int8_t)Operands[Operand];
173 Operands[Operand] = Data.getU16(&
Offset);
175 Operands[Operand] = (int16_t)Operands[Operand];
178 Operands[Operand] = Data.getU32(&
Offset);
180 Operands[Operand] = (int32_t)Operands[Operand];
183 Operands[Operand] = Data.getU64(&
Offset);
186 Operands[Operand] = Data.getUnsigned(&
Offset, AddressSize);
196 Operands[Operand] = Data.getSLEB128(&
Offset);
198 Operands[Operand] = Data.getULEB128(&
Offset);
201 Operands[Operand] = Data.getULEB128(&
Offset);
205 switch (Operands[0]) {
210 Operands[Operand] = Data.getULEB128(&
Offset);
213 Operands[Operand] = Data.getU32(&
Offset);
224 Operands[Operand] =
Offset;
225 Offset += Operands[Operand - 1];
231 OperandEndOffsets[Operand] =
Offset;
247 auto Die = U->getDIEForOffset(U->getOffset() +
Operands[Operand]);
248 if (Die && Die.getTag() == dwarf::DW_TAG_base_type) {
254 OS <<
" \"" << *
Name <<
"\"";
270 if (Opcode == DW_OP_bregx || Opcode == DW_OP_regx ||
271 Opcode == DW_OP_regval_type)
273 else if (Opcode >= DW_OP_breg0 && Opcode < DW_OP_bregx)
274 DwarfRegNum = Opcode - DW_OP_breg0;
276 DwarfRegNum = Opcode - DW_OP_reg0;
280 if ((Opcode >= DW_OP_breg0 && Opcode <= DW_OP_breg31) ||
281 Opcode == DW_OP_bregx)
286 if (Opcode == DW_OP_regval_type)
304 OS <<
"<decoding error>";
309 assert(!
Name.empty() &&
"DW_OP has no name!");
312 if ((Opcode >= DW_OP_breg0 && Opcode <= DW_OP_breg31) ||
313 (Opcode >= DW_OP_reg0 && Opcode <= DW_OP_reg31) ||
314 Opcode == DW_OP_bregx || Opcode == DW_OP_regx ||
315 Opcode == DW_OP_regval_type)
319 for (
unsigned Operand = 0; Operand <
Desc.
Op.
size(); ++Operand) {
325 assert(!SubName.
empty() &&
"DW_OP SubOp has no name!");
326 OS <<
" " << SubName;
331 if (Opcode == DW_OP_convert &&
Operands[Operand] == 0)
349 for (
unsigned i = 0; i <
Operands[Operand - 1]; ++i)
354 else if (Opcode != DW_OP_entry_value &&
355 Opcode != DW_OP_GNU_entry_value)
366 if (Data.getData().empty())
369 for (
auto &
Op : *
this) {
370 DumpOpts.
IsEH = IsEH;
373 while (FailOffset < Data.getData().size())
374 OS <<
format(
" %02x", Data.getU8(&FailOffset));
386 if (EntryValExprSize) {
388 if (EntryValExprSize == 0)
398 for (
unsigned Operand = 0; Operand <
Op.Desc.
Op.
size(); ++Operand) {
399 unsigned Size =
Op.Desc.
Op[Operand];
406 if (
Op.Opcode == DW_OP_convert &&
Op.Operands[Operand] == 0)
408 auto Die = U->getDIEForOffset(U->getOffset() +
Op.Operands[Operand]);
409 if (!Die || Die.getTag() != dwarf::DW_TAG_base_type)
418 for (
auto &
Op : *
this)
450 case dwarf::DW_OP_regx: {
454 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
461 case dwarf::DW_OP_bregx: {
464 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
473 case dwarf::DW_OP_entry_value:
474 case dwarf::DW_OP_GNU_entry_value: {
487 case dwarf::DW_OP_stack_value: {
494 case dwarf::DW_OP_nop: {
497 case dwarf::DW_OP_LLVM_user: {
502 if (Opcode >= dwarf::DW_OP_reg0 && Opcode <= dwarf::DW_OP_reg31) {
505 uint64_t DwarfRegNum = Opcode - dwarf::DW_OP_reg0;
506 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
511 }
else if (Opcode >= dwarf::DW_OP_breg0 &&
512 Opcode <= dwarf::DW_OP_breg31) {
513 int DwarfRegNum = Opcode - dwarf::DW_OP_breg0;
515 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
526 << (int)Opcode <<
")>";
534 if (Stack.size() != 1) {
535 OS <<
"<stack of size " << Stack.size() <<
", expected 1>";
540 OS <<
"[" << Stack.front().String <<
"]";
542 OS << Stack.front().String;
554 if (AddressSize !=
RHS.AddressSize || Format !=
RHS.Format)
556 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)