aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
diff options
context:
space:
mode:
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 {