Skip to content

Commit 282e335

Browse files
committed
Handle mutate accessors similar to borrow accessors in call emission
1 parent 3103be6 commit 282e335

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5225,7 +5225,7 @@ class CallEmission {
52255225

52265226
CleanupHandle applyCoroutine(SmallVectorImpl<ManagedValue> &yields);
52275227

5228-
ManagedValue applyBorrowAccessor();
5228+
ManagedValue applyBorrowMutateAccessor();
52295229

52305230
RValue apply(SGFContext C = SGFContext()) {
52315231
initialWritebackScope.verify();
@@ -5426,7 +5426,7 @@ CleanupHandle SILGenFunction::emitBeginApply(
54265426
return endApplyHandle;
54275427
}
54285428

5429-
ManagedValue CallEmission::applyBorrowAccessor() {
5429+
ManagedValue CallEmission::applyBorrowMutateAccessor() {
54305430
auto origFormalType = callee.getOrigFormalType();
54315431
// Get the callee type information.
54325432
auto calleeTypeInfo = callee.getTypeInfo(SGF);
@@ -5453,14 +5453,14 @@ ManagedValue CallEmission::applyBorrowAccessor() {
54535453
lookThroughMoveOnlyCheckerPattern(selfArgMV.getValue()));
54545454
}
54555455

5456-
auto value = SGF.applyBorrowAccessor(uncurriedLoc.value(), fnValue, canUnwind,
5457-
callee.getSubstitutions(), uncurriedArgs,
5458-
calleeTypeInfo.substFnType, options);
5456+
auto value = SGF.applyBorrowMutateAccessor(
5457+
uncurriedLoc.value(), fnValue, canUnwind, callee.getSubstitutions(),
5458+
uncurriedArgs, calleeTypeInfo.substFnType, options);
54595459

54605460
return value;
54615461
}
54625462

5463-
ManagedValue SILGenFunction::applyBorrowAccessor(
5463+
ManagedValue SILGenFunction::applyBorrowMutateAccessor(
54645464
SILLocation loc, ManagedValue fn, bool canUnwind, SubstitutionMap subs,
54655465
ArrayRef<ManagedValue> args, CanSILFunctionType substFnType,
54665466
ApplyOptions options) {
@@ -7888,7 +7888,7 @@ SILGenFunction::emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,
78887888
return endApplyHandle;
78897889
}
78907890

7891-
ManagedValue SILGenFunction::emitBorrowAccessor(
7891+
ManagedValue SILGenFunction::emitBorrowMutateAccessor(
78927892
SILLocation loc, SILDeclRef accessor, SubstitutionMap substitutions,
78937893
ArgumentSource &&selfValue, bool isSuper, bool isDirectUse,
78947894
PreparedArguments &&subscriptIndices, bool isOnSelfParameter) {
@@ -7913,7 +7913,7 @@ ManagedValue SILGenFunction::emitBorrowAccessor(
79137913

79147914
emission.setCanUnwind(false);
79157915

7916-
return emission.applyBorrowAccessor();
7916+
return emission.applyBorrowMutateAccessor();
79177917
}
79187918

79197919
ManagedValue SILGenFunction::emitAsyncLetStart(

lib/SILGen/SILGenFunction.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,18 +2079,18 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
20792079
SmallVectorImpl<ManagedValue> &yields,
20802080
bool isOnSelfParameter);
20812081

2082-
ManagedValue emitBorrowAccessor(SILLocation loc, SILDeclRef accessor,
2083-
SubstitutionMap substitutions,
2084-
ArgumentSource &&selfValue, bool isSuper,
2085-
bool isDirectUse,
2086-
PreparedArguments &&subscriptIndices,
2087-
bool isOnSelfParameter);
2088-
2089-
ManagedValue applyBorrowAccessor(SILLocation loc, ManagedValue fn,
2090-
bool canUnwind, SubstitutionMap subs,
2091-
ArrayRef<ManagedValue> args,
2092-
CanSILFunctionType substFnType,
2093-
ApplyOptions options);
2082+
ManagedValue emitBorrowMutateAccessor(SILLocation loc, SILDeclRef accessor,
2083+
SubstitutionMap substitutions,
2084+
ArgumentSource &&selfValue,
2085+
bool isSuper, bool isDirectUse,
2086+
PreparedArguments &&subscriptIndices,
2087+
bool isOnSelfParameter);
2088+
2089+
ManagedValue applyBorrowMutateAccessor(SILLocation loc, ManagedValue fn,
2090+
bool canUnwind, SubstitutionMap subs,
2091+
ArrayRef<ManagedValue> args,
2092+
CanSILFunctionType substFnType,
2093+
ApplyOptions options);
20942094

20952095
RValue emitApplyConversionFunction(SILLocation loc,
20962096
Expr *funcExpr,

lib/SILGen/SILGenLValue.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,15 +2286,16 @@ namespace {
22862286
namespace {
22872287

22882288
/// A physical component which involves calling borrow accessors.
2289-
class BorrowAccessorComponent
2289+
class BorrowMutateAccessorComponent
22902290
: public AccessorBasedComponent<PhysicalPathComponent> {
22912291
public:
2292-
BorrowAccessorComponent(AbstractStorageDecl *decl, SILDeclRef accessor,
2293-
bool isSuper, bool isDirectAccessorUse,
2294-
SubstitutionMap substitutions, CanType baseFormalType,
2295-
LValueTypeData typeData,
2296-
ArgumentList *argListForDiagnostics,
2297-
PreparedArguments &&indices, bool isOnSelfParameter)
2292+
BorrowMutateAccessorComponent(AbstractStorageDecl *decl, SILDeclRef accessor,
2293+
bool isSuper, bool isDirectAccessorUse,
2294+
SubstitutionMap substitutions,
2295+
CanType baseFormalType, LValueTypeData typeData,
2296+
ArgumentList *argListForDiagnostics,
2297+
PreparedArguments &&indices,
2298+
bool isOnSelfParameter)
22982299
: AccessorBasedComponent(BorrowMutateKind, decl, accessor, isSuper,
22992300
isDirectAccessorUse, substitutions,
23002301
baseFormalType, typeData, argListForDiagnostics,
@@ -2311,14 +2312,14 @@ class BorrowAccessorComponent
23112312
ManagedValue result;
23122313

23132314
auto args = std::move(*this).prepareAccessorArgs(SGF, loc, base, Accessor);
2314-
auto value = SGF.emitBorrowAccessor(
2315+
auto value = SGF.emitBorrowMutateAccessor(
23152316
loc, Accessor, Substitutions, std::move(args.base), IsSuper,
23162317
IsDirectAccessorUse, std::move(args.Indices), IsOnSelfParameter);
23172318
return value;
23182319
}
23192320

23202321
void dump(raw_ostream &OS, unsigned indent) const override {
2321-
printBase(OS, indent, "BorrowAccessorComponent");
2322+
printBase(OS, indent, "BorrowMutateAccessorComponent");
23222323
}
23232324
};
23242325
} // namespace
@@ -3427,16 +3428,15 @@ namespace {
34273428
AccessKind, FormalRValueType);
34283429
return asImpl().emitUsingInitAccessor(accessor, isDirect, typeData);
34293430
}
3430-
case AccessorKind::Borrow: {
3431+
case AccessorKind::Borrow:
3432+
case AccessorKind::Mutate: {
34313433
auto typeData = getPhysicalStorageTypeData(
34323434
SGF.getTypeExpansionContext(), SGF.SGM, AccessKind, Storage, Subs,
34333435
FormalRValueType);
3434-
return asImpl().emitUsingBorrowAccessor(accessor, isDirect, typeData);
3436+
return asImpl().emitUsingBorrowMutateAccessor(accessor, isDirect,
3437+
typeData);
34353438
}
3436-
case AccessorKind::Mutate:
3437-
llvm_unreachable("mutate accessor is not yet implemented");
34383439
}
3439-
34403440
llvm_unreachable("bad kind");
34413441
}
34423442
};
@@ -3526,9 +3526,9 @@ void LValue::addNonMemberVarComponent(
35263526
PreparedArguments(), /*isOnSelfParameter*/ false);
35273527
}
35283528

3529-
void emitUsingBorrowAccessor(SILDeclRef accessor, bool isDirect,
3530-
LValueTypeData typeData) {
3531-
llvm_unreachable("borrow accessor is not implemented");
3529+
void emitUsingBorrowMutateAccessor(SILDeclRef accessor, bool isDirect,
3530+
LValueTypeData typeData) {
3531+
llvm_unreachable("borrow/mutate accessor is not implemented");
35323532
}
35333533

35343534
void emitUsingGetterSetter(SILDeclRef accessor,
@@ -4211,10 +4211,10 @@ struct MemberStorageAccessEmitter : AccessEmitter<Impl, StorageType> {
42114211
ArgListForDiagnostics, std::move(Indices), IsOnSelfParameter);
42124212
}
42134213

4214-
void emitUsingBorrowAccessor(SILDeclRef accessor, bool isDirect,
4215-
LValueTypeData typeData) {
4214+
void emitUsingBorrowMutateAccessor(SILDeclRef accessor, bool isDirect,
4215+
LValueTypeData typeData) {
42164216
assert(!ActorIso);
4217-
LV.add<BorrowAccessorComponent>(
4217+
LV.add<BorrowMutateAccessorComponent>(
42184218
Storage, accessor, IsSuper, isDirect, Subs, BaseFormalType, typeData,
42194219
ArgListForDiagnostics, std::move(Indices), IsOnSelfParameter);
42204220
}

0 commit comments

Comments
 (0)