summaryrefslogtreecommitdiff
path: root/utils/TableGen/DAGISelMatcher.cpp
blob: 6588bc00e6ed469bd46258e814f99398735006f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
//===- DAGISelMatcher.cpp - Representation of DAG pattern matcher ---------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "DAGISelMatcher.h"
#include "CodeGenDAGPatterns.h"
#include "CodeGenTarget.h"
#include "Record.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;

void MatcherNode::dump() const {
  print(errs());
}

void MatcherNode::printNext(raw_ostream &OS, unsigned indent) const {
  if (Next)
    return Next->print(OS, indent);
}


void ScopeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "Scope\n";
  Check->print(OS, indent+2);
  printNext(OS, indent);
}

void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "Record\n";
  printNext(OS, indent);
}

void RecordChildMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "RecordChild: " << ChildNo << '\n';
  printNext(OS, indent);
}

void RecordMemRefMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "RecordMemRef\n";
  printNext(OS, indent);
}

void CaptureFlagInputMatcherNode::print(raw_ostream &OS, unsigned indent) const{
  OS.indent(indent) << "CaptureFlagInput\n";
  printNext(OS, indent);
}

void MoveChildMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "MoveChild " << ChildNo << '\n';
  printNext(OS, indent);
}

void MoveParentMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "MoveParent\n";
  printNext(OS, indent);
}

void CheckSameMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckSame " << MatchNumber << '\n';
  printNext(OS, indent);
}

void CheckPatternPredicateMatcherNode::
print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n';
  printNext(OS, indent);
}

void CheckPredicateMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckPredicate " << PredName << '\n';
  printNext(OS, indent);
}

void CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n';
  printNext(OS, indent);
}

void CheckMultiOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckMultiOpcode <todo args>\n";
  printNext(OS, indent);
}

void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n';
  printNext(OS, indent);
}

void CheckChildTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckChildType " << ChildNo << " "
    << getEnumName(Type) << '\n';
  printNext(OS, indent);
}


void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckInteger " << Value << '\n';
  printNext(OS, indent);
}

void CheckCondCodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n';
  printNext(OS, indent);
}

void CheckValueTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n';
  printNext(OS, indent);
}

void CheckComplexPatMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n';
  printNext(OS, indent);
}

void CheckAndImmMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckAndImm " << Value << '\n';
  printNext(OS, indent);
}

void CheckOrImmMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CheckOrImm " << Value << '\n';
  printNext(OS, indent);
}

void CheckFoldableChainNodeMatcherNode::print(raw_ostream &OS,
                                              unsigned indent) const {
  OS.indent(indent) << "CheckFoldableChainNode\n";
  printNext(OS, indent);
}

void CheckChainCompatibleMatcherNode::print(raw_ostream &OS,
                                              unsigned indent) const {
  OS.indent(indent) << "CheckChainCompatible " << PreviousOp << "\n";
  printNext(OS, indent);
}

void EmitIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "EmitInteger " << Val << " VT=" << VT << '\n';
  printNext(OS, indent);
}

void EmitStringIntegerMatcherNode::
print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "EmitStringInteger " << Val << " VT=" << VT << '\n';
  printNext(OS, indent);
}

void EmitRegisterMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "EmitRegister ";
  if (Reg)
    OS << Reg->getName();
  else
    OS << "zero_reg";
  OS << " VT=" << VT << '\n';
  printNext(OS, indent);
}

void EmitConvertToTargetMatcherNode::
print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "EmitConvertToTarget " << Slot << '\n';
  printNext(OS, indent);
}

void EmitMergeInputChainsMatcherNode::
print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "EmitMergeInputChains <todo: args>\n";
  printNext(OS, indent);
}

void EmitCopyToRegMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "EmitCopyToReg <todo: args>\n";
  printNext(OS, indent);
}

void EmitNodeXFormMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "EmitNodeXForm " << NodeXForm->getName()
     << " Slot=" << Slot << '\n';
  printNext(OS, indent);
}


void EmitNodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "EmitNode: " << OpcodeName << ": <todo flags> ";

  for (unsigned i = 0, e = VTs.size(); i != e; ++i)
    OS << ' ' << getEnumName(VTs[i]);
  OS << '(';
  for (unsigned i = 0, e = Operands.size(); i != e; ++i)
    OS << Operands[i] << ' ';
  OS << ")\n";
  printNext(OS, indent);
}

void MarkFlagResultsMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "MarkFlagResults <todo: args>\n";
  printNext(OS, indent);
}

void CompleteMatchMatcherNode::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "CompleteMatch <todo args>\n";
  OS.indent(indent) << "Src = " << *Pattern.getSrcPattern() << "\n";
  OS.indent(indent) << "Dst = " << *Pattern.getDstPattern() << "\n";
  printNext(OS, indent);
}