LLVM 24.0.0git
DWARFExpressionUnit.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
13#include <cassert>
14
15using namespace llvm;
16
18 DIDumpOptions DumpOpts,
20 unsigned Operand) {
21 assert(Operand < Operands.size() && "operand out of bounds");
22 auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]);
23 if (Die && Die.getTag() == dwarf::DW_TAG_base_type) {
24 OS << " (";
25 if (DumpOpts.Verbose)
26 OS << formatv("{0:x8} -> ", Operands[Operand]);
27 OS << formatv("{0:x8})", U->getOffset() + Operands[Operand]);
28 if (auto Name = dwarf::toString(Die.find(dwarf::DW_AT_name)))
29 OS << " \"" << *Name << "\"";
30 } else {
31 OS << formatv(" <invalid base_type ref: {0:x}>", Operands[Operand]);
32 }
33}
34
36 DIDumpOptions DumpOpts, DWARFUnit *U,
37 bool IsEH) {
38 auto PrintBaseTypeRef = [U](raw_ostream &OS, DIDumpOptions DumpOpts,
39 ArrayRef<uint64_t> Operands, unsigned Operand) {
40 prettyPrintBaseTypeRef(U, OS, DumpOpts, Operands, Operand);
41 };
43 E, OS, DumpOpts,
44 U ? detail::BaseTypeRefPrinter(PrintBaseTypeRef) : nullptr, IsEH);
45}
46
48 DIDumpOptions DumpOpts, uint8_t Opcode,
50 auto PrintBaseTypeRef = [U](raw_ostream &OS, DIDumpOptions DumpOpts,
51 ArrayRef<uint64_t> Operands, unsigned Operand) {
52 prettyPrintBaseTypeRef(U, OS, DumpOpts, Operands, Operand);
53 };
55 U ? detail::BaseTypeRefPrinter(PrintBaseTypeRef) : nullptr, OS, DumpOpts,
56 Opcode, Operands);
57}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void prettyPrintBaseTypeRef(DWARFUnit *U, raw_ostream &OS, DIDumpOptions DumpOpts, ArrayRef< uint64_t > Operands, unsigned Operand)
SI Fold Operands
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
bool prettyPrintRegisterOp(BaseTypeRefPrinter PrintBaseTypeRef, raw_ostream &OS, DIDumpOptions DumpOpts, uint8_t Opcode, ArrayRef< uint64_t > Operands)
function_ref< void(raw_ostream &OS, DIDumpOptions DumpOpts, ArrayRef< uint64_t > Operands, unsigned Operand)> BaseTypeRefPrinter
Prints the base type DIE that operand Operand of Operands refers to.
void printDwarfExpression(const DWARFExpression *E, raw_ostream &OS, DIDumpOptions DumpOpts, BaseTypeRefPrinter PrintBaseTypeRef, bool IsEH)
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.
LLVM_ABI void printDwarfExpression(const DWARFExpression *E, raw_ostream &OS, DIDumpOptions DumpOpts, bool IsEH=false)
Print a Dwarf expression.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
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.
Container for dump options that control which debug information will be dumped.
Definition DIContext.h:197