Skip to content

Commit b18b4ac

Browse files
committed
[LLVM][TableGen] Adopt indent for indentation
Adopt `indent` for indentation DAGISelMatcher and DecoderEmitter.
1 parent 3e24dd4 commit b18b4ac

File tree

4 files changed

+192
-200
lines changed

4 files changed

+192
-200
lines changed

llvm/utils/TableGen/Common/DAGISelMatcher.cpp

Lines changed: 87 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ void Matcher::anchor() {}
1919

2020
void Matcher::dump() const { print(errs()); }
2121

22-
void Matcher::print(raw_ostream &OS, unsigned Indent) const {
22+
void Matcher::print(raw_ostream &OS, indent Indent) const {
2323
printImpl(OS, Indent);
2424
if (Next)
2525
return Next->print(OS, Indent);
2626
}
2727

28-
void Matcher::printOne(raw_ostream &OS) const { printImpl(OS, 0); }
28+
void Matcher::printOne(raw_ostream &OS) const { printImpl(OS, indent(0)); }
2929

3030
/// unlinkNode - Unlink the specified node from this chain. If Other == this,
3131
/// we unlink the next pointer and return it. Otherwise we unlink Other from
@@ -111,156 +111,150 @@ unsigned CheckPredicateMatcher::getOperandNo(unsigned i) const {
111111

112112
// printImpl methods.
113113

114-
void ScopeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
115-
OS.indent(Indent) << "Scope\n";
114+
void ScopeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
115+
OS << Indent << "Scope\n";
116116
for (const Matcher *C : Children) {
117117
if (!C)
118-
OS.indent(Indent + 1) << "NULL POINTER\n";
118+
OS << Indent + 1 << "NULL POINTER\n";
119119
else
120120
C->print(OS, Indent + 2);
121121
}
122122
}
123123

124-
void RecordMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
125-
OS.indent(Indent) << "Record\n";
124+
void RecordMatcher::printImpl(raw_ostream &OS, indent Indent) const {
125+
OS << Indent << "Record\n";
126126
}
127127

128-
void RecordChildMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
129-
OS.indent(Indent) << "RecordChild: " << ChildNo << '\n';
128+
void RecordChildMatcher::printImpl(raw_ostream &OS, indent Indent) const {
129+
OS << Indent << "RecordChild: " << ChildNo << '\n';
130130
}
131131

132-
void RecordMemRefMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
133-
OS.indent(Indent) << "RecordMemRef\n";
132+
void RecordMemRefMatcher::printImpl(raw_ostream &OS, indent Indent) const {
133+
OS << Indent << "RecordMemRef\n";
134134
}
135135

136-
void CaptureGlueInputMatcher::printImpl(raw_ostream &OS,
137-
unsigned Indent) const {
138-
OS.indent(Indent) << "CaptureGlueInput\n";
136+
void CaptureGlueInputMatcher::printImpl(raw_ostream &OS, indent Indent) const {
137+
OS << Indent << "CaptureGlueInput\n";
139138
}
140139

141-
void MoveChildMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
142-
OS.indent(Indent) << "MoveChild " << ChildNo << '\n';
140+
void MoveChildMatcher::printImpl(raw_ostream &OS, indent Indent) const {
141+
OS << Indent << "MoveChild " << ChildNo << '\n';
143142
}
144143

145-
void MoveSiblingMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
146-
OS.indent(Indent) << "MoveSibling " << SiblingNo << '\n';
144+
void MoveSiblingMatcher::printImpl(raw_ostream &OS, indent Indent) const {
145+
OS << Indent << "MoveSibling " << SiblingNo << '\n';
147146
}
148147

149-
void MoveParentMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
150-
OS.indent(Indent) << "MoveParent\n";
148+
void MoveParentMatcher::printImpl(raw_ostream &OS, indent Indent) const {
149+
OS << Indent << "MoveParent\n";
151150
}
152151

153-
void CheckSameMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
154-
OS.indent(Indent) << "CheckSame " << MatchNumber << '\n';
152+
void CheckSameMatcher::printImpl(raw_ostream &OS, indent Indent) const {
153+
OS << Indent << "CheckSame " << MatchNumber << '\n';
155154
}
156155

157-
void CheckChildSameMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
158-
OS.indent(Indent) << "CheckChild" << ChildNo << "Same\n";
156+
void CheckChildSameMatcher::printImpl(raw_ostream &OS, indent Indent) const {
157+
OS << Indent << "CheckChild" << ChildNo << "Same\n";
159158
}
160159

161160
void CheckPatternPredicateMatcher::printImpl(raw_ostream &OS,
162-
unsigned Indent) const {
163-
OS.indent(Indent) << "CheckPatternPredicate " << Predicate << '\n';
161+
indent Indent) const {
162+
OS << Indent << "CheckPatternPredicate " << Predicate << '\n';
164163
}
165164

166-
void CheckPredicateMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
167-
OS.indent(Indent) << "CheckPredicate " << getPredicate().getFnName() << '\n';
165+
void CheckPredicateMatcher::printImpl(raw_ostream &OS, indent Indent) const {
166+
OS << Indent << "CheckPredicate " << getPredicate().getFnName() << '\n';
168167
}
169168

170-
void CheckOpcodeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
171-
OS.indent(Indent) << "CheckOpcode " << Opcode.getEnumName() << '\n';
169+
void CheckOpcodeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
170+
OS << Indent << "CheckOpcode " << Opcode.getEnumName() << '\n';
172171
}
173172

174-
void SwitchOpcodeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
175-
OS.indent(Indent) << "SwitchOpcode: {\n";
173+
void SwitchOpcodeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
174+
OS << Indent << "SwitchOpcode: {\n";
176175
for (const auto &C : Cases) {
177-
OS.indent(Indent) << "case " << C.first->getEnumName() << ":\n";
176+
OS << Indent << "case " << C.first->getEnumName() << ":\n";
178177
C.second->print(OS, Indent + 2);
179178
}
180-
OS.indent(Indent) << "}\n";
179+
OS << Indent << "}\n";
181180
}
182181

183-
void CheckTypeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
184-
OS.indent(Indent) << "CheckType " << getEnumName(Type) << ", ResNo=" << ResNo
185-
<< '\n';
182+
void CheckTypeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
183+
OS << Indent << "CheckType " << getEnumName(Type) << ", ResNo=" << ResNo
184+
<< '\n';
186185
}
187186

188-
void SwitchTypeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
189-
OS.indent(Indent) << "SwitchType: {\n";
187+
void SwitchTypeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
188+
OS << Indent << "SwitchType: {\n";
190189
for (const auto &C : Cases) {
191-
OS.indent(Indent) << "case " << getEnumName(C.first) << ":\n";
190+
OS << Indent << "case " << getEnumName(C.first) << ":\n";
192191
C.second->print(OS, Indent + 2);
193192
}
194-
OS.indent(Indent) << "}\n";
193+
OS << Indent << "}\n";
195194
}
196195

197-
void CheckChildTypeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
198-
OS.indent(Indent) << "CheckChildType " << ChildNo << " " << getEnumName(Type)
199-
<< '\n';
196+
void CheckChildTypeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
197+
OS << Indent << "CheckChildType " << ChildNo << " " << getEnumName(Type)
198+
<< '\n';
200199
}
201200

202-
void CheckIntegerMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
203-
OS.indent(Indent) << "CheckInteger " << Value << '\n';
201+
void CheckIntegerMatcher::printImpl(raw_ostream &OS, indent Indent) const {
202+
OS << Indent << "CheckInteger " << Value << '\n';
204203
}
205204

206-
void CheckChildIntegerMatcher::printImpl(raw_ostream &OS,
207-
unsigned Indent) const {
208-
OS.indent(Indent) << "CheckChildInteger " << ChildNo << " " << Value << '\n';
205+
void CheckChildIntegerMatcher::printImpl(raw_ostream &OS, indent Indent) const {
206+
OS << Indent << "CheckChildInteger " << ChildNo << " " << Value << '\n';
209207
}
210208

211-
void CheckCondCodeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
212-
OS.indent(Indent) << "CheckCondCode ISD::" << CondCodeName << '\n';
209+
void CheckCondCodeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
210+
OS << Indent << "CheckCondCode ISD::" << CondCodeName << '\n';
213211
}
214212

215213
void CheckChild2CondCodeMatcher::printImpl(raw_ostream &OS,
216-
unsigned Indent) const {
217-
OS.indent(Indent) << "CheckChild2CondCode ISD::" << CondCodeName << '\n';
214+
indent Indent) const {
215+
OS << Indent << "CheckChild2CondCode ISD::" << CondCodeName << '\n';
218216
}
219217

220-
void CheckValueTypeMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
221-
OS.indent(Indent) << "CheckValueType " << getEnumName(VT) << '\n';
218+
void CheckValueTypeMatcher::printImpl(raw_ostream &OS, indent Indent) const {
219+
OS << Indent << "CheckValueType " << getEnumName(VT) << '\n';
222220
}
223221

224-
void CheckComplexPatMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
225-
OS.indent(Indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n';
222+
void CheckComplexPatMatcher::printImpl(raw_ostream &OS, indent Indent) const {
223+
OS << Indent << "CheckComplexPat " << Pattern.getSelectFunc() << '\n';
226224
}
227225

228-
void CheckAndImmMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
229-
OS.indent(Indent) << "CheckAndImm " << Value << '\n';
226+
void CheckAndImmMatcher::printImpl(raw_ostream &OS, indent Indent) const {
227+
OS << Indent << "CheckAndImm " << Value << '\n';
230228
}
231229

232-
void CheckOrImmMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
233-
OS.indent(Indent) << "CheckOrImm " << Value << '\n';
230+
void CheckOrImmMatcher::printImpl(raw_ostream &OS, indent Indent) const {
231+
OS << Indent << "CheckOrImm " << Value << '\n';
234232
}
235233

236234
void CheckFoldableChainNodeMatcher::printImpl(raw_ostream &OS,
237-
unsigned Indent) const {
238-
OS.indent(Indent) << "CheckFoldableChainNode\n";
235+
indent Indent) const {
236+
OS << Indent << "CheckFoldableChainNode\n";
239237
}
240238

241-
void CheckImmAllOnesVMatcher::printImpl(raw_ostream &OS,
242-
unsigned Indent) const {
243-
OS.indent(Indent) << "CheckAllOnesV\n";
239+
void CheckImmAllOnesVMatcher::printImpl(raw_ostream &OS, indent Indent) const {
240+
OS << Indent << "CheckAllOnesV\n";
244241
}
245242

246-
void CheckImmAllZerosVMatcher::printImpl(raw_ostream &OS,
247-
unsigned Indent) const {
248-
OS.indent(Indent) << "CheckAllZerosV\n";
243+
void CheckImmAllZerosVMatcher::printImpl(raw_ostream &OS, indent Indent) const {
244+
OS << Indent << "CheckAllZerosV\n";
249245
}
250246

251-
void EmitIntegerMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
252-
OS.indent(Indent) << "EmitInteger " << Val << " VT=" << getEnumName(VT)
253-
<< '\n';
247+
void EmitIntegerMatcher::printImpl(raw_ostream &OS, indent Indent) const {
248+
OS << Indent << "EmitInteger " << Val << " VT=" << getEnumName(VT) << '\n';
254249
}
255250

256-
void EmitStringIntegerMatcher::printImpl(raw_ostream &OS,
257-
unsigned Indent) const {
258-
OS.indent(Indent) << "EmitStringInteger " << Val << " VT=" << getEnumName(VT)
259-
<< '\n';
251+
void EmitStringIntegerMatcher::printImpl(raw_ostream &OS, indent Indent) const {
252+
OS << Indent << "EmitStringInteger " << Val << " VT=" << getEnumName(VT)
253+
<< '\n';
260254
}
261255

262-
void EmitRegisterMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
263-
OS.indent(Indent) << "EmitRegister ";
256+
void EmitRegisterMatcher::printImpl(raw_ostream &OS, indent Indent) const {
257+
OS << Indent << "EmitRegister ";
264258
if (Reg)
265259
OS << Reg->getName();
266260
else
@@ -269,26 +263,26 @@ void EmitRegisterMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
269263
}
270264

271265
void EmitConvertToTargetMatcher::printImpl(raw_ostream &OS,
272-
unsigned Indent) const {
273-
OS.indent(Indent) << "EmitConvertToTarget " << Slot << '\n';
266+
indent Indent) const {
267+
OS << Indent << "EmitConvertToTarget " << Slot << '\n';
274268
}
275269

276270
void EmitMergeInputChainsMatcher::printImpl(raw_ostream &OS,
277-
unsigned Indent) const {
278-
OS.indent(Indent) << "EmitMergeInputChains <todo: args>\n";
271+
indent Indent) const {
272+
OS << Indent << "EmitMergeInputChains <todo: args>\n";
279273
}
280274

281-
void EmitCopyToRegMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
282-
OS.indent(Indent) << "EmitCopyToReg <todo: args>\n";
275+
void EmitCopyToRegMatcher::printImpl(raw_ostream &OS, indent Indent) const {
276+
OS << Indent << "EmitCopyToReg <todo: args>\n";
283277
}
284278

285-
void EmitNodeXFormMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
286-
OS.indent(Indent) << "EmitNodeXForm " << NodeXForm->getName()
287-
<< " Slot=" << Slot << '\n';
279+
void EmitNodeXFormMatcher::printImpl(raw_ostream &OS, indent Indent) const {
280+
OS << Indent << "EmitNodeXForm " << NodeXForm->getName() << " Slot=" << Slot
281+
<< '\n';
288282
}
289283

290-
void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, unsigned Indent) const {
291-
OS.indent(Indent);
284+
void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, indent Indent) const {
285+
OS << Indent;
292286
OS << (isa<MorphNodeToMatcher>(this) ? "MorphNodeTo: " : "EmitNode: ")
293287
<< CGI.Namespace << "::" << CGI.TheDef->getName() << ": <todo flags> ";
294288

@@ -300,10 +294,10 @@ void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, unsigned Indent) const {
300294
OS << ")\n";
301295
}
302296

303-
void CompleteMatchMatcher::printImpl(raw_ostream &OS, unsigned Indent) const {
304-
OS.indent(Indent) << "CompleteMatch <todo args>\n";
305-
OS.indent(Indent) << "Src = " << Pattern.getSrcPattern() << "\n";
306-
OS.indent(Indent) << "Dst = " << Pattern.getDstPattern() << "\n";
297+
void CompleteMatchMatcher::printImpl(raw_ostream &OS, indent Indent) const {
298+
OS << Indent << "CompleteMatch <todo args>\n";
299+
OS << Indent << "Src = " << Pattern.getSrcPattern() << "\n";
300+
OS << Indent << "Dst = " << Pattern.getDstPattern() << "\n";
307301
}
308302

309303
bool CheckOpcodeMatcher::isEqualImpl(const Matcher *M) const {

0 commit comments

Comments
 (0)