diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-28 02:31:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-28 02:31:26 +0000 |
commit | e86097af5598e44727875f00e492d43c978239be (patch) | |
tree | 079307e8dd552052a12f9d35a526cda038c772c4 /utils/TableGen/DAGISelMatcher.h | |
parent | 6ac33b4533889f132ba10c812ae574d779c827b9 (diff) |
add infrastructure to support forming selectnodeto. Not used yet
because I have to go on another detour first.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97362 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/DAGISelMatcher.h')
-rw-r--r-- | utils/TableGen/DAGISelMatcher.h | 64 |
1 files changed, 53 insertions, 11 deletions
diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h index d80f19b334..3d73262ef8 100644 --- a/utils/TableGen/DAGISelMatcher.h +++ b/utils/TableGen/DAGISelMatcher.h @@ -75,7 +75,8 @@ public: EmitNode, // Create a DAG node EmitNodeXForm, // Run a SDNodeXForm MarkFlagResults, // Indicate which interior nodes have flag results. - CompleteMatch // Finish a match and update the results. + CompleteMatch, // Finish a match and update the results. + SelectNodeTo // Build a node, finish a match and update results. }; const KindTy Kind; @@ -869,8 +870,9 @@ private: } }; -/// EmitNodeMatcher - This signals a successful match and generates a node. -class EmitNodeMatcher : public Matcher { +/// EmitNodeMatcherCommon - Common class shared between EmitNode and +/// SelectNodeTo. +class EmitNodeMatcherCommon : public Matcher { std::string OpcodeName; const SmallVector<MVT::SimpleValueType, 3> VTs; const SmallVector<unsigned, 6> Operands; @@ -881,16 +883,18 @@ class EmitNodeMatcher : public Matcher { /// operands in the root of the pattern. The rest are appended to this node. int NumFixedArityOperands; public: - EmitNodeMatcher(const std::string &opcodeName, - const MVT::SimpleValueType *vts, unsigned numvts, - const unsigned *operands, unsigned numops, - bool hasChain, bool hasFlag, bool hasmemrefs, - int numfixedarityoperands) - : Matcher(EmitNode), OpcodeName(opcodeName), + EmitNodeMatcherCommon(const std::string &opcodeName, + const MVT::SimpleValueType *vts, unsigned numvts, + const unsigned *operands, unsigned numops, + bool hasChain, bool hasFlag, bool hasmemrefs, + int numfixedarityoperands, bool isSelectNodeTo) + : Matcher(isSelectNodeTo ? SelectNodeTo : EmitNode), OpcodeName(opcodeName), VTs(vts, vts+numvts), Operands(operands, operands+numops), HasChain(hasChain), HasFlag(hasFlag), HasMemRefs(hasmemrefs), NumFixedArityOperands(numfixedarityoperands) {} + bool isSelectNodeTo() const { return getKind() == SelectNodeTo; } + const std::string &getOpcodeName() const { return OpcodeName; } unsigned getNumVTs() const { return VTs.size(); } @@ -911,7 +915,7 @@ public: int getNumFixedArityOperands() const { return NumFixedArityOperands; } static inline bool classof(const Matcher *N) { - return N->getKind() == EmitNode; + return N->getKind() == EmitNode || N->getKind() == SelectNodeTo; } private: @@ -920,6 +924,44 @@ private: virtual unsigned getHashImpl() const; }; +/// EmitNodeMatcher - This signals a successful match and generates a node. +class EmitNodeMatcher : public EmitNodeMatcherCommon { +public: + EmitNodeMatcher(const std::string &opcodeName, + const MVT::SimpleValueType *vts, unsigned numvts, + const unsigned *operands, unsigned numops, + bool hasChain, bool hasFlag, bool hasmemrefs, + int numfixedarityoperands) + : EmitNodeMatcherCommon(opcodeName, vts, numvts, operands, numops, hasChain, + hasFlag, hasmemrefs, numfixedarityoperands, false) + {} + + static inline bool classof(const Matcher *N) { + return N->getKind() == EmitNode; + } + +}; + +class SelectNodeToMatcher : public EmitNodeMatcherCommon { + const PatternToMatch &Pattern; +public: + SelectNodeToMatcher(const std::string &opcodeName, + const MVT::SimpleValueType *vts, unsigned numvts, + const unsigned *operands, unsigned numops, + bool hasChain, bool hasFlag, bool hasmemrefs, + int numfixedarityoperands, const PatternToMatch &pattern) + : EmitNodeMatcherCommon(opcodeName, vts, numvts, operands, numops, hasChain, + hasFlag, hasmemrefs, numfixedarityoperands, true), + Pattern(pattern) { + } + + const PatternToMatch &getPattern() const { return Pattern; } + + static inline bool classof(const Matcher *N) { + return N->getKind() == SelectNodeTo; + } +}; + /// MarkFlagResultsMatcher - This node indicates which non-root nodes in the /// pattern produce flags. This allows CompleteMatchMatcher to update them /// with the output flag of the resultant code. @@ -976,7 +1018,7 @@ private: } virtual unsigned getHashImpl() const; }; - + } // end namespace llvm #endif |