Skip to content

Commit 9cd12b5

Browse files
authored
[TableGen] Inline a helper function that didn't seem necessary. NFC (#123440)
The function called find_if and converted the iterator to an index. The caller then had to check the index being non-zero to know if the find succeeded. Seems better to just do the find and distance in the caller.
1 parent 90696d1 commit 9cd12b5

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

llvm/utils/TableGen/Common/CodeGenSchedule.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -809,30 +809,21 @@ void CodeGenSchedModels::expandRWSeqForProc(
809809
}
810810
}
811811

812-
// Find the existing SchedWrite that models this sequence of writes.
813-
unsigned CodeGenSchedModels::findRWForSequence(ArrayRef<unsigned> Seq,
814-
bool IsRead) {
815-
std::vector<CodeGenSchedRW> &RWVec = IsRead ? SchedReads : SchedWrites;
816-
817-
auto I = find_if(RWVec, [Seq](CodeGenSchedRW &RW) {
818-
return ArrayRef(RW.Sequence) == Seq;
819-
});
820-
// Index zero reserved for invalid RW.
821-
return I == RWVec.end() ? 0 : std::distance(RWVec.begin(), I);
822-
}
823-
824812
/// Add this ReadWrite if it doesn't already exist.
825813
unsigned CodeGenSchedModels::findOrInsertRW(ArrayRef<unsigned> Seq,
826814
bool IsRead) {
827815
assert(!Seq.empty() && "cannot insert empty sequence");
828816
if (Seq.size() == 1)
829817
return Seq.back();
830818

831-
unsigned Idx = findRWForSequence(Seq, IsRead);
832-
if (Idx)
833-
return Idx;
834-
835819
std::vector<CodeGenSchedRW> &RWVec = IsRead ? SchedReads : SchedWrites;
820+
821+
auto I = find_if(RWVec, [Seq](CodeGenSchedRW &RW) {
822+
return ArrayRef(RW.Sequence) == Seq;
823+
});
824+
if (I != RWVec.end())
825+
return std::distance(RWVec.begin(), I);
826+
836827
unsigned RWIdx = RWVec.size();
837828
CodeGenSchedRW SchedRW(RWIdx, IsRead, Seq, genRWName(Seq, IsRead));
838829
RWVec.push_back(SchedRW);

llvm/utils/TableGen/Common/CodeGenSchedule.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ class CodeGenSchedModels {
592592
void collectSchedRW();
593593

594594
std::string genRWName(ArrayRef<unsigned> Seq, bool IsRead);
595-
unsigned findRWForSequence(ArrayRef<unsigned> Seq, bool IsRead);
596595

597596
void collectSchedClasses();
598597

0 commit comments

Comments
 (0)