Implement dependent layouts for raw types

Update raw_layout.swift

Allow for concrete specializations of raw layout

Make test platform agnostic
This commit is contained in:
Alejandro Alonso
2023-07-29 17:01:54 -07:00
parent 984b4f2387
commit df17f7be90
16 changed files with 298 additions and 30 deletions

View File

@@ -2905,6 +2905,35 @@ metadata:
}
}
/// Initialize the value witness table for a @_rawLayout struct.
SWIFT_RUNTIME_EXPORT
void swift::swift_initRawStructMetadata(StructMetadata *structType,
StructLayoutFlags layoutFlags,
const TypeLayout *likeTypeLayout,
size_t count) {
auto vwtable = getMutableVWTableForInit(structType, layoutFlags);
// The existing vwt function entries are all fine to preserve, the only thing
// we need to initialize is the actual type layout.
auto size = likeTypeLayout->size;
auto stride = likeTypeLayout->stride;
auto alignMask = likeTypeLayout->flags.getAlignmentMask();
auto extraInhabitantCount = likeTypeLayout->extraInhabitantCount;
// If our count is greater than or equal 0, we're dealing an array like layout.
if (count >= 0) {
stride *= count;
size = stride;
}
vwtable->size = size;
vwtable->stride = stride;
vwtable->flags = ValueWitnessFlags()
.withAlignmentMask(alignMask)
.withCopyable(false);
vwtable->extraInhabitantCount = extraInhabitantCount;
}
/***************************************************************************/
/*** Classes ***************************************************************/
/***************************************************************************/