LLVM 22.0.0git
TypeRecordHelpers.cpp
Go to the documentation of this file.
1//===- TypeRecordHelpers.cpp ------------------------------------*- 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
14
15using namespace llvm;
16using namespace llvm::codeview;
17
18template <typename RecordT> static ClassOptions getUdtOptions(CVType CVT) {
19 RecordT Record;
21 consumeError(std::move(EC));
22 return ClassOptions::None;
23 }
24 return Record.getOptions();
25}
26
29 switch (CVT.kind()) {
30 case LF_STRUCTURE:
31 case LF_CLASS:
32 case LF_INTERFACE:
33 UdtOptions = getUdtOptions<ClassRecord>(std::move(CVT));
34 break;
35 case LF_ENUM:
36 UdtOptions = getUdtOptions<EnumRecord>(std::move(CVT));
37 break;
38 case LF_UNION:
39 UdtOptions = getUdtOptions<UnionRecord>(std::move(CVT));
40 break;
41 default:
42 return false;
43 }
45}
46
48 assert(CVT.kind() == LF_MODIFIER);
50 discoverTypeIndices(CVT, Refs);
51 return Refs.front();
52}
53
55 if (!TI.isSimple())
56 return 0;
58 // We have a native pointer.
59 switch (TI.getSimpleMode()) {
63 return 2;
66 return 4;
68 return 8;
70 return 16;
71 default:
72 assert(false && "invalid simple type mode!");
73 }
74 }
75 switch (TI.getSimpleKind()) {
78 return 0;
80 return 4;
83 return 1;
84
85 // Signed/unsigned integer.
90 return 2;
95 return 4;
100 return 8;
105 return 16;
106
107 // Signed/Unsigned character.
112 return 1;
115 return 2;
117 return 4;
118
119 // Float.
121 return 2;
123 return 4;
125 return 6;
127 return 8;
129 return 10;
131 return 16;
132
133 // Boolean.
135 return 1;
137 return 2;
139 return 4;
141 return 8;
143 return 16;
144
145 // Complex float.
147 return 4;
149 return 8;
151 return 16;
153 return 20;
155 return 32;
156
157 default:
158 return 0;
159 }
160}
161
162template <typename RecordT> static uint64_t getUdtSize(CVType CVT) {
163 RecordT Record;
165 consumeError(std::move(EC));
166 return 0;
167 }
168 return Record.getSize();
169}
170
172 switch (CVT.kind()) {
173 case LF_STRUCTURE:
174 case LF_CLASS:
175 case LF_INTERFACE:
176 return getUdtSize<ClassRecord>(std::move(CVT));
177 case LF_UNION:
178 return getUdtSize<UnionRecord>(std::move(CVT));
179 default:
180 return CVT.length();
181 }
182}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the SmallVector class.
static ClassOptions getUdtOptions(CVType CVT)
static uint64_t getUdtSize(CVType CVT)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
uint32_t length() const
Definition CVRecord.h:40
static Error deserializeAs(CVType &CVT, T &Record)
A 32-bit type reference.
Definition TypeIndex.h:97
SimpleTypeKind getSimpleKind() const
Definition TypeIndex.h:137
SimpleTypeMode getSimpleMode() const
Definition TypeIndex.h:142
LLVM_ABI bool isUdtForwardRef(CVType CVT)
Given an arbitrary codeview type, determine if it is an LF_STRUCTURE, LF_CLASS, LF_INTERFACE,...
CVRecord< TypeLeafKind > CVType
Definition CVRecord.h:64
LLVM_ABI void discoverTypeIndices(ArrayRef< uint8_t > RecordData, SmallVectorImpl< TiReference > &Refs)
LLVM_ABI uint64_t getSizeInBytesForTypeRecord(CVType CVT)
Given an arbitrary codeview type, return the type's size in the case of aggregate (LF_STRUCTURE,...
LLVM_ABI uint64_t getSizeInBytesForTypeIndex(TypeIndex TI)
Given an arbitrary codeview type index, determine its size.
LLVM_ABI TypeIndex getModifiedType(const CVType &CVT)
Given a CVType which is assumed to be an LF_MODIFIER, return the TypeIndex of the type that the LF_MO...
This is an optimization pass for GlobalISel generic memory operations.
void consumeError(Error Err)
Consume a Error without doing anything.
Definition Error.h:1083