[LoongArch][Clang] Make the parameters and return value of {x,}vorn.v builti ns ...
[llvm-project.git] / lldb / source / Plugins / SymbolFile / NativePDB / PdbSymUid.h
blob3accd38d710e1c257a5a4dd8e9530ae06ce58e5d
1 //===-- PdbSymUid.h ---------------------------------------------*- 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 // A unique identification scheme for Pdb records.
9 // The scheme is to partition a 64-bit integer into an 8-bit tag field, which
10 // will contain some value from the PDB_SymType enumeration. The format of the
11 // other 48-bits depend on the tag, but must be sufficient to locate the
12 // corresponding entry in the underlying PDB file quickly. For example, for
13 // a compile unit, we use 2 bytes to represent the index, which allows fast
14 // access to the compile unit's information.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBSYMUID_H
18 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBSYMUID_H
20 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
21 #include "llvm/DebugInfo/PDB/PDBTypes.h"
22 #include "llvm/Support/Compiler.h"
24 #include "lldb/Utility/LLDBAssert.h"
25 #include "lldb/lldb-types.h"
27 namespace lldb_private {
28 namespace npdb {
30 enum class PdbSymUidKind : uint8_t {
31 Compiland,
32 CompilandSym,
33 PublicSym,
34 GlobalSym,
35 Type,
36 FieldListMember
39 struct PdbCompilandId {
40 // 0-based index of module in PDB
41 uint16_t modi;
44 struct PdbCompilandSymId {
45 PdbCompilandSymId() = default;
46 PdbCompilandSymId(uint16_t modi, uint32_t offset)
47 : modi(modi), offset(offset) {}
48 // 0-based index of module in PDB
49 uint16_t modi = 0;
51 // Offset of symbol's record in module stream. This is
52 // offset by 4 from the CVSymbolArray's notion of offset
53 // due to the debug magic at the beginning of the stream.
54 uint32_t offset = 0;
57 struct PdbGlobalSymId {
58 PdbGlobalSymId() = default;
59 PdbGlobalSymId(uint32_t offset, bool is_public)
60 : offset(offset), is_public(is_public) {}
62 // Offset of symbol's record in globals or publics stream.
63 uint32_t offset = 0;
65 // True if this symbol is in the public stream, false if it's in the globals
66 // stream.
67 bool is_public = false;
70 struct PdbTypeSymId {
71 PdbTypeSymId() = default;
72 PdbTypeSymId(llvm::codeview::TypeIndex index, bool is_ipi = false)
73 : index(index), is_ipi(is_ipi) {}
75 // The index of the of the type in the TPI or IPI stream.
76 llvm::codeview::TypeIndex index;
78 // True if this symbol comes from the IPI stream, false if it's from the TPI
79 // stream.
80 bool is_ipi = false;
83 struct PdbFieldListMemberId {
84 // The TypeIndex of the LF_FIELDLIST record.
85 llvm::codeview::TypeIndex index;
87 // The offset from the beginning of the LF_FIELDLIST record to this record.
88 uint16_t offset = 0;
91 class PdbSymUid {
92 uint64_t m_repr = 0;
94 public:
95 PdbSymUid() = default;
96 PdbSymUid(uint64_t repr) : m_repr(repr) {}
97 PdbSymUid(const PdbCompilandId &cid);
98 PdbSymUid(const PdbCompilandSymId &csid);
99 PdbSymUid(const PdbGlobalSymId &gsid);
100 PdbSymUid(const PdbTypeSymId &tsid);
101 PdbSymUid(const PdbFieldListMemberId &flmid);
103 uint64_t toOpaqueId() const { return m_repr; }
105 PdbSymUidKind kind() const;
107 PdbCompilandId asCompiland() const;
108 PdbCompilandSymId asCompilandSym() const;
109 PdbGlobalSymId asGlobalSym() const;
110 PdbTypeSymId asTypeSym() const;
111 PdbFieldListMemberId asFieldListMember() const;
114 template <typename T> uint64_t toOpaqueUid(const T &cid) {
115 return PdbSymUid(cid).toOpaqueId();
118 struct SymbolAndUid {
119 llvm::codeview::CVSymbol sym;
120 PdbSymUid uid;
122 } // namespace npdb
123 } // namespace lldb_private
125 #endif