[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Chris Lattner
sabre at nondot.org
Thu Sep 21 13:46:27 PDT 2006
Changes in directory llvm/utils/TableGen:
DAGISelEmitter.cpp updated: 1.262 -> 1.263
---
Log message:
don't allow 'imm' or specific imms, like '1' on the LHS of a binop.
This shrinks X86GenDAGISel by ~330 lines.
---
Diffs of the changes: (+13 -4)
DAGISelEmitter.cpp | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.262 llvm/utils/TableGen/DAGISelEmitter.cpp:1.263
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.262 Thu Sep 21 13:28:27 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp Thu Sep 21 15:46:13 2006
@@ -800,6 +800,17 @@
}
}
+/// OnlyOnRHSOfCommutative - Return true if this value is only allowed on the
+/// RHS of a commutative operation, not the on LHS.
+static bool OnlyOnRHSOfCommutative(TreePatternNode *N) {
+ if (!N->isLeaf() && N->getOperator()->getName() == "imm")
+ return true;
+ if (N->isLeaf() && dynamic_cast<IntInit*>(N->getLeafValue()))
+ return true;
+ return false;
+}
+
+
/// canPatternMatch - If it is impossible for this pattern to match on this
/// target, fill in Reason and return false. Otherwise, return true. This is
/// used as a santity check for .td files (to prevent people from writing stuff
@@ -825,11 +836,9 @@
if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) {
// Scan all of the operands of the node and make sure that only the last one
// is a constant node, unless the RHS also is.
- if (getChild(getNumChildren()-1)->isLeaf() ||
- getChild(getNumChildren()-1)->getOperator()->getName() != "imm") {
+ if (!OnlyOnRHSOfCommutative(getChild(getNumChildren()-1))) {
for (unsigned i = 0, e = getNumChildren()-1; i != e; ++i)
- if (!getChild(i)->isLeaf() &&
- getChild(i)->getOperator()->getName() == "imm") {
+ if (OnlyOnRHSOfCommutative(getChild(i))) {
Reason="Immediate value must be on the RHS of commutative operators!";
return false;
}
More information about the llvm-commits
mailing list