[llvm] [NFC][TableGen] Use SmallVector range constructor when possible (PR #140284)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Mon May 19 08:51:22 PDT 2025
https://github.com/jurahul updated https://github.com/llvm/llvm-project/pull/140284
>From dc9bcebe62f461cb63dc3cbf2b37f78ad6e2551b Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Fri, 16 May 2025 10:29:57 -0700
Subject: [PATCH] [NFC][TableGen] Use SmallVector range constructor when
possible
Initialize vectors using constructors instead of llvm::append_range
when possible.
---
llvm/lib/TableGen/Record.cpp | 18 +++++++-----------
.../utils/TableGen/Common/CodeGenRegisters.cpp | 3 +--
2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 97e185bbd1267..59884c78565a6 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -334,11 +334,10 @@ static const RecordRecTy *resolveRecordTypes(const RecordRecTy *T1,
while (!Stack.empty()) {
const Record *R = Stack.pop_back_val();
- if (T2->isSubClassOf(R)) {
+ if (T2->isSubClassOf(R))
CommonSuperClasses.push_back(R);
- } else {
- append_range(Stack, make_first_range(R->getDirectSuperClasses()));
- }
+ else
+ llvm::append_range(Stack, make_first_range(R->getDirectSuperClasses()));
}
return RecordRecTy::get(T1->getRecordKeeper(), CommonSuperClasses);
@@ -2733,11 +2732,8 @@ const DagInit *DagInit::get(const Init *V, const StringInit *VN,
const DagInit *DagInit::get(
const Init *V, const StringInit *VN,
ArrayRef<std::pair<const Init *, const StringInit *>> ArgAndNames) {
- SmallVector<const Init *, 8> Args;
- SmallVector<const StringInit *, 8> Names;
-
- llvm::append_range(Args, make_first_range(ArgAndNames));
- llvm::append_range(Names, make_second_range(ArgAndNames));
+ SmallVector<const Init *, 8> Args(make_first_range(ArgAndNames));
+ SmallVector<const StringInit *, 8> Names(make_second_range(ArgAndNames));
return DagInit::get(V, VN, Args, Names);
}
@@ -2901,8 +2897,8 @@ void Record::checkName() {
}
const RecordRecTy *Record::getType() const {
- SmallVector<const Record *, 4> DirectSCs;
- append_range(DirectSCs, make_first_range(getDirectSuperClasses()));
+ SmallVector<const Record *> DirectSCs(
+ make_first_range(getDirectSuperClasses()));
return RecordRecTy::get(TrackedRecords, DirectSCs);
}
diff --git a/llvm/utils/TableGen/Common/CodeGenRegisters.cpp b/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
index 3b7604a05fa88..a833e488c5e33 100644
--- a/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
@@ -650,8 +650,7 @@ struct TupleExpander : SetTheory::Expander {
// Take the cost list of the first register in the tuple.
const ListInit *CostList = Proto->getValueAsListInit("CostPerUse");
- SmallVector<const Init *, 2> CostPerUse;
- llvm::append_range(CostPerUse, *CostList);
+ SmallVector<const Init *, 2> CostPerUse(CostList->getValues());
const StringInit *AsmName = StringInit::get(RK, "");
if (!RegNames.empty()) {
More information about the llvm-commits
mailing list