LLVM  14.0.0git
NativeTypePointer.cpp
Go to the documentation of this file.
1 //===- NativeTypePointer.cpp - info about pointer type ----------*- 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 
10 
12 
13 #include <cassert>
14 
15 using namespace llvm;
16 using namespace llvm::codeview;
17 using namespace llvm::pdb;
18 
19 NativeTypePointer::NativeTypePointer(NativeSession &Session, SymIndexId Id,
21  : NativeRawSymbol(Session, PDB_SymType::PointerType, Id), TI(TI) {
22  assert(TI.isSimple());
23  assert(TI.getSimpleMode() != SimpleTypeMode::Direct);
24 }
25 
29  : NativeRawSymbol(Session, PDB_SymType::PointerType, Id), TI(TI),
30  Record(std::move(Record)) {}
31 
33 
34 void NativeTypePointer::dump(raw_ostream &OS, int Indent,
35  PdbSymbolIdField ShowIdFields,
36  PdbSymbolIdField RecurseIdFields) const {
37  NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
38 
39  if (isMemberPointer()) {
40  dumpSymbolIdField(OS, "classParentId", getClassParentId(), Indent, Session,
41  PdbSymbolIdField::ClassParent, ShowIdFields,
42  RecurseIdFields);
43  }
44  dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
45  PdbSymbolIdField::LexicalParent, ShowIdFields,
46  RecurseIdFields);
47  dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session,
48  PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
49  dumpSymbolField(OS, "length", getLength(), Indent);
50  dumpSymbolField(OS, "constType", isConstType(), Indent);
51  dumpSymbolField(OS, "isPointerToDataMember", isPointerToDataMember(), Indent);
52  dumpSymbolField(OS, "isPointerToMemberFunction", isPointerToMemberFunction(),
53  Indent);
54  dumpSymbolField(OS, "RValueReference", isRValueReference(), Indent);
55  dumpSymbolField(OS, "reference", isReference(), Indent);
56  dumpSymbolField(OS, "restrictedType", isRestrictedType(), Indent);
57  if (isMemberPointer()) {
58  if (isSingleInheritance())
59  dumpSymbolField(OS, "isSingleInheritance", 1, Indent);
60  else if (isMultipleInheritance())
61  dumpSymbolField(OS, "isMultipleInheritance", 1, Indent);
62  else if (isVirtualInheritance())
63  dumpSymbolField(OS, "isVirtualInheritance", 1, Indent);
64  }
65  dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
66  dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
67 }
68 
70  if (!isMemberPointer())
71  return 0;
72 
73  assert(Record);
74  const MemberPointerInfo &MPI = Record->getMemberInfo();
76 }
77 
79  if (Record)
80  return Record->getSize();
81 
82  switch (TI.getSimpleMode()) {
83  case SimpleTypeMode::NearPointer:
84  case SimpleTypeMode::FarPointer:
85  case SimpleTypeMode::HugePointer:
86  return 2;
87  case SimpleTypeMode::NearPointer32:
88  case SimpleTypeMode::FarPointer32:
89  return 4;
90  case SimpleTypeMode::NearPointer64:
91  return 8;
92  case SimpleTypeMode::NearPointer128:
93  return 16;
94  default:
95  assert(false && "invalid simple type mode!");
96  }
97  return 0;
98 }
99 
101  // This is the pointee SymIndexId.
102  TypeIndex Referent = Record ? Record->ReferentType : TI.makeDirect();
103 
104  return Session.getSymbolCache().findSymbolByTypeIndex(Referent);
105 }
106 
108  if (!Record)
109  return false;
110  return Record->getMode() == PointerMode::LValueReference;
111 }
112 
114  if (!Record)
115  return false;
116  return Record->getMode() == PointerMode::RValueReference;
117 }
118 
120  if (!Record)
121  return false;
122  return Record->getMode() == PointerMode::PointerToDataMember;
123 }
124 
126  if (!Record)
127  return false;
128  return Record->getMode() == PointerMode::PointerToMemberFunction;
129 }
130 
132  if (!Record)
133  return false;
134  return (Record->getOptions() & PointerOptions::Const) != PointerOptions::None;
135 }
136 
138  if (!Record)
139  return false;
140  return (Record->getOptions() & PointerOptions::Restrict) !=
142 }
143 
145  if (!Record)
146  return false;
147  return (Record->getOptions() & PointerOptions::Volatile) !=
149 }
150 
152  if (!Record)
153  return false;
154  return (Record->getOptions() & PointerOptions::Unaligned) !=
156 }
157 
158 static inline bool isInheritanceKind(const MemberPointerInfo &MPI,
161  return (MPI.getRepresentation() == P1 || MPI.getRepresentation() == P2);
162 }
163 
165  if (!isMemberPointer())
166  return false;
167  return isInheritanceKind(
168  Record->getMemberInfo(),
169  PointerToMemberRepresentation::SingleInheritanceData,
170  PointerToMemberRepresentation::SingleInheritanceFunction);
171 }
172 
174  if (!isMemberPointer())
175  return false;
176  return isInheritanceKind(
177  Record->getMemberInfo(),
178  PointerToMemberRepresentation::MultipleInheritanceData,
179  PointerToMemberRepresentation::MultipleInheritanceFunction);
180 }
181 
183  if (!isMemberPointer())
184  return false;
185  return isInheritanceKind(
186  Record->getMemberInfo(),
187  PointerToMemberRepresentation::VirtualInheritanceData,
188  PointerToMemberRepresentation::VirtualInheritanceFunction);
189 }
190 
193 }
llvm::pdb::NativeTypePointer::dump
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
Definition: NativeTypePointer.cpp:34
llvm::pdb::NativeTypePointer::isRestrictedType
bool isRestrictedType() const override
Definition: NativeTypePointer.cpp:137
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::pdb::NativeTypePointer::isReference
bool isReference() const override
Definition: NativeTypePointer.cpp:107
llvm::pdb::NativeTypePointer::isPointerToMemberFunction
bool isPointerToMemberFunction() const override
Definition: NativeTypePointer.cpp:125
llvm::pdb::PdbSymbolIdField::Type
@ Type
llvm::pdb::NativeTypePointer::NativeTypePointer
NativeTypePointer(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI)
Definition: NativeTypePointer.cpp:19
llvm::codeview::PointerRecord
Definition: TypeRecord.h:263
llvm::pdb::PDB_SymType
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:243
llvm::pdb::PdbSymbolIdField::ClassParent
@ ClassParent
llvm::pdb::NativeTypePointer::TI
codeview::TypeIndex TI
Definition: NativeTypePointer.h:53
llvm::pdb::NativeTypePointer::isPointerToDataMember
bool isPointerToDataMember() const override
Definition: NativeTypePointer.cpp:119
llvm::pdb::NativeTypePointer::isRValueReference
bool isRValueReference() const override
Definition: NativeTypePointer.cpp:113
NativeTypePointer.h
llvm::pdb::NativeTypePointer::getTypeId
SymIndexId getTypeId() const override
Definition: NativeTypePointer.cpp:100
llvm::codeview::TypeIndex::makeDirect
TypeIndex makeDirect() const
Definition: TypeIndex.h:146
llvm::pdb::NativeTypePointer::getClassParentId
SymIndexId getClassParentId() const override
Definition: NativeTypePointer.cpp:69
P2
This might compile to this xmm1 xorps xmm0 movss xmm0 ret Now consider if the code caused xmm1 to get spilled This might produce this xmm1 movaps xmm0 movaps xmm1 movss xmm0 ret since the reload is only used by these we could fold it into the producing something like xmm1 movaps xmm0 ret saving two instructions The basic idea is that a reload from a spill if only one byte chunk is bring in zeros the one element instead of elements This can be used to simplify a variety of shuffle where the elements are fixed zeros This code generates ugly probably due to costs being off or< 4 x float > * P2
Definition: README-SSE.txt:278
llvm::pdb::PdbSymbolIdField::LexicalParent
@ LexicalParent
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::pdb::NativeTypePointer::isMultipleInheritance
bool isMultipleInheritance() const override
Definition: NativeTypePointer.cpp:173
llvm::None
const NoneType None
Definition: None.h:23
llvm::codeview::MemberPointerInfo::ContainingType
TypeIndex ContainingType
Definition: TypeRecord.h:113
llvm::pdb
Definition: ConcreteSymbolEnumerator.h:20
uint64_t
llvm::pdb::dumpSymbolField
void dumpSymbolField(raw_ostream &OS, StringRef Name, T Value, int Indent)
Definition: PDBExtras.h:47
llvm::PointerType
Class to represent pointers.
Definition: DerivedTypes.h:632
llvm::pdb::dumpSymbolIdField
void dumpSymbolIdField(raw_ostream &OS, StringRef Name, SymIndexId Value, int Indent, const IPDBSession &Session, PdbSymbolIdField FieldId, PdbSymbolIdField ShowFlags, PdbSymbolIdField RecurseFlags)
Definition: PDBSymbol.cpp:202
isInheritanceKind
static bool isInheritanceKind(const MemberPointerInfo &MPI, PointerToMemberRepresentation P1, PointerToMemberRepresentation P2)
Definition: NativeTypePointer.cpp:158
llvm::pdb::NativeSession::getSymbolCache
SymbolCache & getSymbolCache()
Definition: NativeSession.h:109
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1609
llvm::Record
Definition: Record.h:1472
llvm::pdb::NativeTypePointer::isVirtualInheritance
bool isVirtualInheritance() const override
Definition: NativeTypePointer.cpp:182
uint32_t
llvm::codeview::TypeIndex::getSimpleMode
SimpleTypeMode getSimpleMode() const
Definition: TypeIndex.h:141
llvm::pdb::NativeTypePointer::isVolatileType
bool isVolatileType() const override
Definition: NativeTypePointer.cpp:144
llvm::codeview::PointerToMemberRepresentation
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
Definition: CodeView.h:374
llvm::pdb::NativeTypePointer::getLength
uint64_t getLength() const override
Definition: NativeTypePointer.cpp:78
llvm::pdb::SymbolCache::findSymbolByTypeIndex
SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI) const
Definition: SymbolCache.cpp:153
std
Definition: BitVector.h:838
llvm::pdb::NativeTypePointer::isConstType
bool isConstType() const override
Definition: NativeTypePointer.cpp:131
TypeDeserializer.h
llvm::pdb::NativeTypePointer::isUnalignedType
bool isUnalignedType() const override
Definition: NativeTypePointer.cpp:151
llvm::pdb::NativeTypePointer::isMemberPointer
bool isMemberPointer() const
Definition: NativeTypePointer.cpp:191
llvm::codeview::MemberPointerInfo::getRepresentation
PointerToMemberRepresentation getRepresentation() const
Definition: TypeRecord.h:109
llvm::pdb::NativeRawSymbol::dump
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
Definition: NativeRawSymbol.cpp:22
llvm::pdb::NativeSession
Definition: NativeSession.h:28
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
llvm::pdb::PdbSymbolIdField
PdbSymbolIdField
Definition: IPDBRawSymbol.h:24
llvm::codeview::TypeIndex::isSimple
bool isSimple() const
Definition: TypeIndex.h:113
llvm::codeview::TypeIndex
A 32-bit type reference.
Definition: TypeIndex.h:96
llvm::pdb::NativeRawSymbol::Session
NativeSession & Session
Definition: NativeRawSymbol.h:232
llvm::pdb::NativeTypePointer::isSingleInheritance
bool isSingleInheritance() const override
Definition: NativeTypePointer.cpp:164
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:231
llvm::codeview::MemberPointerInfo
Definition: TypeRecord.h:100
llvm::pdb::NativeRawSymbol
Definition: NativeRawSymbol.h:21
llvm::pdb::NativeTypePointer::~NativeTypePointer
~NativeTypePointer() override
Definition: NativeTypePointer.cpp:32