-
- virtual void print(raw_ostream &OS, unsigned indent = 0) const;
-};
-
-/// CheckMultiOpcodeMatcherNode - This checks to see if the current node has one
-/// of the specified opcode, if not it fails to match.
-class CheckMultiOpcodeMatcherNode : public MatcherNode {
- SmallVector<StringRef, 4> OpcodeNames;
-public:
- CheckMultiOpcodeMatcherNode(const StringRef *opcodes, unsigned numops)
- : MatcherNode(CheckMultiOpcode), OpcodeNames(opcodes, opcodes+numops) {}
-
- unsigned getNumOpcodeNames() const { return OpcodeNames.size(); }
- StringRef getOpcodeName(unsigned i) const { return OpcodeNames[i]; }
-
- static inline bool classof(const MatcherNode *N) {
- return N->getKind() == CheckMultiOpcode;
- }
-
- virtual void print(raw_ostream &OS, unsigned indent = 0) const;
-};
-
-
-
-/// CheckTypeMatcherNode - This checks to see if the current node has the
-/// specified type, if not it fails to match.
-class CheckTypeMatcherNode : public MatcherNode {
+
+ virtual bool isSafeToReorderWithPatternPredicate() const { return true; }
+
+private:
+ virtual void printImpl(raw_ostream &OS, unsigned indent) const;
+ virtual bool isEqualImpl(const Matcher *M) const;
+ virtual unsigned getHashImpl() const;
+ virtual bool isContradictoryImpl(const Matcher *M) const;
+};
+
+/// SwitchOpcodeMatcher - Switch based on the current node's opcode, dispatching
+/// to one matcher per opcode. If the opcode doesn't match any of the cases,
+/// then the match fails. This is semantically equivalent to a Scope node where
+/// every child does a CheckOpcode, but is much faster.
+class SwitchOpcodeMatcher : public Matcher {
+ SmallVector<std::pair<const SDNodeInfo*, Matcher*>, 8> Cases;
+public:
+ SwitchOpcodeMatcher(const std::pair<const SDNodeInfo*, Matcher*> *cases,
+ unsigned numcases)
+ : Matcher(SwitchOpcode), Cases(cases, cases+numcases) {}
+
+ static inline bool classof(const Matcher *N) {
+ return N->getKind() == SwitchOpcode;
+ }
+
+ unsigned getNumCases() const { return Cases.size(); }
+
+ const SDNodeInfo &getCaseOpcode(unsigned i) const { return *Cases[i].first; }
+ Matcher *getCaseMatcher(unsigned i) { return Cases[i].second; }
+ const Matcher *getCaseMatcher(unsigned i) const { return Cases[i].second; }
+
+private:
+ virtual void printImpl(raw_ostream &OS, unsigned indent) const;
+ virtual bool isEqualImpl(const Matcher *M) const { return false; }
+ virtual unsigned getHashImpl() const { return 4123; }
+};
+
+/// CheckTypeMatcher - This checks to see if the current node has the
+/// specified type at the specified result, if not it fails to match.
+class CheckTypeMatcher : public Matcher {