LLVM  16.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 
11 
13 
14 #include <cassert>
15 
16 using namespace llvm;
17 using namespace llvm::codeview;
18 using namespace llvm::pdb;
19 
20 NativeTypePointer::NativeTypePointer(NativeSession &Session, SymIndexId Id,
22  : NativeRawSymbol(Session, PDB_SymType::PointerType, Id), TI(TI) {
23  assert(TI.isSimple());
24  assert(TI.getSimpleMode() != SimpleTypeMode::Direct);
25 }
26 
30  : NativeRawSymbol(Session, PDB_SymType::PointerType, Id), TI(TI),
31  Record(std::move(Record)) {}
32 
34 
35 void NativeTypePointer::dump(raw_ostream &OS, int Indent,
36  PdbSymbolIdField ShowIdFields,
37  PdbSymbolIdField RecurseIdFields) const {
38  NativeRawSymbol::dump(OS, Indent, ShowIdFields, RecurseIdFields);
39 
40  if (isMemberPointer()) {
41  dumpSymbolIdField(OS, "classParentId", getClassParentId(), Indent, Session,
42  PdbSymbolIdField::ClassParent, ShowIdFields,
43  RecurseIdFields);
44  }
45  dumpSymbolIdField(OS, "lexicalParentId", 0, Indent, Session,
46  PdbSymbolIdField::LexicalParent, ShowIdFields,
47  RecurseIdFields);
48  dumpSymbolIdField(OS, "typeId", getTypeId(), Indent, Session,
49  PdbSymbolIdField::Type, ShowIdFields, RecurseIdFields);
50  dumpSymbolField(OS, "length", getLength(), Indent);
51  dumpSymbolField(OS, "constType", isConstType(), Indent);
52  dumpSymbolField(OS, "isPointerToDataMember", isPointerToDataMember(), Indent);
53  dumpSymbolField(OS, "isPointerToMemberFunction", isPointerToMemberFunction(),
54  Indent);
55  dumpSymbolField(OS, "RValueReference", isRValueReference(), Indent);
56  dumpSymbolField(OS, "reference", isReference(), Indent);
57  dumpSymbolField(OS, "restrictedType", isRestrictedType(), Indent);
58  if (isMemberPointer()) {
59  if (isSingleInheritance())
60  dumpSymbolField(OS, "isSingleInheritance", 1, Indent);
61  else if (isMultipleInheritance())
62  dumpSymbolField(OS, "isMultipleInheritance", 1, Indent);
63  else if (isVirtualInheritance())
64  dumpSymbolField(OS, "isVirtualInheritance", 1, Indent);
65  }
66  dumpSymbolField(OS, "unalignedType", isUnalignedType(), Indent);
67  dumpSymbolField(OS, "volatileType", isVolatileType(), Indent);
68 }
69 
71  if (!isMemberPointer())
72  return 0;
73 
74  assert(Record);
75  const MemberPointerInfo &MPI = Record->getMemberInfo();
77 }
78 
80  if (Record)
81  return Record->getSize();
82 
83  switch (TI.getSimpleMode()) {
84  case SimpleTypeMode::NearPointer:
85  case SimpleTypeMode::FarPointer:
86  case SimpleTypeMode::HugePointer:
87  return 2;
88  case SimpleTypeMode::NearPointer32:
89  case SimpleTypeMode::FarPointer32:
90  return 4;
91  case SimpleTypeMode::NearPointer64:
92  return 8;
93  case SimpleTypeMode::NearPointer128:
94  return 16;
95  default:
96  assert(false && "invalid simple type mode!");
97  }
98  return 0;
99 }
100 
102  // This is the pointee SymIndexId.
103  TypeIndex Referent = Record ? Record->ReferentType : TI.makeDirect();
104 
105  return Session.getSymbolCache().findSymbolByTypeIndex(Referent);
106 }
107 
109  if (!Record)
110  return false;
111  return Record->getMode() == PointerMode::LValueReference;
112 }
113 
115  if (!Record)
116  return false;
117  return Record->getMode() == PointerMode::RValueReference;
118 }
119 
121  if (!Record)
122  return false;
123  return Record->getMode() == PointerMode::PointerToDataMember;
124 }
125 
127  if (!Record)
128  return false;
129  return Record->getMode() == PointerMode::PointerToMemberFunction;
130 }
131 
133  if (!Record)
134  return false;
135  return (Record->getOptions() & PointerOptions::Const) != PointerOptions::None;
136 }
137 
139  if (!Record)
140  return false;
141  return (Record->getOptions() & PointerOptions::Restrict) !=
143 }
144 
146  if (!Record)
147  return false;
148  return (Record->getOptions() & PointerOptions::Volatile) !=
150 }
151 
153  if (!Record)
154  return false;
155  return (Record->getOptions() & PointerOptions::Unaligned) !=
157 }
158 
159 static inline bool isInheritanceKind(const MemberPointerInfo &MPI,
162  return (MPI.getRepresentation() == P1 || MPI.getRepresentation() == P2);
163 }
164 
166  if (!isMemberPointer())
167  return false;
168  return isInheritanceKind(
169  Record->getMemberInfo(),
170  PointerToMemberRepresentation::SingleInheritanceData,
171  PointerToMemberRepresentation::SingleInheritanceFunction);
172 }
173 
175  if (!isMemberPointer())
176  return false;
177  return isInheritanceKind(
178  Record->getMemberInfo(),
179  PointerToMemberRepresentation::MultipleInheritanceData,
180  PointerToMemberRepresentation::MultipleInheritanceFunction);
181 }
182 
184  if (!isMemberPointer())
185  return false;
186  return isInheritanceKind(
187  Record->getMemberInfo(),
188  PointerToMemberRepresentation::VirtualInheritanceData,
189  PointerToMemberRepresentation::VirtualInheritanceFunction);
190 }
191 
194 }
llvm::pdb::NativeTypePointer::dump
void dump(raw_ostream &OS, int Indent, PdbSymbolIdField ShowIdFields, PdbSymbolIdField RecurseIdFields) const override
Definition: NativeTypePointer.cpp:35
llvm::pdb::NativeTypePointer::isRestrictedType
bool isRestrictedType() const override
Definition: NativeTypePointer.cpp:138
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::pdb::NativeTypePointer::isReference
bool isReference() const override
Definition: NativeTypePointer.cpp:108
llvm::pdb::NativeTypePointer::isPointerToMemberFunction
bool isPointerToMemberFunction() const override
Definition: NativeTypePointer.cpp:126
llvm::pdb::PdbSymbolIdField::Type
@ Type
llvm::pdb::NativeTypePointer::NativeTypePointer
NativeTypePointer(NativeSession &Session, SymIndexId Id, codeview::TypeIndex TI)
Definition: NativeTypePointer.cpp:20
llvm::codeview::PointerRecord
Definition: TypeRecord.h:264
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:54
llvm::pdb::NativeTypePointer::isPointerToDataMember
bool isPointerToDataMember() const override
Definition: NativeTypePointer.cpp:120
llvm::pdb::NativeTypePointer::isRValueReference
bool isRValueReference() const override
Definition: NativeTypePointer.cpp:114
NativeTypePointer.h
llvm::pdb::NativeTypePointer::getTypeId
SymIndexId getTypeId() const override
Definition: NativeTypePointer.cpp:101
llvm::codeview::TypeIndex::makeDirect
TypeIndex makeDirect() const
Definition: TypeIndex.h:146
llvm::pdb::NativeTypePointer::getClassParentId
SymIndexId getClassParentId() const override
Definition: NativeTypePointer.cpp:70
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:174
CodeView.h
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:159
llvm::pdb::NativeSession::getSymbolCache
SymbolCache & getSymbolCache()
Definition: NativeSession.h:113
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:1861
llvm::Record
Definition: Record.h:1573
llvm::pdb::NativeTypePointer::isVirtualInheritance
bool isVirtualInheritance() const override
Definition: NativeTypePointer.cpp:183
uint32_t
llvm::codeview::TypeIndex::getSimpleMode
SimpleTypeMode getSimpleMode() const
Definition: TypeIndex.h:141
llvm::pdb::NativeTypePointer::isVolatileType
bool isVolatileType() const override
Definition: NativeTypePointer.cpp:145
llvm::codeview::PointerToMemberRepresentation
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
Definition: CodeView.h:376
llvm::pdb::NativeTypePointer::getLength
uint64_t getLength() const override
Definition: NativeTypePointer.cpp:79
llvm::pdb::SymbolCache::findSymbolByTypeIndex
SymIndexId findSymbolByTypeIndex(codeview::TypeIndex TI) const
Definition: SymbolCache.cpp:158
std
Definition: BitVector.h:851
llvm::pdb::NativeTypePointer::isConstType
bool isConstType() const override
Definition: NativeTypePointer.cpp:132
llvm::None
constexpr std::nullopt_t None
Definition: None.h:27
llvm::pdb::NativeTypePointer::isUnalignedType
bool isUnalignedType() const override
Definition: NativeTypePointer.cpp:152
llvm::pdb::NativeTypePointer::isMemberPointer
bool isMemberPointer() const
Definition: NativeTypePointer.cpp:192
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:21
llvm::pdb::NativeSession
Definition: NativeSession.h:32
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:165
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:241
llvm::codeview::MemberPointerInfo
Definition: TypeRecord.h:100
llvm::pdb::NativeRawSymbol
Definition: NativeRawSymbol.h:21
llvm::pdb::NativeTypePointer::~NativeTypePointer
~NativeTypePointer() override
NativeSession.h