diff options
author | Christopher Lamb <christopher.lamb@gmail.com> | 2008-01-31 07:27:46 +0000 |
---|---|---|
committer | Christopher Lamb <christopher.lamb@gmail.com> | 2008-01-31 07:27:46 +0000 |
commit | 8535624739e55ab7424eadf792e1a3b4123421c7 (patch) | |
tree | 805dabe014aa0a4759c10d0dfca36de28e5bf673 /utils/TableGen/DAGISelEmitter.cpp | |
parent | 175e81598ad3fc02f9f5a2ac3ef578a9fed31b6e (diff) | |
download | llvm-8535624739e55ab7424eadf792e1a3b4123421c7.tar.gz llvm-8535624739e55ab7424eadf792e1a3b4123421c7.tar.bz2 llvm-8535624739e55ab7424eadf792e1a3b4123421c7.tar.xz |
Allow ComplexExpressions in InstrInfo.td files to be slightly more... complex! ComplexExpressions can now have attributes which affect how TableGen interprets
the pattern when generating matchin code.
The first (and currently, only) attribute causes the immediate parent node of the ComplexPattern operand to be passed into the matching code rather than the node at the root of the entire DAG containing the pattern.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46606 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/DAGISelEmitter.cpp')
-rw-r--r-- | utils/TableGen/DAGISelEmitter.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index d685f701f0..1f568ad5ee 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -550,7 +550,7 @@ public: emitCheck(MaskPredicate + RootName + "0, cast<ConstantSDNode>(" + RootName + "1), " + itostr(II->getValue()) + ")"); - EmitChildMatchCode(N->getChild(0), N, RootName + utostr(0), + EmitChildMatchCode(N->getChild(0), N, RootName + utostr(0), RootName, ChainSuffix + utostr(0), FoundChain); return; } @@ -561,7 +561,7 @@ public: emitInit("SDOperand " + RootName + utostr(OpNo) + " = " + RootName + ".getOperand(" +utostr(OpNo) + ");"); - EmitChildMatchCode(N->getChild(i), N, RootName + utostr(OpNo), + EmitChildMatchCode(N->getChild(i), N, RootName + utostr(OpNo), RootName, ChainSuffix + utostr(OpNo), FoundChain); } @@ -593,7 +593,8 @@ public: } void EmitChildMatchCode(TreePatternNode *Child, TreePatternNode *Parent, - const std::string &RootName, + const std::string &RootName, + const std::string &ParentRootName, const std::string &ChainSuffix, bool &FoundChain) { if (!Child->isLeaf()) { // If it's not a leaf, recursively match. @@ -649,7 +650,12 @@ public: emitCode("SDOperand " + ChainName + ";"); } - std::string Code = Fn + "(N, "; + std::string Code = Fn + "("; + if (CP->hasAttribute(CPAttrParentAsRoot)) { + Code += ParentRootName + ", "; + } else { + Code += "N, "; + } if (CP->hasProperty(SDNPHasChain)) { std::string ParentName(RootName.begin(), RootName.end()-1); Code += ParentName + ", "; |