From 8ead1290e687b27bb7bd877b6b1768f6579d84b7 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Fri, 15 Jun 2018 23:13:43 +0000 Subject: [globalisel][tablegen] Add support for C++ predicates on PatFrags and use it to support BFC on ARM. So far, we've only handled special cases of PatFrag like ImmLeaf. This patch adds support for the remaining cases using similar mechanisms. Like most C++ code from SelectionDAG, GISel and DAGISel expect to operate on different types and representations and as such the code is not compatible between the two. It's therefore necessary to add an alternative implementation in the GISelPredicateCode field. The target test for this feature could easily be done with IntImmLeaf and this would save on a little boilerplate. The reason I've chosen to implement this using PatFrag.GISelPredicateCode and not IntImmLeaf is because I was unable to find a rule that was blocked solely by lack of support for PatFrag predicates. I found that the ones I investigated as being likely candidates for the test were further blocked by other things. llvm-svn: 334871 --- llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'llvm/utils/TableGen/CodeGenDAGPatterns.cpp') diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 610513b38b0..699ff5d49b1 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -1134,6 +1134,14 @@ Record *TreePredicateFn::getScalarMemoryVT() const { return nullptr; return R->getValueAsDef("ScalarMemoryVT"); } +bool TreePredicateFn::hasGISelPredicateCode() const { + return !PatFragRec->getRecord() + ->getValueAsString("GISelPredicateCode") + .empty(); +} +std::string TreePredicateFn::getGISelPredicateCode() const { + return PatFragRec->getRecord()->getValueAsString("GISelPredicateCode"); +} StringRef TreePredicateFn::getImmType() const { if (immCodeUsesAPInt()) -- cgit v1.2.3