@@ -122,8 +122,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
122
122
// / information like knowledge of an enum case. Trivial values have no
123
123
// / ownership semantics.
124
124
// /
125
- // / * OperandConstraint : This represents a constraint on the values that can be
126
- // / used by a specific operand. Here Any is valid and is used for operands
125
+ // / * OwnershipConstraint : This represents a constraint on the values that can
126
+ // / be used by a specific operand. Here Any is valid and is used for operands
127
127
// / that don't care about the ownership kind (lack ownership constraints). In
128
128
// / contrast, a constraint of None is the most restrictive. It requires a
129
129
// / trivial value. An Unowned, Owned, or Guaranteed constraint requires either
@@ -588,6 +588,18 @@ inline bool ValueOwnershipKind::isCompatibleWith(SILValue other) const {
588
588
return isCompatibleWith (other.getOwnershipKind ());
589
589
}
590
590
591
+ // / Constraints on the ownership of an operand value.
592
+ // /
593
+ // / The ownershipKind component constrains the operand's value ownership to be
594
+ // / the same or "above" the constraint in the lattice, such that
595
+ // / join(constraint, valueOwnership) == valueOwnership. In other words, applying
596
+ // / the constraint does not change the value's ownership. For example, a value
597
+ // / with None ownership is accepted by any OwnershipConstraint, and an
598
+ // / OwnershipConstraint with 'Any' ownership kind can accept any value. Note
599
+ // / that operands commonly allow either Owned or Guaranteed operands. These
600
+ // / operands have an Any ownership constraint to allow either. However,
601
+ // / enforcement of Unowned value is more strict. This requires separate logic in
602
+ // / canAcceptUnownedValue() to avoid complicating the OwnershipKind lattice.
591
603
class OwnershipConstraint {
592
604
OwnershipKind ownershipKind;
593
605
UseLifetimeConstraint lifetimeConstraint;
@@ -746,6 +758,11 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
746
758
const OperandOwnership &operandOwnership);
747
759
748
760
// / Defined inline so the switch is eliminated for constant OperandOwnership.
761
+ // /
762
+ // / Here, an Any ownership constraint is used to allow either Owned or
763
+ // / Guaranteed values. However, enforcement of Unowned values is more
764
+ // / strict. This is handled by separate logic in canAcceptUnownedValue() to
765
+ // / avoid complicating the OwnershipKind lattice.
749
766
inline OwnershipConstraint OperandOwnership::getOwnershipConstraint () {
750
767
switch (value) {
751
768
case OperandOwnership::TrivialUse:
0 commit comments