File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ class SILInstructionResultArray;
62
62
class SILOpenedArchetypesState ;
63
63
class SILType ;
64
64
class SILArgument ;
65
+ class SILPHIArgument ;
65
66
class SILUndef ;
66
67
class Stmt ;
67
68
class StringLiteralExpr ;
@@ -6835,6 +6836,11 @@ class BranchInst final
6835
6836
6836
6837
unsigned getNumArgs () const { return getAllOperands ().size (); }
6837
6838
SILValue getArg (unsigned i) const { return getAllOperands ()[i].get (); }
6839
+
6840
+ // / Return the SILPHIArgument for the given operand.
6841
+ // /
6842
+ // / See SILArgument.cpp.
6843
+ const SILPHIArgument *getArgForOperand (const Operand *oper) const ;
6838
6844
};
6839
6845
6840
6846
// / A conditional branch.
@@ -6976,6 +6982,15 @@ class CondBranchInst final
6976
6982
SILValue getArgForDestBB (const SILBasicBlock *DestBB,
6977
6983
unsigned ArgIndex) const ;
6978
6984
6985
+ // / Return the SILPHIArgument from either the true or false destination for
6986
+ // / the given operand.
6987
+ // /
6988
+ // / Returns nullptr for an operand with no block argument
6989
+ // / (i.e the branch condition).
6990
+ // /
6991
+ // / See SILArgument.cpp.
6992
+ const SILPHIArgument *getArgForOperand (const Operand *oper) const ;
6993
+
6979
6994
void swapSuccessors ();
6980
6995
};
6981
6996
Original file line number Diff line number Diff line change @@ -188,6 +188,28 @@ SILValue SILPHIArgument::getIncomingValue(SILBasicBlock *BB) {
188
188
return getIncomingValueForPred (Parent, BB, Index);
189
189
}
190
190
191
+ const SILPHIArgument *BranchInst::getArgForOperand (const Operand *oper) const {
192
+ assert (oper->getUser () == this );
193
+ return cast<SILPHIArgument>(
194
+ getDestBB ()->getArgument (oper->getOperandNumber ()));
195
+ }
196
+
197
+ const SILPHIArgument *
198
+ CondBranchInst::getArgForOperand (const Operand *oper) const {
199
+ assert (oper->getUser () == this );
200
+
201
+ unsigned operIdx = oper->getOperandNumber ();
202
+ if (isTrueOperandIndex (operIdx)) {
203
+ return cast<SILPHIArgument>(getTrueBB ()->getArgument (
204
+ operIdx - getTrueOperands ().front ().getOperandNumber ()));
205
+ }
206
+ if (isFalseOperandIndex (operIdx)) {
207
+ return cast<SILPHIArgument>(getFalseBB ()->getArgument (
208
+ operIdx - getFalseOperands ().front ().getOperandNumber ()));
209
+ }
210
+ return nullptr ;
211
+ }
212
+
191
213
// ===----------------------------------------------------------------------===//
192
214
// SILFunctionArgument
193
215
// ===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments