@@ -51,6 +51,10 @@ LayoutConstraint getLayoutConstraint(Identifier ID, ASTContext &Ctx) {
51
51
return LayoutConstraint::getLayoutConstraint (
52
52
LayoutConstraintKind::BridgeObject, Ctx);
53
53
54
+ if (ID == Ctx.Id_TrivialStrideLayout )
55
+ return LayoutConstraint::getLayoutConstraint (
56
+ LayoutConstraintKind::TrivialStride, 0 , 0 , Ctx);
57
+
54
58
return LayoutConstraint::getLayoutConstraint (
55
59
LayoutConstraintKind::UnknownLayout, Ctx);
56
60
}
@@ -79,6 +83,8 @@ StringRef LayoutConstraintInfo::getName(LayoutConstraintKind Kind, bool internal
79
83
return " _Trivial" ;
80
84
case LayoutConstraintKind::BridgeObject:
81
85
return " _BridgeObject" ;
86
+ case LayoutConstraintKind::TrivialStride:
87
+ return " _TrivialStride" ;
82
88
}
83
89
84
90
llvm_unreachable (" Unhandled LayoutConstraintKind in switch." );
@@ -112,8 +118,9 @@ bool LayoutConstraintInfo::isAddressOnlyTrivial(LayoutConstraintKind Kind) {
112
118
}
113
119
114
120
bool LayoutConstraintInfo::isTrivial (LayoutConstraintKind Kind) {
115
- return Kind > LayoutConstraintKind::UnknownLayout &&
116
- Kind <= LayoutConstraintKind::Trivial;
121
+ return (Kind > LayoutConstraintKind::UnknownLayout &&
122
+ Kind <= LayoutConstraintKind::Trivial) ||
123
+ Kind == LayoutConstraintKind::TrivialStride;
117
124
}
118
125
119
126
bool LayoutConstraintInfo::isRefCountedObject (LayoutConstraintKind Kind) {
@@ -150,6 +157,10 @@ bool LayoutConstraintInfo::isBridgeObject(LayoutConstraintKind Kind) {
150
157
return Kind == LayoutConstraintKind::BridgeObject;
151
158
}
152
159
160
+ bool LayoutConstraintInfo::isTrivialStride (LayoutConstraintKind Kind) {
161
+ return Kind == LayoutConstraintKind::TrivialStride;
162
+ }
163
+
153
164
SourceRange LayoutConstraintLoc::getSourceRange () const { return getLoc (); }
154
165
155
166
#define MERGE_LOOKUP (lhs, rhs ) \
@@ -180,55 +191,64 @@ static LayoutConstraintKind mergeTable[unsigned(E(LastLayout)) +
180
191
E (/* TrivialOfAtMostSize */ TrivialOfAtMostSize), E (/* Trivial */ Trivial),
181
192
E (/* Class */ Class), E (/* NativeClass */ NativeClass),
182
193
E (/* RefCountedObject*/ RefCountedObject),
183
- E (/* NativeRefCountedObject */ NativeRefCountedObject), MERGE_CONFLICT},
194
+ E (/* NativeRefCountedObject */ NativeRefCountedObject), MERGE_CONFLICT,
195
+ MERGE_CONFLICT},
184
196
185
197
// Initialize the row for TrivialOfExactSize.
186
198
{E (/* UnknownLayout */ TrivialOfExactSize),
187
199
E (/* TrivialOfExactSize */ TrivialOfExactSize), MERGE_CONFLICT,
188
200
E (/* Trivial */ TrivialOfExactSize), MERGE_CONFLICT, MERGE_CONFLICT,
189
- MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT},
201
+ MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT },
190
202
191
203
// Initialize the row for TrivialOfAtMostSize.
192
204
{E (/* UnknownLayout */ TrivialOfAtMostSize), MERGE_CONFLICT,
193
205
E (/* TrivialOfAtMostSize */ TrivialOfAtMostSize),
194
206
E (/* Trivial */ TrivialOfAtMostSize), MERGE_CONFLICT, MERGE_CONFLICT,
195
- MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT},
207
+ MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT },
196
208
197
209
// Initialize the row for Trivial.
198
210
{E (/* UnknownLayout */ Trivial),
199
211
E (/* TrivialOfExactSize */ TrivialOfExactSize),
200
212
E (/* TrivialOfAtMostSize */ TrivialOfAtMostSize), E (/* Trivial */ Trivial),
201
213
MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT,
202
- MERGE_CONFLICT},
214
+ MERGE_CONFLICT, MERGE_CONFLICT },
203
215
204
216
// Initialize the row for Class.
205
217
{E (/* UnknownLayout*/ Class), MERGE_CONFLICT, MERGE_CONFLICT,
206
218
MERGE_CONFLICT, E (/* Class */ Class), E (/* NativeClass */ NativeClass),
207
219
E (/* RefCountedObject */ Class),
208
- E (/* NativeRefCountedObject */ NativeClass), MERGE_CONFLICT},
220
+ E (/* NativeRefCountedObject */ NativeClass), MERGE_CONFLICT,
221
+ MERGE_CONFLICT},
209
222
210
223
// Initialize the row for NativeClass.
211
224
{E (/* UnknownLayout */ NativeClass), MERGE_CONFLICT, MERGE_CONFLICT,
212
225
MERGE_CONFLICT, E (/* Class */ NativeClass),
213
226
E (/* NativeClass */ NativeClass), E (/* RefCountedObject */ NativeClass),
214
- E (/* NativeRefCountedObject */ NativeClass), MERGE_CONFLICT},
227
+ E (/* NativeRefCountedObject */ NativeClass), MERGE_CONFLICT,
228
+ MERGE_CONFLICT},
215
229
216
230
// Initialize the row for RefCountedObject.
217
231
{E (/* UnknownLayout */ RefCountedObject), MERGE_CONFLICT, MERGE_CONFLICT,
218
232
MERGE_CONFLICT, E (/* Class */ Class), E (/* NativeClass */ NativeClass),
219
233
E (/* RefCountedObject */ RefCountedObject),
220
- E (/* NativeRefCountedObject */ NativeRefCountedObject), MERGE_CONFLICT},
234
+ E (/* NativeRefCountedObject */ NativeRefCountedObject), MERGE_CONFLICT,
235
+ MERGE_CONFLICT},
221
236
222
237
// Initialize the row for NativeRefCountedObject.
223
238
{E (/* UnknownLayout */ NativeRefCountedObject), MERGE_CONFLICT,
224
239
MERGE_CONFLICT, MERGE_CONFLICT, E (/* Class */ NativeClass),
225
240
E (/* NativeClass */ NativeClass),
226
241
E (/* RefCountedObject */ NativeRefCountedObject),
227
- E (/* NativeRefCountedObject*/ NativeRefCountedObject), MERGE_CONFLICT},
242
+ E (/* NativeRefCountedObject*/ NativeRefCountedObject), MERGE_CONFLICT,
243
+ MERGE_CONFLICT},
228
244
229
245
{E (BridgeObject), MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT,
230
246
MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT,
231
- E (/* BridgeObject*/ BridgeObject)},
247
+ E (/* BridgeObject*/ BridgeObject), MERGE_CONFLICT},
248
+
249
+ {E (TrivialStride), MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT,
250
+ MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT, MERGE_CONFLICT,
251
+ MERGE_CONFLICT, E (/* TrivialStride*/ TrivialStride)},
232
252
};
233
253
234
254
#undef E
@@ -324,6 +344,7 @@ LayoutConstraint::merge(LayoutConstraint Other) {
324
344
LayoutConstraint
325
345
LayoutConstraint::getLayoutConstraint (LayoutConstraintKind Kind) {
326
346
assert (!LayoutConstraintInfo::isKnownSizeTrivial (Kind));
347
+ assert (!LayoutConstraintInfo::isTrivialStride (Kind));
327
348
switch (Kind) {
328
349
case LayoutConstraintKind::Trivial:
329
350
return LayoutConstraint (&LayoutConstraintInfo::TrivialConstraintInfo);
@@ -343,6 +364,7 @@ LayoutConstraint::getLayoutConstraint(LayoutConstraintKind Kind) {
343
364
return LayoutConstraint (&LayoutConstraintInfo::BridgeObjectConstraintInfo);
344
365
case LayoutConstraintKind::TrivialOfAtMostSize:
345
366
case LayoutConstraintKind::TrivialOfExactSize:
367
+ case LayoutConstraintKind::TrivialStride:
346
368
llvm_unreachable (" Wrong layout constraint kind" );
347
369
}
348
370
llvm_unreachable (" unhandled kind" );
0 commit comments