@@ -117,6 +117,9 @@ class SILArgument : public ValueBase {
117117 // / opposed to a cast or projection.
118118 bool isPhiArgument () const ;
119119
120+ // / Return true if this block argument is a terminator result.
121+ bool isTerminatorResult () const ;
122+
120123 // / If this argument is a phi, return the incoming phi value for the given
121124 // / predecessor BB. If this argument is not a phi, return an invalid SILValue.
122125 SILValue getIncomingPhiValue (SILBasicBlock *predBlock) const ;
@@ -208,6 +211,9 @@ class SILPhiArgument : public SILArgument {
208211 // / opposed to a cast or projection.
209212 bool isPhiArgument () const ;
210213
214+ // / Return true if this block argument is a terminator result.
215+ bool isTerminatorResult () const { return !isPhiArgument (); }
216+
211217 // / If this argument is a phi, return the incoming phi value for the given
212218 // / predecessor BB. If this argument is not a phi, return an invalid SILValue.
213219 // /
@@ -283,6 +289,10 @@ class SILPhiArgument : public SILArgument {
283289 // / terminator has a single operand, return that terminator.
284290 TermInst *getSingleTerminator () const ;
285291
292+ // / Return the terminator instruction of which this argument is a result or
293+ // / nullptr.
294+ TermInst *getTransformingTerminator () const ;
295+
286296 static bool classof (const SILInstruction *) = delete;
287297 static bool classof (const SILUndef *) = delete;
288298 static bool classof (SILNodePointer node) {
@@ -347,6 +357,16 @@ inline bool SILArgument::isPhiArgument() const {
347357 llvm_unreachable (" Covered switch is not covered?!" );
348358}
349359
360+ inline bool SILArgument::isTerminatorResult () const {
361+ switch (getKind ()) {
362+ case SILArgumentKind::SILPhiArgument:
363+ return cast<SILPhiArgument>(this )->isTerminatorResult ();
364+ case SILArgumentKind::SILFunctionArgument:
365+ return false ;
366+ }
367+ llvm_unreachable (" Covered switch is not covered?!" );
368+ }
369+
350370inline SILValue
351371SILArgument::getIncomingPhiValue (SILBasicBlock *predBlock) const {
352372 switch (getKind ()) {
0 commit comments