forked from OSchip/llvm-project
[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.
This commit is contained in:
parent
9b123cde63
commit
56277e3e10
|
@ -272,7 +272,7 @@ std::string CodeEmitterGen::getInstructionCase(Record *R,
|
||||||
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
|
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
|
||||||
Case += " switch (HwMode) {\n";
|
Case += " switch (HwMode) {\n";
|
||||||
Case += " default: llvm_unreachable(\"Unhandled 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 += " case " + itostr(KV.first) + ": {\n";
|
||||||
Case += getInstructionCaseForEncoding(R, KV.second, Target);
|
Case += getInstructionCaseForEncoding(R, KV.second, Target);
|
||||||
Case += " break;\n";
|
Case += " break;\n";
|
||||||
|
@ -409,7 +409,7 @@ void CodeEmitterGen::run(raw_ostream &o) {
|
||||||
if (const RecordVal *RV = R->getValue("EncodingInfos")) {
|
if (const RecordVal *RV = R->getValue("EncodingInfos")) {
|
||||||
if (DefInit *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
|
if (DefInit *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
|
||||||
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
|
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
|
||||||
for (auto &KV : EBM.Map) {
|
for (auto &KV : EBM) {
|
||||||
BitsInit *BI = KV.second->getValueAsBitsInit("Inst");
|
BitsInit *BI = KV.second->getValueAsBitsInit("Inst");
|
||||||
BitWidth = std::max(BitWidth, BI->getNumBits());
|
BitWidth = std::max(BitWidth, BI->getNumBits());
|
||||||
HwModes.insert(KV.first);
|
HwModes.insert(KV.first);
|
||||||
|
|
|
@ -796,7 +796,7 @@ CodeGenRegisterClass::CodeGenRegisterClass(CodeGenRegBank &RegBank, Record *R)
|
||||||
RI.RegSize = RI.SpillSize = Size ? Size
|
RI.RegSize = RI.SpillSize = Size ? Size
|
||||||
: VTs[0].getSimple().getSizeInBits();
|
: VTs[0].getSimple().getSizeInBits();
|
||||||
RI.SpillAlignment = R->getValueAsInt("Alignment");
|
RI.SpillAlignment = R->getValueAsInt("Alignment");
|
||||||
RSI.Map.insert({DefaultMode, RI});
|
RSI.insertRegSizeForMode(DefaultMode, RI);
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyCost = R->getValueAsInt("CopyCost");
|
CopyCost = R->getValueAsInt("CopyCost");
|
||||||
|
|
|
@ -2418,7 +2418,7 @@ void FixedLenDecoderEmitter::run(raw_ostream &o) {
|
||||||
if (auto *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
|
if (auto *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
|
||||||
const CodeGenHwModes &HWM = Target.getHwModes();
|
const CodeGenHwModes &HWM = Target.getHwModes();
|
||||||
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
|
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
|
||||||
for (auto &KV : EBM.Map)
|
for (auto &KV : EBM)
|
||||||
HwModeNames.insert(HWM.getMode(KV.first).Name);
|
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())) {
|
if (DefInit *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
|
||||||
const CodeGenHwModes &HWM = Target.getHwModes();
|
const CodeGenHwModes &HWM = Target.getHwModes();
|
||||||
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
|
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
|
||||||
for (auto &KV : EBM.Map) {
|
for (auto &KV : EBM) {
|
||||||
NumberedEncodings.emplace_back(KV.second, NumberedInstruction,
|
NumberedEncodings.emplace_back(KV.second, NumberedInstruction,
|
||||||
HWM.getMode(KV.first).Name);
|
HWM.getMode(KV.first).Name);
|
||||||
HwModeNames.insert(HWM.getMode(KV.first).Name);
|
HwModeNames.insert(HWM.getMode(KV.first).Name);
|
||||||
|
|
|
@ -114,6 +114,7 @@ struct InfoByHwMode {
|
||||||
Map.insert(std::make_pair(DefaultMode, I));
|
Map.insert(std::make_pair(DefaultMode, I));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
MapType Map;
|
MapType Map;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -178,6 +179,10 @@ struct RegSizeInfoByHwMode : public InfoByHwMode<RegSizeInfo> {
|
||||||
bool hasStricterSpillThan(const RegSizeInfoByHwMode &I) const;
|
bool hasStricterSpillThan(const RegSizeInfoByHwMode &I) const;
|
||||||
|
|
||||||
void writeToStream(raw_ostream &OS) 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);
|
raw_ostream &operator<<(raw_ostream &OS, const ValueTypeByHwMode &T);
|
||||||
|
|
Loading…
Reference in New Issue