1//===-- NVPTXDwarfDebug.h - NVPTX DwarfDebug Implementation ---*- C++ -*-===//
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//
9// This file declares the NVPTXDwarfDebug class, the NVPTX-specific subclass
10// of DwarfDebug. It customizes DWARF emission for PTX: address space
11// attributes, compile-unit range suppression, base address handling, and
12// enhanced line information with inlined_at directives.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXDWARFDEBUG_H
17#define LLVM_LIB_TARGET_NVPTX_NVPTXDWARFDEBUG_H
18
19#include "../../CodeGen/AsmPrinter/DwarfCompileUnit.h"
20#include "llvm/ADT/DenseSet.h"
21
22namespace llvm {
23
24/// NVPTX-specific DwarfDebug implementation.
25///
26/// Customizes DWARF emission for PTX targets: DWARF v2 defaults, address
27/// space attributes (DW_AT_address_class) for cuda-gdb, compile-unit range
28/// suppression, range-list base address handling, and enhanced line
29/// information with inlined_at directives.
30class NVPTXDwarfDebug : public DwarfDebug {
31private:
32 /// Set of inlined_at locations that have already been emitted.
33 /// Used to avoid redundant emission of parent chain .loc directives.
34 DenseSet<const DILocation *> EmittedInlinedAtLocs;
35
36public:
37 NVPTXDwarfDebug(AsmPrinter *A);
38
39 bool shouldResetBaseAddress(const MCSection &Section) const override;
40 const DIExpression *adjustExpressionForTarget(
41 const DIExpression *Expr,
42 std::optional<unsigned> &TargetAddrSpace) const override;
43 void addTargetVariableAttributes(
44 DwarfCompileUnit &CU, DIE &Die, std::optional<unsigned> TargetAddrSpace,
45 VariableLocationKind VarLocKind,
46 const GlobalVariable *GV = nullptr) const override;
47
48protected:
49 void initializeTargetDebugInfo(const MachineFunction &MF) override;
50 void recordTargetSourceLine(const DebugLoc &DL, unsigned Flags) override;
51 bool shouldAttachCompileUnitRanges() const override;
52};
53
54} // end namespace llvm
55
56#endif // LLVM_LIB_TARGET_NVPTX_NVPTXDWARFDEBUG_H
57