@@ -38,7 +38,7 @@ class CallingConvEmitter {
38
38
39
39
private:
40
40
void EmitCallingConv (const Record *CC, raw_ostream &O);
41
- void EmitAction (const Record *Action, unsigned Indent, raw_ostream &O);
41
+ void EmitAction (const Record *Action, indent Indent, raw_ostream &O);
42
42
void EmitArgRegisterLists (raw_ostream &O);
43
43
};
44
44
} // End anonymous namespace
@@ -116,26 +116,24 @@ void CallingConvEmitter::EmitCallingConv(const Record *CC, raw_ostream &O) {
116
116
});
117
117
118
118
O << " \n " ;
119
- EmitAction (Action, 2 , O);
119
+ EmitAction (Action, indent ( 2 ) , O);
120
120
}
121
121
122
122
O << " \n return true; // CC didn't match.\n " ;
123
123
O << " }\n " ;
124
124
}
125
125
126
- void CallingConvEmitter::EmitAction (const Record *Action, unsigned Indent,
126
+ void CallingConvEmitter::EmitAction (const Record *Action, indent Indent,
127
127
raw_ostream &O) {
128
- std::string IndentStr = std::string (Indent, ' ' );
129
-
130
128
if (Action->isSubClassOf (" CCPredicateAction" )) {
131
- O << IndentStr << " if (" ;
129
+ O << Indent << " if (" ;
132
130
133
131
if (Action->isSubClassOf (" CCIfType" )) {
134
132
const ListInit *VTs = Action->getValueAsListInit (" VTs" );
135
133
for (unsigned i = 0 , e = VTs->size (); i != e; ++i) {
136
134
const Record *VT = VTs->getElementAsRecord (i);
137
135
if (i != 0 )
138
- O << " ||\n " << IndentStr ;
136
+ O << " ||\n " << Indent ;
139
137
O << " LocVT == " << getEnumName (getValueType (VT));
140
138
}
141
139
@@ -148,29 +146,29 @@ void CallingConvEmitter::EmitAction(const Record *Action, unsigned Indent,
148
146
149
147
O << " ) {\n " ;
150
148
EmitAction (Action->getValueAsDef (" SubAction" ), Indent + 2 , O);
151
- O << IndentStr << " }\n " ;
149
+ O << Indent << " }\n " ;
152
150
} else {
153
151
if (Action->isSubClassOf (" CCDelegateTo" )) {
154
152
const Record *CC = Action->getValueAsDef (" CC" );
155
- O << IndentStr << " if (!" << CC->getName ()
153
+ O << Indent << " if (!" << CC->getName ()
156
154
<< " (ValNo, ValVT, LocVT, LocInfo, ArgFlags, State))\n "
157
- << IndentStr << " return false;\n " ;
155
+ << Indent + 2 << " return false;\n " ;
158
156
DelegateToMap[CurrentAction].insert (CC->getName ().str ());
159
157
} else if (Action->isSubClassOf (" CCAssignToReg" ) ||
160
158
Action->isSubClassOf (" CCAssignToRegAndStack" )) {
161
159
const ListInit *RegList = Action->getValueAsListInit (" RegList" );
162
160
if (RegList->size () == 1 ) {
163
161
std::string Name = getQualifiedName (RegList->getElementAsRecord (0 ));
164
- O << IndentStr << " if (MCRegister Reg = State.AllocateReg(" << Name
162
+ O << Indent << " if (MCRegister Reg = State.AllocateReg(" << Name
165
163
<< " )) {\n " ;
166
164
if (SwiftAction)
167
165
AssignedSwiftRegsMap[CurrentAction].insert (Name);
168
166
else
169
167
AssignedRegsMap[CurrentAction].insert (Name);
170
168
} else {
171
- O << IndentStr << " static const MCPhysReg RegList" << ++Counter
169
+ O << Indent << " static const MCPhysReg RegList" << ++Counter
172
170
<< " [] = {\n " ;
173
- O << IndentStr << " " ;
171
+ O << Indent << " " ;
174
172
ListSeparator LS;
175
173
for (unsigned i = 0 , e = RegList->size (); i != e; ++i) {
176
174
std::string Name = getQualifiedName (RegList->getElementAsRecord (i));
@@ -180,36 +178,36 @@ void CallingConvEmitter::EmitAction(const Record *Action, unsigned Indent,
180
178
AssignedRegsMap[CurrentAction].insert (Name);
181
179
O << LS << Name;
182
180
}
183
- O << " \n " << IndentStr << " };\n " ;
184
- O << IndentStr << " if (MCRegister Reg = State.AllocateReg(RegList"
181
+ O << " \n " << Indent << " };\n " ;
182
+ O << Indent << " if (MCRegister Reg = State.AllocateReg(RegList"
185
183
<< Counter << " )) {\n " ;
186
184
}
187
- O << IndentStr << " State.addLoc(CCValAssign::getReg(ValNo, ValVT, "
185
+ O << Indent << " State.addLoc(CCValAssign::getReg(ValNo, ValVT, "
188
186
<< " Reg, LocVT, LocInfo));\n " ;
189
187
if (Action->isSubClassOf (" CCAssignToRegAndStack" )) {
190
188
int Size = Action->getValueAsInt (" Size" );
191
189
int Align = Action->getValueAsInt (" Align" );
192
- O << IndentStr << " (void)State.AllocateStack(" ;
190
+ O << Indent << " (void)State.AllocateStack(" ;
193
191
if (Size)
194
192
O << Size << " , " ;
195
193
else
196
194
O << " \n "
197
- << IndentStr
195
+ << Indent
198
196
<< " State.getMachineFunction().getDataLayout()."
199
197
" getTypeAllocSize(EVT(LocVT).getTypeForEVT(State.getContext())),"
200
198
" " ;
201
199
if (Align)
202
200
O << " Align(" << Align << " )" ;
203
201
else
204
202
O << " \n "
205
- << IndentStr
203
+ << Indent
206
204
<< " State.getMachineFunction().getDataLayout()."
207
205
" getABITypeAlign(EVT(LocVT).getTypeForEVT(State.getContext()"
208
206
" ))" ;
209
207
O << " );\n " ;
210
208
}
211
- O << IndentStr << " return false;\n " ;
212
- O << IndentStr << " }\n " ;
209
+ O << Indent << " return false;\n " ;
210
+ O << Indent << " }\n " ;
213
211
} else if (Action->isSubClassOf (" CCAssignToRegWithShadow" )) {
214
212
const ListInit *RegList = Action->getValueAsListInit (" RegList" );
215
213
const ListInit *ShadowRegList =
@@ -219,64 +217,63 @@ void CallingConvEmitter::EmitAction(const Record *Action, unsigned Indent,
219
217
" Invalid length of list of shadowed registers" );
220
218
221
219
if (RegList->size () == 1 ) {
222
- O << IndentStr << " if (MCRegister Reg = State.AllocateReg(" ;
220
+ O << Indent << " if (MCRegister Reg = State.AllocateReg(" ;
223
221
O << getQualifiedName (RegList->getElementAsRecord (0 ));
224
222
O << " , " << getQualifiedName (ShadowRegList->getElementAsRecord (0 ));
225
223
O << " )) {\n " ;
226
224
} else {
227
225
unsigned RegListNumber = ++Counter;
228
226
unsigned ShadowRegListNumber = ++Counter;
229
227
230
- O << IndentStr << " static const MCPhysReg RegList" << RegListNumber
228
+ O << Indent << " static const MCPhysReg RegList" << RegListNumber
231
229
<< " [] = {\n " ;
232
- O << IndentStr << " " ;
230
+ O << Indent << " " ;
233
231
ListSeparator LS;
234
232
for (unsigned i = 0 , e = RegList->size (); i != e; ++i)
235
233
O << LS << getQualifiedName (RegList->getElementAsRecord (i));
236
- O << " \n " << IndentStr << " };\n " ;
234
+ O << " \n " << Indent << " };\n " ;
237
235
238
- O << IndentStr << " static const MCPhysReg RegList"
239
- << ShadowRegListNumber << " [] = {\n " ;
240
- O << IndentStr << " " ;
236
+ O << Indent << " static const MCPhysReg RegList" << ShadowRegListNumber
237
+ << " [] = {\n " ;
238
+ O << Indent << " " ;
241
239
ListSeparator LSS;
242
240
for (unsigned i = 0 , e = ShadowRegList->size (); i != e; ++i)
243
241
O << LSS << getQualifiedName (ShadowRegList->getElementAsRecord (i));
244
- O << " \n " << IndentStr << " };\n " ;
242
+ O << " \n " << Indent << " };\n " ;
245
243
246
- O << IndentStr << " if (MCRegister Reg = State.AllocateReg(RegList"
244
+ O << Indent << " if (MCRegister Reg = State.AllocateReg(RegList"
247
245
<< RegListNumber << " , "
248
246
<< " RegList" << ShadowRegListNumber << " )) {\n " ;
249
247
}
250
- O << IndentStr << " State.addLoc(CCValAssign::getReg(ValNo, ValVT, "
248
+ O << Indent << " State.addLoc(CCValAssign::getReg(ValNo, ValVT, "
251
249
<< " Reg, LocVT, LocInfo));\n " ;
252
- O << IndentStr << " return false;\n " ;
253
- O << IndentStr << " }\n " ;
250
+ O << Indent << " return false;\n " ;
251
+ O << Indent << " }\n " ;
254
252
} else if (Action->isSubClassOf (" CCAssignToStack" )) {
255
253
int Size = Action->getValueAsInt (" Size" );
256
254
int Align = Action->getValueAsInt (" Align" );
257
255
258
- O << IndentStr << " int64_t Offset" << ++Counter
259
- << " = State.AllocateStack(" ;
256
+ O << Indent << " int64_t Offset" << ++Counter << " = State.AllocateStack(" ;
260
257
if (Size)
261
258
O << Size << " , " ;
262
259
else
263
260
O << " \n "
264
- << IndentStr
261
+ << Indent
265
262
<< " State.getMachineFunction().getDataLayout()."
266
263
" getTypeAllocSize(EVT(LocVT).getTypeForEVT(State.getContext())),"
267
264
" " ;
268
265
if (Align)
269
266
O << " Align(" << Align << " )" ;
270
267
else
271
268
O << " \n "
272
- << IndentStr
269
+ << Indent
273
270
<< " State.getMachineFunction().getDataLayout()."
274
271
" getABITypeAlign(EVT(LocVT).getTypeForEVT(State.getContext()"
275
272
" ))" ;
276
273
O << " );\n "
277
- << IndentStr << " State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
274
+ << Indent << " State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
278
275
<< Counter << " , LocVT, LocInfo));\n " ;
279
- O << IndentStr << " return false;\n " ;
276
+ O << Indent << " return false;\n " ;
280
277
} else if (Action->isSubClassOf (" CCAssignToStackWithShadow" )) {
281
278
int Size = Action->getValueAsInt (" Size" );
282
279
int Align = Action->getValueAsInt (" Align" );
@@ -285,76 +282,73 @@ void CallingConvEmitter::EmitAction(const Record *Action, unsigned Indent,
285
282
286
283
unsigned ShadowRegListNumber = ++Counter;
287
284
288
- O << IndentStr << " static const MCPhysReg ShadowRegList"
285
+ O << Indent << " static const MCPhysReg ShadowRegList"
289
286
<< ShadowRegListNumber << " [] = {\n " ;
290
- O << IndentStr << " " ;
287
+ O << Indent << " " ;
291
288
ListSeparator LS;
292
289
for (unsigned i = 0 , e = ShadowRegList->size (); i != e; ++i)
293
290
O << LS << getQualifiedName (ShadowRegList->getElementAsRecord (i));
294
- O << " \n " << IndentStr << " };\n " ;
291
+ O << " \n " << Indent << " };\n " ;
295
292
296
- O << IndentStr << " int64_t Offset" << ++Counter
297
- << " = State.AllocateStack( " << Size << " , Align(" << Align << " ), "
293
+ O << Indent << " int64_t Offset" << ++Counter << " = State.AllocateStack( "
294
+ << Size << " , Align(" << Align << " ), "
298
295
<< " ShadowRegList" << ShadowRegListNumber << " );\n " ;
299
- O << IndentStr << " State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
296
+ O << Indent << " State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
300
297
<< Counter << " , LocVT, LocInfo));\n " ;
301
- O << IndentStr << " return false;\n " ;
298
+ O << Indent << " return false;\n " ;
302
299
} else if (Action->isSubClassOf (" CCPromoteToType" )) {
303
300
const Record *DestTy = Action->getValueAsDef (" DestTy" );
304
301
MVT::SimpleValueType DestVT = getValueType (DestTy);
305
- O << IndentStr << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
302
+ O << Indent << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
306
303
if (MVT (DestVT).isFloatingPoint ()) {
307
- O << IndentStr << " LocInfo = CCValAssign::FPExt;\n " ;
304
+ O << Indent << " LocInfo = CCValAssign::FPExt;\n " ;
308
305
} else {
309
- O << IndentStr << " if (ArgFlags.isSExt())\n "
310
- << IndentStr << " LocInfo = CCValAssign::SExt;\n "
311
- << IndentStr << " else if (ArgFlags.isZExt())\n "
312
- << IndentStr << " LocInfo = CCValAssign::ZExt;\n "
313
- << IndentStr << " else\n "
314
- << IndentStr << " LocInfo = CCValAssign::AExt;\n " ;
306
+ O << Indent << " if (ArgFlags.isSExt())\n "
307
+ << Indent << " LocInfo = CCValAssign::SExt;\n "
308
+ << Indent << " else if (ArgFlags.isZExt())\n "
309
+ << Indent << " LocInfo = CCValAssign::ZExt;\n "
310
+ << Indent << " else\n "
311
+ << Indent << " LocInfo = CCValAssign::AExt;\n " ;
315
312
}
316
313
} else if (Action->isSubClassOf (" CCPromoteToUpperBitsInType" )) {
317
314
const Record *DestTy = Action->getValueAsDef (" DestTy" );
318
315
MVT::SimpleValueType DestVT = getValueType (DestTy);
319
- O << IndentStr << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
316
+ O << Indent << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
320
317
if (MVT (DestVT).isFloatingPoint ()) {
321
318
PrintFatalError (Action->getLoc (),
322
319
" CCPromoteToUpperBitsInType does not handle floating "
323
320
" point" );
324
321
} else {
325
- O << IndentStr << " if (ArgFlags.isSExt())\n "
326
- << IndentStr << " LocInfo = CCValAssign::SExtUpper;\n "
327
- << IndentStr << " else if (ArgFlags.isZExt())\n "
328
- << IndentStr << " LocInfo = CCValAssign::ZExtUpper;\n "
329
- << IndentStr << " else\n "
330
- << IndentStr << " LocInfo = CCValAssign::AExtUpper;\n " ;
322
+ O << Indent << " if (ArgFlags.isSExt())\n "
323
+ << Indent << " LocInfo = CCValAssign::SExtUpper;\n "
324
+ << Indent << " else if (ArgFlags.isZExt())\n "
325
+ << Indent << " LocInfo = CCValAssign::ZExtUpper;\n "
326
+ << Indent << " else\n "
327
+ << Indent << " LocInfo = CCValAssign::AExtUpper;\n " ;
331
328
}
332
329
} else if (Action->isSubClassOf (" CCBitConvertToType" )) {
333
330
const Record *DestTy = Action->getValueAsDef (" DestTy" );
334
- O << IndentStr << " LocVT = " << getEnumName (getValueType (DestTy))
335
- << " ;\n " ;
336
- O << IndentStr << " LocInfo = CCValAssign::BCvt;\n " ;
331
+ O << Indent << " LocVT = " << getEnumName (getValueType (DestTy)) << " ;\n " ;
332
+ O << Indent << " LocInfo = CCValAssign::BCvt;\n " ;
337
333
} else if (Action->isSubClassOf (" CCTruncToType" )) {
338
334
const Record *DestTy = Action->getValueAsDef (" DestTy" );
339
- O << IndentStr << " LocVT = " << getEnumName (getValueType (DestTy))
340
- << " ;\n " ;
341
- O << IndentStr << " LocInfo = CCValAssign::Trunc;\n " ;
335
+ O << Indent << " LocVT = " << getEnumName (getValueType (DestTy)) << " ;\n " ;
336
+ O << Indent << " LocInfo = CCValAssign::Trunc;\n " ;
342
337
} else if (Action->isSubClassOf (" CCPassIndirect" )) {
343
338
const Record *DestTy = Action->getValueAsDef (" DestTy" );
344
- O << IndentStr << " LocVT = " << getEnumName (getValueType (DestTy))
345
- << " ;\n " ;
346
- O << IndentStr << " LocInfo = CCValAssign::Indirect;\n " ;
339
+ O << Indent << " LocVT = " << getEnumName (getValueType (DestTy)) << " ;\n " ;
340
+ O << Indent << " LocInfo = CCValAssign::Indirect;\n " ;
347
341
} else if (Action->isSubClassOf (" CCPassByVal" )) {
348
342
int Size = Action->getValueAsInt (" Size" );
349
343
int Align = Action->getValueAsInt (" Align" );
350
- O << IndentStr << " State.HandleByVal(ValNo, ValVT, LocVT, LocInfo, "
351
- << Size << " , Align(" << Align << " ), ArgFlags);\n " ;
352
- O << IndentStr << " return false;\n " ;
344
+ O << Indent << " State.HandleByVal(ValNo, ValVT, LocVT, LocInfo, " << Size
345
+ << " , Align(" << Align << " ), ArgFlags);\n " ;
346
+ O << Indent << " return false;\n " ;
353
347
} else if (Action->isSubClassOf (" CCCustom" )) {
354
- O << IndentStr << " if (" << Action->getValueAsString (" FuncName" )
348
+ O << Indent << " if (" << Action->getValueAsString (" FuncName" )
355
349
<< " (ValNo, ValVT, "
356
350
<< " LocVT, LocInfo, ArgFlags, State))\n " ;
357
- O << IndentStr << " return false;\n " ;
351
+ O << Indent << " return false;\n " ;
358
352
} else {
359
353
errs () << *Action;
360
354
PrintFatalError (Action->getLoc (), " Unknown CCAction!" );
0 commit comments