[llvm] r315872 - [tablegen] Use hasPredCode()/hasImmCode() instead of getPredCode().empty()/getImmCode().empty(). NFC
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 15 12:01:32 PDT 2017
Author: dsanders
Date: Sun Oct 15 12:01:32 2017
New Revision: 315872
URL: http://llvm.org/viewvc/llvm-project?rev=315872&view=rev
Log:
[tablegen] Use hasPredCode()/hasImmCode() instead of getPredCode().empty()/getImmCode().empty(). NFC
These are cheaper ways of testing for the presence of code than generating the C++ code and testing it's empty.
Modified:
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=315872&r1=315871&r2=315872&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Sun Oct 15 12:01:32 2017
@@ -807,8 +807,14 @@ TypeSetByHwMode TypeInfer::getLegalTypes
/// TreePredicateFn constructor. Here 'N' is a subclass of PatFrag.
TreePredicateFn::TreePredicateFn(TreePattern *N) : PatFragRec(N) {
- assert((getPredCode().empty() || getImmCode().empty()) &&
- ".td file corrupt: can't have a node predicate *and* an imm predicate");
+ assert(
+ (!hasPredCode() || !hasImmCode()) &&
+ ".td file corrupt: can't have a node predicate *and* an imm predicate");
+}
+
+bool TreePredicateFn::hasPredCode() const {
+ return isLoad() || isStore() ||
+ !PatFragRec->getRecord()->getValueAsString("PredicateCode").empty();
}
std::string TreePredicateFn::getPredCode() const {
@@ -933,6 +939,10 @@ std::string TreePredicateFn::getPredCode
return Code;
}
+bool TreePredicateFn::hasImmCode() const {
+ return !PatFragRec->getRecord()->getValueAsString("ImmediateCode").empty();
+}
+
std::string TreePredicateFn::getImmCode() const {
return PatFragRec->getRecord()->getValueAsString("ImmediateCode");
}
@@ -1015,7 +1025,7 @@ StringRef TreePredicateFn::getImmTypeIde
/// isAlwaysTrue - Return true if this is a noop predicate.
bool TreePredicateFn::isAlwaysTrue() const {
- return getPredCode().empty() && getImmCode().empty();
+ return !hasPredCode() && !hasImmCode();
}
/// Return the name to use in the generated code to reference this, this is
@@ -1085,7 +1095,7 @@ std::string TreePredicateFn::getCodeToRu
}
// Handle arbitrary node predicates.
- assert(!getPredCode().empty() && "Don't have any predicate code!");
+ assert(hasPredCode() && "Don't have any predicate code!");
StringRef ClassName;
if (PatFragRec->getOnlyTree()->isLeaf())
ClassName = "SDNode";
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=315872&r1=315871&r2=315872&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Sun Oct 15 12:01:32 2017
@@ -447,7 +447,7 @@ public:
/// isAlwaysTrue - Return true if this is a noop predicate.
bool isAlwaysTrue() const;
- bool isImmediatePattern() const { return !getImmCode().empty(); }
+ bool isImmediatePattern() const { return hasImmCode(); }
/// getImmediatePredicateCode - Return the code that evaluates this pattern if
/// this is an immediate predicate. It is an error to call this on a
@@ -511,6 +511,8 @@ public:
Record *getScalarMemoryVT() const;
private:
+ bool hasPredCode() const;
+ bool hasImmCode() const;
std::string getPredCode() const;
std::string getImmCode() const;
bool immCodeUsesAPInt() const;
More information about the llvm-commits
mailing list