Skip to content

Commit 6c3a0ab

Browse files
committed
[TableGen][DecoderEmitter] Shorten a few variable names (NFC)
These "Numbered"-prefixed names were rather confusing than helpful.
1 parent 9247be8 commit 6c3a0ab

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ using NamespacesHwModesMap = std::map<std::string, std::set<unsigned>>;
219219

220220
class DecoderEmitter {
221221
const RecordKeeper &RK;
222-
std::vector<EncodingAndInst> NumberedEncodings;
222+
std::vector<EncodingAndInst> Encodings;
223223

224224
public:
225225
DecoderEmitter(const RecordKeeper &R, StringRef PredicateNamespace)
@@ -810,11 +810,11 @@ unsigned DecoderEmitter::emitTable(formatted_raw_ostream &OS,
810810
ArrayRef<unsigned> EncodingIDs) const {
811811
// We'll need to be able to map from a decoded opcode into the corresponding
812812
// EncodingID for this specific combination of BitWidth and Namespace. This
813-
// is used below to index into NumberedEncodings.
813+
// is used below to index into Encodings.
814814
DenseMap<unsigned, unsigned> OpcodeToEncodingID;
815815
OpcodeToEncodingID.reserve(EncodingIDs.size());
816816
for (unsigned EncodingID : EncodingIDs) {
817-
const Record *InstDef = NumberedEncodings[EncodingID].Inst->TheDef;
817+
const Record *InstDef = Encodings[EncodingID].Inst->TheDef;
818818
OpcodeToEncodingID[Target.getInstrIntValue(InstDef)] = EncodingID;
819819
}
820820

@@ -965,15 +965,15 @@ unsigned DecoderEmitter::emitTable(formatted_raw_ostream &OS,
965965
auto EncodingID = EncI->second;
966966

967967
if (!IsTry) {
968-
OS << "// Opcode: " << NumberedEncodings[EncodingID]
968+
OS << "// Opcode: " << Encodings[EncodingID]
969969
<< ", DecodeIdx: " << DecodeIdx << '\n';
970970
break;
971971
}
972972

973973
// Fallthrough for OPC_TryDecode.
974974
if (!IsFail) {
975975
uint32_t NumToSkip = emitNumToSkip(I, OS);
976-
OS << "// Opcode: " << NumberedEncodings[EncodingID]
976+
OS << "// Opcode: " << Encodings[EncodingID]
977977
<< ", DecodeIdx: " << DecodeIdx;
978978
emitNumToSkipComment(NumToSkip, /*InComment=*/true);
979979
}
@@ -2481,29 +2481,29 @@ namespace {
24812481
if (HwModeIDs.empty())
24822482
HwModeIDs.push_back(DefaultMode);
24832483

2484-
const auto &NumberedInstructions = Target.getInstructions();
2485-
NumberedEncodings.reserve(NumberedInstructions.size());
2486-
NumInstructions = NumberedInstructions.size();
2484+
ArrayRef<const CodeGenInstruction *> Instructions = Target.getInstructions();
2485+
Encodings.reserve(Instructions.size());
2486+
NumInstructions = Instructions.size();
24872487

2488-
for (const auto &NumberedInstruction : NumberedInstructions) {
2489-
const Record *InstDef = NumberedInstruction->TheDef;
2488+
for (const CodeGenInstruction *Inst : Instructions) {
2489+
const Record *InstDef = Inst->TheDef;
24902490
if (const Record *RV = InstDef->getValueAsOptionalDef("EncodingInfos")) {
24912491
EncodingInfoByHwMode EBM(RV, HWM);
24922492
for (auto [HwModeID, EncodingDef] : EBM)
2493-
NumberedEncodings.emplace_back(EncodingDef, NumberedInstruction,
2494-
HwModeID);
2493+
Encodings.emplace_back(EncodingDef, Inst, HwModeID);
24952494
continue;
24962495
}
24972496
// This instruction is encoded the same on all HwModes.
24982497
// According to user needs, provide varying degrees of suppression.
2499-
handleHwModesUnrelatedEncodings(NumberedInstruction, HwModeIDs,
2500-
NamespacesWithHwModes, NumberedEncodings);
2498+
handleHwModesUnrelatedEncodings(Inst, HwModeIDs, NamespacesWithHwModes,
2499+
Encodings);
2500+
}
2501+
2502+
for (const Record *EncodingDef :
2503+
RK.getAllDerivedDefinitions("AdditionalEncoding")) {
2504+
const Record *InstDef = EncodingDef->getValueAsDef("AliasOf");
2505+
Encodings.emplace_back(EncodingDef, &Target.getInstruction(InstDef));
25012506
}
2502-
for (const Record *NumberedAlias :
2503-
RK.getAllDerivedDefinitions("AdditionalEncoding"))
2504-
NumberedEncodings.emplace_back(
2505-
NumberedAlias,
2506-
&Target.getInstruction(NumberedAlias->getValueAsDef("AliasOf")));
25072507

25082508
// Map of (namespace, hwmode, size) tuple to encoding IDs.
25092509
std::map<std::tuple<StringRef, unsigned, unsigned>, std::vector<unsigned>>
@@ -2512,12 +2512,12 @@ namespace {
25122512
std::vector<unsigned> InstrLen;
25132513
bool IsVarLenInst = Target.hasVariableLengthEncodings();
25142514
if (IsVarLenInst)
2515-
InstrLen.resize(NumberedInstructions.size(), 0);
2515+
InstrLen.resize(Instructions.size(), 0);
25162516
unsigned MaxInstLen = 0;
25172517

2518-
for (const auto &[NEI, NumberedEncoding] : enumerate(NumberedEncodings)) {
2519-
const Record *EncodingDef = NumberedEncoding.EncodingDef;
2520-
const CodeGenInstruction *Inst = NumberedEncoding.Inst;
2518+
for (const auto &[EncodingID, Encoding] : enumerate(Encodings)) {
2519+
const Record *EncodingDef = Encoding.EncodingDef;
2520+
const CodeGenInstruction *Inst = Encoding.Inst;
25212521
const Record *Def = Inst->TheDef;
25222522
unsigned Size = EncodingDef->getValueAsInt("Size");
25232523
if (Def->getValueAsString("Namespace") == "TargetOpcode" ||
@@ -2533,16 +2533,15 @@ namespace {
25332533
if (!Size && !IsVarLenInst)
25342534
continue;
25352535

2536-
if (unsigned Len = populateInstruction(Target, *EncodingDef, *Inst, NEI,
2537-
Operands, IsVarLenInst)) {
2536+
if (unsigned Len = populateInstruction(
2537+
Target, *EncodingDef, *Inst, EncodingID, Operands, IsVarLenInst)) {
25382538
if (IsVarLenInst) {
25392539
MaxInstLen = std::max(MaxInstLen, Len);
2540-
InstrLen[NEI] = Len;
2540+
InstrLen[EncodingID] = Len;
25412541
}
25422542
StringRef DecoderNamespace =
25432543
EncodingDef->getValueAsString("DecoderNamespace");
2544-
EncMap[{DecoderNamespace, NumberedEncoding.HwModeID, Size}].push_back(
2545-
NEI);
2544+
EncMap[{DecoderNamespace, Encoding.HwModeID, Size}].push_back(EncodingID);
25462545
} else {
25472546
NumEncodingsOmitted++;
25482547
}
@@ -2554,7 +2553,7 @@ namespace {
25542553
auto [DecoderNamespace, HwModeID, Size] = Key;
25552554
const unsigned BitWidth = IsVarLenInst ? MaxInstLen : 8 * Size;
25562555
// Emit the decoder for this (namespace, hwmode, width) combination.
2557-
FilterChooser FC(NumberedEncodings, EncodingIDs, Operands, BitWidth, this);
2556+
FilterChooser FC(Encodings, EncodingIDs, Operands, BitWidth, this);
25582557

25592558
// The decode table is cleared for each top level decoder function. The
25602559
// predicates and decoders themselves, however, are shared across all

0 commit comments

Comments
 (0)