Skip to content

Commit f84ce1e

Browse files
committed
[TableGen][DecoderEmitter] Extract a couple of loop invariants (NFC)
1 parent da19383 commit f84ce1e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,6 +2483,8 @@ namespace {
24832483

24842484
const auto &NumberedInstructions = Target.getInstructions();
24852485
NumberedEncodings.reserve(NumberedInstructions.size());
2486+
NumInstructions = NumberedInstructions.size();
2487+
24862488
for (const auto &NumberedInstruction : NumberedInstructions) {
24872489
const Record *InstDef = NumberedInstruction->TheDef;
24882490
if (const Record *RV = InstDef->getValueAsOptionalDef("EncodingInfos")) {
@@ -2509,6 +2511,8 @@ namespace {
25092511
std::map<unsigned, std::vector<OperandInfo>> Operands;
25102512
std::vector<unsigned> InstrLen;
25112513
bool IsVarLenInst = Target.hasVariableLengthEncodings();
2514+
if (IsVarLenInst)
2515+
InstrLen.resize(NumberedInstructions.size(), 0);
25122516
unsigned MaxInstLen = 0;
25132517

25142518
for (const auto &[NEI, NumberedEncoding] : enumerate(NumberedEncodings)) {
@@ -2524,16 +2528,11 @@ namespace {
25242528
continue;
25252529
}
25262530

2527-
if (NEI < NumberedInstructions.size())
2528-
NumInstructions++;
25292531
NumEncodings++;
25302532

25312533
if (!Size && !IsVarLenInst)
25322534
continue;
25332535

2534-
if (IsVarLenInst)
2535-
InstrLen.resize(NumberedInstructions.size(), 0);
2536-
25372536
if (unsigned Len = populateInstruction(Target, *EncodingDef, *Inst, NEI,
25382537
Operands, IsVarLenInst)) {
25392538
if (IsVarLenInst) {

0 commit comments

Comments
 (0)