Lines Matching full:matcher
1 //===- DAGISelMatcher.h - Representation of DAG pattern matcher -----------===//
22 class Matcher;
31 Matcher *ConvertPatternToMatcher(const PatternToMatch &Pattern,unsigned Variant,
33 Matcher *OptimizeMatcher(Matcher *Matcher, const CodeGenDAGPatterns &CGP);
34 void EmitMatcherTable(const Matcher *Matcher, const CodeGenDAGPatterns &CGP,
38 /// Matcher - Base class for all the the DAG ISel Matcher representation
40 class Matcher {
41 // The next matcher node that is executed after this one. Null if this is the
43 OwningPtr<Matcher> Next;
46 // Matcher state manipulation.
88 Matcher(KindTy K) : Kind(K) {}
90 virtual ~Matcher() {}
94 Matcher *getNext() { return Next.get(); }
95 const Matcher *getNext() const { return Next.get(); }
96 void setNext(Matcher *C) { Next.reset(C); }
97 Matcher *takeNext() { return Next.take(); }
99 OwningPtr<Matcher> &getNextPtr() { return Next; }
101 static inline bool classof(const Matcher *) { return true; }
103 bool isEqual(const Matcher *M) const {
151 Matcher *unlinkNode(Matcher *Other);
153 /// canMoveBefore - Return true if this matcher is the same as Other, or if
154 /// we can move this matcher past all of the nodes in-between Other and this
156 bool canMoveBefore(const Matcher *Other) const;
158 /// canMoveBefore - Return true if it is safe to move the current matcher
160 bool canMoveBeforeNode(const Matcher *Other) const;
164 bool isContradictory(const Matcher *Other) const {
179 virtual bool isEqualImpl(const Matcher *M) const = 0;
181 virtual bool isContradictoryImpl(const Matcher *M) const { return false; }
187 class ScopeMatcher : public Matcher {
188 SmallVector<Matcher*, 4> Children;
190 ScopeMatcher(Matcher *const *children, unsigned numchildren)
191 : Matcher(Scope), Children(children, children+numchildren) {
197 Matcher *getChild(unsigned i) { return Children[i]; }
198 const Matcher *getChild(unsigned i) const { return Children[i]; }
200 void resetChild(unsigned i, Matcher *N) {
205 Matcher *takeChild(unsigned i) {
206 Matcher *Res = Children[i];
220 static inline bool classof(const Matcher *N) {
226 virtual bool isEqualImpl(const Matcher *M) const { return false; }
231 class RecordMatcher : public Matcher {
241 : Matcher(RecordNode), WhatFor(whatfor), ResultNo(resultNo) {}
246 static inline bool classof(const Matcher *N) {
253 virtual bool isEqualImpl(const Matcher *M) const { return true; }
260 class RecordChildMatcher : public Matcher {
273 : Matcher(RecordChild), ChildNo(childno), WhatFor(whatfor),
280 static inline bool classof(const Matcher *N) {
288 virtual bool isEqualImpl(const Matcher *M) const {
295 class RecordMemRefMatcher : public Matcher {
297 RecordMemRefMatcher() : Matcher(RecordMemRef) {}
299 static inline bool classof(const Matcher *N) {
307 virtual bool isEqualImpl(const Matcher *M) const { return true; }
314 class CaptureGlueInputMatcher : public Matcher {
316 CaptureGlueInputMatcher() : Matcher(CaptureGlueInput) {}
318 static inline bool classof(const Matcher *N) {
326 virtual bool isEqualImpl(const Matcher *M) const { return true; }
332 class MoveChildMatcher : public Matcher {
335 MoveChildMatcher(unsigned childNo) : Matcher(MoveChild), ChildNo(childNo) {}
339 static inline bool classof(const Matcher *N) {
347 virtual bool isEqualImpl(const Matcher *M) const {
355 class MoveParentMatcher : public Matcher {
357 MoveParentMatcher() : Matcher(MoveParent) {}
359 static inline bool classof(const Matcher *N) {
367 virtual bool isEqualImpl(const Matcher *M) const { return true; }
374 class CheckSameMatcher : public Matcher {
378 : Matcher(CheckSame), MatchNumber(matchnumber) {}
382 static inline bool classof(const Matcher *N) {
390 virtual bool isEqualImpl(const Matcher *M) const {
399 class CheckPatternPredicateMatcher : public Matcher {
403 : Matcher(CheckPatternPredicate), Predicate(predicate) {}
407 static inline bool classof(const Matcher *N) {
415 virtual bool isEqualImpl(const Matcher *M) const {
423 class CheckPredicateMatcher : public Matcher {
430 static inline bool classof(const Matcher *N) {
439 virtual bool isEqualImpl(const Matcher *M) const {
448 class CheckOpcodeMatcher : public Matcher {
452 : Matcher(CheckOpcode), Opcode(opcode) {}
456 static inline bool classof(const Matcher *N) {
464 virtual bool isEqualImpl(const Matcher *M) const;
466 virtual bool isContradictoryImpl(const Matcher *M) const;
470 /// to one matcher
473 class SwitchOpcodeMatcher : public Matcher {
474 SmallVector<std::pair<const SDNodeInfo*, Matcher*>, 8> Cases;
476 SwitchOpcodeMatcher(const std::pair<const SDNodeInfo*, Matcher*> *cases,
478 : Matcher(SwitchOpcode), Cases(cases, cases+numcases) {}
480 static inline bool classof(const Matcher *N) {
487 Matcher *getCaseMatcher(unsigned i) { return Cases[i].second; }
488 const Matcher *getCaseMatcher(unsigned i) const { return Cases[i].second; }
492 virtual bool isEqualImpl(const Matcher *M) const { return false; }
498 class CheckTypeMatcher : public Matcher {
503 : Matcher(CheckType), Type(type), ResNo(resno) {}
508 static inline bool classof(const Matcher *N) {
516 virtual bool isEqualImpl(const Matcher *M) const {
520 virtual bool isContradictoryImpl(const Matcher *M) const;
524 /// to one matcher per case. If the type doesn't match any of the cases,
527 class SwitchTypeMatcher : public Matcher {
528 SmallVector<std::pair<MVT::SimpleValueType, Matcher*>, 8> Cases;
530 SwitchTypeMatcher(const std::pair<MVT::SimpleValueType, Matcher*> *cases,
532 : Matcher(SwitchType), Cases(cases, cases+numcases) {}
534 static inline bool classof(const Matcher *N) {
541 Matcher *getCaseMatcher(unsigned i) { return Cases[i].second; }
542 const Matcher *getCaseMatcher(unsigned i) const { return Cases[i].second; }
546 virtual bool isEqualImpl(const Matcher *M) const { return false; }
553 class CheckChildTypeMatcher : public Matcher {
558 : Matcher(CheckChildType), ChildNo(childno), Type(type) {}
563 static inline bool classof(const Matcher *N) {
571 virtual bool isEqualImpl(const Matcher *M) const {
576 virtual bool isContradictoryImpl(const Matcher *M) const;
582 class CheckIntegerMatcher : public Matcher {
586 : Matcher(CheckInteger), Value(value) {}
590 static inline bool classof(const Matcher *N) {
598 virtual bool isEqualImpl(const Matcher *M) const {
602 virtual bool isContradictoryImpl(const Matcher *M) const;
607 class CheckCondCodeMatcher : public Matcher {
611 : Matcher(CheckCondCode), CondCodeName(condcodename) {}
615 static inline bool classof(const Matcher *N) {
623 virtual bool isEqualImpl(const Matcher *M) const {
631 class CheckValueTypeMatcher : public Matcher {
635 : Matcher(CheckValueType), TypeName(type_name) {}
639 static inline bool classof(const Matcher *N) {
647 virtual bool isEqualImpl(const Matcher *M) const {
651 bool isContradictoryImpl(const Matcher *M) const;
658 class CheckComplexPatMatcher : public Matcher {
674 : Matcher(CheckComplexPat), Pattern(pattern), MatchNumber(matchnumber),
683 static inline bool classof(const Matcher *N) {
692 virtual bool isEqualImpl(const Matcher *M) const {
703 class CheckAndImmMatcher : public Matcher {
707 : Matcher(CheckAndImm), Value(value) {}
711 static inline bool classof(const Matcher *N) {
719 virtual bool isEqualImpl(const Matcher *M) const {
727 class CheckOrImmMatcher : public Matcher {
731 : Matcher(CheckOrImm), Value(value) {}
735 static inline bool classof(const Matcher *N) {
743 virtual bool isEqualImpl(const Matcher *M) const {
751 class CheckFoldableChainNodeMatcher : public Matcher {
754 : Matcher(CheckFoldableChainNode) {}
756 static inline bool classof(const Matcher *N) {
764 virtual bool isEqualImpl(const Matcher *M) const { return true; }
769 class EmitIntegerMatcher : public Matcher {
774 : Matcher(EmitInteger), Val(val), VT(vt) {}
779 static inline bool classof(const Matcher *N) {
785 virtual bool isEqualImpl(const Matcher *M) const {
794 class EmitStringIntegerMatcher : public Matcher {
799 : Matcher(EmitStringInteger), Val(val), VT(vt) {}
804 static inline bool classof(const Matcher *N) {
810 virtual bool isEqualImpl(const Matcher *M) const {
818 class EmitRegisterMatcher : public Matcher {
825 : Matcher(EmitRegister), Reg(reg), VT(vt) {}
830 static inline bool classof(const Matcher *N) {
836 virtual bool isEqualImpl(const Matcher *M) const {
848 class EmitConvertToTargetMatcher : public Matcher {
852 : Matcher(EmitConvertToTarget), Slot(slot) {}
856 static inline bool classof(const Matcher *N) {
862 virtual bool isEqualImpl(const Matcher *M) const {
872 class EmitMergeInputChainsMatcher : public Matcher {
876 : Matcher(EmitMergeInputChains), ChainNodes(nodes, nodes+NumNodes) {}
885 static inline bool classof(const Matcher *N) {
891 virtual bool isEqualImpl(const Matcher *M) const {
900 class EmitCopyToRegMatcher : public Matcher {
905 : Matcher(EmitCopyToReg), SrcSlot(srcSlot), DestPhysReg(destPhysReg) {}
910 static inline bool classof(const Matcher *N) {
916 virtual bool isEqualImpl(const Matcher *M) const {
929 class EmitNodeXFormMatcher : public Matcher {
934 : Matcher(EmitNodeXForm), Slot(slot), NodeXForm(nodeXForm) {}
939 static inline bool classof(const Matcher *N) {
945 virtual bool isEqualImpl(const Matcher *M) const {
956 class EmitNodeMatcherCommon : public Matcher {
973 : Matcher(isMorphNodeTo ? MorphNodeTo : EmitNode), OpcodeName(opcodeName),
1002 static inline bool classof(const Matcher *N) {
1008 virtual bool isEqualImpl(const Matcher *M) const;
1029 static inline bool classof(const Matcher *N) {
1052 static inline bool classof(const Matcher *N) {
1060 class MarkGlueResultsMatcher : public Matcher {
1064 : Matcher(MarkGlueResults), GlueResultNodes(nodes, nodes+NumNodes) {}
1073 static inline bool classof(const Matcher *N) {
1079 virtual bool isEqualImpl(const Matcher *M) const {
1088 class CompleteMatchMatcher : public Matcher {
1094 : Matcher(CompleteMatch), Results(results, results+numresults),
1101 static inline bool classof(const Matcher *N) {
1107 virtual bool isEqualImpl(const Matcher *M) const {