@@ -173,6 +173,15 @@ enum class SILFunctionTypeRepresentation : uint8_t {
173
173
// / constructor). Except for
174
174
// / handling the "this" argument, has the same behavior as "CFunctionPointer".
175
175
CXXMethod,
176
+
177
+ // / A KeyPath accessor function, which is thin and also uses the variadic
178
+ // / length generic components serialization in trailing buffer.
179
+ // / Each representation has a different convention for which parameters
180
+ // / have serialized generic type info.
181
+ KeyPathAccessorGetter,
182
+ KeyPathAccessorSetter,
183
+ KeyPathAccessorEquals,
184
+ KeyPathAccessorHash,
176
185
};
177
186
178
187
// / Returns true if the function with this convention doesn't carry a context.
@@ -203,6 +212,10 @@ isThinRepresentation(SILFunctionTypeRepresentation rep) {
203
212
case SILFunctionTypeRepresentation::CFunctionPointer:
204
213
case SILFunctionTypeRepresentation::Closure:
205
214
case SILFunctionTypeRepresentation::CXXMethod:
215
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
216
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
217
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
218
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
206
219
return true ;
207
220
}
208
221
llvm_unreachable (" Unhandled SILFunctionTypeRepresentation in switch." );
@@ -215,6 +228,31 @@ isThickRepresentation(Repr repr) {
215
228
return !isThinRepresentation (repr);
216
229
}
217
230
231
+ // / Returns true if the function with this convention receives generic arguments
232
+ // / from KeyPath argument buffer.
233
+ constexpr bool
234
+ isKeyPathAccessorRepresentation (SILFunctionTypeRepresentation rep) {
235
+ switch (rep) {
236
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
237
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
238
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
239
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
240
+ return true ;
241
+ case SILFunctionTypeRepresentation::Thick:
242
+ case SILFunctionTypeRepresentation::Block:
243
+ case SILFunctionTypeRepresentation::Thin:
244
+ case SILFunctionTypeRepresentation::Method:
245
+ case SILFunctionTypeRepresentation::ObjCMethod:
246
+ case SILFunctionTypeRepresentation::WitnessMethod:
247
+ case SILFunctionTypeRepresentation::CFunctionPointer:
248
+ case SILFunctionTypeRepresentation::Closure:
249
+ case SILFunctionTypeRepresentation::CXXMethod:
250
+ return false ;
251
+ }
252
+ llvm_unreachable (" Unhandled SILFunctionTypeRepresentation in switch." );
253
+ }
254
+
255
+
218
256
constexpr SILFunctionTypeRepresentation
219
257
convertRepresentation (FunctionTypeRepresentation rep) {
220
258
switch (rep) {
@@ -246,6 +284,10 @@ convertRepresentation(SILFunctionTypeRepresentation rep) {
246
284
case SILFunctionTypeRepresentation::ObjCMethod:
247
285
case SILFunctionTypeRepresentation::WitnessMethod:
248
286
case SILFunctionTypeRepresentation::Closure:
287
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
288
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
289
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
290
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
249
291
return llvm::None;
250
292
}
251
293
llvm_unreachable (" Unhandled SILFunctionTypeRepresentation!" );
@@ -265,6 +307,10 @@ constexpr bool canBeCalledIndirectly(SILFunctionTypeRepresentation rep) {
265
307
case SILFunctionTypeRepresentation::ObjCMethod:
266
308
case SILFunctionTypeRepresentation::Method:
267
309
case SILFunctionTypeRepresentation::WitnessMethod:
310
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
311
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
312
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
313
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
268
314
return true ;
269
315
}
270
316
@@ -286,6 +332,10 @@ template <typename Repr> constexpr bool shouldStoreClangType(Repr repr) {
286
332
case SILFunctionTypeRepresentation::Method:
287
333
case SILFunctionTypeRepresentation::WitnessMethod:
288
334
case SILFunctionTypeRepresentation::Closure:
335
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
336
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
337
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
338
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
289
339
return false ;
290
340
}
291
341
llvm_unreachable (" Unhandled SILFunctionTypeRepresentation." );
@@ -396,6 +446,10 @@ class ASTExtInfoBuilder {
396
446
case SILFunctionTypeRepresentation::Thin:
397
447
case SILFunctionTypeRepresentation::CFunctionPointer:
398
448
case SILFunctionTypeRepresentation::Closure:
449
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
450
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
451
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
452
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
399
453
return false ;
400
454
case SILFunctionTypeRepresentation::ObjCMethod:
401
455
case SILFunctionTypeRepresentation::Method:
@@ -634,6 +688,10 @@ SILFunctionLanguage getSILFunctionLanguage(SILFunctionTypeRepresentation rep) {
634
688
case SILFunctionTypeRepresentation::Method:
635
689
case SILFunctionTypeRepresentation::WitnessMethod:
636
690
case SILFunctionTypeRepresentation::Closure:
691
+ case SILFunctionTypeRepresentation::KeyPathAccessorGetter:
692
+ case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
693
+ case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
694
+ case SILFunctionTypeRepresentation::KeyPathAccessorHash:
637
695
return SILFunctionLanguage::Swift;
638
696
}
639
697
@@ -652,20 +710,20 @@ class SILExtInfoBuilder {
652
710
// and NumMaskBits must be updated, and they must match.
653
711
654
712
// |representation|pseudogeneric| noescape | concurrent | async
655
- // | 0 .. 3 | 4 | 5 | 6 | 7
713
+ // | 0 .. 4 | 5 | 6 | 7 | 8
656
714
// |differentiability|unimplementable|
657
- // | 8 .. 10 | 11 |
715
+ // | 9 .. 11 | 12 |
658
716
//
659
717
enum : unsigned {
660
- RepresentationMask = 0xF << 0 ,
661
- PseudogenericMask = 1 << 4 ,
662
- NoEscapeMask = 1 << 5 ,
663
- SendableMask = 1 << 6 ,
664
- AsyncMask = 1 << 7 ,
665
- DifferentiabilityMaskOffset = 8 ,
718
+ RepresentationMask = 0x1F << 0 ,
719
+ PseudogenericMask = 1 << 5 ,
720
+ NoEscapeMask = 1 << 6 ,
721
+ SendableMask = 1 << 7 ,
722
+ AsyncMask = 1 << 8 ,
723
+ DifferentiabilityMaskOffset = 9 ,
666
724
DifferentiabilityMask = 0x7 << DifferentiabilityMaskOffset,
667
- UnimplementableMask = 1 << 11 ,
668
- NumMaskBits = 12
725
+ UnimplementableMask = 1 << 12 ,
726
+ NumMaskBits = 13
669
727
};
670
728
671
729
unsigned bits; // Naturally sized for speed.
@@ -765,6 +823,10 @@ class SILExtInfoBuilder {
765
823
case Representation::Thin:
766
824
case Representation::CFunctionPointer:
767
825
case Representation::Closure:
826
+ case Representation::KeyPathAccessorGetter:
827
+ case Representation::KeyPathAccessorSetter:
828
+ case Representation::KeyPathAccessorEquals:
829
+ case Representation::KeyPathAccessorHash:
768
830
return false ;
769
831
case Representation::ObjCMethod:
770
832
case Representation::Method:
@@ -788,6 +850,10 @@ class SILExtInfoBuilder {
788
850
case Representation::WitnessMethod:
789
851
case Representation::Closure:
790
852
case SILFunctionTypeRepresentation::CXXMethod:
853
+ case Representation::KeyPathAccessorGetter:
854
+ case Representation::KeyPathAccessorSetter:
855
+ case Representation::KeyPathAccessorEquals:
856
+ case Representation::KeyPathAccessorHash:
791
857
return false ;
792
858
}
793
859
llvm_unreachable (" Unhandled Representation in switch." );
0 commit comments