@@ -519,8 +519,6 @@ class DecoderTableBuilder {
519519
520520 bool emitPredicateMatch (raw_ostream &OS, unsigned EncodingID) const ;
521521
522- bool doesOpcodeNeedPredicate (unsigned EncodingID) const ;
523-
524522 void emitPredicateTableEntry (unsigned EncodingID) const ;
525523
526524 void emitSoftFailTableEntry (unsigned EncodingID) const ;
@@ -1138,7 +1136,8 @@ bool DecoderTableBuilder::emitPredicateMatch(raw_ostream &OS,
11381136 unsigned EncodingID) const {
11391137 const ListInit *Predicates =
11401138 Encodings[EncodingID].getRecord ()->getValueAsListInit (" Predicates" );
1141- bool IsFirstEmission = true ;
1139+ ListSeparator LS (" && " );
1140+ bool AnyPredicate = false ;
11421141 for (unsigned i = 0 ; i < Predicates->size (); ++i) {
11431142 const Record *Pred = Predicates->getElementAsRecord (i);
11441143 if (!Pred->getValue (" AssemblerMatcherPredicate" ))
@@ -1147,28 +1146,13 @@ bool DecoderTableBuilder::emitPredicateMatch(raw_ostream &OS,
11471146 if (!isa<DagInit>(Pred->getValue (" AssemblerCondDag" )->getValue ()))
11481147 continue ;
11491148
1150- if (!IsFirstEmission)
1151- OS << " && " ;
1149+ AnyPredicate = true ;
1150+ OS << LS ;
11521151 if (emitPredicateMatchAux (*Pred->getValueAsDag (" AssemblerCondDag" ),
11531152 Predicates->size () > 1 , OS))
11541153 PrintFatalError (Pred->getLoc (), " Invalid AssemblerCondDag!" );
1155- IsFirstEmission = false ;
1156- }
1157- return !Predicates->empty ();
1158- }
1159-
1160- bool DecoderTableBuilder::doesOpcodeNeedPredicate (unsigned EncodingID) const {
1161- const ListInit *Predicates =
1162- Encodings[EncodingID].getRecord ()->getValueAsListInit (" Predicates" );
1163- for (unsigned i = 0 ; i < Predicates->size (); ++i) {
1164- const Record *Pred = Predicates->getElementAsRecord (i);
1165- if (!Pred->getValue (" AssemblerMatcherPredicate" ))
1166- continue ;
1167-
1168- if (isa<DagInit>(Pred->getValue (" AssemblerCondDag" )->getValue ()))
1169- return true ;
11701154 }
1171- return false ;
1155+ return AnyPredicate ;
11721156}
11731157
11741158unsigned DecoderTableBuilder::getPredicateIndex (StringRef Predicate) const {
@@ -1186,15 +1170,13 @@ unsigned DecoderTableBuilder::getPredicateIndex(StringRef Predicate) const {
11861170}
11871171
11881172void DecoderTableBuilder::emitPredicateTableEntry (unsigned EncodingID) const {
1189- if (!doesOpcodeNeedPredicate (EncodingID))
1190- return ;
1191-
11921173 // Build up the predicate string.
11931174 SmallString<256 > Predicate;
11941175 // FIXME: emitPredicateMatch() functions can take a buffer directly rather
11951176 // than a stream.
11961177 raw_svector_ostream PS (Predicate);
1197- emitPredicateMatch (PS, EncodingID);
1178+ if (!emitPredicateMatch (PS, EncodingID))
1179+ return ;
11981180
11991181 // Figure out the index into the predicate table for the predicate just
12001182 // computed.
0 commit comments