[llvm] 1021404 - [GISel] Make RegBank constructor constexpr. NFC (#71109)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 2 18:05:10 PDT 2023
Author: Craig Topper
Date: 2023-11-02T18:05:05-07:00
New Revision: 1021404619724568d62f53e575b61ae84e82ca02
URL: https://github.com/llvm/llvm-project/commit/1021404619724568d62f53e575b61ae84e82ca02
DIFF: https://github.com/llvm/llvm-project/commit/1021404619724568d62f53e575b61ae84e82ca02.diff
LOG: [GISel] Make RegBank constructor constexpr. NFC (#71109)
RegBanks are constructed as global objects. Making the constructor
constexpr helps the compiler construct it without a global
constructor.
clang's optimizer seems to figure this out on its own, but at
least gcc 8 does not.
Added:
Modified:
llvm/include/llvm/CodeGen/RegisterBank.h
llvm/utils/TableGen/RegisterBankEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/RegisterBank.h b/llvm/include/llvm/CodeGen/RegisterBank.h
index 3862b51a1320222..3efd896ce059213 100644
--- a/llvm/include/llvm/CodeGen/RegisterBank.h
+++ b/llvm/include/llvm/CodeGen/RegisterBank.h
@@ -36,8 +36,8 @@ class RegisterBank {
friend RegisterBankInfo;
public:
- RegisterBank(unsigned ID, const char *Name, const uint32_t *CoveredClasses,
- unsigned NumRegClasses)
+ constexpr RegisterBank(unsigned ID, const char *Name,
+ const uint32_t *CoveredClasses, unsigned NumRegClasses)
: ID(ID), NumRegClasses(NumRegClasses), Name(Name),
CoveredClasses(CoveredClasses) {}
diff --git a/llvm/utils/TableGen/RegisterBankEmitter.cpp b/llvm/utils/TableGen/RegisterBankEmitter.cpp
index 60c3fcdba70ed88..f851d9a79870b45 100644
--- a/llvm/utils/TableGen/RegisterBankEmitter.cpp
+++ b/llvm/utils/TableGen/RegisterBankEmitter.cpp
@@ -244,7 +244,7 @@ void RegisterBankEmitter::emitBaseClassImplementation(
for (const auto &Bank : Banks) {
std::string QualifiedBankID =
(TargetName + "::" + Bank.getEnumeratorName()).str();
- OS << "const RegisterBank " << Bank.getInstanceVarName() << "(/* ID */ "
+ OS << "constexpr RegisterBank " << Bank.getInstanceVarName() << "(/* ID */ "
<< QualifiedBankID << ", /* Name */ \"" << Bank.getName() << "\", "
<< "/* CoveredRegClasses */ " << Bank.getCoverageArrayName()
<< ", /* NumRegClasses */ "
More information about the llvm-commits
mailing list