@@ -199,6 +199,17 @@ class InstructionEncoding {
199199 // / Returns a mask of bits that should be considered unknown during decoding.
200200 const APInt &getSoftFailBits () const { return SoftFailBits; }
201201
202+ // / Returns the known bits of this encoding that must match for
203+ // / successful decoding.
204+ KnownBits getMandatoryBits () const {
205+ KnownBits EncodingBits = InstBits;
206+ // Mark all bits that are allowed to change according to SoftFail mask
207+ // as unknown.
208+ EncodingBits.Zero &= ~SoftFailBits;
209+ EncodingBits.One &= ~SoftFailBits;
210+ return EncodingBits;
211+ }
212+
202213 // / Returns the name of the function to use for decoding, or an empty string
203214 // / if the decoder is generated.
204215 StringRef getDecoderMethod () const { return DecoderMethod; }
@@ -559,15 +570,6 @@ class FilterChooser {
559570 }
560571
561572protected:
562- KnownBits getMandatoryEncodingBits (unsigned EncodingID) const {
563- const InstructionEncoding &Encoding = Encodings[EncodingID];
564- KnownBits EncodingBits = Encoding.getInstBits ();
565- // Clear all bits that are allowed to change according to SoftFail mask.
566- EncodingBits.Zero &= ~Encoding.getSoftFailBits ();
567- EncodingBits.One &= ~Encoding.getSoftFailBits ();
568- return EncodingBits;
569- }
570-
571573 // / dumpStack - dumpStack traverses the filter chooser chain and calls
572574 // / dumpFilterArray on each filter chooser up to the top level one.
573575 void dumpStack (raw_ostream &OS, indent Indent, unsigned PadToWidth) const ;
@@ -655,8 +657,8 @@ Filter::Filter(const FilterChooser &owner, unsigned startBit, unsigned numBits)
655657 assert (StartBit + NumBits - 1 < Owner.FilterBits .getBitWidth ());
656658
657659 for (unsigned EncodingID : Owner.EncodingIDs ) {
658- // Populates the insn given the uid.
659- KnownBits EncodingBits = Owner. getMandatoryEncodingBits (EncodingID );
660+ const InstructionEncoding &Encoding = Owner. Encodings [EncodingID];
661+ KnownBits EncodingBits = Encoding. getMandatoryBits ( );
660662
661663 // Scans the segment for possibly well-specified encoding bits.
662664 KnownBits FieldBits = EncodingBits.extractBits (NumBits, StartBit);
@@ -1381,7 +1383,8 @@ void FilterChooser::emitSoftFailTableEntry(DecoderTableInfo &TableInfo,
13811383// Emits table entries to decode the singleton.
13821384void FilterChooser::emitSingletonTableEntry (DecoderTableInfo &TableInfo,
13831385 unsigned EncodingID) const {
1384- KnownBits EncodingBits = getMandatoryEncodingBits (EncodingID);
1386+ const InstructionEncoding &Encoding = Encodings[EncodingID];
1387+ KnownBits EncodingBits = Encoding.getMandatoryBits ();
13851388
13861389 // Look for islands of undecoded bits of the singleton.
13871390 std::vector<Island> Islands = getIslands (EncodingBits);
@@ -1425,7 +1428,6 @@ void FilterChooser::emitSingletonTableEntry(DecoderTableInfo &TableInfo,
14251428 // decoder method indicates that additional processing should be done to see
14261429 // if there is any other instruction that also matches the bitpattern and
14271430 // can decode it.
1428- const InstructionEncoding &Encoding = Encodings[EncodingID];
14291431 const uint8_t DecoderOp =
14301432 Encoding.hasCompleteDecoder ()
14311433 ? MCD::OPC_Decode
@@ -1484,7 +1486,8 @@ bool FilterChooser::filterProcessor(ArrayRef<bitAttr_t> BitAttrs,
14841486 assert (EncodingIDs.size () == 3 );
14851487
14861488 for (unsigned EncodingID : EncodingIDs) {
1487- KnownBits EncodingBits = getMandatoryEncodingBits (EncodingID);
1489+ const InstructionEncoding &Encoding = Encodings[EncodingID];
1490+ KnownBits EncodingBits = Encoding.getMandatoryBits ();
14881491
14891492 // Look for islands of undecoded bits of any instruction.
14901493 std::vector<Island> Islands = getIslands (EncodingBits);
@@ -1675,7 +1678,8 @@ void FilterChooser::doFilter() {
16751678 BitAttrs[BitIndex] = ATTR_FILTERED;
16761679
16771680 for (unsigned EncodingID : EncodingIDs) {
1678- KnownBits EncodingBits = getMandatoryEncodingBits (EncodingID);
1681+ const InstructionEncoding &Encoding = Encodings[EncodingID];
1682+ KnownBits EncodingBits = Encoding.getMandatoryBits ();
16791683
16801684 for (unsigned BitIndex = 0 ; BitIndex != FilterWidth; ++BitIndex) {
16811685 bool IsKnown = EncodingBits.Zero [BitIndex] || EncodingBits.One [BitIndex];
@@ -1732,10 +1736,10 @@ void FilterChooser::doFilter() {
17321736
17331737 // Dump encodings.
17341738 for (unsigned EncodingID : EncodingIDs) {
1735- const InstructionEncoding &Enc = Encodings[EncodingID];
1736- errs () << Indent << indent (PadToWidth - Enc .getBitWidth ());
1737- printKnownBits (errs (), getMandatoryEncodingBits (EncodingID ), ' _' );
1738- errs () << " " << Enc .getName () << ' \n ' ;
1739+ const InstructionEncoding &Encoding = Encodings[EncodingID];
1740+ errs () << Indent << indent (PadToWidth - Encoding .getBitWidth ());
1741+ printKnownBits (errs (), Encoding. getMandatoryBits ( ), ' _' );
1742+ errs () << " " << Encoding .getName () << ' \n ' ;
17391743 }
17401744 PrintFatalError (" Decoding conflict encountered" );
17411745}
0 commit comments