Skip to content

Commit 12ffdd3

Browse files
authored
Merge pull request #32885 from gottesmm/pr-9162e369eb8d716656842a8502a098f9c43a8423
[ownership] Update LowerAggregateInstrs for Ownership
2 parents 3882beb + ba46bc4 commit 12ffdd3

File tree

8 files changed

+855
-120
lines changed

8 files changed

+855
-120
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,27 @@ class SILBuilder {
725725
return lowering.emitLoad(*this, Loc, LV, Qualifier);
726726
}
727727

728+
/// Convenience function for calling emitLoad on the type lowering for
729+
/// non-address values.
730+
SILValue emitLoweredLoadValueOperation(
731+
SILLocation Loc, SILValue LV, LoadOwnershipQualifier Qualifier,
732+
Lowering::TypeLowering::TypeExpansionKind ExpansionKind) {
733+
assert(isLoadableOrOpaque(LV->getType()));
734+
const auto &lowering = getTypeLowering(LV->getType());
735+
return lowering.emitLoweredLoad(*this, Loc, LV, Qualifier, ExpansionKind);
736+
}
737+
738+
/// Convenience function for calling emitLoweredStore on the type lowering for
739+
/// non-address values.
740+
void emitLoweredStoreValueOperation(
741+
SILLocation Loc, SILValue Value, SILValue Addr,
742+
StoreOwnershipQualifier Qual,
743+
Lowering::TypeLowering::TypeExpansionKind ExpansionKind) {
744+
assert(isLoadableOrOpaque(Value->getType()));
745+
const auto &lowering = getTypeLowering(Value->getType());
746+
lowering.emitLoweredStore(*this, Loc, Value, Addr, Qual, ExpansionKind);
747+
}
748+
728749
LoadBorrowInst *createLoadBorrow(SILLocation Loc, SILValue LV) {
729750
assert(isLoadableOrOpaque(LV->getType()) &&
730751
!LV->getType().isTrivial(getFunction()));
@@ -2186,6 +2207,16 @@ class SILBuilder {
21862207
return lowering.emitCopyValue(*this, Loc, v);
21872208
}
21882209

2210+
/// Convenience function for calling emitCopy on the type lowering
2211+
/// for the non-address value.
2212+
SILValue emitLoweredCopyValueOperation(
2213+
SILLocation Loc, SILValue v,
2214+
Lowering::TypeLowering::TypeExpansionKind expansionKind) {
2215+
assert(!v->getType().isAddress());
2216+
auto &lowering = getTypeLowering(v->getType());
2217+
return lowering.emitLoweredCopyValue(*this, Loc, v, expansionKind);
2218+
}
2219+
21892220
/// Convenience function for calling TypeLowering.emitDestroy on the type
21902221
/// lowering for the non-address value.
21912222
void emitDestroyValueOperation(SILLocation Loc, SILValue v) {
@@ -2196,6 +2227,18 @@ class SILBuilder {
21962227
lowering.emitDestroyValue(*this, Loc, v);
21972228
}
21982229

2230+
/// Convenience function for calling TypeLowering.emitDestroy on the type
2231+
/// lowering for the non-address value.
2232+
void emitLoweredDestroyValueOperation(
2233+
SILLocation Loc, SILValue v,
2234+
Lowering::TypeLowering::TypeExpansionKind expansionKind) {
2235+
assert(!v->getType().isAddress());
2236+
if (F->hasOwnership() && v.getOwnershipKind() == ValueOwnershipKind::None)
2237+
return;
2238+
auto &lowering = getTypeLowering(v->getType());
2239+
lowering.emitLoweredDestroyValue(*this, Loc, v, expansionKind);
2240+
}
2241+
21992242
/// Convenience function for destroying objects and addresses.
22002243
///
22012244
/// Objects are destroyed using emitDestroyValueOperation and addresses by

include/swift/SIL/TypeLowering.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,28 @@ class TypeLowering {
391391
///> types.
392392
};
393393

394+
/// Emit a load from \p addr given the LoadOwnershipQualifier \p qual.
395+
///
396+
/// This abstracts over the differences in between trivial and non-trivial
397+
/// types and lets one specify an expansion kind that gets passed to any
398+
/// copy_value that we create.
399+
virtual SILValue emitLoweredLoad(
400+
SILBuilder &B, SILLocation loc, SILValue addr,
401+
LoadOwnershipQualifier qual,
402+
Lowering::TypeLowering::TypeExpansionKind expansionKind) const = 0;
403+
404+
/// Emit a store of \p value into \p addr given the StoreOwnershipQualifier
405+
/// qual.
406+
///
407+
/// This abstracts over the differences in between trivial and non-trivial
408+
/// types and allows for one to specify an expansion kind that is passed to
409+
/// any destroy operations we create if we are asked to assign in non-ossa
410+
/// code.
411+
virtual void emitLoweredStore(
412+
SILBuilder &B, SILLocation loc, SILValue value, SILValue addr,
413+
StoreOwnershipQualifier qual,
414+
Lowering::TypeLowering::TypeExpansionKind expansionKind) const = 0;
415+
394416
//===--------------------------------------------------------------------===//
395417
// DestroyValue
396418
//===--------------------------------------------------------------------===//

0 commit comments

Comments
 (0)