Skip to content

[sil] Define ValueOwnershipKind::isCompatibleWith(SILValue v). #33293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions include/swift/SIL/SILValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class SILLocation;
class DeadEndBlocks;
class ValueBaseUseIterator;
class ValueUseIterator;
class SILValue;

/// An enumeration which contains values for all the concrete ValueBase
/// subclasses.
Expand Down Expand Up @@ -188,6 +189,12 @@ struct ValueOwnershipKind {
return merge(other).hasValue();
}

/// Returns isCompatibleWith(other.getOwnershipKind()).
///
/// Definition is inline after SILValue is defined to work around circular
/// dependencies.
bool isCompatibleWith(SILValue other) const;

template <typename RangeTy>
static Optional<ValueOwnershipKind> merge(RangeTy &&r) {
auto initial = Optional<ValueOwnershipKind>(ValueOwnershipKind::None);
Expand Down Expand Up @@ -440,6 +447,10 @@ class SILValue {
void verifyOwnership(DeadEndBlocks *DEBlocks = nullptr) const;
};

inline bool ValueOwnershipKind::isCompatibleWith(SILValue other) const {
return isCompatibleWith(other.getOwnershipKind());
}

/// A map from a ValueOwnershipKind that an operand can accept to a
/// UseLifetimeConstraint that describes the effect that the operand's use has
/// on the underlying value. If a ValueOwnershipKind is not in this map then
Expand Down