1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[IR] Add GEPOperator::indices() (NFC)

In order to mirror the GetElementPtrInst::indices() API.

Wanted to use this in the IRForTarget code, and was surprised to
find that it didn't exist yet.
This commit is contained in:
Nikita Popov 2021-07-09 21:38:41 +02:00
parent 86ce446efa
commit 103545107e
2 changed files with 11 additions and 3 deletions

View File

@ -488,6 +488,14 @@ public:
inline op_iterator idx_end() { return op_end(); } inline op_iterator idx_end() { return op_end(); }
inline const_op_iterator idx_end() const { return op_end(); } inline const_op_iterator idx_end() const { return op_end(); }
inline iterator_range<op_iterator> indices() {
return make_range(idx_begin(), idx_end());
}
inline iterator_range<const_op_iterator> indices() const {
return make_range(idx_begin(), idx_end());
}
Value *getPointerOperand() { Value *getPointerOperand() {
return getOperand(0); return getOperand(0);
} }
@ -544,7 +552,7 @@ public:
} }
unsigned countNonConstantIndices() const { unsigned countNonConstantIndices() const {
return count_if(make_range(idx_begin(), idx_end()), [](const Use& use) { return count_if(indices(), [](const Use& use) {
return !isa<ConstantInt>(*use); return !isa<ConstantInt>(*use);
}); });
} }

View File

@ -5732,8 +5732,8 @@ const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) {
return getUnknown(GEP); return getUnknown(GEP);
SmallVector<const SCEV *, 4> IndexExprs; SmallVector<const SCEV *, 4> IndexExprs;
for (auto Index = GEP->idx_begin(); Index != GEP->idx_end(); ++Index) for (Value *Index : GEP->indices())
IndexExprs.push_back(getSCEV(*Index)); IndexExprs.push_back(getSCEV(Index));
return getGEPExpr(GEP, IndexExprs); return getGEPExpr(GEP, IndexExprs);
} }