[llvm] f84ce1e - [TableGen][DecoderEmitter] Extract a couple of loop invariants (NFC)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 18 21:47:27 PDT 2025
Author: Sergei Barannikov
Date: 2025-08-19T07:47:15+03:00
New Revision: f84ce1e1d0e2ebe944b4f5d1b5340beffaa534d7
URL: https://github.com/llvm/llvm-project/commit/f84ce1e1d0e2ebe944b4f5d1b5340beffaa534d7
DIFF: https://github.com/llvm/llvm-project/commit/f84ce1e1d0e2ebe944b4f5d1b5340beffaa534d7.diff
LOG: [TableGen][DecoderEmitter] Extract a couple of loop invariants (NFC)
Added:
Modified:
llvm/utils/TableGen/DecoderEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp
index c16d5b5d317d6..50cda0cc533f6 100644
--- a/llvm/utils/TableGen/DecoderEmitter.cpp
+++ b/llvm/utils/TableGen/DecoderEmitter.cpp
@@ -2483,6 +2483,8 @@ namespace {
const auto &NumberedInstructions = Target.getInstructions();
NumberedEncodings.reserve(NumberedInstructions.size());
+ NumInstructions = NumberedInstructions.size();
+
for (const auto &NumberedInstruction : NumberedInstructions) {
const Record *InstDef = NumberedInstruction->TheDef;
if (const Record *RV = InstDef->getValueAsOptionalDef("EncodingInfos")) {
@@ -2509,6 +2511,8 @@ namespace {
std::map<unsigned, std::vector<OperandInfo>> Operands;
std::vector<unsigned> InstrLen;
bool IsVarLenInst = Target.hasVariableLengthEncodings();
+ if (IsVarLenInst)
+ InstrLen.resize(NumberedInstructions.size(), 0);
unsigned MaxInstLen = 0;
for (const auto &[NEI, NumberedEncoding] : enumerate(NumberedEncodings)) {
@@ -2524,16 +2528,11 @@ namespace {
continue;
}
- if (NEI < NumberedInstructions.size())
- NumInstructions++;
NumEncodings++;
if (!Size && !IsVarLenInst)
continue;
- if (IsVarLenInst)
- InstrLen.resize(NumberedInstructions.size(), 0);
-
if (unsigned Len = populateInstruction(Target, *EncodingDef, *Inst, NEI,
Operands, IsVarLenInst)) {
if (IsVarLenInst) {
More information about the llvm-commits
mailing list