From 49e19e906fd445f8dcc90b6b6d620ade9dc2f7dd Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 22 Aug 2008 00:20:26 +0000 Subject: Factor out the predicate check code from DAGISelEmitter.cpp and use it in FastISelEmitter.cpp, and make FastISel subtarget aware. Among other things, this lets it work properly on x86 targets that don't have SSE, where it successfully selects x87 instructions. llvm-svn: 55156 --- llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'llvm/utils/TableGen/CodeGenDAGPatterns.cpp') diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 1e957834a88..1e595dd4744 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -140,6 +140,33 @@ void DumpDepVars(MultipleUseVarSet &DepVars) { } } +//===----------------------------------------------------------------------===// +// PatternToMatch implementation +// + +/// getPredicateCheck - Return a single string containing all of this +/// pattern's predicates concatenated with "&&" operators. +/// +std::string PatternToMatch::getPredicateCheck() const { + std::string PredicateCheck; + for (unsigned i = 0, e = Predicates->getSize(); i != e; ++i) { + if (DefInit *Pred = dynamic_cast(Predicates->getElement(i))) { + Record *Def = Pred->getDef(); + if (!Def->isSubClassOf("Predicate")) { +#ifndef NDEBUG + Def->dump(); +#endif + assert(0 && "Unknown predicate type!"); + } + if (!PredicateCheck.empty()) + PredicateCheck += " && "; + PredicateCheck += "(" + Def->getValueAsString("CondString") + ")"; + } + } + + return PredicateCheck; +} + //===----------------------------------------------------------------------===// // SDTypeConstraint implementation // -- cgit v1.2.3