@@ -38,7 +38,7 @@ class CallingConvEmitter {
3838
3939private:
4040 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);
4242 void EmitArgRegisterLists (raw_ostream &O);
4343};
4444} // End anonymous namespace
@@ -116,26 +116,24 @@ void CallingConvEmitter::EmitCallingConv(const Record *CC, raw_ostream &O) {
116116 });
117117
118118 O << " \n " ;
119- EmitAction (Action, 2 , O);
119+ EmitAction (Action, indent ( 2 ) , O);
120120 }
121121
122122 O << " \n return true; // CC didn't match.\n " ;
123123 O << " }\n " ;
124124}
125125
126- void CallingConvEmitter::EmitAction (const Record *Action, unsigned Indent,
126+ void CallingConvEmitter::EmitAction (const Record *Action, indent Indent,
127127 raw_ostream &O) {
128- std::string IndentStr = std::string (Indent, ' ' );
129-
130128 if (Action->isSubClassOf (" CCPredicateAction" )) {
131- O << IndentStr << " if (" ;
129+ O << Indent << " if (" ;
132130
133131 if (Action->isSubClassOf (" CCIfType" )) {
134132 const ListInit *VTs = Action->getValueAsListInit (" VTs" );
135133 for (unsigned i = 0 , e = VTs->size (); i != e; ++i) {
136134 const Record *VT = VTs->getElementAsRecord (i);
137135 if (i != 0 )
138- O << " ||\n " << IndentStr ;
136+ O << " ||\n " << Indent ;
139137 O << " LocVT == " << getEnumName (getValueType (VT));
140138 }
141139
@@ -148,29 +146,29 @@ void CallingConvEmitter::EmitAction(const Record *Action, unsigned Indent,
148146
149147 O << " ) {\n " ;
150148 EmitAction (Action->getValueAsDef (" SubAction" ), Indent + 2 , O);
151- O << IndentStr << " }\n " ;
149+ O << Indent << " }\n " ;
152150 } else {
153151 if (Action->isSubClassOf (" CCDelegateTo" )) {
154152 const Record *CC = Action->getValueAsDef (" CC" );
155- O << IndentStr << " if (!" << CC->getName ()
153+ O << Indent << " if (!" << CC->getName ()
156154 << " (ValNo, ValVT, LocVT, LocInfo, ArgFlags, State))\n "
157- << IndentStr << " return false;\n " ;
155+ << Indent + 2 << " return false;\n " ;
158156 DelegateToMap[CurrentAction].insert (CC->getName ().str ());
159157 } else if (Action->isSubClassOf (" CCAssignToReg" ) ||
160158 Action->isSubClassOf (" CCAssignToRegAndStack" )) {
161159 const ListInit *RegList = Action->getValueAsListInit (" RegList" );
162160 if (RegList->size () == 1 ) {
163161 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
165163 << " )) {\n " ;
166164 if (SwiftAction)
167165 AssignedSwiftRegsMap[CurrentAction].insert (Name);
168166 else
169167 AssignedRegsMap[CurrentAction].insert (Name);
170168 } else {
171- O << IndentStr << " static const MCPhysReg RegList" << ++Counter
169+ O << Indent << " static const MCPhysReg RegList" << ++Counter
172170 << " [] = {\n " ;
173- O << IndentStr << " " ;
171+ O << Indent << " " ;
174172 ListSeparator LS;
175173 for (unsigned i = 0 , e = RegList->size (); i != e; ++i) {
176174 std::string Name = getQualifiedName (RegList->getElementAsRecord (i));
@@ -180,36 +178,36 @@ void CallingConvEmitter::EmitAction(const Record *Action, unsigned Indent,
180178 AssignedRegsMap[CurrentAction].insert (Name);
181179 O << LS << Name;
182180 }
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"
185183 << Counter << " )) {\n " ;
186184 }
187- O << IndentStr << " State.addLoc(CCValAssign::getReg(ValNo, ValVT, "
185+ O << Indent << " State.addLoc(CCValAssign::getReg(ValNo, ValVT, "
188186 << " Reg, LocVT, LocInfo));\n " ;
189187 if (Action->isSubClassOf (" CCAssignToRegAndStack" )) {
190188 int Size = Action->getValueAsInt (" Size" );
191189 int Align = Action->getValueAsInt (" Align" );
192- O << IndentStr << " (void)State.AllocateStack(" ;
190+ O << Indent << " (void)State.AllocateStack(" ;
193191 if (Size)
194192 O << Size << " , " ;
195193 else
196194 O << " \n "
197- << IndentStr
195+ << Indent
198196 << " State.getMachineFunction().getDataLayout()."
199197 " getTypeAllocSize(EVT(LocVT).getTypeForEVT(State.getContext())),"
200198 " " ;
201199 if (Align)
202200 O << " Align(" << Align << " )" ;
203201 else
204202 O << " \n "
205- << IndentStr
203+ << Indent
206204 << " State.getMachineFunction().getDataLayout()."
207205 " getABITypeAlign(EVT(LocVT).getTypeForEVT(State.getContext()"
208206 " ))" ;
209207 O << " );\n " ;
210208 }
211- O << IndentStr << " return false;\n " ;
212- O << IndentStr << " }\n " ;
209+ O << Indent << " return false;\n " ;
210+ O << Indent << " }\n " ;
213211 } else if (Action->isSubClassOf (" CCAssignToRegWithShadow" )) {
214212 const ListInit *RegList = Action->getValueAsListInit (" RegList" );
215213 const ListInit *ShadowRegList =
@@ -219,64 +217,63 @@ void CallingConvEmitter::EmitAction(const Record *Action, unsigned Indent,
219217 " Invalid length of list of shadowed registers" );
220218
221219 if (RegList->size () == 1 ) {
222- O << IndentStr << " if (MCRegister Reg = State.AllocateReg(" ;
220+ O << Indent << " if (MCRegister Reg = State.AllocateReg(" ;
223221 O << getQualifiedName (RegList->getElementAsRecord (0 ));
224222 O << " , " << getQualifiedName (ShadowRegList->getElementAsRecord (0 ));
225223 O << " )) {\n " ;
226224 } else {
227225 unsigned RegListNumber = ++Counter;
228226 unsigned ShadowRegListNumber = ++Counter;
229227
230- O << IndentStr << " static const MCPhysReg RegList" << RegListNumber
228+ O << Indent << " static const MCPhysReg RegList" << RegListNumber
231229 << " [] = {\n " ;
232- O << IndentStr << " " ;
230+ O << Indent << " " ;
233231 ListSeparator LS;
234232 for (unsigned i = 0 , e = RegList->size (); i != e; ++i)
235233 O << LS << getQualifiedName (RegList->getElementAsRecord (i));
236- O << " \n " << IndentStr << " };\n " ;
234+ O << " \n " << Indent << " };\n " ;
237235
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 << " " ;
241239 ListSeparator LSS;
242240 for (unsigned i = 0 , e = ShadowRegList->size (); i != e; ++i)
243241 O << LSS << getQualifiedName (ShadowRegList->getElementAsRecord (i));
244- O << " \n " << IndentStr << " };\n " ;
242+ O << " \n " << Indent << " };\n " ;
245243
246- O << IndentStr << " if (MCRegister Reg = State.AllocateReg(RegList"
244+ O << Indent << " if (MCRegister Reg = State.AllocateReg(RegList"
247245 << RegListNumber << " , "
248246 << " RegList" << ShadowRegListNumber << " )) {\n " ;
249247 }
250- O << IndentStr << " State.addLoc(CCValAssign::getReg(ValNo, ValVT, "
248+ O << Indent << " State.addLoc(CCValAssign::getReg(ValNo, ValVT, "
251249 << " Reg, LocVT, LocInfo));\n " ;
252- O << IndentStr << " return false;\n " ;
253- O << IndentStr << " }\n " ;
250+ O << Indent << " return false;\n " ;
251+ O << Indent << " }\n " ;
254252 } else if (Action->isSubClassOf (" CCAssignToStack" )) {
255253 int Size = Action->getValueAsInt (" Size" );
256254 int Align = Action->getValueAsInt (" Align" );
257255
258- O << IndentStr << " int64_t Offset" << ++Counter
259- << " = State.AllocateStack(" ;
256+ O << Indent << " int64_t Offset" << ++Counter << " = State.AllocateStack(" ;
260257 if (Size)
261258 O << Size << " , " ;
262259 else
263260 O << " \n "
264- << IndentStr
261+ << Indent
265262 << " State.getMachineFunction().getDataLayout()."
266263 " getTypeAllocSize(EVT(LocVT).getTypeForEVT(State.getContext())),"
267264 " " ;
268265 if (Align)
269266 O << " Align(" << Align << " )" ;
270267 else
271268 O << " \n "
272- << IndentStr
269+ << Indent
273270 << " State.getMachineFunction().getDataLayout()."
274271 " getABITypeAlign(EVT(LocVT).getTypeForEVT(State.getContext()"
275272 " ))" ;
276273 O << " );\n "
277- << IndentStr << " State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
274+ << Indent << " State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
278275 << Counter << " , LocVT, LocInfo));\n " ;
279- O << IndentStr << " return false;\n " ;
276+ O << Indent << " return false;\n " ;
280277 } else if (Action->isSubClassOf (" CCAssignToStackWithShadow" )) {
281278 int Size = Action->getValueAsInt (" Size" );
282279 int Align = Action->getValueAsInt (" Align" );
@@ -285,76 +282,73 @@ void CallingConvEmitter::EmitAction(const Record *Action, unsigned Indent,
285282
286283 unsigned ShadowRegListNumber = ++Counter;
287284
288- O << IndentStr << " static const MCPhysReg ShadowRegList"
285+ O << Indent << " static const MCPhysReg ShadowRegList"
289286 << ShadowRegListNumber << " [] = {\n " ;
290- O << IndentStr << " " ;
287+ O << Indent << " " ;
291288 ListSeparator LS;
292289 for (unsigned i = 0 , e = ShadowRegList->size (); i != e; ++i)
293290 O << LS << getQualifiedName (ShadowRegList->getElementAsRecord (i));
294- O << " \n " << IndentStr << " };\n " ;
291+ O << " \n " << Indent << " };\n " ;
295292
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 << " ), "
298295 << " ShadowRegList" << ShadowRegListNumber << " );\n " ;
299- O << IndentStr << " State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
296+ O << Indent << " State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
300297 << Counter << " , LocVT, LocInfo));\n " ;
301- O << IndentStr << " return false;\n " ;
298+ O << Indent << " return false;\n " ;
302299 } else if (Action->isSubClassOf (" CCPromoteToType" )) {
303300 const Record *DestTy = Action->getValueAsDef (" DestTy" );
304301 MVT::SimpleValueType DestVT = getValueType (DestTy);
305- O << IndentStr << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
302+ O << Indent << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
306303 if (MVT (DestVT).isFloatingPoint ()) {
307- O << IndentStr << " LocInfo = CCValAssign::FPExt;\n " ;
304+ O << Indent << " LocInfo = CCValAssign::FPExt;\n " ;
308305 } 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 " ;
315312 }
316313 } else if (Action->isSubClassOf (" CCPromoteToUpperBitsInType" )) {
317314 const Record *DestTy = Action->getValueAsDef (" DestTy" );
318315 MVT::SimpleValueType DestVT = getValueType (DestTy);
319- O << IndentStr << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
316+ O << Indent << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
320317 if (MVT (DestVT).isFloatingPoint ()) {
321318 PrintFatalError (Action->getLoc (),
322319 " CCPromoteToUpperBitsInType does not handle floating "
323320 " point" );
324321 } 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 " ;
331328 }
332329 } else if (Action->isSubClassOf (" CCBitConvertToType" )) {
333330 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 " ;
337333 } else if (Action->isSubClassOf (" CCTruncToType" )) {
338334 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 " ;
342337 } else if (Action->isSubClassOf (" CCPassIndirect" )) {
343338 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 " ;
347341 } else if (Action->isSubClassOf (" CCPassByVal" )) {
348342 int Size = Action->getValueAsInt (" Size" );
349343 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 " ;
353347 } else if (Action->isSubClassOf (" CCCustom" )) {
354- O << IndentStr << " if (" << Action->getValueAsString (" FuncName" )
348+ O << Indent << " if (" << Action->getValueAsString (" FuncName" )
355349 << " (ValNo, ValVT, "
356350 << " LocVT, LocInfo, ArgFlags, State))\n " ;
357- O << IndentStr << " return false;\n " ;
351+ O << Indent << " return false;\n " ;
358352 } else {
359353 errs () << *Action;
360354 PrintFatalError (Action->getLoc (), " Unknown CCAction!" );
0 commit comments