@@ -518,7 +518,7 @@ class DecoderTableBuilder {
518518 bool emitPredicateMatchAux (const Init &Val, bool ParenIfBinOp,
519519 raw_ostream &OS) const ;
520520
521- void emitPredicateMatch (raw_ostream &OS, unsigned EncodingID) const ;
521+ bool emitPredicateMatch (raw_ostream &OS, unsigned EncodingID) const ;
522522
523523 void emitPredicateTableEntry (unsigned EncodingID) const ;
524524
@@ -1133,14 +1133,19 @@ bool DecoderTableBuilder::emitPredicateMatchAux(const Init &Val,
11331133 return true ;
11341134}
11351135
1136- void DecoderTableBuilder::emitPredicateMatch (raw_ostream &OS,
1136+ // Returns true if there was any predicate emitted.
1137+ bool DecoderTableBuilder::emitPredicateMatch (raw_ostream &OS,
11371138 unsigned EncodingID) const {
1138- const ListInit *PredicateList =
1139- Encodings[EncodingID].getRecord ()->getValueAsListInit (" Predicates" );
1140- std::vector<const Record *> Predicates;
1141- for (unsigned i = 0 ; i < PredicateList->size (); ++i)
1142- Predicates.push_back (PredicateList->getElementAsRecord (i));
1139+ std::vector<const Record *> Predicates =
1140+ Encodings[EncodingID].getRecord ()->getValueAsListOfDefs (" Predicates" );
1141+ auto It = llvm::find_if (Predicates, [](const Record *R) {
1142+ return R->getValueAsBit (" AssemblerMatcherPredicate" );
1143+ });
1144+ bool AnyAsmPredicate = It != Predicates.end ();
1145+ if (!AnyAsmPredicate)
1146+ return false ;
11431147 SubtargetFeatureInfo::emitMCPredicateCheck (OS, Target.getName (), Predicates);
1148+ return true ;
11441149}
11451150
11461151unsigned DecoderTableBuilder::getPredicateIndex (StringRef Predicate) const {
@@ -1161,11 +1166,7 @@ void DecoderTableBuilder::emitPredicateTableEntry(unsigned EncodingID) const {
11611166 // Build up the predicate string.
11621167 SmallString<256 > Predicate;
11631168 raw_svector_ostream PS (Predicate);
1164- emitPredicateMatch (PS, EncodingID);
1165- // Predicate being empty indicates that there are no predicates.
1166- // Predicate being "false" indicate that there are predicates but with no
1167- // AssemblerMatcherPredicate.
1168- if (Predicate.empty () || Predicate == " false" )
1169+ if (!emitPredicateMatch (PS, EncodingID))
11691170 return ;
11701171
11711172 // Figure out the index into the predicate table for the predicate just
0 commit comments