@@ -117,6 +117,9 @@ class SILArgument : public ValueBase {
117
117
// / opposed to a cast or projection.
118
118
bool isPhiArgument () const ;
119
119
120
+ // / Return true if this block argument is a terminator result.
121
+ bool isTerminatorResult () const ;
122
+
120
123
// / If this argument is a phi, return the incoming phi value for the given
121
124
// / predecessor BB. If this argument is not a phi, return an invalid SILValue.
122
125
SILValue getIncomingPhiValue (SILBasicBlock *predBlock) const ;
@@ -178,6 +181,10 @@ class SILArgument : public ValueBase {
178
181
// / terminator has a single operand, return that terminator.
179
182
TermInst *getSingleTerminator () const ;
180
183
184
+ // / Return the terminator instruction for which this argument is a result,
185
+ // / otherwise return nullptr.
186
+ TermInst *getTerminatorForResultArg () const ;
187
+
181
188
// / Return the SILArgumentKind of this argument.
182
189
SILArgumentKind getKind () const {
183
190
return SILArgumentKind (ValueBase::getKind ());
@@ -208,6 +215,9 @@ class SILPhiArgument : public SILArgument {
208
215
// / opposed to a cast or projection.
209
216
bool isPhiArgument () const ;
210
217
218
+ // / Return true if this block argument is a terminator result.
219
+ bool isTerminatorResult () const { return !isPhiArgument (); }
220
+
211
221
// / If this argument is a phi, return the incoming phi value for the given
212
222
// / predecessor BB. If this argument is not a phi, return an invalid SILValue.
213
223
// /
@@ -283,6 +293,10 @@ class SILPhiArgument : public SILArgument {
283
293
// / terminator has a single operand, return that terminator.
284
294
TermInst *getSingleTerminator () const ;
285
295
296
+ // / Return the terminator instruction for which this argument is a result,
297
+ // / otherwise return nullptr.
298
+ TermInst *getTerminatorForResultArg () const ;
299
+
286
300
static bool classof (const SILInstruction *) = delete;
287
301
static bool classof (const SILUndef *) = delete;
288
302
static bool classof (SILNodePointer node) {
@@ -347,6 +361,16 @@ inline bool SILArgument::isPhiArgument() const {
347
361
llvm_unreachable (" Covered switch is not covered?!" );
348
362
}
349
363
364
+ inline bool SILArgument::isTerminatorResult () const {
365
+ switch (getKind ()) {
366
+ case SILArgumentKind::SILPhiArgument:
367
+ return cast<SILPhiArgument>(this )->isTerminatorResult ();
368
+ case SILArgumentKind::SILFunctionArgument:
369
+ return false ;
370
+ }
371
+ llvm_unreachable (" Covered switch is not covered?!" );
372
+ }
373
+
350
374
inline SILValue
351
375
SILArgument::getIncomingPhiValue (SILBasicBlock *predBlock) const {
352
376
switch (getKind ()) {
@@ -417,6 +441,16 @@ inline TermInst *SILArgument::getSingleTerminator() const {
417
441
llvm_unreachable (" Covered switch is not covered?!" );
418
442
}
419
443
444
+ inline TermInst *SILArgument::getTerminatorForResultArg () const {
445
+ switch (getKind ()) {
446
+ case SILArgumentKind::SILPhiArgument:
447
+ return cast<SILPhiArgument>(this )->getTerminatorForResultArg ();
448
+ case SILArgumentKind::SILFunctionArgument:
449
+ return nullptr ;
450
+ }
451
+ llvm_unreachable (" Covered switch is not covered?!" );
452
+ }
453
+
420
454
inline bool SILArgument::getIncomingPhiOperands (
421
455
SmallVectorImpl<Operand *> &returnedPhiOperands) const {
422
456
switch (getKind ()) {
0 commit comments