@@ -186,69 +186,6 @@ class BuiltinTypeInfo : public TypeInfo {
186
186
}
187
187
};
188
188
189
- // / Utility class for performing universal layout for types such as
190
- // / tuples, structs, thick functions, etc.
191
- class RecordTypeInfoBuilder {
192
- TypeConverter &TC;
193
- unsigned Size, Alignment, Stride, NumExtraInhabitants;
194
- RecordKind Kind;
195
- std::vector<FieldInfo> Fields;
196
- bool Invalid;
197
-
198
- public:
199
- RecordTypeInfoBuilder (TypeConverter &TC, RecordKind Kind)
200
- : TC(TC), Size(0 ), Alignment(1 ), Stride(0 ), NumExtraInhabitants(0 ),
201
- Kind (Kind), Invalid(false ) {}
202
-
203
- unsigned addField (unsigned fieldSize, unsigned fieldAlignment) {
204
- // Align the current size appropriately
205
- Size = ((Size + fieldAlignment - 1 ) & ~(fieldAlignment - 1 ));
206
-
207
- // Record the offset
208
- unsigned offset = Size;
209
-
210
- // Update the aggregate size
211
- Size += fieldSize;
212
-
213
- // Update the aggregate alignment
214
- Alignment = std::max (Alignment, fieldAlignment);
215
-
216
- // Re-calculate the stride
217
- Stride = ((Size + Alignment - 1 ) & ~(Alignment - 1 ));
218
-
219
- return offset;
220
- }
221
-
222
- void addField (const std::string &Name, const TypeRef *TR) {
223
- const TypeInfo *TI = TC.getTypeInfo (TR);
224
- if (TI == nullptr ) {
225
- Invalid = true ;
226
- return ;
227
- }
228
-
229
- // FIXME: I just made this up
230
- if (Size == 0 )
231
- NumExtraInhabitants = TI->getNumExtraInhabitants ();
232
- else
233
- NumExtraInhabitants = 0 ;
234
-
235
- unsigned fieldSize = TI->getSize ();
236
- unsigned fieldAlignment = TI->getAlignment ();
237
-
238
- unsigned fieldOffset = addField (fieldSize, fieldAlignment);
239
- Fields.push_back ({Name, fieldOffset, TR, *TI});
240
- }
241
-
242
- const RecordTypeInfo *build () {
243
- if (Invalid)
244
- return nullptr ;
245
-
246
- return TC.makeTypeInfo <RecordTypeInfo>(
247
- Size, Alignment, Stride,
248
- NumExtraInhabitants, Kind, Fields);
249
- }
250
- };
251
-
252
189
// / Utility class for building values that contain witness tables.
253
190
class ExistentialTypeInfoBuilder {
254
191
TypeConverter &TC;
@@ -361,6 +298,56 @@ class ExistentialTypeInfoBuilder {
361
298
362
299
}
363
300
301
+ unsigned RecordTypeInfoBuilder::addField (unsigned fieldSize,
302
+ unsigned fieldAlignment) {
303
+ // Align the current size appropriately
304
+ Size = ((Size + fieldAlignment - 1 ) & ~(fieldAlignment - 1 ));
305
+
306
+ // Record the offset
307
+ unsigned offset = Size;
308
+
309
+ // Update the aggregate size
310
+ Size += fieldSize;
311
+
312
+ // Update the aggregate alignment
313
+ Alignment = std::max (Alignment, fieldAlignment);
314
+
315
+ // Re-calculate the stride
316
+ Stride = ((Size + Alignment - 1 ) & ~(Alignment - 1 ));
317
+
318
+ return offset;
319
+ }
320
+
321
+ void RecordTypeInfoBuilder::addField (const std::string &Name,
322
+ const TypeRef *TR) {
323
+ const TypeInfo *TI = TC.getTypeInfo (TR);
324
+ if (TI == nullptr ) {
325
+ Invalid = true ;
326
+ return ;
327
+ }
328
+
329
+ // FIXME: I just made this up
330
+ if (Size == 0 )
331
+ NumExtraInhabitants = TI->getNumExtraInhabitants ();
332
+ else
333
+ NumExtraInhabitants = 0 ;
334
+
335
+ unsigned fieldSize = TI->getSize ();
336
+ unsigned fieldAlignment = TI->getAlignment ();
337
+
338
+ unsigned fieldOffset = addField (fieldSize, fieldAlignment);
339
+ Fields.push_back ({Name, fieldOffset, TR, *TI});
340
+ }
341
+
342
+ const RecordTypeInfo *RecordTypeInfoBuilder::build () {
343
+ if (Invalid)
344
+ return nullptr ;
345
+
346
+ return TC.makeTypeInfo <RecordTypeInfo>(
347
+ Size, Alignment, Stride,
348
+ NumExtraInhabitants, Kind, Fields);
349
+ }
350
+
364
351
const ReferenceTypeInfo *
365
352
TypeConverter::getReferenceTypeInfo (ReferenceKind Kind,
366
353
ReferenceCounting Refcounting) {
0 commit comments