@@ -33,8 +33,10 @@ class Initialization;
33
33
class SILGenFunction ;
34
34
35
35
// / An "exploded" SIL rvalue, in which tuple values are recursively
36
- // / destructured. (In SILGen we don't try to explode structs, because doing so
37
- // / would require considering resilience, a job we want to delegate to IRGen).
36
+ // / destructured.
37
+ // /
38
+ // / *NOTE* In SILGen we don't try to explode structs, because doing so would
39
+ // / require considering resilience, a job we want to delegate to IRGen.
38
40
class RValue {
39
41
std::vector<ManagedValue> values;
40
42
CanType type;
@@ -60,12 +62,18 @@ class RValue {
60
62
elementsToBeAdded = Used;
61
63
values = {};
62
64
}
63
-
64
- // / Private constructor used by copy().
65
- RValue (const RValue &copied, SILGenFunction &SGF, SILLocation l);
66
-
67
- // / Construct an RValue from a pre-exploded set of
68
- // / ManagedValues. Used to implement the extractElement* methods.
65
+
66
+ // / Private constructor used by copy() and borrow().
67
+ RValue (std::vector<ManagedValue> &&values, CanType type,
68
+ unsigned elementsToBeAdded)
69
+ : values(std::move(values)), type(type),
70
+ elementsToBeAdded (elementsToBeAdded) {}
71
+
72
+ // / Construct an RValue from a pre-exploded set of ManagedValues.
73
+ // /
74
+ // / Used to implement the extractElement* methods. *NOTE* This constructor
75
+ // / assumes that the constructed RValue is fully formed and thus has
76
+ // / elementsToBeAdded set to zero.
69
77
RValue (ArrayRef<ManagedValue> values, CanType type);
70
78
71
79
RValue (unsigned state) : elementsToBeAdded(state) {
@@ -106,8 +114,9 @@ class RValue {
106
114
// / will be exploded.
107
115
RValue (SILGenFunction &SGF, SILLocation l, CanType type, ManagedValue v);
108
116
109
- // / Construct an RValue from a pre-exploded set of
110
- // / ManagedValues. Used to implement the extractElement* methods.
117
+ // / Construct an RValue from a pre-exploded set of ManagedValues.
118
+ // /
119
+ // / This is used to implement the extractElement* methods.
111
120
static RValue withPreExplodedElements (ArrayRef<ManagedValue> values,
112
121
CanType type);
113
122
@@ -259,9 +268,10 @@ class RValue {
259
268
}
260
269
261
270
// / Emit an equivalent value with independent ownership.
262
- RValue copy (SILGenFunction &SGF, SILLocation l) const & {
263
- return RValue (*this , SGF, l);
264
- }
271
+ RValue copy (SILGenFunction &SGF, SILLocation loc) const &;
272
+
273
+ // / Borrow all subvalues of the rvalue.
274
+ RValue borrow (SILGenFunction &SGF, SILLocation loc) const &;
265
275
266
276
static bool areObviouslySameValue (SILValue lhs, SILValue rhs);
267
277
bool isObviouslyEqual (const RValue &rhs) const ;
0 commit comments