@@ -340,7 +340,7 @@ class DecoderEmitter {
340340 SmallDenseMap<unsigned , std::vector<unsigned >> EncodingIDsByHwMode;
341341
342342public:
343- DecoderEmitter (const RecordKeeper &RK, StringRef PredicateNamespace );
343+ explicit DecoderEmitter (const RecordKeeper &RK);
344344
345345 const CodeGenTarget &getTarget () const { return Target; }
346346
@@ -370,9 +370,6 @@ class DecoderEmitter {
370370 NamespacesHwModesMap &NamespacesWithHwModes);
371371
372372 void parseInstructionEncodings ();
373-
374- public:
375- StringRef PredicateNamespace;
376373};
377374
378375} // end anonymous namespace
@@ -487,8 +484,7 @@ class FilterChooser {
487484 // / This field allows us to ignore the extra bits.
488485 unsigned MaxFilterWidth;
489486
490- // Parent emitter
491- const DecoderEmitter *Emitter;
487+ const CodeGenTarget &Target;
492488
493489 // / If the selected filter matches multiple encodings, then this is the
494490 // / starting position and the width of the filtered range.
@@ -524,9 +520,9 @@ class FilterChooser {
524520 // / Constructs a top-level filter chooser.
525521 FilterChooser (ArrayRef<InstructionEncoding> Encodings,
526522 ArrayRef<unsigned > EncodingIDs, unsigned MaxFilterWidth,
527- const DecoderEmitter *E )
523+ const CodeGenTarget &Target )
528524 : Encodings(Encodings), EncodingIDs(EncodingIDs), Parent(nullptr ),
529- MaxFilterWidth (MaxFilterWidth), Emitter(E ) {
525+ MaxFilterWidth (MaxFilterWidth), Target(Target ) {
530526 // Sort encoding IDs once.
531527 stable_sort (this ->EncodingIDs , LessEncodingIDByWidth (Encodings));
532528 // Filter width is the width of the smallest encoding.
@@ -542,7 +538,7 @@ class FilterChooser {
542538 ArrayRef<unsigned > EncodingIDs, const KnownBits &FilterBits,
543539 const FilterChooser &Parent)
544540 : Encodings(Encodings), EncodingIDs(EncodingIDs), Parent(&Parent),
545- MaxFilterWidth(Parent.MaxFilterWidth), Emitter (Parent.Emitter ) {
541+ MaxFilterWidth(Parent.MaxFilterWidth), Target (Parent.Target ) {
546542 // Inferior filter choosers are created from sorted array of encoding IDs.
547543 assert (is_sorted (EncodingIDs, LessEncodingIDByWidth (Encodings)));
548544 assert (!FilterBits.hasConflict () && " Broken filter" );
@@ -1155,8 +1151,7 @@ bool FilterChooser::emitPredicateMatchAux(const Init &Val, bool ParenIfBinOp,
11551151 if (const auto *D = dyn_cast<DefInit>(&Val)) {
11561152 if (!D->getDef ()->isSubClassOf (" SubtargetFeature" ))
11571153 return true ;
1158- OS << " Bits[" << Emitter->PredicateNamespace << " ::" << D->getAsString ()
1159- << " ]" ;
1154+ OS << " Bits[" << Target.getName () << " ::" << D->getAsString () << " ]" ;
11601155 return false ;
11611156 }
11621157 if (const auto *D = dyn_cast<DagInit>(&Val)) {
@@ -1350,7 +1345,7 @@ void FilterChooser::emitSingletonTableEntry(DecoderTableInfo &TableInfo,
13501345 : MCD::OPC_TryDecode;
13511346 TableInfo.Table .insertOpcode (DecoderOp);
13521347 const Record *InstDef = Encodings[EncodingID].getInstruction ()->TheDef ;
1353- TableInfo.Table .insertULEB128 (Emitter-> getTarget () .getInstrIntValue (InstDef));
1348+ TableInfo.Table .insertULEB128 (Target .getInstrIntValue (InstDef));
13541349 TableInfo.Table .insertULEB128 (DIdx);
13551350
13561351 if (DecoderOp == MCD::OPC_TryDecode) {
@@ -2502,10 +2497,8 @@ void DecoderEmitter::parseInstructionEncodings() {
25022497 NumEncodings = NumEncodingsSupported + NumEncodingsOmitted;
25032498}
25042499
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()) {
25092502 Target.reverseBitsForLittleEndianEncoding ();
25102503 parseInstructionEncodings ();
25112504}
@@ -2560,7 +2553,7 @@ namespace {
25602553 auto [DecoderNamespace, HwModeID, Size] = Key;
25612554 const unsigned BitWidth = IsVarLenInst ? MaxInstLen : 8 * Size;
25622555 // Emit the decoder for this (namespace, hwmode, width) combination.
2563- FilterChooser FC (Encodings, EncodingIDs, BitWidth, this );
2556+ FilterChooser FC (Encodings, EncodingIDs, BitWidth, Target );
25642557
25652558 // The decode table is cleared for each top level decoder function. The
25662559 // predicates and decoders themselves, however, are shared across all
@@ -2603,7 +2596,6 @@ namespace {
26032596 OS << " \n } // namespace\n " ;
26042597}
26052598
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);
26092601}
0 commit comments