File: VISADebugInfo.hpp

package info (click to toggle)
intel-graphics-compiler 1.0.12504.6-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 83,912 kB
  • sloc: cpp: 910,147; lisp: 202,655; ansic: 15,197; python: 4,025; yacc: 2,241; lex: 1,570; pascal: 244; sh: 104; makefile: 25
file content (116 lines) | stat: -rw-r--r-- 3,453 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*========================== begin_copyright_notice ============================

Copyright (C) 2022 Intel Corporation

SPDX-License-Identifier: MIT

============================= end_copyright_notice ===========================*/

#pragma once

// clang-format off
#include "common/LLVMWarningsPush.hpp"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/DenseMap.h"
#include "common/LLVMWarningsPop.hpp"
// clang-format on

#include "VISADebugDecoder.hpp"

#include <unordered_map>
#include <vector>
#include <map>

namespace IGC {

class VISAModule;

struct IDX_Gen2Visa {
  unsigned GenOffset;
  unsigned VisaOffset;
};

// provides access to debug information for the compiled VISA object
// that supports user-friendly queries and provides several LUT
// for GEN<->VISA mappings.
class VISAObjectDebugInfo {

public:
  using CompiledObjectInfo = IGC::DbgDecoder::DbgInfoFormat;
  using CallFrameInfo = IGC::DbgDecoder::CallFrameInfo;
  using SubroutinesList = decltype(CompiledObjectInfo::subs);
  using RelocOffsetTy = decltype(CompiledObjectInfo::relocOffset);
  using CisaIndexLUT = decltype(CompiledObjectInfo::CISAIndexMap);
  using VISAVariablesList = decltype(CompiledObjectInfo::Vars);

  using GenIsaToSizeMapping = llvm::DenseMap<unsigned, unsigned>;
  using VisaToGenMapping = std::map<unsigned, std::vector<unsigned>>;
  using GenToVisaIndexes = std::vector<IDX_Gen2Visa>;

private:
  const CompiledObjectInfo &CO;

  GenIsaToSizeMapping GenISAInstSizeBytes;
  VisaToGenMapping VISAIndexToAllGenISAOff;
  GenToVisaIndexes GenISAToVISAIndex;

public:
  VISAObjectDebugInfo(const CompiledObjectInfo &COIn);

  const CompiledObjectInfo &getCompiledObject() const { return CO; }

  const CallFrameInfo &getCFI() const { return CO.cfi; }

  RelocOffsetTy getRelocOffset() const { return CO.relocOffset; }

  const SubroutinesList &getSubroutines() const { return CO.subs; }
  const VISAVariablesList &getVISAVariables() const { return CO.Vars; }

  const CisaIndexLUT &getCISAIndexLUT() const { return CO.CISAIndexMap; }

  const VisaToGenMapping &getVisaToGenLUT() const {
    return VISAIndexToAllGenISAOff;
  }

  const GenIsaToSizeMapping &getGenToSizeInBytesLUT() const {
    return GenISAInstSizeBytes;
  }

  const GenToVisaIndexes &getGenToVisaIndexLUT() const {
    return GenISAToVISAIndex;
  }

  void dump() const;
  void print(llvm::raw_ostream &OS) const;
};

// This class is essentially a wrapper over IGC::DbgDecoder object
class VISADebugInfo {
  const IGC::DbgDecoder DecodedDebugStorage;

  using CompiledObjectDI = IGC::DbgDecoder::DbgInfoFormat;
  using DebugInfoHolders =
      std::unordered_map<const CompiledObjectDI *, VISAObjectDebugInfo>;
  DebugInfoHolders DebugInfoMap;

public:
  // VISADebugInfo(const IGC::DbgDecoder &DecodedDebugStorageIn);
  VISADebugInfo(const void *RawDbgDataPtr);

  // get's the underlying IGC::DbgDecoder object
  // TODO: remove, for now we need it for backwards compatibility.
  const IGC::DbgDecoder &getRawDecodedData() const {
    return DecodedDebugStorage;
  }

  // gets Visa Object Debug Info that corresponds to a particular named
  // entity - that is a kernel/stack-called function or a subroutine
  const VISAObjectDebugInfo &getVisaObjectDI(const VISAModule &VM) const;
  const VISAObjectDebugInfo &
  getVisaObjectByCompliledObjectName(llvm::StringRef CompiledObjectName) const;

  void dump() const;
  void print(llvm::raw_ostream &OS) const;
};

} // namespace IGC