[llvm] [LLVM][TableGen] Change DFAPacketizerEmitter to use const RecordKeeper (PR #109044)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 17 13:36:19 PDT 2024
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/109044
Change DFAPacketizerEmitter to use const RecordKeeper.
>From 27ea5e648c9a8f8b6a7cae569579942035d65435 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Tue, 17 Sep 2024 13:34:17 -0700
Subject: [PATCH] [LLVM][TableGen] Change DFAPacketizerEmitter to use const
RecordKeeper
---
llvm/utils/TableGen/DFAPacketizerEmitter.cpp | 43 ++++++++++----------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
index 55cb39c9de5faa..42155e78d0a262 100644
--- a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
+++ b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
@@ -61,7 +61,7 @@ struct ScheduleClass {
class DFAPacketizerEmitter {
private:
std::string TargetName;
- RecordKeeper &Records;
+ const RecordKeeper &Records;
UniqueVector<ResourceVector> UniqueResources;
std::vector<ScheduleClass> ScheduleClasses;
@@ -69,17 +69,18 @@ class DFAPacketizerEmitter {
std::map<unsigned, uint64_t> ComboBitToBitsMap;
public:
- DFAPacketizerEmitter(RecordKeeper &R);
+ DFAPacketizerEmitter(const RecordKeeper &R);
// Construct a map of function unit names to bits.
int collectAllFuncUnits(ArrayRef<const CodeGenProcModel *> ProcModels);
// Construct a map from a combo function unit bit to the bits of all included
// functional units.
- int collectAllComboFuncs(ArrayRef<Record *> ComboFuncList);
+ int collectAllComboFuncs(ArrayRef<const Record *> ComboFuncList);
- ResourceVector getResourcesForItinerary(Record *Itinerary);
- void createScheduleClasses(unsigned ItineraryIdx, const RecVec &Itineraries);
+ ResourceVector getResourcesForItinerary(const Record *Itinerary);
+ void createScheduleClasses(unsigned ItineraryIdx,
+ ArrayRef<const Record *> Itineraries);
// Emit code for a subset of itineraries.
void emitForItineraries(raw_ostream &OS,
@@ -90,7 +91,7 @@ class DFAPacketizerEmitter {
};
} // end anonymous namespace
-DFAPacketizerEmitter::DFAPacketizerEmitter(RecordKeeper &R)
+DFAPacketizerEmitter::DFAPacketizerEmitter(const RecordKeeper &R)
: TargetName(std::string(CodeGenTarget(R).getName())), Records(R) {}
int DFAPacketizerEmitter::collectAllFuncUnits(
@@ -107,7 +108,7 @@ int DFAPacketizerEmitter::collectAllFuncUnits(
int totalFUs = 0;
// Parse functional units for all the itineraries.
for (const Record *Proc : ProcItinList) {
- std::vector<Record *> FUs = Proc->getValueAsListOfDefs("FU");
+ std::vector<const Record *> FUs = Proc->getValueAsListOfConstDefs("FU");
LLVM_DEBUG(dbgs() << " FU:"
<< " (" << FUs.size() << " FUs) " << Proc->getName());
@@ -129,7 +130,7 @@ int DFAPacketizerEmitter::collectAllFuncUnits(
}
int DFAPacketizerEmitter::collectAllComboFuncs(
- ArrayRef<Record *> ComboFuncList) {
+ ArrayRef<const Record *> ComboFuncList) {
LLVM_DEBUG(dbgs() << "-------------------------------------------------------"
"----------------------\n");
LLVM_DEBUG(dbgs() << "collectAllComboFuncs");
@@ -137,8 +138,8 @@ int DFAPacketizerEmitter::collectAllComboFuncs(
int numCombos = 0;
for (unsigned i = 0, N = ComboFuncList.size(); i < N; ++i) {
- Record *Func = ComboFuncList[i];
- std::vector<Record *> FUs = Func->getValueAsListOfDefs("CFD");
+ const Record *Func = ComboFuncList[i];
+ std::vector<const Record *> FUs = Func->getValueAsListOfConstDefs("CFD");
LLVM_DEBUG(dbgs() << " CFD:" << i << " (" << FUs.size() << " combo FUs) "
<< Func->getName() << "\n");
@@ -147,16 +148,16 @@ int DFAPacketizerEmitter::collectAllComboFuncs(
for (unsigned j = 0, N = FUs.size(); j < N; ++j) {
assert((j < DFA_MAX_RESOURCES) &&
"Exceeded maximum number of DFA resources");
- Record *FuncData = FUs[j];
- Record *ComboFunc = FuncData->getValueAsDef("TheComboFunc");
- const std::vector<Record *> &FuncList =
- FuncData->getValueAsListOfDefs("FuncList");
+ const Record *FuncData = FUs[j];
+ const Record *ComboFunc = FuncData->getValueAsDef("TheComboFunc");
+ const std::vector<const Record *> FuncList =
+ FuncData->getValueAsListOfConstDefs("FuncList");
const std::string &ComboFuncName = std::string(ComboFunc->getName());
uint64_t ComboBit = FUNameToBitsMap[ComboFuncName];
uint64_t ComboResources = ComboBit;
LLVM_DEBUG(dbgs() << " combo: " << ComboFuncName << ":0x"
<< Twine::utohexstr(ComboResources) << "\n");
- for (auto *K : FuncList) {
+ for (const Record *K : FuncList) {
std::string FuncName = std::string(K->getName());
uint64_t FuncResources = FUNameToBitsMap[FuncName];
LLVM_DEBUG(dbgs() << " " << FuncName << ":0x"
@@ -174,12 +175,12 @@ int DFAPacketizerEmitter::collectAllComboFuncs(
}
ResourceVector
-DFAPacketizerEmitter::getResourcesForItinerary(Record *Itinerary) {
+DFAPacketizerEmitter::getResourcesForItinerary(const Record *Itinerary) {
ResourceVector Resources;
assert(Itinerary);
- for (Record *StageDef : Itinerary->getValueAsListOfDefs("Stages")) {
+ for (const Record *StageDef : Itinerary->getValueAsListOfDefs("Stages")) {
uint64_t StageResources = 0;
- for (Record *Unit : StageDef->getValueAsListOfDefs("Units")) {
+ for (const Record *Unit : StageDef->getValueAsListOfDefs("Units")) {
StageResources |= FUNameToBitsMap[std::string(Unit->getName())];
}
if (StageResources != 0)
@@ -188,10 +189,10 @@ DFAPacketizerEmitter::getResourcesForItinerary(Record *Itinerary) {
return Resources;
}
-void DFAPacketizerEmitter::createScheduleClasses(unsigned ItineraryIdx,
- const RecVec &Itineraries) {
+void DFAPacketizerEmitter::createScheduleClasses(
+ unsigned ItineraryIdx, ArrayRef<const Record *> Itineraries) {
unsigned Idx = 0;
- for (Record *Itinerary : Itineraries) {
+ for (const Record *Itinerary : Itineraries) {
if (!Itinerary) {
ScheduleClasses.push_back({ItineraryIdx, Idx++, 0, ResourceVector{}});
continue;
More information about the llvm-commits
mailing list