[llvm] [TableGen] Directly use SDNode functions to implement HasOneUse and HasNoUse. NFC (PR #133976)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 1 21:54:26 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Craig Topper (topperc)
<details>
<summary>Changes</summary>
The SDValue functions we were calling wrap SDNode functions we can call directly.
---
Full diff: https://github.com/llvm/llvm-project/pull/133976.diff
3 Files Affected:
- (modified) llvm/test/TableGen/HasNoUse.td (+1-1)
- (modified) llvm/test/TableGen/predicate-patfags.td (+1-1)
- (modified) llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp (+2-2)
``````````diff
diff --git a/llvm/test/TableGen/HasNoUse.td b/llvm/test/TableGen/HasNoUse.td
index 6e6bcc2a81df7..0947be11caa4c 100644
--- a/llvm/test/TableGen/HasNoUse.td
+++ b/llvm/test/TableGen/HasNoUse.td
@@ -13,7 +13,7 @@ def NO_RET_ATOMIC_ADD : I<(outs), (ins GPR32Op:$src0, GPR32Op:$src1), []>;
// SDAG-NEXT: SDNode *N = Node;
// SDAG-NEXT: (void)N;
// SDAG-NEXT: if (cast<MemSDNode>(N)->getMemoryVT() != MVT::i32) return false;
-// SDAG-NEXT: if (!SDValue(N, 0).use_empty()) return false;
+// SDAG-NEXT: if (N->hasAnyUseOfValue(0)) return false;
// SDAG-NEXT: return true;
// GISEL: GIM_CheckOpcode, /*MI*/0, GIMT_Encode2(TargetOpcode::G_ATOMICRMW_ADD),
diff --git a/llvm/test/TableGen/predicate-patfags.td b/llvm/test/TableGen/predicate-patfags.td
index 39133f324f305..b69c4acfd6431 100644
--- a/llvm/test/TableGen/predicate-patfags.td
+++ b/llvm/test/TableGen/predicate-patfags.td
@@ -52,7 +52,7 @@ def TGTmul24_oneuse : PatFrag<
// SDAG: OPC_CheckPredicate0, // Predicate_TGTmul24_oneuse
// SCUSTOM: return N->hasOneUse();
-// SBUILTIN: if (!SDValue(N, 0).hasOneUse()) return false;
+// SBUILTIN: if (!N->hasNUsesOfValue(1, 0)) return false;
// GISEL: GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS),
// GISEL: GIM_CheckIntrinsicID, /*MI*/1, /*Op*/1, GIMT_Encode2(Intrinsic::tgt_mul24),
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
index 5ee8c50d6e51b..7f58c4a88c76d 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
@@ -1127,9 +1127,9 @@ std::string TreePredicateFn::getPredCode() const {
}
if (hasNoUse())
- Code += "if (!SDValue(N, 0).use_empty()) return false;\n";
+ Code += "if (N->hasAnyUseOfValue(0)) return false;\n";
if (hasOneUse())
- Code += "if (!SDValue(N, 0).hasOneUse()) return false;\n";
+ Code += "if (!N->hasNUsesOfValue(1, 0)) return false;\n";
std::string PredicateCode =
std::string(PatFragRec->getRecord()->getValueAsString("PredicateCode"));
``````````
</details>
https://github.com/llvm/llvm-project/pull/133976
More information about the llvm-commits
mailing list