@@ -66,7 +66,7 @@ bool isOwnedForwardingInstruction(SILInstruction *inst);
66
66
// / previous terminator.
67
67
bool isOwnedForwardingValue (SILValue value);
68
68
69
- struct BorrowScopeOperandKind {
69
+ struct BorrowingOperandKind {
70
70
enum Kind {
71
71
BeginBorrow,
72
72
BeginApply,
@@ -75,30 +75,29 @@ struct BorrowScopeOperandKind {
75
75
76
76
Kind value;
77
77
78
- BorrowScopeOperandKind (Kind newValue) : value(newValue) {}
79
- BorrowScopeOperandKind (const BorrowScopeOperandKind &other)
78
+ BorrowingOperandKind (Kind newValue) : value(newValue) {}
79
+ BorrowingOperandKind (const BorrowingOperandKind &other)
80
80
: value(other.value) {}
81
81
operator Kind () const { return value; }
82
82
83
- static Optional<BorrowScopeOperandKind > get (SILInstructionKind kind) {
83
+ static Optional<BorrowingOperandKind > get (SILInstructionKind kind) {
84
84
switch (kind) {
85
85
default :
86
86
return None;
87
87
case SILInstructionKind::BeginBorrowInst:
88
- return BorrowScopeOperandKind (BeginBorrow);
88
+ return BorrowingOperandKind (BeginBorrow);
89
89
case SILInstructionKind::BeginApplyInst:
90
- return BorrowScopeOperandKind (BeginApply);
90
+ return BorrowingOperandKind (BeginApply);
91
91
case SILInstructionKind::BranchInst:
92
- return BorrowScopeOperandKind (Branch);
92
+ return BorrowingOperandKind (Branch);
93
93
}
94
94
}
95
95
96
96
void print (llvm::raw_ostream &os) const ;
97
97
SWIFT_DEBUG_DUMP { print (llvm::dbgs ()); }
98
98
};
99
99
100
- llvm::raw_ostream &operator <<(llvm::raw_ostream &os,
101
- BorrowScopeOperandKind kind);
100
+ llvm::raw_ostream &operator <<(llvm::raw_ostream &os, BorrowingOperandKind kind);
102
101
103
102
struct BorrowedValue ;
104
103
@@ -111,11 +110,11 @@ struct BorrowedValue;
111
110
// / guaranteed value in the same function: see begin_apply. In such cases, we
112
111
// / require instead an end_* instruction to mark the end of the scope's region.
113
112
struct BorrowingOperand {
114
- BorrowScopeOperandKind kind;
113
+ BorrowingOperandKind kind;
115
114
Operand *op;
116
115
117
116
BorrowingOperand (Operand *op)
118
- : kind(*BorrowScopeOperandKind ::get (op->getUser ()->getKind())), op(op) {}
117
+ : kind(*BorrowingOperandKind ::get (op->getUser ()->getKind())), op(op) {}
119
118
BorrowingOperand (const BorrowingOperand &other)
120
119
: kind(other.kind), op(other.op) {}
121
120
BorrowingOperand &operator =(const BorrowingOperand &other) {
@@ -127,7 +126,7 @@ struct BorrowingOperand {
127
126
// / If value is a borrow introducer return it after doing some checks.
128
127
static Optional<BorrowingOperand> get (Operand *op) {
129
128
auto *user = op->getUser ();
130
- auto kind = BorrowScopeOperandKind ::get (user->getKind ());
129
+ auto kind = BorrowingOperandKind ::get (user->getKind ());
131
130
if (!kind)
132
131
return None;
133
132
return BorrowingOperand (*kind, op);
@@ -139,10 +138,10 @@ struct BorrowingOperand {
139
138
// / values and produces a new scope afterwards.
140
139
bool consumesGuaranteedValues () const {
141
140
switch (kind) {
142
- case BorrowScopeOperandKind ::BeginBorrow:
143
- case BorrowScopeOperandKind ::BeginApply:
141
+ case BorrowingOperandKind ::BeginBorrow:
142
+ case BorrowingOperandKind ::BeginApply:
144
143
return false ;
145
- case BorrowScopeOperandKind ::Branch:
144
+ case BorrowingOperandKind ::Branch:
146
145
return true ;
147
146
}
148
147
llvm_unreachable (" Covered switch isn't covered?!" );
@@ -152,10 +151,10 @@ struct BorrowingOperand {
152
151
// / for owned values.
153
152
bool canAcceptOwnedValues () const {
154
153
switch (kind) {
155
- case BorrowScopeOperandKind ::BeginBorrow:
156
- case BorrowScopeOperandKind ::BeginApply:
154
+ case BorrowingOperandKind ::BeginBorrow:
155
+ case BorrowingOperandKind ::BeginApply:
157
156
return true ;
158
- case BorrowScopeOperandKind ::Branch:
157
+ case BorrowingOperandKind ::Branch:
159
158
return false ;
160
159
}
161
160
llvm_unreachable (" Covered switch isn't covered?!" );
@@ -167,10 +166,10 @@ struct BorrowingOperand {
167
166
bool areAnyUserResultsBorrowIntroducers () const {
168
167
// TODO: Can we derive this by running a borrow introducer check ourselves?
169
168
switch (kind) {
170
- case BorrowScopeOperandKind ::BeginBorrow:
171
- case BorrowScopeOperandKind ::Branch:
169
+ case BorrowingOperandKind ::BeginBorrow:
170
+ case BorrowingOperandKind ::Branch:
172
171
return true ;
173
- case BorrowScopeOperandKind ::BeginApply:
172
+ case BorrowingOperandKind ::BeginApply:
174
173
return false ;
175
174
}
176
175
llvm_unreachable (" Covered switch isn't covered?!" );
@@ -201,7 +200,7 @@ struct BorrowingOperand {
201
200
private:
202
201
// / Internal constructor for failable static constructor. Please do not expand
203
202
// / its usage since it assumes the code passed in is well formed.
204
- BorrowingOperand (BorrowScopeOperandKind kind, Operand *op)
203
+ BorrowingOperand (BorrowingOperandKind kind, Operand *op)
205
204
: kind(kind), op(op) {}
206
205
};
207
206
0 commit comments