LLVM 24.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 case LF_STRUCTURE2:
34 case LF_CLASS2:
35 case LF_INTERFACE2:
36 UdtOptions = getUdtOptions<ClassRecord>(std::move(CVT));
37 break;
38 case LF_ENUM:
39 UdtOptions = getUdtOptions<EnumRecord>(std::move(CVT));
40 break;
41 case LF_UNION:
42 case LF_UNION2:
43 UdtOptions = getUdtOptions<UnionRecord>(std::move(CVT));
44 break;
45 default:
46 return false;
47 }
49}
50
52 assert(CVT.kind() == LF_MODIFIER);
54 discoverTypeIndices(CVT, Refs);
55 return Refs.front();
56}
57
59 if (!TI.isSimple())
60 return 0;
62 // We have a native pointer.
63 switch (TI.getSimpleMode()) {
67 return 2;
70 return 4;
72 return 8;
74 return 16;
75 default:
76 assert(false && "invalid simple type mode!");
77 }
78 }
79 switch (TI.getSimpleKind()) {
82 return 0;
84 return 4;
87 return 1;
88
89 // Signed/unsigned integer.
94 return 2;
99 return 4;
104 return 8;
109 return 16;
110
111 // Signed/Unsigned character.
116 return 1;
119 return 2;
121 return 4;
122
123 // Float.
125 return 2;
127 return 4;
129 return 6;
131 return 8;
133 return 10;
135 return 16;
136
137 // Boolean.
139 return 1;
141 return 2;
143 return 4;
145 return 8;
147 return 16;
148
149 // Complex float.
151 return 4;
153 return 8;
155 return 16;
157 return 20;
159 return 32;
160
161 default:
162 return 0;
163 }
164}
165
166template <typename RecordT> static uint64_t getUdtSize(CVType CVT) {
167 RecordT Record;
169 consumeError(std::move(EC));
170 return 0;
171 }
172 return Record.getSize();
173}
174
176 switch (CVT.kind()) {
177 case LF_STRUCTURE:
178 case LF_CLASS:
179 case LF_INTERFACE:
180 case LF_STRUCTURE2:
181 case LF_CLASS2:
182 case LF_INTERFACE2:
183 return getUdtSize<ClassRecord>(std::move(CVT));
184 case LF_UNION:
185 case LF_UNION2:
186 return getUdtSize<UnionRecord>(std::move(CVT));
187 default:
188 assert(false && "not an aggregate");
189 return 0;
190 }
191}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
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.
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:1106