@@ -51,59 +51,70 @@ static inline llvm::hash_code hash_value(ValueKind K) {
51
51
52
52
// / A value representing the specific ownership semantics that a SILValue may
53
53
// / have.
54
- enum class ValueOwnershipKind : uint8_t {
55
- // / A SILValue with Trivial ownership kind is an independent value that can
56
- // / not be owned. Ownership does not place any constraints on how a SILValue
57
- // / with Trivial ownership kind can be used. Other side effects (e.g. Memory
58
- // / dependencies) must still be respected. A SILValue with Trivial ownership
59
- // / kind must be of Trivial SILType (i.e. SILType::isTrivial(SILModule &) must
60
- // / return true).
61
- // /
62
- // / Some examples of SIL types with Trivial ownership are: Builtin.Int32,
63
- // / Builtin.RawPointer, aggregates containing all trivial types.
64
- Trivial,
65
-
66
- // / A SILValue with `Unowned` ownership kind is an independent value that has
67
- // / a lifetime that is only guaranteed to last until the next program visible
68
- // / side-effect. To maintain the lifetime of an unowned value, it must be
69
- // / converted to an owned representation via a copy_value.
70
- // /
71
- // / Unowned ownership kind occurs mainly along method/function boundaries in
72
- // / between Swift and Objective-C code.
73
- Unowned,
74
-
75
- // / A SILValue with `Owned` ownership kind is an independent value that has an
76
- // / ownership independent of any other ownership imbued within it. The
77
- // / SILValue must be paired with a consuming operation that ends the SSA
78
- // / value's lifetime exactly once along all paths through the program.
79
- Owned,
80
-
81
- // / A SILValue with `Guaranteed` ownership kind is an independent value that
82
- // / is guaranteed to be live over a specific region of the program. This
83
- // / region can come in several forms:
84
- // /
85
- // / 1. @guaranteed function argument. This guarantees that a value will
86
- // / outlive a function.
87
- // /
88
- // / 2. A shared borrow region. This is a region denoted by a
89
- // / begin_borrow/load_borrow instruction and an end_borrow instruction. The
90
- // / SSA value must not be destroyed or taken inside the borrowed region.
91
- // /
92
- // / Any value with guaranteed ownership must be paired with an end_borrow
93
- // / instruction exactly once along any path through the program.
94
- Guaranteed,
95
-
96
- // / A SILValue with undefined ownership. It can pair with /Any/ ownership
97
- // / kinds . This means that it could take on /any/ ownership semantics. This
98
- // / is meant only to model SILUndef and to express certain situations where we
99
- // / use unqualified ownership. Expected to tighten over time.
100
- Any,
54
+ struct ValueOwnershipKind {
55
+ enum innerty : uint8_t {
56
+ // / A SILValue with Trivial ownership kind is an independent value that can
57
+ // / not be owned. Ownership does not place any constraints on how a SILValue
58
+ // / with Trivial ownership kind can be used. Other side effects (e.g. Memory
59
+ // / dependencies) must still be respected. A SILValue with Trivial ownership
60
+ // / kind must be of Trivial SILType (i.e. SILType::isTrivial(SILModule &)
61
+ // / must
62
+ // / return true).
63
+ // /
64
+ // / Some examples of SIL types with Trivial ownership are: Builtin.Int32,
65
+ // / Builtin.RawPointer, aggregates containing all trivial types.
66
+ Trivial,
67
+
68
+ // / A SILValue with `Unowned` ownership kind is an independent value that
69
+ // / has
70
+ // / a lifetime that is only guaranteed to last until the next program
71
+ // / visible
72
+ // / side-effect. To maintain the lifetime of an unowned value, it must be
73
+ // / converted to an owned representation via a copy_value.
74
+ // /
75
+ // / Unowned ownership kind occurs mainly along method/function boundaries in
76
+ // / between Swift and Objective-C code.
77
+ Unowned,
78
+
79
+ // / A SILValue with `Owned` ownership kind is an independent value that has
80
+ // / an
81
+ // / ownership independent of any other ownership imbued within it. The
82
+ // / SILValue must be paired with a consuming operation that ends the SSA
83
+ // / value's lifetime exactly once along all paths through the program.
84
+ Owned,
85
+
86
+ // / A SILValue with `Guaranteed` ownership kind is an independent value that
87
+ // / is guaranteed to be live over a specific region of the program. This
88
+ // / region can come in several forms:
89
+ // /
90
+ // / 1. @guaranteed function argument. This guarantees that a value will
91
+ // / outlive a function.
92
+ // /
93
+ // / 2. A shared borrow region. This is a region denoted by a
94
+ // / begin_borrow/load_borrow instruction and an end_borrow instruction. The
95
+ // / SSA value must not be destroyed or taken inside the borrowed region.
96
+ // /
97
+ // / Any value with guaranteed ownership must be paired with an end_borrow
98
+ // / instruction exactly once along any path through the program.
99
+ Guaranteed,
100
+
101
+ // / A SILValue with undefined ownership. It can pair with /Any/ ownership
102
+ // / kinds . This means that it could take on /any/ ownership semantics. This
103
+ // / is meant only to model SILUndef and to express certain situations where
104
+ // / we
105
+ // / use unqualified ownership. Expected to tighten over time.
106
+ Any,
107
+ } Value;
108
+
109
+ ValueOwnershipKind (innerty NewValue) : Value(NewValue) {}
110
+ ValueOwnershipKind (SILModule &M, SILType Type,
111
+ SILArgumentConvention Convention);
112
+
113
+ operator innerty () const { return Value; }
114
+
115
+ Optional<ValueOwnershipKind> merge (ValueOwnershipKind RHS) const ;
101
116
};
102
117
103
- Optional<ValueOwnershipKind>
104
- ValueOwnershipKindMerge (Optional<ValueOwnershipKind> LHS,
105
- Optional<ValueOwnershipKind> RHS);
106
-
107
118
llvm::raw_ostream &operator <<(llvm::raw_ostream &os, ValueOwnershipKind Kind);
108
119
109
120
// / This is the base class of the SIL value hierarchy, which represents a
0 commit comments