From 3f014992ff86092f3caee271e884ada60cf9500c Mon Sep 17 00:00:00 2001 From: "Pande, Pratyay" Date: Sun, 29 Sep 2024 22:54:18 -0700 Subject: [PATCH 1/4] [NFC] Use references to avoid copying Modifying auto to const auto& to avoid unnecessary copying --- llvm/utils/TableGen/IntrinsicEmitter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/utils/TableGen/IntrinsicEmitter.cpp b/llvm/utils/TableGen/IntrinsicEmitter.cpp index 51c2e9a12e00cf..ecd722ca0cfe74 100644 --- a/llvm/utils/TableGen/IntrinsicEmitter.cpp +++ b/llvm/utils/TableGen/IntrinsicEmitter.cpp @@ -229,8 +229,8 @@ struct IntrinsicTargetInfo { }; static constexpr IntrinsicTargetInfo TargetInfos[] = { )"; - for (const auto [Name, Offset, Count] : Ints.Targets) - OS << formatv(" {{\"{}\", {}, {}},\n", Name, Offset, Count); + for (const auto &Target : Ints.Targets) + OS << formatv(" {{\"{}\", {}, {}},\n", Target.Name, Target.Offset, Target.Count); OS << R"(}; #endif @@ -255,7 +255,7 @@ void IntrinsicEmitter::EmitIntrinsicToOverloadTable( static constexpr uint8_t OTable[] = { 0 )"; - for (auto [I, Int] : enumerate(Ints)) { + for (const auto& [I, Int] : enumerate(Ints)) { // Add one to the index so we emit a null bit for the invalid #0 intrinsic. size_t Idx = I + 1; @@ -347,7 +347,7 @@ static constexpr {} IIT_Table[] = {{ FixedEncodingTypeName); unsigned MaxOffset = 0; - for (auto [Idx, FixedEncoding, Int] : enumerate(FixedEncodings, Ints)) { + for (const auto& [Idx, FixedEncoding, Int] : enumerate(FixedEncodings, Ints)) { if ((Idx & 7) == 7) OS << "\n "; From a6e6e75ceba9ae37138a9364ecd4b38a22f30644 Mon Sep 17 00:00:00 2001 From: "Pande, Pratyay" Date: Mon, 30 Sep 2024 01:20:14 -0700 Subject: [PATCH 2/4] Removing reference as enumerate returns a ref. Fixed clang-format issues --- llvm/utils/TableGen/IntrinsicEmitter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/llvm/utils/TableGen/IntrinsicEmitter.cpp b/llvm/utils/TableGen/IntrinsicEmitter.cpp index 469d0bbf3ae4b6..c3a547ee862631 100644 --- a/llvm/utils/TableGen/IntrinsicEmitter.cpp +++ b/llvm/utils/TableGen/IntrinsicEmitter.cpp @@ -230,7 +230,8 @@ struct IntrinsicTargetInfo { static constexpr IntrinsicTargetInfo TargetInfos[] = { )"; for (const auto &Target : Ints.Targets) - OS << formatv(" {{\"{}\", {}, {}},\n", Target.Name, Target.Offset, Target.Count); + OS << formatv(" {{\"{}\", {}, {}},\n", Target.Name, Target.Offset, + Target.Count); OS << R"(}; #endif @@ -255,7 +256,7 @@ void IntrinsicEmitter::EmitIntrinsicToOverloadTable( static constexpr uint8_t OTable[] = { 0 )"; - for (const auto& [I, Int] : enumerate(Ints)) { + for (const auto [I, Int] : enumerate(Ints)) { // Add one to the index so we emit a null bit for the invalid #0 intrinsic. size_t Idx = I + 1; @@ -345,7 +346,8 @@ static constexpr {} IIT_Table[] = {{ FixedEncodingTypeName); unsigned MaxOffset = 0; - for (const auto& [Idx, FixedEncoding, Int] : enumerate(FixedEncodings, Ints)) { + for (const auto [Idx, FixedEncoding, Int] : + enumerate(FixedEncodings, Ints)) { if ((Idx & 7) == 7) OS << "\n "; From 9c3570618cd518671fb0f16897b3e51cef06ad48 Mon Sep 17 00:00:00 2001 From: "Pande, Pratyay" Date: Mon, 30 Sep 2024 01:29:59 -0700 Subject: [PATCH 3/4] Fixed clang-format issues --- llvm/utils/TableGen/IntrinsicEmitter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/utils/TableGen/IntrinsicEmitter.cpp b/llvm/utils/TableGen/IntrinsicEmitter.cpp index c3a547ee862631..791867de00c078 100644 --- a/llvm/utils/TableGen/IntrinsicEmitter.cpp +++ b/llvm/utils/TableGen/IntrinsicEmitter.cpp @@ -346,8 +346,7 @@ static constexpr {} IIT_Table[] = {{ FixedEncodingTypeName); unsigned MaxOffset = 0; - for (const auto [Idx, FixedEncoding, Int] : - enumerate(FixedEncodings, Ints)) { + for (const auto [Idx, FixedEncoding, Int] : enumerate(FixedEncodings, Ints)) { if ((Idx & 7) == 7) OS << "\n "; From b83572813da554706611b513b32cce78df64637c Mon Sep 17 00:00:00 2001 From: Pratyay Pande Date: Fri, 18 Oct 2024 13:11:32 +0530 Subject: [PATCH 4/4] Update IntrinsicEmitter.cpp --- llvm/utils/TableGen/IntrinsicEmitter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/utils/TableGen/IntrinsicEmitter.cpp b/llvm/utils/TableGen/IntrinsicEmitter.cpp index 3c5f3e3ef56d97..bbf651e8906393 100644 --- a/llvm/utils/TableGen/IntrinsicEmitter.cpp +++ b/llvm/utils/TableGen/IntrinsicEmitter.cpp @@ -256,7 +256,7 @@ void IntrinsicEmitter::EmitIntrinsicToOverloadTable( static constexpr uint8_t OTable[] = { 0 )"; - for (const auto [I, Int] : enumerate(Ints)) { + for (auto [I, Int] : enumerate(Ints)) { // Add one to the index so we emit a null bit for the invalid #0 intrinsic. size_t Idx = I + 1;