31 OS <<
format(
" <base_type ref: 0x%" PRIx64
">",
Operands[Operand]);
34 auto Die = U->getDIEForOffset(U->getOffset() +
Operands[Operand]);
35 if (Die && Die.getTag() == dwarf::DW_TAG_base_type) {
39 OS <<
format(
"0x%08" PRIx64
")", U->getOffset() +
Operands[Operand]);
41 OS <<
" \"" << *Name <<
"\"";
43 OS <<
format(
" <invalid base_type ref: 0x%" PRIx64
">",
Operands[Operand]);
52 OS <<
"<decoding error>";
56 std::optional<unsigned> SubOpcode =
Op->getSubCode();
65 if ((
Op->getCode() >= DW_OP_breg0 &&
Op->getCode() <= DW_OP_breg31) ||
66 (
Op->getCode() >= DW_OP_reg0 &&
Op->getCode() <= DW_OP_reg31) ||
67 Op->getCode() == DW_OP_bregx ||
Op->getCode() == DW_OP_regx ||
68 Op->getCode() == DW_OP_regval_type ||
69 SubOpcode == DW_OP_LLVM_call_frame_entry_reg ||
70 SubOpcode == DW_OP_LLVM_aspace_bregx) {
72 Op->getRawOperands()))
78 if (
Op->getCode() == DW_OP_constu) {
82 if (
Op->getCode() == DW_OP_consts) {
83 OS << (int64_t)
Op->getRawOperand(0);
86 if (
Op->getCode() >= DW_OP_lit0 &&
Op->getCode() <= DW_OP_lit31) {
90 if (
Op->getCode() == DW_OP_stack_value)
98 assert(!Name.empty() &&
"DW_OP has no name!");
103 assert(!SubName.
empty() &&
"DW_OP SubOp has no name!");
104 OS <<
' ' << SubName;
108 if ((
Op->getCode() >= DW_OP_breg0 &&
Op->getCode() <= DW_OP_breg31) ||
109 (
Op->getCode() >= DW_OP_reg0 &&
Op->getCode() <= DW_OP_reg31) ||
110 Op->getCode() == DW_OP_bregx ||
Op->getCode() == DW_OP_regx ||
111 Op->getCode() == DW_OP_regval_type ||
112 SubOpcode == DW_OP_LLVM_call_frame_entry_reg ||
113 SubOpcode == DW_OP_LLVM_aspace_bregx)
115 Op->getRawOperands()))
119 for (
unsigned Operand = 0; Operand <
Op->getDescription().
Op.size();
121 unsigned Size =
Op->getDescription().Op[Operand];
125 assert(Operand == 0 &&
"DW_OP SubOp must be the first operand");
126 assert(SubOpcode &&
"DW_OP SubOp description is inconsistent");
131 if (
Op->getCode() == DW_OP_convert &&
Op->getRawOperand(Operand) == 0)
138 switch (
Op->getRawOperand(0)) {
144 OS <<
format(
" 0x%" PRIx64,
Op->getRawOperand(Operand));
151 for (
unsigned i = 0; i <
Op->getRawOperand(Operand - 1); ++i)
156 OS <<
format(
" %+" PRId64, (int64_t)
Op->getRawOperand(Operand));
157 else if (
Op->getCode() != DW_OP_entry_value &&
158 Op->getCode() != DW_OP_GNU_entry_value)
159 OS <<
format(
" 0x%" PRIx64,
Op->getRawOperand(Operand));
170 if (E->getData().empty())
173 for (
auto &
Op : *E) {
174 DumpOpts.
IsEH = IsEH;
177 while (FailOffset < E->getData().
size())
178 OS <<
format(
" %02x",
static_cast<uint8_t>(E->getData()[FailOffset++]));
182 if (
Op.getCode() == DW_OP_entry_value ||
183 Op.getCode() == DW_OP_GNU_entry_value) {
185 EntryValExprSize =
Op.getRawOperand(0);
186 EntryValStartOffset =
Op.getEndOffset();
190 if (EntryValExprSize) {
191 EntryValExprSize -=
Op.getEndOffset() - EntryValStartOffset;
192 if (EntryValExprSize == 0)
196 if (
Op.getEndOffset() < E->getData().size())
224 std::optional<unsigned> SubOpcode) ->
bool {
231 <<
" (" << *SubOpcode;
240 case dwarf::DW_OP_regx: {
244 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
251 case dwarf::DW_OP_bregx: {
252 int DwarfRegNum =
Op.getRawOperand(0);
253 int64_t
Offset =
Op.getRawOperand(1);
254 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
263 case dwarf::DW_OP_entry_value:
264 case dwarf::DW_OP_GNU_entry_value: {
277 case dwarf::DW_OP_stack_value: {
284 case dwarf::DW_OP_nop: {
287 case dwarf::DW_OP_LLVM_user: {
288 std::optional<unsigned> SubOpcode =
Op.getSubCode();
289 if (SubOpcode == dwarf::DW_OP_LLVM_nop)
291 return UnknownOpcode(OS, Opcode, SubOpcode);
294 if (Opcode >= dwarf::DW_OP_reg0 && Opcode <= dwarf::DW_OP_reg31) {
297 uint64_t DwarfRegNum = Opcode - dwarf::DW_OP_reg0;
298 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
303 }
else if (Opcode >= dwarf::DW_OP_breg0 &&
304 Opcode <= dwarf::DW_OP_breg31) {
305 int DwarfRegNum = Opcode - dwarf::DW_OP_breg0;
306 int64_t
Offset =
Op.getRawOperand(0);
307 auto RegName = GetNameForDWARFReg(DwarfRegNum,
false);
315 return UnknownOpcode(OS, Opcode, std::nullopt);
322 if (Stack.size() != 1) {
323 OS <<
"<stack of size " << Stack.size() <<
", expected 1>";
328 OS <<
"[" << Stack.front().String <<
"]";
330 OS << Stack.front().String;
350 std::optional<unsigned> SubOpcode;
351 if (Opcode == DW_OP_LLVM_user)
354 if (Opcode == DW_OP_bregx || Opcode == DW_OP_regx ||
355 Opcode == DW_OP_regval_type || SubOpcode == DW_OP_LLVM_aspace_bregx ||
356 SubOpcode == DW_OP_LLVM_call_frame_entry_reg)
358 else if (Opcode >= DW_OP_breg0 && Opcode < DW_OP_bregx)
359 DwarfRegNum = Opcode - DW_OP_breg0;
361 DwarfRegNum = Opcode - DW_OP_reg0;
365 if ((Opcode >= DW_OP_breg0 && Opcode <= DW_OP_breg31) ||
366 Opcode == DW_OP_bregx || SubOpcode == DW_OP_LLVM_aspace_bregx)
371 if (Opcode == DW_OP_regval_type)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
mir Rename Register Operands
This file defines the SmallString class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class represents an Operation in the Expression.
@ SizeSubOpLEB
The operand is a ULEB128 encoded SubOpcode.
@ SizeBlock
Preceding operand contains block size.
An iterator to go through the expression operations.
StringRef getData() const
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.
LLVM_ABI StringRef SubOperationEncodingString(unsigned OpEncoding, unsigned SubOpEncoding)
LLVM_ABI StringRef OperationEncodingString(unsigned Encoding)
Calculates the starting offsets for various sections within the .debug_names section.
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
static bool printOp(const DWARFExpression::Operation *Op, raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, DWARFUnit *U)
LLVM_ABI void printDwarfExpression(const DWARFExpression *E, raw_ostream &OS, DIDumpOptions DumpOpts, DWARFUnit *U, bool IsEH=false)
Print a Dwarf expression/.
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.
DWARFExpression::Operation Op
LLVM_ABI bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS, DIDumpOptions DumpOpts, uint8_t Opcode, ArrayRef< uint64_t > Operands)
Pretty print a register opcode and operands.
LLVM_ABI bool printDwarfExpressionCompact(const DWARFExpression *E, 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...
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.
PrintedExpr(ExprKind K=Address)