1717#include " Common/InfoByHwMode.h"
1818#include " Common/InstructionEncoding.h"
1919#include " Common/VarLenCodeEmitterGen.h"
20+ #include " Common/SubtargetFeatureInfo.h"
2021#include " TableGenBackends.h"
2122#include " llvm/ADT/APInt.h"
2223#include " llvm/ADT/ArrayRef.h"
@@ -517,7 +518,7 @@ class DecoderTableBuilder {
517518 bool emitPredicateMatchAux (const Init &Val, bool ParenIfBinOp,
518519 raw_ostream &OS) const ;
519520
520- bool emitPredicateMatch (raw_ostream &OS, unsigned EncodingID) const ;
521+ void emitPredicateMatch (raw_ostream &OS, unsigned EncodingID) const ;
521522
522523 void emitPredicateTableEntry (unsigned EncodingID) const ;
523524
@@ -837,7 +838,7 @@ void DecoderEmitter::emitPredicateFunction(formatted_raw_ostream &OS,
837838 // The predicate function is just a big switch statement based on the
838839 // input predicate index.
839840 OS << " static bool checkDecoderPredicate(unsigned Idx, const FeatureBitset "
840- " &Bits ) {\n " ;
841+ " &FB ) {\n " ;
841842 OS << " switch (Idx) {\n " ;
842843 OS << " default: llvm_unreachable(\" Invalid index!\" );\n " ;
843844 for (const auto &[Index, Predicate] : enumerate(Predicates)) {
@@ -1132,27 +1133,14 @@ bool DecoderTableBuilder::emitPredicateMatchAux(const Init &Val,
11321133 return true ;
11331134}
11341135
1135- bool DecoderTableBuilder::emitPredicateMatch (raw_ostream &OS,
1136+ void DecoderTableBuilder::emitPredicateMatch (raw_ostream &OS,
11361137 unsigned EncodingID) const {
1137- const ListInit *Predicates =
1138+ const ListInit *PredicateList =
11381139 Encodings[EncodingID].getRecord ()->getValueAsListInit (" Predicates" );
1139- ListSeparator LS (" && " );
1140- bool AnyPredicate = false ;
1141- for (unsigned i = 0 ; i < Predicates->size (); ++i) {
1142- const Record *Pred = Predicates->getElementAsRecord (i);
1143- if (!Pred->getValue (" AssemblerMatcherPredicate" ))
1144- continue ;
1145-
1146- if (!isa<DagInit>(Pred->getValue (" AssemblerCondDag" )->getValue ()))
1147- continue ;
1148-
1149- AnyPredicate = true ;
1150- OS << LS;
1151- if (emitPredicateMatchAux (*Pred->getValueAsDag (" AssemblerCondDag" ),
1152- Predicates->size () > 1 , OS))
1153- PrintFatalError (Pred->getLoc (), " Invalid AssemblerCondDag!" );
1154- }
1155- return AnyPredicate;
1140+ std::vector<const Record *> Predicates;
1141+ for (unsigned i = 0 ; i < PredicateList->size (); ++i)
1142+ Predicates.push_back (PredicateList->getElementAsRecord (i));
1143+ SubtargetFeatureInfo::emitMCPredicateCheck (OS, Target.getName (), Predicates);
11561144}
11571145
11581146unsigned DecoderTableBuilder::getPredicateIndex (StringRef Predicate) const {
@@ -1172,10 +1160,12 @@ unsigned DecoderTableBuilder::getPredicateIndex(StringRef Predicate) const {
11721160void DecoderTableBuilder::emitPredicateTableEntry (unsigned EncodingID) const {
11731161 // Build up the predicate string.
11741162 SmallString<256 > Predicate;
1175- // FIXME: emitPredicateMatch() functions can take a buffer directly rather
1176- // than a stream.
11771163 raw_svector_ostream PS (Predicate);
1178- if (!emitPredicateMatch (PS, EncodingID))
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" )
11791169 return ;
11801170
11811171 // Figure out the index into the predicate table for the predicate just
0 commit comments