[TableGen] Reduce size of MatchTableRecord (NFC) (#125221) · llvm/llvm-project@e2301d6 (original) (raw)

`@@ -227,26 +227,12 @@ MatchTableRecord MatchTable::NamedValue(unsigned NumBytes,

`

227

227

` MatchTableRecord::MTRF_CommaFollows);

`

228

228

`}

`

229

229

``

230

``

`-

MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef NamedValue,

`

231

``

`-

int64_t RawValue) {

`

232

``

`-

return MatchTableRecord(std::nullopt, NamedValue, NumBytes,

`

233

``

`-

MatchTableRecord::MTRF_CommaFollows, RawValue);

`

234

``

`-

}

`

235

``

-

236

230

`MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef Namespace,

`

237

231

` StringRef NamedValue) {

`

238

232

`return MatchTableRecord(std::nullopt, (Namespace + "::" + NamedValue).str(),

`

239

233

` NumBytes, MatchTableRecord::MTRF_CommaFollows);

`

240

234

`}

`

241

235

``

242

``

`-

MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef Namespace,

`

243

``

`-

StringRef NamedValue,

`

244

``

`-

int64_t RawValue) {

`

245

``

`-

return MatchTableRecord(std::nullopt, (Namespace + "::" + NamedValue).str(),

`

246

``

`-

NumBytes, MatchTableRecord::MTRF_CommaFollows,

`

247

``

`-

RawValue);

`

248

``

`-

}

`

249

``

-

250

236

`MatchTableRecord MatchTable::IntValue(unsigned NumBytes, int64_t IntValue) {

`

251

237

`assert(isUIntN(NumBytes * 8, IntValue) || isIntN(NumBytes * 8, IntValue));

`

252

238

`auto Str = llvm::to_string(IntValue);

`

`@@ -651,8 +637,8 @@ void SwitchMatcher::emit(MatchTable &Table) {

`

651

637

` &Table { return Table.allocateLabelID(); });

`

652

638

`const unsigned Default = Table.allocateLabelID();

`

653

639

``

654

``

`-

const int64_t LowerBound = Values.begin()->getRawValue();

`

655

``

`-

const int64_t UpperBound = Values.rbegin()->getRawValue() + 1;

`

``

640

`+

const int64_t LowerBound = Values.begin()->RawValue;

`

``

641

`+

const int64_t UpperBound = Values.rbegin()->RawValue + 1;

`

656

642

``

657

643

`emitPredicateSpecificOpcodes(*Condition, Table);

`

658

644

``

`@@ -664,10 +650,11 @@ void SwitchMatcher::emit(MatchTable &Table) {

`

664

650

`auto VI = Values.begin();

`

665

651

`for (unsigned I = 0, E = Values.size(); I < E; ++I) {

`

666

652

`auto V = *VI++;

`

667

``

`-

while (J++ < V.getRawValue())

`

``

653

`+

while (J++ < V.RawValue)

`

668

654

` Table << MatchTable::IntValue(4, 0);

`

669

``

`-

V.turnIntoComment();

`

670

``

`-

Table << MatchTable::LineBreak << V << MatchTable::JumpTarget(LabelIDs[I]);

`

``

655

`+

V.Record.turnIntoComment();

`

``

656

`+

Table << MatchTable::LineBreak << V.Record

`

``

657

`+

<< MatchTable::JumpTarget(LabelIDs[I]);

`

671

658

` }

`

672

659

` Table << MatchTable::LineBreak;

`

673

660

``

`@@ -1145,11 +1132,11 @@ void SameOperandMatcher::emitPredicateOpcodes(MatchTable &Table,

`

1145

1132

``

1146

1133

`std::map<LLTCodeGen, unsigned> LLTOperandMatcher::TypeIDValues;

`

1147

1134

``

1148

``

`-

MatchTableRecord LLTOperandMatcher::getValue() const {

`

``

1135

`+

RecordAndValue LLTOperandMatcher::getValue() const {

`

1149

1136

`const auto VI = TypeIDValues.find(Ty);

`

1150

1137

`if (VI == TypeIDValues.end())

`

1151

1138

`return MatchTable::NamedValue(1, getTy().getCxxEnumValue());

`

1152

``

`-

return MatchTable::NamedValue(1, getTy().getCxxEnumValue(), VI->second);

`

``

1139

`+

return {MatchTable::NamedValue(1, getTy().getCxxEnumValue()), VI->second};

`

1153

1140

`}

`

1154

1141

``

1155

1142

`bool LLTOperandMatcher::hasValue() const {

`

`@@ -1167,7 +1154,8 @@ void LLTOperandMatcher::emitPredicateOpcodes(MatchTable &Table,

`

1167

1154

` << MatchTable::ULEB128Value(InsnVarID);

`

1168

1155

` }

`

1169

1156

` Table << MatchTable::Comment("Op") << MatchTable::ULEB128Value(OpIdx)

`

1170

``

`-

<< MatchTable::Comment("Type") << getValue() << MatchTable::LineBreak;

`

``

1157

`+

<< MatchTable::Comment("Type") << getValue().Record

`

``

1158

`+

<< MatchTable::LineBreak;

`

1171

1159

`}

`

1172

1160

``

1173

1161

`//===- PointerToAnyOperandMatcher -----------------------------------------===//

`

`@@ -1411,12 +1399,12 @@ Error OperandMatcher::addTypeCheckPredicate(const TypeSetByHwMode &VTy,

`

1411

1399

`DenseMap<const CodeGenInstruction *, unsigned>

`

1412

1400

` InstructionOpcodeMatcher::OpcodeValues;

`

1413

1401

``

1414

``

`-

MatchTableRecord

`

``

1402

`+

RecordAndValue

`

1415

1403

`InstructionOpcodeMatcher::getInstValue(const CodeGenInstruction *I) const {

`

1416

1404

`const auto VI = OpcodeValues.find(I);

`

1417

1405

`if (VI != OpcodeValues.end())

`

1418

``

`-

return MatchTable::NamedValue(2, I->Namespace, I->TheDef->getName(),

`

1419

``

`-

VI->second);

`

``

1406

`+

return {MatchTable::NamedValue(2, I->Namespace, I->TheDef->getName()),

`

``

1407

`+

VI->second};

`

1420

1408

`return MatchTable::NamedValue(2, I->Namespace, I->TheDef->getName());

`

1421

1409

`}

`

1422

1410

``

`@@ -1428,14 +1416,14 @@ void InstructionOpcodeMatcher::initOpcodeValuesMap(

`

1428

1416

` OpcodeValues[I] = Target.getInstrIntValue(I->TheDef);

`

1429

1417

`}

`

1430

1418

``

1431

``

`-

MatchTableRecord InstructionOpcodeMatcher::getValue() const {

`

``

1419

`+

RecordAndValue InstructionOpcodeMatcher::getValue() const {

`

1432

1420

`assert(Insts.size() == 1);

`

1433

1421

``

1434

1422

`const CodeGenInstruction *I = Insts[0];

`

1435

1423

`const auto VI = OpcodeValues.find(I);

`

1436

1424

`if (VI != OpcodeValues.end())

`

1437

``

`-

return MatchTable::NamedValue(2, I->Namespace, I->TheDef->getName(),

`

1438

``

`-

VI->second);

`

``

1425

`+

return {MatchTable::NamedValue(2, I->Namespace, I->TheDef->getName()),

`

``

1426

`+

VI->second};

`

1439

1427

`return MatchTable::NamedValue(2, I->Namespace, I->TheDef->getName());

`

1440

1428

`}

`

1441

1429

``

`@@ -1447,7 +1435,7 @@ void InstructionOpcodeMatcher::emitPredicateOpcodes(MatchTable &Table,

`

1447

1435

` << MatchTable::ULEB128Value(InsnVarID);

`

1448

1436

``

1449

1437

`for (const CodeGenInstruction *I : Insts)

`

1450

``

`-

Table << getInstValue(I);

`

``

1438

`+

Table << getInstValue(I).Record;

`

1451

1439

` Table << MatchTable::LineBreak;

`

1452

1440

`}

`

1453

1441

``