[llvm] 9cd12b5 - [TableGen] Inline a helper function that didn't seem necessary. NFC (#123440)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 17 21:41:08 PST 2025
Author: Craig Topper
Date: 2025-01-17T21:41:04-08:00
New Revision: 9cd12b5652ec0bcf8670aa7c8ddfddf9212aa94c
URL: https://github.com/llvm/llvm-project/commit/9cd12b5652ec0bcf8670aa7c8ddfddf9212aa94c
DIFF: https://github.com/llvm/llvm-project/commit/9cd12b5652ec0bcf8670aa7c8ddfddf9212aa94c.diff
LOG: [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.
Added:
Modified:
llvm/utils/TableGen/Common/CodeGenSchedule.cpp
llvm/utils/TableGen/Common/CodeGenSchedule.h
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
index a5ca060533bcef..1d1de884990855 100644
--- a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
@@ -809,18 +809,6 @@ void CodeGenSchedModels::expandRWSeqForProc(
}
}
-// Find the existing SchedWrite that models this sequence of writes.
-unsigned CodeGenSchedModels::findRWForSequence(ArrayRef<unsigned> Seq,
- bool IsRead) {
- std::vector<CodeGenSchedRW> &RWVec = IsRead ? SchedReads : SchedWrites;
-
- auto I = find_if(RWVec, [Seq](CodeGenSchedRW &RW) {
- return ArrayRef(RW.Sequence) == Seq;
- });
- // Index zero reserved for invalid RW.
- return I == RWVec.end() ? 0 : std::distance(RWVec.begin(), I);
-}
-
/// Add this ReadWrite if it doesn't already exist.
unsigned CodeGenSchedModels::findOrInsertRW(ArrayRef<unsigned> Seq,
bool IsRead) {
@@ -828,11 +816,14 @@ unsigned CodeGenSchedModels::findOrInsertRW(ArrayRef<unsigned> Seq,
if (Seq.size() == 1)
return Seq.back();
- unsigned Idx = findRWForSequence(Seq, IsRead);
- if (Idx)
- return Idx;
-
std::vector<CodeGenSchedRW> &RWVec = IsRead ? SchedReads : SchedWrites;
+
+ auto I = find_if(RWVec, [Seq](CodeGenSchedRW &RW) {
+ return ArrayRef(RW.Sequence) == Seq;
+ });
+ if (I != RWVec.end())
+ return std::distance(RWVec.begin(), I);
+
unsigned RWIdx = RWVec.size();
CodeGenSchedRW SchedRW(RWIdx, IsRead, Seq, genRWName(Seq, IsRead));
RWVec.push_back(SchedRW);
diff --git a/llvm/utils/TableGen/Common/CodeGenSchedule.h b/llvm/utils/TableGen/Common/CodeGenSchedule.h
index f43c856b274ce8..d47c03514b155f 100644
--- a/llvm/utils/TableGen/Common/CodeGenSchedule.h
+++ b/llvm/utils/TableGen/Common/CodeGenSchedule.h
@@ -592,7 +592,6 @@ class CodeGenSchedModels {
void collectSchedRW();
std::string genRWName(ArrayRef<unsigned> Seq, bool IsRead);
- unsigned findRWForSequence(ArrayRef<unsigned> Seq, bool IsRead);
void collectSchedClasses();
More information about the llvm-commits
mailing list