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" |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 13 | #include "Record.h" |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 14 | #include "llvm/Support/raw_ostream.h" |
| 15 | using namespace llvm; |
| 16 | |
| 17 | void MatcherNode::dump() const { |
| 18 | print(errs()); |
| 19 | } |
| 20 | |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 21 | void MatcherNode::printNext(raw_ostream &OS, unsigned indent) const { |
| 22 | if (Next) |
| 23 | return Next->print(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | |
| 27 | void PushMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 28 | OS.indent(indent) << "Push\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 29 | printNext(OS, indent+2); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 30 | Failure->print(OS, indent); |
| 31 | } |
| 32 | |
| 33 | void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 34 | OS.indent(indent) << "Record\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 35 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Chris Lattner | 19b5a75 | 2010-02-24 07:31:45 +0000 | [diff] [blame] | 38 | void RecordChildMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 39 | OS.indent(indent) << "RecordChild: " << ChildNo << '\n'; |
| 40 | printNext(OS, indent); |
| 41 | } |
| 42 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 43 | void RecordMemRefMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 44 | OS.indent(indent) << "RecordMemRef\n"; |
| 45 | printNext(OS, indent); |
| 46 | } |
| 47 | |
| 48 | void CaptureFlagInputMatcherNode::print(raw_ostream &OS, unsigned indent) const{ |
| 49 | OS.indent(indent) << "CaptureFlagInput\n"; |
| 50 | printNext(OS, indent); |
| 51 | } |
| 52 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 53 | void MoveChildMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 54 | OS.indent(indent) << "MoveChild " << ChildNo << '\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 MoveParentMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 59 | OS.indent(indent) << "MoveParent\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 60 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | void CheckSameMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 64 | OS.indent(indent) << "CheckSame " << MatchNumber << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 65 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | void CheckPatternPredicateMatcherNode:: |
| 69 | print(raw_ostream &OS, unsigned indent) const { |
| 70 | OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\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 CheckPredicateMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 75 | OS.indent(indent) << "CheckPredicate " << PredName << '\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 CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 80 | OS.indent(indent) << "CheckOpcode " << OpcodeName << '\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 | |
Chris Lattner | 12a667c | 2010-02-22 22:30:37 +0000 | [diff] [blame] | 84 | void CheckMultiOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 85 | OS.indent(indent) << "CheckMultiOpcode <todo args>\n"; |
| 86 | printNext(OS, indent); |
| 87 | } |
| 88 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 89 | void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 90 | OS.indent(indent) << "CheckType " << getEnumName(Type) << '\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 CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 95 | OS.indent(indent) << "CheckInteger " << Value << '\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 CheckCondCodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 100 | OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\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 CheckValueTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 105 | OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\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 | |
| 109 | void CheckComplexPatMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 110 | OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 111 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | void CheckAndImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 115 | OS.indent(indent) << "CheckAndImm " << Value << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 116 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | void CheckOrImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 120 | OS.indent(indent) << "CheckOrImm " << Value << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 121 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Chris Lattner | 21390d7 | 2010-02-16 19:15:55 +0000 | [diff] [blame] | 124 | void CheckFoldableChainNodeMatcherNode::print(raw_ostream &OS, |
| 125 | unsigned indent) const { |
| 126 | OS.indent(indent) << "CheckFoldableChainNode\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 127 | printNext(OS, indent); |
Chris Lattner | e39650a | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 128 | } |
Chris Lattner | 9a747f1 | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 129 | |
| 130 | void CheckChainCompatibleMatcherNode::print(raw_ostream &OS, |
| 131 | unsigned indent) const { |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 132 | OS.indent(indent) << "CheckChainCompatible " << PreviousOp << "\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 133 | printNext(OS, indent); |
Chris Lattner | 9a747f1 | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 134 | } |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 135 | |
| 136 | void EmitIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 137 | OS.indent(indent) << "EmitInteger " << Val << " VT=" << VT << '\n'; |
| 138 | printNext(OS, indent); |
| 139 | } |
| 140 | |
| 141 | void EmitStringIntegerMatcherNode:: |
| 142 | print(raw_ostream &OS, unsigned indent) const { |
| 143 | OS.indent(indent) << "EmitStringInteger " << Val << " VT=" << VT << '\n'; |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 144 | printNext(OS, indent); |
| 145 | } |
| 146 | |
| 147 | void EmitRegisterMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 148 | OS.indent(indent) << "EmitRegister "; |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 149 | if (Reg) |
| 150 | OS << Reg->getName(); |
| 151 | else |
| 152 | OS << "zero_reg"; |
| 153 | OS << " VT=" << VT << '\n'; |
| 154 | printNext(OS, indent); |
| 155 | } |
| 156 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 157 | void EmitConvertToTargetMatcherNode:: |
| 158 | print(raw_ostream &OS, unsigned indent) const { |
| 159 | OS.indent(indent) << "EmitConvertToTarget " << Slot << '\n'; |
| 160 | printNext(OS, indent); |
| 161 | } |
| 162 | |
| 163 | void EmitMergeInputChainsMatcherNode:: |
| 164 | print(raw_ostream &OS, unsigned indent) const { |
| 165 | OS.indent(indent) << "EmitMergeInputChains <todo: args>\n"; |
| 166 | printNext(OS, indent); |
| 167 | } |
| 168 | |
| 169 | void EmitCopyToRegMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 170 | OS.indent(indent) << "EmitCopyToReg <todo: args>\n"; |
| 171 | printNext(OS, indent); |
| 172 | } |
| 173 | |
| 174 | void EmitNodeXFormMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 175 | OS.indent(indent) << "EmitNodeXForm " << NodeXForm->getName() |
| 176 | << " Slot=" << Slot << '\n'; |
| 177 | printNext(OS, indent); |
| 178 | } |
| 179 | |
| 180 | |
| 181 | void EmitNodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 182 | OS.indent(indent) << "EmitNode: " << OpcodeName << ": <todo flags> "; |
| 183 | |
| 184 | for (unsigned i = 0, e = VTs.size(); i != e; ++i) |
| 185 | OS << ' ' << getEnumName(VTs[i]); |
| 186 | OS << '('; |
| 187 | for (unsigned i = 0, e = Operands.size(); i != e; ++i) |
| 188 | OS << Operands[i] << ' '; |
| 189 | OS << ")\n"; |
| 190 | printNext(OS, indent); |
| 191 | } |
| 192 | |
Chris Lattner | 02f7358 | 2010-02-24 05:33:42 +0000 | [diff] [blame] | 193 | void MarkFlagResultsMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 194 | OS.indent(indent) << "MarkFlagResults <todo: args>\n"; |
| 195 | printNext(OS, indent); |
| 196 | } |
| 197 | |
Chris Lattner | 77f2e27 | 2010-02-21 06:03:07 +0000 | [diff] [blame] | 198 | void CompleteMatchMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 199 | OS.indent(indent) << "CompleteMatch <todo args>\n"; |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 200 | OS.indent(indent) << "Src = " << *Pattern.getSrcPattern() << "\n"; |
| 201 | OS.indent(indent) << "Dst = " << *Pattern.getDstPattern() << "\n"; |
| 202 | printNext(OS, indent); |
| 203 | } |
| 204 | |