diff options
author | Abinav Puthan Purayil <abinavpp@gmail.com> | 2022-05-08 21:24:52 +0530 |
---|---|---|
committer | Abinav Puthan Purayil <abinavpp@gmail.com> | 2022-07-08 09:47:33 +0530 |
commit | c42fe5bd7a336250dfcce18673b717af9380a69a (patch) | |
tree | dc834cbd6a59c71f932a314c66a8cab4dbff8e7a /llvm/utils/TableGen/CodeGenDAGPatterns.cpp | |
parent | 7504c7a8772b1205eb561ecc5a1a73b9d4e99d27 (diff) | |
download | llvm-c42fe5bd7a336250dfcce18673b717af9380a69a.zip llvm-c42fe5bd7a336250dfcce18673b717af9380a69a.tar.gz llvm-c42fe5bd7a336250dfcce18673b717af9380a69a.tar.bz2 |
[GlobalISel][SelectionDAG] Implement the HasNoUse builtin predicate
This change introduces the HasNoUse builtin predicate in PatFrags that
checks for the absence of use of the first result operand.
GlobalISelEmitter will allow source PatFrags with this predicate to be
matched with destination instructions with empty outs. This predicate is
required for selecting the no-return variant of atomic instructions in
AMDGPU.
Differential Revision: https://reviews.llvm.org/D125212
Diffstat (limited to 'llvm/utils/TableGen/CodeGenDAGPatterns.cpp')
-rw-r--r-- | llvm/utils/TableGen/CodeGenDAGPatterns.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp index 03566a9..0f37875 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -932,7 +932,7 @@ TreePredicateFn::TreePredicateFn(TreePattern *N) : PatFragRec(N) { } bool TreePredicateFn::hasPredCode() const { - return isLoad() || isStore() || isAtomic() || + return isLoad() || isStore() || isAtomic() || hasNoUse() || !PatFragRec->getRecord()->getValueAsString("PredicateCode").empty(); } @@ -1154,6 +1154,9 @@ std::string TreePredicateFn::getPredCode() const { .str(); } + if (hasNoUse()) + Code += "if (!SDValue(N, 0).use_empty()) return false;\n"; + std::string PredicateCode = std::string(PatFragRec->getRecord()->getValueAsString("PredicateCode")); @@ -1197,6 +1200,9 @@ bool TreePredicateFn::isPredefinedPredicateEqualTo(StringRef Field, bool TreePredicateFn::usesOperands() const { return isPredefinedPredicateEqualTo("PredicateCodeUsesOperands", true); } +bool TreePredicateFn::hasNoUse() const { + return isPredefinedPredicateEqualTo("HasNoUse", true); +} bool TreePredicateFn::isLoad() const { return isPredefinedPredicateEqualTo("IsLoad", true); } |