@@ -110,6 +110,12 @@ enum IsAddressableForDependencies_t : bool {
110110 IsAddressableForDependencies = true ,
111111};
112112
113+ // / Is a lowered SIL type a struct with `@_rawLayout` or contains such a struct?
114+ enum HasRawLayout_t : bool {
115+ DoesNotHaveRawLayout = false ,
116+ HasRawLayout = true
117+ };
118+
113119class SILTypeProperties {
114120 // These are chosen so that bitwise-or merges the flags properly.
115121 //
@@ -125,6 +131,7 @@ class SILTypeProperties {
125131 LexicalFlag = 1 << 7 ,
126132 HasPackFlag = 1 << 8 ,
127133 AddressableForDependenciesFlag = 1 << 9 ,
134+ HasRawLayoutFlag = 1 << 10 ,
128135 };
129136 // clang-format on
130137
@@ -142,7 +149,8 @@ class SILTypeProperties {
142149 IsNotTypeExpansionSensitive,
143150 HasRawPointer_t hasRawPointer = DoesNotHaveRawPointer,
144151 IsLexical_t isLexical = IsNotLexical, HasPack_t hasPack = HasNoPack,
145- IsAddressableForDependencies_t isAFD = IsNotAddressableForDependencies)
152+ IsAddressableForDependencies_t isAFD = IsNotAddressableForDependencies,
153+ HasRawLayout_t hasRawLayout = DoesNotHaveRawLayout)
146154 : Flags((isTrivial ? 0U : NonTrivialFlag) |
147155 (isFixedABI ? 0U : NonFixedABIFlag) |
148156 (isAddressOnly ? AddressOnlyFlag : 0U ) |
@@ -151,7 +159,8 @@ class SILTypeProperties {
151159 (hasRawPointer ? HasRawPointerFlag : 0U ) |
152160 (isLexical ? LexicalFlag : 0U ) |
153161 (hasPack ? HasPackFlag : 0U ) |
154- (isAFD ? AddressableForDependenciesFlag : 0U )) {}
162+ (isAFD ? AddressableForDependenciesFlag : 0U ) |
163+ (hasRawLayout ? HasRawLayoutFlag : 0U )) {}
155164
156165 constexpr bool operator ==(SILTypeProperties p) const {
157166 return Flags == p.Flags ;
@@ -180,7 +189,7 @@ class SILTypeProperties {
180189 static constexpr SILTypeProperties forOpaque () {
181190 return {IsNotTrivial, IsNotFixedABI, IsAddressOnly, IsNotResilient,
182191 IsNotTypeExpansionSensitive, HasRawPointer, IsLexical,
183- HasNoPack, IsAddressableForDependencies};
192+ HasNoPack, IsAddressableForDependencies, HasRawLayout };
184193 }
185194
186195 static constexpr SILTypeProperties forResilient () {
@@ -228,6 +237,9 @@ class SILTypeProperties {
228237 return IsAddressableForDependencies_t (
229238 (Flags & AddressableForDependenciesFlag) != 0 );
230239 }
240+ HasRawLayout_t isOrContainsRawLayout () const {
241+ return HasRawLayout_t ((Flags & HasRawLayoutFlag) != 0 );
242+ }
231243
232244 void setNonTrivial () { Flags |= NonTrivialFlag; }
233245 void setIsOrContainsRawPointer () { Flags |= HasRawPointerFlag; }
@@ -247,6 +259,9 @@ class SILTypeProperties {
247259 void setAddressableForDependencies () {
248260 Flags |= AddressableForDependenciesFlag;
249261 }
262+ void setHasRawLayout () {
263+ Flags |= HasRawLayoutFlag;
264+ }
250265};
251266
252267} // end namespace swift
0 commit comments