summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/GlobalISelEmitter.cpp
diff options
context:
space:
mode:
authorNicolai Haehnle <nhaehnle@gmail.com>2018-11-30 14:15:13 +0000
committerNicolai Haehnle <nhaehnle@gmail.com>2018-11-30 14:15:13 +0000
commit445b0b6260238f3e59204e6af921447564962004 (patch)
tree1b6d43d2dc8333e31fe464aeda870853c219f798 /llvm/utils/TableGen/GlobalISelEmitter.cpp
parent4830fdd21afd9e4f15cd610422ccab760779ef98 (diff)
downloadbcm5719-llvm-445b0b6260238f3e59204e6af921447564962004.tar.gz
bcm5719-llvm-445b0b6260238f3e59204e6af921447564962004.zip
TableGen/ISel: Allow PatFrag predicate code to access captured operands
Summary: This simplifies writing predicates for pattern fragments that are automatically re-associated or commuted. For example, a followup patch adds patterns for fragments of the form (add (shl $x, $y), $z) to the AMDGPU backend. Such patterns are automatically commuted to (add $z, (shl $x, $y)), which makes it basically impossible to refer to $x, $y, and $z generically in the PredicateCode. With this change, the PredicateCode can refer to $x, $y, and $z simply as `Operands[i]`. Test confirmed that there are no changes to any of the generated files when building all (non-experimental) targets. Change-Id: I61c00ace7eed42c1d4edc4c5351174b56b77a79c Reviewers: arsenm, rampitec, RKSimon, craig.topper, hfinkel, uweigand Subscribers: wdng, tpr, llvm-commits Differential Revision: https://reviews.llvm.org/D51994 llvm-svn: 347992
Diffstat (limited to 'llvm/utils/TableGen/GlobalISelEmitter.cpp')
-rw-r--r--llvm/utils/TableGen/GlobalISelEmitter.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index ad0ee3dfbc4..997ceb12bec 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -200,7 +200,8 @@ static Optional<LLTCodeGen> MVTToLLT(MVT::SimpleValueType SVT) {
static std::string explainPredicates(const TreePatternNode *N) {
std::string Explanation = "";
StringRef Separator = "";
- for (const auto &P : N->getPredicateFns()) {
+ for (const TreePredicateCall &Call : N->getPredicateCalls()) {
+ const TreePredicateFn &P = Call.Fn;
Explanation +=
(Separator + P.getOrigPatFragRecord()->getRecord()->getName()).str();
Separator = ", ";
@@ -284,7 +285,9 @@ static Error isTrivialOperatorNode(const TreePatternNode *N) {
std::string Separator = "";
bool HasUnsupportedPredicate = false;
- for (const auto &Predicate : N->getPredicateFns()) {
+ for (const TreePredicateCall &Call : N->getPredicateCalls()) {
+ const TreePredicateFn &Predicate = Call.Fn;
+
if (Predicate.isAlwaysTrue())
continue;
@@ -3117,7 +3120,8 @@ Record *GlobalISelEmitter::findNodeEquiv(Record *N) const {
const CodeGenInstruction *
GlobalISelEmitter::getEquivNode(Record &Equiv, const TreePatternNode *N) const {
- for (const auto &Predicate : N->getPredicateFns()) {
+ for (const TreePredicateCall &Call : N->getPredicateCalls()) {
+ const TreePredicateFn &Predicate = Call.Fn;
if (!Equiv.isValueUnset("IfSignExtend") && Predicate.isLoad() &&
Predicate.isSignExtLoad())
return &Target.getInstruction(Equiv.getValueAsDef("IfSignExtend"));
@@ -3186,7 +3190,8 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
" for result of Src pattern operator");
}
- for (const auto &Predicate : Src->getPredicateFns()) {
+ for (const TreePredicateCall &Call : Src->getPredicateCalls()) {
+ const TreePredicateFn &Predicate = Call.Fn;
if (Predicate.isAlwaysTrue())
continue;
OpenPOWER on IntegriCloud