[llvm] 56015da - [LLVM][TableGen] Change RegisterBankEmitter to use const RecordKeeper (#109195)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 20:45:31 PDT 2024
Author: Rahul Joshi
Date: 2024-09-18T20:45:26-07:00
New Revision: 56015da593b646489c43263625cd2a8ceb7ef906
URL: https://github.com/llvm/llvm-project/commit/56015da593b646489c43263625cd2a8ceb7ef906
DIFF: https://github.com/llvm/llvm-project/commit/56015da593b646489c43263625cd2a8ceb7ef906.diff
LOG: [LLVM][TableGen] Change RegisterBankEmitter to use const RecordKeeper (#109195)
Change RegisterBankEmitter to use const RecordKeeper.
This is a part of effort to have better const correctness in TableGen
backends:
https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
Added:
Modified:
llvm/utils/TableGen/RegisterBankEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/RegisterBankEmitter.cpp b/llvm/utils/TableGen/RegisterBankEmitter.cpp
index 6872f16df4724e..460f286543b176 100644
--- a/llvm/utils/TableGen/RegisterBankEmitter.cpp
+++ b/llvm/utils/TableGen/RegisterBankEmitter.cpp
@@ -107,18 +107,18 @@ class RegisterBank {
class RegisterBankEmitter {
private:
- CodeGenTarget Target;
- RecordKeeper &Records;
+ const CodeGenTarget Target;
+ const RecordKeeper &Records;
void emitHeader(raw_ostream &OS, const StringRef TargetName,
- const std::vector<RegisterBank> &Banks);
+ ArrayRef<RegisterBank> Banks);
void emitBaseClassDefinition(raw_ostream &OS, const StringRef TargetName,
- const std::vector<RegisterBank> &Banks);
+ ArrayRef<RegisterBank> Banks);
void emitBaseClassImplementation(raw_ostream &OS, const StringRef TargetName,
- std::vector<RegisterBank> &Banks);
+ ArrayRef<RegisterBank> Banks);
public:
- RegisterBankEmitter(RecordKeeper &R) : Target(R), Records(R) {}
+ RegisterBankEmitter(const RecordKeeper &R) : Target(R), Records(R) {}
void run(raw_ostream &OS);
};
@@ -129,7 +129,7 @@ class RegisterBankEmitter {
/// variables.
void RegisterBankEmitter::emitHeader(raw_ostream &OS,
const StringRef TargetName,
- const std::vector<RegisterBank> &Banks) {
+ ArrayRef<RegisterBank> Banks) {
// <Target>RegisterBankInfo.h
OS << "namespace llvm {\n"
<< "namespace " << TargetName << " {\n"
@@ -147,8 +147,7 @@ void RegisterBankEmitter::emitHeader(raw_ostream &OS,
/// Emit declarations of the <Target>GenRegisterBankInfo class.
void RegisterBankEmitter::emitBaseClassDefinition(
- raw_ostream &OS, const StringRef TargetName,
- const std::vector<RegisterBank> &Banks) {
+ raw_ostream &OS, const StringRef TargetName, ArrayRef<RegisterBank> Banks) {
OS << "private:\n"
<< " static const RegisterBank *RegBanks[];\n"
<< " static const unsigned Sizes[];\n\n"
@@ -218,7 +217,7 @@ static void visitRegisterBankClasses(
}
void RegisterBankEmitter::emitBaseClassImplementation(
- raw_ostream &OS, StringRef TargetName, std::vector<RegisterBank> &Banks) {
+ raw_ostream &OS, StringRef TargetName, ArrayRef<RegisterBank> Banks) {
const CodeGenRegBank &RegisterClassHierarchy = Target.getRegBank();
const CodeGenHwModes &CGH = Target.getHwModes();
More information about the llvm-commits
mailing list