Lines Matching full:matcher
1 //===- DAGISelMatcher.h - Representation of DAG pattern matcher -*- C++ -*-===//
22 class Matcher;
31 Matcher *ConvertPatternToMatcher(const PatternToMatch &Pattern,unsigned Variant,
33 void OptimizeMatcher(std::unique_ptr<Matcher> &Matcher,
35 void EmitMatcherTable(const Matcher *Matcher, const CodeGenDAGPatterns &CGP,
39 /// Matcher - Base class for all the DAG ISel Matcher representation
41 class Matcher {
42 // The next matcher node that is executed after this one. Null if this is the
44 std::unique_ptr<Matcher> Next;
48 // Matcher state manipulation.
91 Matcher(KindTy K) : Kind(K) {}
93 virtual ~Matcher() {}
97 Matcher *getNext() { return Next.get(); }
98 const Matcher *getNext() const { return Next.get(); }
99 void setNext(Matcher *C) { Next.reset(C); }
100 Matcher *takeNext() { return Next.release(); }
102 std::unique_ptr<Matcher> &getNextPtr() { return Next; }
104 bool isEqual(const Matcher *M) const {
143 Matcher *unlinkNode(Matcher *Other);
145 /// canMoveBefore - Return true if this matcher is the same as Other, or if
146 /// we can move this matcher past all of the nodes in-between Other and this
148 bool canMoveBefore(const Matcher *Other) const;
150 /// canMoveBeforeNode - Return true if it is safe to move the current matcher
152 bool canMoveBeforeNode(const Matcher *Other) const;
156 bool isContradictory(const Matcher *Other) const {
171 virtual bool isEqualImpl(const Matcher *M) const = 0;
172 virtual bool isContradictoryImpl(const Matcher *M) const { return false; }
178 class ScopeMatcher : public Matcher {
179 SmallVector<Matcher*, 4> Children;
181 ScopeMatcher(ArrayRef<Matcher *> children)
182 : Matcher(Scope), Children(children.begin(), children.end()) {
188 Matcher *getChild(unsigned i) { return Children[i]; }
189 const Matcher *getChild(unsigned i) const { return Children[i]; }
191 void resetChild(unsigned i, Matcher *N) {
196 Matcher *takeChild(unsigned i) {
197 Matcher *Res = Children[i];
211 static inline bool classof(const Matcher *N) {
217 bool isEqualImpl(const Matcher *M) const override { return false; }
221 class RecordMatcher : public Matcher {
231 : Matcher(RecordNode), WhatFor(whatfor), ResultNo(resultNo) {}
236 static inline bool classof(const Matcher *N) {
242 bool isEqualImpl(const Matcher *M) const override { return true; }
248 class RecordChildMatcher : public Matcher {
261 : Matcher(RecordChild), ChildNo(childno), WhatFor(whatfor),
268 static inline bool classof(const Matcher *N) {
274 bool isEqualImpl(const Matcher *M) const override {
280 class RecordMemRefMatcher : public Matcher {
282 RecordMemRefMatcher() : Matcher(RecordMemRef) {}
284 static inline bool classof(const Matcher *N) {
290 bool isEqualImpl(const Matcher *M) const override { return true; }
296 class CaptureGlueInputMatcher : public Matcher {
298 CaptureGlueInputMatcher() : Matcher(CaptureGlueInput) {}
300 static inline bool classof(const Matcher *N) {
306 bool isEqualImpl(const Matcher *M) const override { return true; }
311 class MoveChildMatcher : public Matcher {
314 MoveChildMatcher(unsigned childNo) : Matcher(MoveChild), ChildNo(childNo) {}
318 static inline bool classof(const Matcher *N) {
324 bool isEqualImpl(const Matcher *M) const override {
331 class MoveParentMatcher : public Matcher {
333 MoveParentMatcher() : Matcher(MoveParent) {}
335 static inline bool classof(const Matcher *N) {
341 bool isEqualImpl(const Matcher *M) const override { return true; }
347 class CheckSameMatcher : public Matcher {
351 : Matcher(CheckSame), MatchNumber(matchnumber) {}
355 static inline bool classof(const Matcher *N) {
361 bool isEqualImpl(const Matcher *M) const override {
369 class CheckChildSameMatcher : public Matcher {
374 : Matcher(CheckChildSame), ChildNo(childno), MatchNumber(matchnumber) {}
379 static inline bool classof(const Matcher *N) {
385 bool isEqualImpl(const Matcher *M) const override {
394 class CheckPatternPredicateMatcher : public Matcher {
398 : Matcher(CheckPatternPredicate), Predicate(predicate) {}
402 static inline bool classof(const Matcher *N) {
408 bool isEqualImpl(const Matcher *M) const override {
415 class CheckPredicateMatcher : public Matcher {
422 static inline bool classof(const Matcher *N) {
428 bool isEqualImpl(const Matcher *M) const override {
436 class CheckOpcodeMatcher : public Matcher {
440 : Matcher(CheckOpcode), Opcode(opcode) {}
444 static inline bool classof(const Matcher *N) {
450 bool isEqualImpl(const Matcher *M) const override;
451 bool isContradictoryImpl(const Matcher *M) const override;
455 /// to one matcher per opcode. If the opcode doesn't match any of the cases,
458 class SwitchOpcodeMatcher : public Matcher {
459 SmallVector<std::pair<const SDNodeInfo*, Matcher*>, 8> Cases;
461 SwitchOpcodeMatcher(ArrayRef<std::pair<const SDNodeInfo*, Matcher*> > cases)
462 : Matcher(SwitchOpcode), Cases(cases.begin(), cases.end()) {}
465 static inline bool classof(const Matcher *N) {
472 Matcher *getCaseMatcher(unsigned i) { return Cases[i].second; }
473 const Matcher *getCaseMatcher(unsigned i) const { return Cases[i].second; }
477 bool isEqualImpl(const Matcher *M) const override { return false; }
482 class CheckTypeMatcher : public Matcher {
487 : Matcher(CheckType), Type(type), ResNo(resno) {}
492 static inline bool classof(const Matcher *N) {
498 bool isEqualImpl(const Matcher *M) const override {
501 bool isContradictoryImpl(const Matcher *M) const override;
505 /// to one matcher per case. If the type doesn't match any of the cases,
508 class SwitchTypeMatcher : public Matcher {
509 SmallVector<std::pair<MVT::SimpleValueType, Matcher*>, 8> Cases;
511 SwitchTypeMatcher(ArrayRef<std::pair<MVT::SimpleValueType, Matcher*> > cases)
512 : Matcher(SwitchType), Cases(cases.begin(), cases.end()) {}
515 static inline bool classof(const Matcher *N) {
522 Matcher *getCaseMatcher(unsigned i) { return Cases[i].second; }
523 const Matcher *getCaseMatcher(unsigned i) const { return Cases[i].second; }
527 bool isEqualImpl(const Matcher *M) const override { return false; }
533 class CheckChildTypeMatcher : public Matcher {
538 : Matcher(CheckChildType), ChildNo(childno), Type(type) {}
543 static inline bool classof(const Matcher *N) {
549 bool isEqualImpl(const Matcher *M) const override {
553 bool isContradictoryImpl(const Matcher *M) const override;
559 class CheckIntegerMatcher : public Matcher {
563 : Matcher(CheckInteger), Value(value) {}
567 static inline bool classof(const Matcher *N) {
573 bool isEqualImpl(const Matcher *M) const override {
576 bool isContradictoryImpl(const Matcher *M) const override;
581 class CheckChildIntegerMatcher : public Matcher {
586 : Matcher(CheckChildInteger), ChildNo(childno), Value(value) {}
591 static inline bool classof(const Matcher *N) {
597 bool isEqualImpl(const Matcher *M) const override {
601 bool isContradictoryImpl(const Matcher *M) const override;
606 class CheckCondCodeMatcher : public Matcher {
610 : Matcher(CheckCondCode), CondCodeName(condcodename) {}
614 static inline bool classof(const Matcher *N) {
620 bool isEqualImpl(const Matcher *M) const override {
627 class CheckValueTypeMatcher : public Matcher {
631 : Matcher(CheckValueType), TypeName(type_name) {}
635 static inline bool classof(const Matcher *N) {
641 bool isEqualImpl(const Matcher *M) const override {
644 bool isContradictoryImpl(const Matcher *M) const override;
651 class CheckComplexPatMatcher : public Matcher {
667 : Matcher(CheckComplexPat), Pattern(pattern), MatchNumber(matchnumber),
676 static inline bool classof(const Matcher *N) {
682 bool isEqualImpl(const Matcher *M) const override {
690 class CheckAndImmMatcher : public Matcher {
694 : Matcher(CheckAndImm), Value(value) {}
698 static inline bool classof(const Matcher *N) {
704 bool isEqualImpl(const Matcher *M) const override {
711 class CheckOrImmMatcher : public Matcher {
715 : Matcher(CheckOrImm), Value(value) {}
719 static inline bool classof(const Matcher *N) {
725 bool isEqualImpl(const Matcher *M) const override {
732 class CheckFoldableChainNodeMatcher : public Matcher {
735 : Matcher(CheckFoldableChainNode) {}
737 static inline bool classof(const Matcher *N) {
743 bool isEqualImpl(const Matcher *M) const override { return true; }
747 class EmitIntegerMatcher : public Matcher {
752 : Matcher(EmitInteger), Val(val), VT(vt) {}
757 static inline bool classof(const Matcher *N) {
763 bool isEqualImpl(const Matcher *M) const override {
771 class EmitStringIntegerMatcher : public Matcher {
776 : Matcher(EmitStringInteger), Val(val), VT(vt) {}
781 static inline bool classof(const Matcher *N) {
787 bool isEqualImpl(const Matcher *M) const override {
794 class EmitRegisterMatcher : public Matcher {
801 : Matcher(EmitRegister), Reg(reg), VT(vt) {}
806 static inline bool classof(const Matcher *N) {
812 bool isEqualImpl(const Matcher *M) const override {
821 class EmitConvertToTargetMatcher : public Matcher {
825 : Matcher(EmitConvertToTarget), Slot(slot) {}
829 static inline bool classof(const Matcher *N) {
835 bool isEqualImpl(const Matcher *M) const override {
844 class EmitMergeInputChainsMatcher : public Matcher {
848 : Matcher(EmitMergeInputChains), ChainNodes(nodes.begin(), nodes.end()) {}
857 static inline bool classof(const Matcher *N) {
863 bool isEqualImpl(const Matcher *M) const override {
871 class EmitCopyToRegMatcher : public Matcher {
876 : Matcher(EmitCopyToReg), SrcSlot(srcSlot), DestPhysReg(destPhysReg) {}
881 static inline bool classof(const Matcher *N) {
887 bool isEqualImpl(const Matcher *M) const override {
897 class EmitNodeXFormMatcher : public Matcher {
902 : Matcher(EmitNodeXForm), Slot(slot), NodeXForm(nodeXForm) {}
907 static inline bool classof(const Matcher *N) {
913 bool isEqualImpl(const Matcher *M) const override {
921 class EmitNodeMatcherCommon : public Matcher {
938 : Matcher(isMorphNodeTo ? MorphNodeTo : EmitNode), OpcodeName(opcodeName),
967 static inline bool classof(const Matcher *N) {
973 bool isEqualImpl(const Matcher *M) const override;
994 static inline bool classof(const Matcher *N) {
1018 static inline bool classof(const Matcher *N) {
1026 class CompleteMatchMatcher : public Matcher {
1032 : Matcher(CompleteMatch), Results(results.begin(), results.end()),
1039 static inline bool classof(const Matcher *N) {
1045 bool isEqualImpl(const Matcher *M) const override {