[llvm] 56277e3 - [TableGen] Make the map in InfoByHwMode protected. NFCI
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 11 21:16:40 PST 2021
Author: Craig Topper
Date: 2021-02-11T21:16:10-08:00
New Revision: 56277e3e10d204e26e7884c4d978b82fd1620f02
URL: https://github.com/llvm/llvm-project/commit/56277e3e10d204e26e7884c4d978b82fd1620f02
DIFF: https://github.com/llvm/llvm-project/commit/56277e3e10d204e26e7884c4d978b82fd1620f02.diff
LOG: [TableGen] Make the map in InfoByHwMode protected. NFCI
Switch some for loops to just use the begin()/end() implementations
in the InfoByHwMode struct.
Add a method to insert into the map for the one case that was
modifying the map directly.
Added:
Modified:
llvm/utils/TableGen/CodeEmitterGen.cpp
llvm/utils/TableGen/CodeGenRegisters.cpp
llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
llvm/utils/TableGen/InfoByHwMode.h
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp
index 3b77f09d9b79..24cb485c032f 100644
--- a/llvm/utils/TableGen/CodeEmitterGen.cpp
+++ b/llvm/utils/TableGen/CodeEmitterGen.cpp
@@ -272,7 +272,7 @@ std::string CodeEmitterGen::getInstructionCase(Record *R,
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
Case += " switch (HwMode) {\n";
Case += " default: llvm_unreachable(\"Unhandled HwMode\");\n";
- for (auto &KV : EBM.Map) {
+ for (auto &KV : EBM) {
Case += " case " + itostr(KV.first) + ": {\n";
Case += getInstructionCaseForEncoding(R, KV.second, Target);
Case += " break;\n";
@@ -409,7 +409,7 @@ void CodeEmitterGen::run(raw_ostream &o) {
if (const RecordVal *RV = R->getValue("EncodingInfos")) {
if (DefInit *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
- for (auto &KV : EBM.Map) {
+ for (auto &KV : EBM) {
BitsInit *BI = KV.second->getValueAsBitsInit("Inst");
BitWidth = std::max(BitWidth, BI->getNumBits());
HwModes.insert(KV.first);
diff --git a/llvm/utils/TableGen/CodeGenRegisters.cpp b/llvm/utils/TableGen/CodeGenRegisters.cpp
index d0c9db4eaef6..5ef3cf9ee498 100644
--- a/llvm/utils/TableGen/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/CodeGenRegisters.cpp
@@ -796,7 +796,7 @@ CodeGenRegisterClass::CodeGenRegisterClass(CodeGenRegBank &RegBank, Record *R)
RI.RegSize = RI.SpillSize = Size ? Size
: VTs[0].getSimple().getSizeInBits();
RI.SpillAlignment = R->getValueAsInt("Alignment");
- RSI.Map.insert({DefaultMode, RI});
+ RSI.insertRegSizeForMode(DefaultMode, RI);
}
CopyCost = R->getValueAsInt("CopyCost");
diff --git a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
index e4ecb5dd7c90..b5a280ba1a5a 100644
--- a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
+++ b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp
@@ -2418,7 +2418,7 @@ void FixedLenDecoderEmitter::run(raw_ostream &o) {
if (auto *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
const CodeGenHwModes &HWM = Target.getHwModes();
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
- for (auto &KV : EBM.Map)
+ for (auto &KV : EBM)
HwModeNames.insert(HWM.getMode(KV.first).Name);
}
}
@@ -2436,7 +2436,7 @@ void FixedLenDecoderEmitter::run(raw_ostream &o) {
if (DefInit *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
const CodeGenHwModes &HWM = Target.getHwModes();
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
- for (auto &KV : EBM.Map) {
+ for (auto &KV : EBM) {
NumberedEncodings.emplace_back(KV.second, NumberedInstruction,
HWM.getMode(KV.first).Name);
HwModeNames.insert(HWM.getMode(KV.first).Name);
diff --git a/llvm/utils/TableGen/InfoByHwMode.h b/llvm/utils/TableGen/InfoByHwMode.h
index d92e5901a7f3..4233a581a632 100644
--- a/llvm/utils/TableGen/InfoByHwMode.h
+++ b/llvm/utils/TableGen/InfoByHwMode.h
@@ -114,6 +114,7 @@ struct InfoByHwMode {
Map.insert(std::make_pair(DefaultMode, I));
}
+protected:
MapType Map;
};
@@ -178,6 +179,10 @@ struct RegSizeInfoByHwMode : public InfoByHwMode<RegSizeInfo> {
bool hasStricterSpillThan(const RegSizeInfoByHwMode &I) const;
void writeToStream(raw_ostream &OS) const;
+
+ void insertRegSizeForMode(unsigned Mode, RegSizeInfo Info) {
+ Map.insert(std::make_pair(Mode, Info));
+ }
};
raw_ostream &operator<<(raw_ostream &OS, const ValueTypeByHwMode &T);
More information about the llvm-commits
mailing list