DAGISelMatcher.cpp revision 60df53e30a7e39c884f4ca4eb03346bea5825109
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 "Record.h"
14#include "llvm/Support/raw_ostream.h"
15using namespace llvm;
16
17void MatcherNode::dump() const {
18  print(errs());
19}
20
21void MatcherNode::printNext(raw_ostream &OS, unsigned indent) const {
22  if (Next)
23    return Next->print(OS, indent);
24}
25
26
27void ScopeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
28  OS.indent(indent) << "Scope\n";
29  Check->print(OS, indent+2);
30  printNext(OS, indent);
31}
32
33void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const {
34  OS.indent(indent) << "Record\n";
35  printNext(OS, indent);
36}
37
38void RecordChildMatcherNode::print(raw_ostream &OS, unsigned indent) const {
39  OS.indent(indent) << "RecordChild: " << ChildNo << '\n';
40  printNext(OS, indent);
41}
42
43void RecordMemRefMatcherNode::print(raw_ostream &OS, unsigned indent) const {
44  OS.indent(indent) << "RecordMemRef\n";
45  printNext(OS, indent);
46}
47
48void CaptureFlagInputMatcherNode::print(raw_ostream &OS, unsigned indent) const{
49  OS.indent(indent) << "CaptureFlagInput\n";
50  printNext(OS, indent);
51}
52
53void MoveChildMatcherNode::print(raw_ostream &OS, unsigned indent) const {
54  OS.indent(indent) << "MoveChild " << ChildNo << '\n';
55  printNext(OS, indent);
56}
57
58void MoveParentMatcherNode::print(raw_ostream &OS, unsigned indent) const {
59  OS.indent(indent) << "MoveParent\n";
60  printNext(OS, indent);
61}
62
63void CheckSameMatcherNode::print(raw_ostream &OS, unsigned indent) const {
64  OS.indent(indent) << "CheckSame " << MatchNumber << '\n';
65  printNext(OS, indent);
66}
67
68void CheckPatternPredicateMatcherNode::
69print(raw_ostream &OS, unsigned indent) const {
70  OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n';
71  printNext(OS, indent);
72}
73
74void CheckPredicateMatcherNode::print(raw_ostream &OS, unsigned indent) const {
75  OS.indent(indent) << "CheckPredicate " << PredName << '\n';
76  printNext(OS, indent);
77}
78
79void CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
80  OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n';
81  printNext(OS, indent);
82}
83
84void CheckMultiOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
85  OS.indent(indent) << "CheckMultiOpcode <todo args>\n";
86  printNext(OS, indent);
87}
88
89void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
90  OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n';
91  printNext(OS, indent);
92}
93
94void CheckChildTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
95  OS.indent(indent) << "CheckChildType " << ChildNo << " "
96    << getEnumName(Type) << '\n';
97  printNext(OS, indent);
98}
99
100
101void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const {
102  OS.indent(indent) << "CheckInteger " << Value << '\n';
103  printNext(OS, indent);
104}
105
106void CheckCondCodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
107  OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n';
108  printNext(OS, indent);
109}
110
111void CheckValueTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
112  OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n';
113  printNext(OS, indent);
114}
115
116void CheckComplexPatMatcherNode::print(raw_ostream &OS, unsigned indent) const {
117  OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n';
118  printNext(OS, indent);
119}
120
121void CheckAndImmMatcherNode::print(raw_ostream &OS, unsigned indent) const {
122  OS.indent(indent) << "CheckAndImm " << Value << '\n';
123  printNext(OS, indent);
124}
125
126void CheckOrImmMatcherNode::print(raw_ostream &OS, unsigned indent) const {
127  OS.indent(indent) << "CheckOrImm " << Value << '\n';
128  printNext(OS, indent);
129}
130
131void CheckFoldableChainNodeMatcherNode::print(raw_ostream &OS,
132                                              unsigned indent) const {
133  OS.indent(indent) << "CheckFoldableChainNode\n";
134  printNext(OS, indent);
135}
136
137void CheckChainCompatibleMatcherNode::print(raw_ostream &OS,
138                                              unsigned indent) const {
139  OS.indent(indent) << "CheckChainCompatible " << PreviousOp << "\n";
140  printNext(OS, indent);
141}
142
143void EmitIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const {
144  OS.indent(indent) << "EmitInteger " << Val << " VT=" << VT << '\n';
145  printNext(OS, indent);
146}
147
148void EmitStringIntegerMatcherNode::
149print(raw_ostream &OS, unsigned indent) const {
150  OS.indent(indent) << "EmitStringInteger " << Val << " VT=" << VT << '\n';
151  printNext(OS, indent);
152}
153
154void EmitRegisterMatcherNode::print(raw_ostream &OS, unsigned indent) const {
155  OS.indent(indent) << "EmitRegister ";
156  if (Reg)
157    OS << Reg->getName();
158  else
159    OS << "zero_reg";
160  OS << " VT=" << VT << '\n';
161  printNext(OS, indent);
162}
163
164void EmitConvertToTargetMatcherNode::
165print(raw_ostream &OS, unsigned indent) const {
166  OS.indent(indent) << "EmitConvertToTarget " << Slot << '\n';
167  printNext(OS, indent);
168}
169
170void EmitMergeInputChainsMatcherNode::
171print(raw_ostream &OS, unsigned indent) const {
172  OS.indent(indent) << "EmitMergeInputChains <todo: args>\n";
173  printNext(OS, indent);
174}
175
176void EmitCopyToRegMatcherNode::print(raw_ostream &OS, unsigned indent) const {
177  OS.indent(indent) << "EmitCopyToReg <todo: args>\n";
178  printNext(OS, indent);
179}
180
181void EmitNodeXFormMatcherNode::print(raw_ostream &OS, unsigned indent) const {
182  OS.indent(indent) << "EmitNodeXForm " << NodeXForm->getName()
183     << " Slot=" << Slot << '\n';
184  printNext(OS, indent);
185}
186
187
188void EmitNodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
189  OS.indent(indent) << "EmitNode: " << OpcodeName << ": <todo flags> ";
190
191  for (unsigned i = 0, e = VTs.size(); i != e; ++i)
192    OS << ' ' << getEnumName(VTs[i]);
193  OS << '(';
194  for (unsigned i = 0, e = Operands.size(); i != e; ++i)
195    OS << Operands[i] << ' ';
196  OS << ")\n";
197  printNext(OS, indent);
198}
199
200void MarkFlagResultsMatcherNode::print(raw_ostream &OS, unsigned indent) const {
201  OS.indent(indent) << "MarkFlagResults <todo: args>\n";
202  printNext(OS, indent);
203}
204
205void CompleteMatchMatcherNode::print(raw_ostream &OS, unsigned indent) const {
206  OS.indent(indent) << "CompleteMatch <todo args>\n";
207  OS.indent(indent) << "Src = " << *Pattern.getSrcPattern() << "\n";
208  OS.indent(indent) << "Dst = " << *Pattern.getDstPattern() << "\n";
209  printNext(OS, indent);
210}
211
212