aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
diff options
context:
space:
mode:
authorjyli0116 <yu.li@arm.com>2025-06-09 09:02:56 +0100
committerGitHub <noreply@github.com>2025-06-09 09:02:56 +0100
commitf3ffee601c1746eafa9a6684541e90d182c9126e (patch)
treee964933542e6bef4f5d383f05185f8846e14f3be /llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
parent2f15637e04f51e3ef435c0c0d39aab0e8b933023 (diff)
downloadllvm-f3ffee601c1746eafa9a6684541e90d182c9126e.zip
llvm-f3ffee601c1746eafa9a6684541e90d182c9126e.tar.gz
llvm-f3ffee601c1746eafa9a6684541e90d182c9126e.tar.bz2
[GISel][AArch64] Allow PatLeafs to be imported in GISel which were previously causing warnings (#140935)
Previously PatLeafs could not be imported, causing the following warnings to be emitted when running tblgen with `-warn-on-skipped-patterns:` ``` /work/clean/llvm/lib/Target/AArch64/AArch64InstrInfo.td:2631:1: warning: Skipped pattern: Src pattern child has unsupported predicate def : Pat<(i64 (mul top32Zero:$Rn, top32Zero:$Rm)), ^ ``` These changes allow the patterns to now be imported successfully.
Diffstat (limited to 'llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp')
-rw-r--r--llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
index a87aa8b..d33c0db 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
@@ -899,6 +899,11 @@ TreePredicateFn::TreePredicateFn(TreePattern *N) : PatFragRec(N) {
assert(
(!hasPredCode() || !hasImmCode()) &&
".td file corrupt: can't have a node predicate *and* an imm predicate");
+
+ if (hasGISelPredicateCode() && hasGISelLeafPredicateCode())
+ PrintFatalError(getOrigPatFragRecord()->getRecord()->getLoc(),
+ ".td file corrupt: can't have GISelPredicateCode *and* "
+ "GISelLeafPredicateCode");
}
bool TreePredicateFn::hasPredCode() const {
@@ -1293,8 +1298,20 @@ bool TreePredicateFn::hasGISelPredicateCode() const {
}
std::string TreePredicateFn::getGISelPredicateCode() const {
- return std::string(
- PatFragRec->getRecord()->getValueAsString("GISelPredicateCode"));
+ return PatFragRec->getRecord()->getValueAsString("GISelPredicateCode").str();
+}
+
+bool TreePredicateFn::hasGISelLeafPredicateCode() const {
+ return PatFragRec->getRecord()
+ ->getValueAsOptionalString("GISelLeafPredicateCode")
+ .has_value();
+}
+
+std::string TreePredicateFn::getGISelLeafPredicateCode() const {
+ return PatFragRec->getRecord()
+ ->getValueAsOptionalString("GISelLeafPredicateCode")
+ .value_or(StringRef())
+ .str();
}
StringRef TreePredicateFn::getImmType() const {