Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 1 | //===- DAGISelMatcher.cpp - Representation of DAG pattern matcher ---------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "DAGISelMatcher.h" |
| 11 | #include "CodeGenDAGPatterns.h" |
| 12 | #include "CodeGenTarget.h" |
| 13 | #include "llvm/Support/raw_ostream.h" |
| 14 | using namespace llvm; |
| 15 | |
| 16 | void MatcherNode::dump() const { |
| 17 | print(errs()); |
| 18 | } |
| 19 | |
| 20 | void EmitNodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 21 | OS.indent(indent) << "EmitNode: Src = " << *Pattern.getSrcPattern() << "\n"; |
| 22 | OS.indent(indent) << "EmitNode: Dst = " << *Pattern.getDstPattern() << "\n"; |
| 23 | } |
| 24 | |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 25 | void MatcherNode::printNext(raw_ostream &OS, unsigned indent) const { |
| 26 | if (Next) |
| 27 | return Next->print(OS, indent); |
| 28 | OS.indent(indent) << "<null next field>\n"; |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | |
| 32 | void PushMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 33 | OS.indent(indent) << "Push\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 34 | printNext(OS, indent+2); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 35 | Failure->print(OS, indent); |
| 36 | } |
| 37 | |
| 38 | void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 39 | OS.indent(indent) << "Record\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 40 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | void MoveChildMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 44 | OS.indent(indent) << "MoveChild " << ChildNo << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 45 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | void MoveParentMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 49 | OS.indent(indent) << "MoveParent\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 50 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void CheckSameMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 54 | OS.indent(indent) << "CheckSame " << MatchNumber << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 55 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void CheckPatternPredicateMatcherNode:: |
| 59 | print(raw_ostream &OS, unsigned indent) const { |
| 60 | OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 61 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | void CheckPredicateMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 65 | OS.indent(indent) << "CheckPredicate " << PredName << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 66 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | void CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 70 | OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 71 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 75 | OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 76 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 80 | OS.indent(indent) << "CheckInteger " << Value << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 81 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | void CheckCondCodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 85 | OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 86 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | void CheckValueTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 90 | OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 91 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | void CheckComplexPatMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 95 | OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 96 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | void CheckAndImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 100 | OS.indent(indent) << "CheckAndImm " << Value << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 101 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | void CheckOrImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 105 | OS.indent(indent) << "CheckOrImm " << Value << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 106 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Chris Lattner | 21390d7 | 2010-02-16 19:15:55 +0000 | [diff] [blame] | 109 | void CheckFoldableChainNodeMatcherNode::print(raw_ostream &OS, |
| 110 | unsigned indent) const { |
| 111 | OS.indent(indent) << "CheckFoldableChainNode\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 112 | printNext(OS, indent); |
Chris Lattner | e39650a | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 113 | } |
Chris Lattner | 9a747f1 | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 114 | |
| 115 | void CheckChainCompatibleMatcherNode::print(raw_ostream &OS, |
| 116 | unsigned indent) const { |
| 117 | OS.indent(indent) << "CheckChainCompatibleMatcherNode " << PreviousOp << "\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 118 | printNext(OS, indent); |
Chris Lattner | 9a747f1 | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 119 | } |