@@ -340,7 +340,7 @@ class DecoderEmitter {
340
340
SmallDenseMap<unsigned , std::vector<unsigned >> EncodingIDsByHwMode;
341
341
342
342
public:
343
- DecoderEmitter (const RecordKeeper &RK, StringRef PredicateNamespace );
343
+ explicit DecoderEmitter (const RecordKeeper &RK);
344
344
345
345
const CodeGenTarget &getTarget () const { return Target; }
346
346
@@ -370,9 +370,6 @@ class DecoderEmitter {
370
370
NamespacesHwModesMap &NamespacesWithHwModes);
371
371
372
372
void parseInstructionEncodings ();
373
-
374
- public:
375
- StringRef PredicateNamespace;
376
373
};
377
374
378
375
} // end anonymous namespace
@@ -487,8 +484,7 @@ class FilterChooser {
487
484
// / This field allows us to ignore the extra bits.
488
485
unsigned MaxFilterWidth;
489
486
490
- // Parent emitter
491
- const DecoderEmitter *Emitter;
487
+ const CodeGenTarget &Target;
492
488
493
489
// / If the selected filter matches multiple encodings, then this is the
494
490
// / starting position and the width of the filtered range.
@@ -524,9 +520,9 @@ class FilterChooser {
524
520
// / Constructs a top-level filter chooser.
525
521
FilterChooser (ArrayRef<InstructionEncoding> Encodings,
526
522
ArrayRef<unsigned > EncodingIDs, unsigned MaxFilterWidth,
527
- const DecoderEmitter *E )
523
+ const CodeGenTarget &Target )
528
524
: Encodings(Encodings), EncodingIDs(EncodingIDs), Parent(nullptr ),
529
- MaxFilterWidth (MaxFilterWidth), Emitter(E ) {
525
+ MaxFilterWidth (MaxFilterWidth), Target(Target ) {
530
526
// Sort encoding IDs once.
531
527
stable_sort (this ->EncodingIDs , LessEncodingIDByWidth (Encodings));
532
528
// Filter width is the width of the smallest encoding.
@@ -542,7 +538,7 @@ class FilterChooser {
542
538
ArrayRef<unsigned > EncodingIDs, const KnownBits &FilterBits,
543
539
const FilterChooser &Parent)
544
540
: Encodings(Encodings), EncodingIDs(EncodingIDs), Parent(&Parent),
545
- MaxFilterWidth(Parent.MaxFilterWidth), Emitter (Parent.Emitter ) {
541
+ MaxFilterWidth(Parent.MaxFilterWidth), Target (Parent.Target ) {
546
542
// Inferior filter choosers are created from sorted array of encoding IDs.
547
543
assert (is_sorted (EncodingIDs, LessEncodingIDByWidth (Encodings)));
548
544
assert (!FilterBits.hasConflict () && " Broken filter" );
@@ -1155,8 +1151,7 @@ bool FilterChooser::emitPredicateMatchAux(const Init &Val, bool ParenIfBinOp,
1155
1151
if (const auto *D = dyn_cast<DefInit>(&Val)) {
1156
1152
if (!D->getDef ()->isSubClassOf (" SubtargetFeature" ))
1157
1153
return true ;
1158
- OS << " Bits[" << Emitter->PredicateNamespace << " ::" << D->getAsString ()
1159
- << " ]" ;
1154
+ OS << " Bits[" << Target.getName () << " ::" << D->getAsString () << " ]" ;
1160
1155
return false ;
1161
1156
}
1162
1157
if (const auto *D = dyn_cast<DagInit>(&Val)) {
@@ -1350,7 +1345,7 @@ void FilterChooser::emitSingletonTableEntry(DecoderTableInfo &TableInfo,
1350
1345
: MCD::OPC_TryDecode;
1351
1346
TableInfo.Table .insertOpcode (DecoderOp);
1352
1347
const Record *InstDef = Encodings[EncodingID].getInstruction ()->TheDef ;
1353
- TableInfo.Table .insertULEB128 (Emitter-> getTarget () .getInstrIntValue (InstDef));
1348
+ TableInfo.Table .insertULEB128 (Target .getInstrIntValue (InstDef));
1354
1349
TableInfo.Table .insertULEB128 (DIdx);
1355
1350
1356
1351
if (DecoderOp == MCD::OPC_TryDecode) {
@@ -2502,10 +2497,8 @@ void DecoderEmitter::parseInstructionEncodings() {
2502
2497
NumEncodings = NumEncodingsSupported + NumEncodingsOmitted;
2503
2498
}
2504
2499
2505
- DecoderEmitter::DecoderEmitter (const RecordKeeper &RK,
2506
- StringRef PredicateNamespace)
2507
- : RK(RK), Target(RK), CGH(Target.getHwModes()),
2508
- PredicateNamespace(PredicateNamespace) {
2500
+ DecoderEmitter::DecoderEmitter (const RecordKeeper &RK)
2501
+ : RK(RK), Target(RK), CGH(Target.getHwModes()) {
2509
2502
Target.reverseBitsForLittleEndianEncoding ();
2510
2503
parseInstructionEncodings ();
2511
2504
}
@@ -2560,7 +2553,7 @@ namespace {
2560
2553
auto [DecoderNamespace, HwModeID, Size] = Key;
2561
2554
const unsigned BitWidth = IsVarLenInst ? MaxInstLen : 8 * Size;
2562
2555
// Emit the decoder for this (namespace, hwmode, width) combination.
2563
- FilterChooser FC (Encodings, EncodingIDs, BitWidth, this );
2556
+ FilterChooser FC (Encodings, EncodingIDs, BitWidth, Target );
2564
2557
2565
2558
// The decode table is cleared for each top level decoder function. The
2566
2559
// predicates and decoders themselves, however, are shared across all
@@ -2603,7 +2596,6 @@ namespace {
2603
2596
OS << " \n } // namespace\n " ;
2604
2597
}
2605
2598
2606
- void llvm::EmitDecoder (const RecordKeeper &RK, raw_ostream &OS,
2607
- StringRef PredicateNamespace) {
2608
- DecoderEmitter (RK, PredicateNamespace).run (OS);
2599
+ void llvm::EmitDecoder (const RecordKeeper &RK, raw_ostream &OS) {
2600
+ DecoderEmitter (RK).run (OS);
2609
2601
}
0 commit comments