@@ -66,6 +66,8 @@ bool requiresForeignEntryPoint(ValueDecl *vd);
66
66
// / True if the entry point is natively foreign.
67
67
bool requiresForeignToNativeThunk (ValueDecl *vd);
68
68
69
+ unsigned getNaturalUncurryLevel (ValueDecl *vd);
70
+
69
71
enum ForDefinition_t : bool {
70
72
NotForDefinition = false ,
71
73
ForDefinition = true
@@ -144,8 +146,6 @@ struct SILDeclRef {
144
146
Loc loc;
145
147
// / The Kind of this SILDeclRef.
146
148
Kind kind : 4 ;
147
- // / The uncurry level of this SILDeclRef.
148
- unsigned uncurryLevel : 8 ;
149
149
// / The required resilience expansion of the declaration.
150
150
unsigned Expansion : 1 ;
151
151
// / True if the SILDeclRef is a curry thunk.
@@ -158,28 +158,19 @@ struct SILDeclRef {
158
158
// / The default argument index for a default argument getter.
159
159
unsigned defaultArgIndex : 10 ;
160
160
161
- // / A magic value for SILDeclRef constructors to ask for the natural uncurry
162
- // / level of the constant.
163
- enum : unsigned { ConstructAtNaturalUncurryLevel = ~0U };
164
-
165
- // / A magic value for SILDeclRef constructors to ask for the best
166
- // / available resilience expansion of the constant.
167
- static constexpr ResilienceExpansion ConstructAtBestResilienceExpansion
168
- = /* TODO*/ ResilienceExpansion::Minimal;
169
-
170
161
// / Produces a null SILDeclRef.
171
- SILDeclRef () : loc(), kind(Kind::Func), uncurryLevel( 0 ), Expansion(0 ),
162
+ SILDeclRef () : loc(), kind(Kind::Func), Expansion(0 ),
172
163
isCurried (0 ), isForeign(0 ), isDirectReference(0 ),
173
164
defaultArgIndex(0 ) {}
174
165
175
166
// / Produces a SILDeclRef of the given kind for the given decl.
176
167
explicit SILDeclRef (ValueDecl *decl, Kind kind,
177
168
ResilienceExpansion expansion
178
169
= ResilienceExpansion::Minimal,
179
- unsigned uncurryLevel = ConstructAtNaturalUncurryLevel ,
170
+ bool isCurried = false ,
180
171
bool isForeign = false );
181
172
182
- // / Produces the 'natural' SILDeclRef for the given ValueDecl or
173
+ // / Produces a SILDeclRef for the given ValueDecl or
183
174
// / AbstractClosureExpr:
184
175
// / - If 'loc' is a func or closure, this returns a Func SILDeclRef.
185
176
// / - If 'loc' is a ConstructorDecl, this returns the Allocator SILDeclRef
@@ -190,13 +181,15 @@ struct SILDeclRef {
190
181
// / for the containing ClassDecl.
191
182
// / - If 'loc' is a global VarDecl, this returns its GlobalAccessor
192
183
// / SILDeclRef.
193
- // / If the uncurry level is unspecified or specified as NaturalUncurryLevel,
194
- // / then the SILDeclRef for the natural uncurry level of the definition is
195
- // / used.
184
+ // /
185
+ // / If 'isCurried' is true, the loc must be a method or enum element;
186
+ // / the SILDeclRef will then refer to a curry thunk with type
187
+ // / (Self) -> (Args...) -> Result, rather than a direct reference to
188
+ // / the actual method whose lowered type is (Args..., Self) -> Result.
196
189
explicit SILDeclRef (Loc loc,
197
190
ResilienceExpansion expansion
198
191
= ResilienceExpansion::Minimal,
199
- unsigned uncurryLevel = ConstructAtNaturalUncurryLevel ,
192
+ bool isCurried = false ,
200
193
bool isForeign = false );
201
194
202
195
// / Produce a SIL constant for a default argument generator.
@@ -284,7 +277,7 @@ struct SILDeclRef {
284
277
llvm::hash_code getHashCode () const {
285
278
return llvm::hash_combine (loc.getOpaqueValue (),
286
279
static_cast <int >(kind),
287
- Expansion, uncurryLevel ,
280
+ Expansion, isCurried ,
288
281
isForeign, isDirectReference,
289
282
defaultArgIndex);
290
283
}
@@ -293,7 +286,7 @@ struct SILDeclRef {
293
286
return loc.getOpaqueValue () == rhs.loc .getOpaqueValue ()
294
287
&& kind == rhs.kind
295
288
&& Expansion == rhs.Expansion
296
- && uncurryLevel == rhs.uncurryLevel
289
+ && isCurried == rhs.isCurried
297
290
&& isForeign == rhs.isForeign
298
291
&& isDirectReference == rhs.isDirectReference
299
292
&& defaultArgIndex == rhs.defaultArgIndex ;
@@ -305,26 +298,28 @@ struct SILDeclRef {
305
298
void print (llvm::raw_ostream &os) const ;
306
299
void dump () const ;
307
300
301
+ unsigned getUncurryLevel () const ;
302
+
308
303
ResilienceExpansion getResilienceExpansion () const {
309
304
return ResilienceExpansion (Expansion);
310
305
}
311
306
312
307
// Returns the SILDeclRef for an entity at a shallower uncurry level.
313
- SILDeclRef atUncurryLevel (unsigned level) const {
314
- assert (level <= uncurryLevel && " can't safely go to deeper uncurry level" );
315
- bool willBeCurried = isCurried || level < uncurryLevel;
308
+ SILDeclRef asCurried (bool curried = true ) const {
309
+ assert (!isCurried && " can't safely go to deeper uncurry level" );
316
310
// Curry thunks are never foreign.
317
- bool willBeForeign = isForeign && !willBeCurried ;
311
+ bool willBeForeign = isForeign && !curried ;
318
312
bool willBeDirect = isDirectReference;
319
- return SILDeclRef (loc.getOpaqueValue (), kind, Expansion, level,
320
- willBeCurried , willBeDirect, willBeForeign,
313
+ return SILDeclRef (loc.getOpaqueValue (), kind, Expansion,
314
+ curried , willBeDirect, willBeForeign,
321
315
defaultArgIndex);
322
316
}
323
317
324
318
// / Returns the foreign (or native) entry point corresponding to the same
325
319
// / decl.
326
320
SILDeclRef asForeign (bool foreign = true ) const {
327
- return SILDeclRef (loc.getOpaqueValue (), kind, Expansion, uncurryLevel,
321
+ assert (!isCurried);
322
+ return SILDeclRef (loc.getOpaqueValue (), kind, Expansion,
328
323
isCurried, isDirectReference, foreign, defaultArgIndex);
329
324
}
330
325
@@ -379,13 +374,13 @@ struct SILDeclRef {
379
374
explicit SILDeclRef (void *opaqueLoc,
380
375
Kind kind,
381
376
unsigned rawExpansion,
382
- unsigned uncurryLevel,
383
377
bool isCurried,
384
378
bool isDirectReference,
385
379
bool isForeign,
386
380
unsigned defaultArgIndex)
387
381
: loc(Loc::getFromOpaqueValue(opaqueLoc)),
388
- kind(kind), uncurryLevel(uncurryLevel), Expansion(rawExpansion),
382
+ kind(kind),
383
+ Expansion(rawExpansion),
389
384
isCurried(isCurried),
390
385
isForeign(isForeign), isDirectReference(isDirectReference),
391
386
defaultArgIndex(defaultArgIndex)
@@ -413,18 +408,18 @@ template<> struct DenseMapInfo<swift::SILDeclRef> {
413
408
414
409
static SILDeclRef getEmptyKey () {
415
410
return SILDeclRef (PointerInfo::getEmptyKey (), Kind::Func,
416
- 0 , 0 , false , false , false , 0 );
411
+ 0 , false , false , false , 0 );
417
412
}
418
413
static SILDeclRef getTombstoneKey () {
419
414
return SILDeclRef (PointerInfo::getTombstoneKey (), Kind::Func,
420
- 0 , 0 , false , false , false , 0 );
415
+ 0 , false , false , false , 0 );
421
416
}
422
417
static unsigned getHashValue (swift::SILDeclRef Val) {
423
418
unsigned h1 = PointerInfo::getHashValue (Val.loc .getOpaqueValue ());
424
419
unsigned h2 = UnsignedInfo::getHashValue (unsigned (Val.kind ));
425
420
unsigned h3 = (Val.kind == Kind::DefaultArgGenerator)
426
421
? UnsignedInfo::getHashValue (Val.defaultArgIndex )
427
- : UnsignedInfo::getHashValue (Val.uncurryLevel );
422
+ : UnsignedInfo::getHashValue (Val.isCurried );
428
423
unsigned h4 = UnsignedInfo::getHashValue (Val.isForeign );
429
424
unsigned h5 = UnsignedInfo::getHashValue (Val.isDirectReference );
430
425
return h1 ^ (h2 << 4 ) ^ (h3 << 9 ) ^ (h4 << 7 ) ^ (h5 << 11 );
0 commit comments