Improve the SILInstruction::getOperandValues() API.

Add NonTypeDependentOperandToValue predicate for composability.

Add a getNonTypeDependentOperandValues(), which can be used as a functor.

The skipTypeDependentOperands parameter complicated the API.
This commit is contained in:
Andrew Trick
2022-01-18 09:12:33 -08:00
parent 23252935f6
commit 05224aaa1f
3 changed files with 52 additions and 22 deletions

View File

@@ -1055,7 +1055,7 @@ bool swift::getAllBorrowIntroducingValues(SILValue inputValue,
// instruction
if (isForwardingBorrow(value)) {
if (auto *i = value->getDefiningInstruction()) {
llvm::copy(i->getOperandValues(true /*skip type dependent ops*/),
llvm::copy(i->getNonTypeDependentOperandValues(),
std::back_inserter(worklist));
continue;
}
@@ -1100,7 +1100,7 @@ BorrowedValue swift::getSingleBorrowIntroducingValue(SILValue inputValue) {
// instruction
if (isForwardingBorrow(currentValue)) {
if (auto *i = currentValue->getDefiningInstruction()) {
auto instOps = i->getOperandValues(true /*ignore type dependent ops*/);
auto instOps = i->getNonTypeDependentOperandValues();
// If we have multiple incoming values, return .None. We can't handle
// this.
auto begin = instOps.begin();
@@ -1160,7 +1160,7 @@ bool swift::getAllOwnedValueIntroducers(
// instruction
if (isForwardingConsume(value)) {
if (auto *i = value->getDefiningInstruction()) {
llvm::copy(i->getOperandValues(true /*skip type dependent ops*/),
llvm::copy(i->getNonTypeDependentOperandValues(),
std::back_inserter(worklist));
continue;
}
@@ -1201,7 +1201,7 @@ OwnedValueIntroducer swift::getSingleOwnedValueIntroducer(SILValue inputValue) {
// instruction
if (isForwardingConsume(currentValue)) {
if (auto *i = currentValue->getDefiningInstruction()) {
auto instOps = i->getOperandValues(true /*ignore type dependent ops*/);
auto instOps = i->getNonTypeDependentOperandValues();
// If we have multiple incoming values, return .None. We can't handle
// this.
auto begin = instOps.begin();