@@ -172,6 +172,14 @@ enum class SILFunctionTypeRepresentation : uint8_t {
172
172
// / constructor). Except for
173
173
// / handling the "this" argument, has the same behavior as "CFunctionPointer".
174
174
CXXMethod,
175
+
176
+ // / A KeyPath accessor function, which is thin and also uses the variadic
177
+ // / length
178
+ // / generic components serialization in trailing buffer.
179
+ KeyPathAccessorGetter,
180
+ KeyPathAccessorSetter,
181
+ KeyPathAccessorEquals,
182
+ KeyPathAccessorHash,
175
183
};
176
184
177
185
// / Returns true if the function with this convention doesn't carry a context.
@@ -202,6 +210,10 @@ isThinRepresentation(SILFunctionTypeRepresentation rep) {
202
210
case SILFunctionTypeRepresentation::CFunctionPointer:
203
211
case SILFunctionTypeRepresentation::Closure:
204
212
case SILFunctionTypeRepresentation::CXXMethod:
213
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
214
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
215
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
216
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
205
217
return true ;
206
218
}
207
219
llvm_unreachable (" Unhandled SILFunctionTypeRepresentation in switch." );
@@ -214,6 +226,31 @@ isThickRepresentation(Repr repr) {
214
226
return !isThinRepresentation (repr);
215
227
}
216
228
229
+ // / Returns true if the function with this convention receives generic arguments
230
+ // / from KeyPath argument buffer.
231
+ constexpr bool
232
+ isKeyPathAccessorRepresentation (SILFunctionTypeRepresentation rep) {
233
+ switch (rep) {
234
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
235
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
236
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
237
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
238
+ return true ;
239
+ case SILFunctionTypeRepresentation::Thick:
240
+ case SILFunctionTypeRepresentation::Block:
241
+ case SILFunctionTypeRepresentation::Thin:
242
+ case SILFunctionTypeRepresentation::Method:
243
+ case SILFunctionTypeRepresentation::ObjCMethod:
244
+ case SILFunctionTypeRepresentation::WitnessMethod:
245
+ case SILFunctionTypeRepresentation::CFunctionPointer:
246
+ case SILFunctionTypeRepresentation::Closure:
247
+ case SILFunctionTypeRepresentation::CXXMethod:
248
+ return false ;
249
+ }
250
+ llvm_unreachable (" Unhandled SILFunctionTypeRepresentation in switch." );
251
+ }
252
+
253
+
217
254
constexpr SILFunctionTypeRepresentation
218
255
convertRepresentation (FunctionTypeRepresentation rep) {
219
256
switch (rep) {
@@ -245,6 +282,10 @@ convertRepresentation(SILFunctionTypeRepresentation rep) {
245
282
case SILFunctionTypeRepresentation::ObjCMethod:
246
283
case SILFunctionTypeRepresentation::WitnessMethod:
247
284
case SILFunctionTypeRepresentation::Closure:
285
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
286
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
287
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
288
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
248
289
return None;
249
290
}
250
291
llvm_unreachable (" Unhandled SILFunctionTypeRepresentation!" );
@@ -264,6 +305,10 @@ constexpr bool canBeCalledIndirectly(SILFunctionTypeRepresentation rep) {
264
305
case SILFunctionTypeRepresentation::ObjCMethod:
265
306
case SILFunctionTypeRepresentation::Method:
266
307
case SILFunctionTypeRepresentation::WitnessMethod:
308
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
309
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
310
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
311
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
267
312
return true ;
268
313
}
269
314
@@ -285,6 +330,10 @@ template <typename Repr> constexpr bool shouldStoreClangType(Repr repr) {
285
330
case SILFunctionTypeRepresentation::Method:
286
331
case SILFunctionTypeRepresentation::WitnessMethod:
287
332
case SILFunctionTypeRepresentation::Closure:
333
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
334
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
335
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
336
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
288
337
return false ;
289
338
}
290
339
llvm_unreachable (" Unhandled SILFunctionTypeRepresentation." );
@@ -395,6 +444,10 @@ class ASTExtInfoBuilder {
395
444
case SILFunctionTypeRepresentation::Thin:
396
445
case SILFunctionTypeRepresentation::CFunctionPointer:
397
446
case SILFunctionTypeRepresentation::Closure:
447
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
448
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
449
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
450
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
398
451
return false ;
399
452
case SILFunctionTypeRepresentation::ObjCMethod:
400
453
case SILFunctionTypeRepresentation::Method:
@@ -633,6 +686,10 @@ SILFunctionLanguage getSILFunctionLanguage(SILFunctionTypeRepresentation rep) {
633
686
case SILFunctionTypeRepresentation::Method:
634
687
case SILFunctionTypeRepresentation::WitnessMethod:
635
688
case SILFunctionTypeRepresentation::Closure:
689
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
690
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
691
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
692
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
636
693
return SILFunctionLanguage::Swift;
637
694
}
638
695
@@ -651,17 +708,17 @@ class SILExtInfoBuilder {
651
708
// and NumMaskBits must be updated, and they must match.
652
709
653
710
// |representation|pseudogeneric| noescape | concurrent | async |differentiability|
654
- // | 0 .. 3 | 4 | 5 | 6 | 7 | 8 .. 10 |
711
+ // | 0 .. 4 | 5 | 6 | 7 | 8 | 9 .. 11 |
655
712
//
656
713
enum : unsigned {
657
- RepresentationMask = 0xF << 0 ,
658
- PseudogenericMask = 1 << 4 ,
659
- NoEscapeMask = 1 << 5 ,
660
- SendableMask = 1 << 6 ,
661
- AsyncMask = 1 << 7 ,
662
- DifferentiabilityMaskOffset = 8 ,
714
+ RepresentationMask = 0x1F << 0 ,
715
+ PseudogenericMask = 1 << 5 ,
716
+ NoEscapeMask = 1 << 6 ,
717
+ SendableMask = 1 << 7 ,
718
+ AsyncMask = 1 << 8 ,
719
+ DifferentiabilityMaskOffset = 9 ,
663
720
DifferentiabilityMask = 0x7 << DifferentiabilityMaskOffset,
664
- NumMaskBits = 11
721
+ NumMaskBits = 12
665
722
};
666
723
667
724
unsigned bits; // Naturally sized for speed.
@@ -755,6 +812,10 @@ class SILExtInfoBuilder {
755
812
case Representation::Thin:
756
813
case Representation::CFunctionPointer:
757
814
case Representation::Closure:
815
+ case Representation::KeyPathAccessorGetter:
816
+ case Representation::KeyPathAccessorSetter:
817
+ case Representation::KeyPathAccessorEquals:
818
+ case Representation::KeyPathAccessorHash:
758
819
return false ;
759
820
case Representation::ObjCMethod:
760
821
case Representation::Method:
@@ -778,6 +839,10 @@ class SILExtInfoBuilder {
778
839
case Representation::WitnessMethod:
779
840
case Representation::Closure:
780
841
case SILFunctionTypeRepresentation::CXXMethod:
842
+ case Representation::KeyPathAccessorGetter:
843
+ case Representation::KeyPathAccessorSetter:
844
+ case Representation::KeyPathAccessorEquals:
845
+ case Representation::KeyPathAccessorHash:
781
846
return false ;
782
847
}
783
848
llvm_unreachable (" Unhandled Representation in switch." );
0 commit comments