[llvm] e020fc1 - [TableGen] Directly use SDNode functions to implement HasOneUse and HasNoUse. NFC (#133976)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 1 22:14:20 PDT 2025
Author: Craig Topper
Date: 2025-04-01T22:14:17-07:00
New Revision: e020fc18959a71c75257dd89ce3d6c86eb388043
URL: https://github.com/llvm/llvm-project/commit/e020fc18959a71c75257dd89ce3d6c86eb388043
DIFF: https://github.com/llvm/llvm-project/commit/e020fc18959a71c75257dd89ce3d6c86eb388043.diff
LOG: [TableGen] Directly use SDNode functions to implement HasOneUse and HasNoUse. NFC (#133976)
The SDValue functions we were calling wrap SDNode functions we can call
directly.
Added:
Modified:
llvm/test/TableGen/HasNoUse.td
llvm/test/TableGen/predicate-patfags.td
llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
Removed:
################################################################################
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"));
More information about the llvm-commits
mailing list