[llvm] [NFC][TableGen] Use SmallVector range constructor when possible (PR #140284)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 19 10:25:08 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-tablegen
Author: Rahul Joshi (jurahul)
<details>
<summary>Changes</summary>
Initialize vectors using constructors instead of llvm::append_range when possible.
---
Full diff: https://github.com/llvm/llvm-project/pull/140284.diff
2 Files Affected:
- (modified) llvm/lib/TableGen/Record.cpp (+7-11)
- (modified) llvm/utils/TableGen/Common/CodeGenRegisters.cpp (+1-2)
``````````diff
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()) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/140284
More information about the llvm-commits
mailing list