diff options
author | Craig Topper <craig.topper@sifive.com> | 2023-11-02 18:05:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-02 18:05:05 -0700 |
commit | 1021404619724568d62f53e575b61ae84e82ca02 (patch) | |
tree | ee98d7a6dd1ecb53765153d766202307fb555a0f | |
parent | 308f58cedac17c9acc8686713ee652a8d4020adb (diff) | |
download | llvm-1021404619724568d62f53e575b61ae84e82ca02.zip llvm-1021404619724568d62f53e575b61ae84e82ca02.tar.gz llvm-1021404619724568d62f53e575b61ae84e82ca02.tar.bz2 |
[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.
-rw-r--r-- | llvm/include/llvm/CodeGen/RegisterBank.h | 4 | ||||
-rw-r--r-- | llvm/utils/TableGen/RegisterBankEmitter.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/llvm/include/llvm/CodeGen/RegisterBank.h b/llvm/include/llvm/CodeGen/RegisterBank.h index 3862b51..3efd896 100644 --- a/llvm/include/llvm/CodeGen/RegisterBank.h +++ b/llvm/include/llvm/CodeGen/RegisterBank.h @@ -36,8 +36,8 @@ private: 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 60c3fcd..f851d9a 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 */ " |