llvm/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h

//===- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework --------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file contains support for writing dwarf debug info into asm files.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H

#include "AddressPool.h"
#include "DebugLocEntry.h"
#include "DebugLocStream.h"
#include "DwarfFile.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/CodeGen/AccelTable.h"
#include "llvm/CodeGen/DbgEntityHistoryCalculator.h"
#include "llvm/CodeGen/DebugHandlerBase.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/Metadata.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Target/TargetOptions.h"
#include <cassert>
#include <cstdint>
#include <limits>
#include <memory>
#include <utility>
#include <variant>
#include <vector>

namespace llvm {

class AsmPrinter;
class ByteStreamer;
class DIE;
class DwarfCompileUnit;
class DwarfExpression;
class DwarfTypeUnit;
class DwarfUnit;
class LexicalScope;
class MachineFunction;
class MCSection;
class MCSymbol;
class Module;

//===----------------------------------------------------------------------===//
/// This class is defined as the common parent of DbgVariable and DbgLabel
/// such that it could levarage polymorphism to extract common code for
/// DbgVariable and DbgLabel.
class DbgEntity {};

class DbgVariable;

bool operator<(const struct FrameIndexExpr &LHS,
               const struct FrameIndexExpr &RHS);
bool operator<(const struct EntryValueInfo &LHS,
               const struct EntryValueInfo &RHS);

/// Proxy for one MMI entry.
struct FrameIndexExpr {};

/// Represents an entry-value location, or a fragment of one.
struct EntryValueInfo {};

// Namespace for alternatives of a DbgVariable.
namespace Loc {
/// Single value location description.
class Single {};
/// Multi-value location description.
class Multi {};
/// Single location defined by (potentially multiple) MMI entries.
struct MMI {};
/// Single location defined by (potentially multiple) EntryValueInfo.
struct EntryValue {};
/// Alias for the std::variant specialization base class of DbgVariable.
Variant;
} // namespace Loc

//===----------------------------------------------------------------------===//
/// This class is used to track local variable information.
///
/// Variables that have been optimized out hold the \c monostate alternative.
/// This is not distinguished from the case of a constructed \c DbgVariable
/// which has not be initialized yet.
///
/// Variables can be created from allocas, in which case they're generated from
/// the MMI table. Such variables hold the \c Loc::MMI alternative which can
/// have multiple expressions and frame indices.
///
/// Variables can be created from the entry value of registers, in which case
/// they're generated from the MMI table. Such variables hold the \c
/// EntryValueLoc alternative which can either have a single expression or
/// multiple *fragment* expressions.
///
/// Variables can be created from \c DBG_VALUE instructions. Those whose
/// location changes over time hold a \c Loc::Multi alternative which uses \c
/// DebugLocListIndex and (optionally) \c DebugLocListTagOffset, while those
/// with a single location hold a \c Loc::Single alternative which use \c
/// ValueLoc and (optionally) a single \c Expr.
class DbgVariable : public DbgEntity, public Loc::Variant {};

//===----------------------------------------------------------------------===//
/// This class is used to track label information.
///
/// Labels are collected from \c DBG_LABEL instructions.
class DbgLabel : public DbgEntity {};

/// Used for tracking debug info about call site parameters.
class DbgCallSiteParam {};

/// Collection used for storing debug call site parameters.
ParamSet;

/// Helper used to pair up a symbol and its DWARF compile unit.
struct SymbolCU {};

/// The kind of accelerator tables we should emit.
enum class AccelTableKind {};

/// Collects and handles dwarf debug information.
class DwarfDebug : public DebugHandlerBase {};

} // end namespace llvm

#endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H