@@ -578,12 +578,6 @@ class FilterChooser {
578578 // decoded bits in order to verify that the instruction matches the Opcode.
579579 std::vector<Island> getIslands (const KnownBits &EncodingBits) const ;
580580
581- // reportRegion is a helper function for filterProcessor to mark a region as
582- // eligible for use as a filter region.
583- void reportRegion (std::vector<std::unique_ptr<Filter>> &Filters, bitAttr_t RA,
584- unsigned StartBit, unsigned BitIndex,
585- bool AllowMixed) const ;
586-
587581 // / Scans the well-known encoding bits of the encodings and, builds up a list
588582 // / of candidate filters, and then returns the best one, if any.
589583 std::unique_ptr<Filter> findBestFilter (ArrayRef<bitAttr_t> BitAttrs,
@@ -1343,16 +1337,6 @@ void DecoderTableBuilder::emitSingletonTableEntry(
13431337 TableInfo.Table .insertULEB128 (DIdx);
13441338}
13451339
1346- // reportRegion is a helper function for filterProcessor to mark a region as
1347- // eligible for use as a filter region.
1348- void FilterChooser::reportRegion (std::vector<std::unique_ptr<Filter>> &Filters,
1349- bitAttr_t RA, unsigned StartBit,
1350- unsigned BitIndex, bool AllowMixed) const {
1351- if (AllowMixed ? RA == ATTR_MIXED : RA == ATTR_ALL_SET)
1352- Filters.push_back (std::make_unique<Filter>(Encodings, EncodingIDs, StartBit,
1353- BitIndex - StartBit));
1354- }
1355-
13561340std::unique_ptr<Filter>
13571341FilterChooser::findBestFilter (ArrayRef<bitAttr_t> BitAttrs, bool AllowMixed,
13581342 bool Greedy) const {
@@ -1401,6 +1385,12 @@ FilterChooser::findBestFilter(ArrayRef<bitAttr_t> BitAttrs, bool AllowMixed,
14011385 unsigned StartBit = 0 ;
14021386
14031387 std::vector<std::unique_ptr<Filter>> Filters;
1388+
1389+ auto addCandidateFilter = [&](unsigned StartBit, unsigned EndBit) {
1390+ Filters.push_back (std::make_unique<Filter>(Encodings, EncodingIDs, StartBit,
1391+ EndBit - StartBit));
1392+ };
1393+
14041394 unsigned FilterWidth = FilterBits.getBitWidth ();
14051395 for (unsigned BitIndex = 0 ; BitIndex != FilterWidth; ++BitIndex) {
14061396 bitAttr_t bitAttr = BitAttrs[BitIndex];
@@ -1427,19 +1417,18 @@ FilterChooser::findBestFilter(ArrayRef<bitAttr_t> BitAttrs, bool AllowMixed,
14271417 }
14281418 break ;
14291419 case ATTR_ALL_SET:
1420+ if (!AllowMixed && bitAttr != ATTR_ALL_SET)
1421+ addCandidateFilter (StartBit, BitIndex);
14301422 switch (bitAttr) {
14311423 case ATTR_FILTERED:
1432- reportRegion (Filters, RA, StartBit, BitIndex, AllowMixed);
14331424 RA = ATTR_NONE;
14341425 break ;
14351426 case ATTR_ALL_SET:
14361427 break ;
14371428 case ATTR_ALL_UNSET:
1438- reportRegion (Filters, RA, StartBit, BitIndex, AllowMixed);
14391429 RA = ATTR_NONE;
14401430 break ;
14411431 case ATTR_MIXED:
1442- reportRegion (Filters, RA, StartBit, BitIndex, AllowMixed);
14431432 StartBit = BitIndex;
14441433 RA = ATTR_MIXED;
14451434 break ;
@@ -1448,19 +1437,18 @@ FilterChooser::findBestFilter(ArrayRef<bitAttr_t> BitAttrs, bool AllowMixed,
14481437 }
14491438 break ;
14501439 case ATTR_MIXED:
1440+ if (AllowMixed && bitAttr != ATTR_MIXED)
1441+ addCandidateFilter (StartBit, BitIndex);
14511442 switch (bitAttr) {
14521443 case ATTR_FILTERED:
1453- reportRegion (Filters, RA, StartBit, BitIndex, AllowMixed);
14541444 StartBit = BitIndex;
14551445 RA = ATTR_NONE;
14561446 break ;
14571447 case ATTR_ALL_SET:
1458- reportRegion (Filters, RA, StartBit, BitIndex, AllowMixed);
14591448 StartBit = BitIndex;
14601449 RA = ATTR_ALL_SET;
14611450 break ;
14621451 case ATTR_ALL_UNSET:
1463- reportRegion (Filters, RA, StartBit, BitIndex, AllowMixed);
14641452 RA = ATTR_NONE;
14651453 break ;
14661454 case ATTR_MIXED:
@@ -1483,12 +1471,14 @@ FilterChooser::findBestFilter(ArrayRef<bitAttr_t> BitAttrs, bool AllowMixed,
14831471 case ATTR_FILTERED:
14841472 break ;
14851473 case ATTR_ALL_SET:
1486- reportRegion (Filters, RA, StartBit, FilterWidth, AllowMixed);
1474+ if (!AllowMixed)
1475+ addCandidateFilter (StartBit, FilterWidth);
14871476 break ;
14881477 case ATTR_ALL_UNSET:
14891478 break ;
14901479 case ATTR_MIXED:
1491- reportRegion (Filters, RA, StartBit, FilterWidth, AllowMixed);
1480+ if (AllowMixed)
1481+ addCandidateFilter (StartBit, FilterWidth);
14921482 break ;
14931483 }
14941484
0 commit comments