summaryrefslogtreecommitdiff
path: root/utils/TableGen/DAGISelMatcher.cpp
blob: c38b2307b678114d45faebc0f6ef02828e957bb4 (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 Matcher::dump() const {
  print(errs());
}

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

void EmitRegisterMatcher::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 EmitConvertToTargetMatcher::
print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "EmitConvertToTarget " << Slot << '\n';
  printNext(OS, indent);
}

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

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

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


void EmitNodeMatcher::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 MarkFlagResultsMatcher::print(raw_ostream &OS, unsigned indent) const {
  OS.indent(indent) << "MarkFlagResults <todo: args>\n";
  printNext(OS, indent);
}

void CompleteMatchMatcher::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);
}