@@ -22,7 +22,7 @@ using namespace llvm;
2222
2323namespace {
2424class CallingConvEmitter {
25- RecordKeeper &Records;
25+ const RecordKeeper &Records;
2626 unsigned Counter = 0u ;
2727 std::string CurrentAction;
2828 bool SwiftAction = false ;
@@ -32,27 +32,28 @@ class CallingConvEmitter {
3232 std::map<std::string, std::set<std::string>> DelegateToMap;
3333
3434public:
35- explicit CallingConvEmitter (RecordKeeper &R) : Records(R) {}
35+ explicit CallingConvEmitter (const RecordKeeper &R) : Records(R) {}
3636
3737 void run (raw_ostream &o);
3838
3939private:
40- void EmitCallingConv (Record *CC, raw_ostream &O);
41- void EmitAction (Record *Action, unsigned Indent, raw_ostream &O);
40+ void EmitCallingConv (const Record *CC, raw_ostream &O);
41+ void EmitAction (const Record *Action, unsigned Indent, raw_ostream &O);
4242 void EmitArgRegisterLists (raw_ostream &O);
4343};
4444} // End anonymous namespace
4545
4646void CallingConvEmitter::run (raw_ostream &O) {
4747 emitSourceFileHeader (" Calling Convention Implementation Fragment" , O);
4848
49- std::vector<Record *> CCs = Records.getAllDerivedDefinitions (" CallingConv" );
49+ ArrayRef<const Record *> CCs =
50+ Records.getAllDerivedDefinitions (" CallingConv" );
5051
5152 // Emit prototypes for all of the non-custom CC's so that they can forward ref
5253 // each other.
5354 Records.startTimer (" Emit prototypes" );
5455 O << " #ifndef GET_CC_REGISTER_LISTS\n\n " ;
55- for (Record *CC : CCs) {
56+ for (const Record *CC : CCs) {
5657 if (!CC->getValueAsBit (" Custom" )) {
5758 unsigned Pad = CC->getName ().size ();
5859 if (CC->getValueAsBit (" Entry" )) {
@@ -71,7 +72,7 @@ void CallingConvEmitter::run(raw_ostream &O) {
7172
7273 // Emit each non-custom calling convention description in full.
7374 Records.startTimer (" Emit full descriptions" );
74- for (Record *CC : CCs) {
75+ for (const Record *CC : CCs) {
7576 if (!CC->getValueAsBit (" Custom" )) {
7677 EmitCallingConv (CC, O);
7778 }
@@ -82,8 +83,8 @@ void CallingConvEmitter::run(raw_ostream &O) {
8283 O << " \n #endif // CC_REGISTER_LIST\n " ;
8384}
8485
85- void CallingConvEmitter::EmitCallingConv (Record *CC, raw_ostream &O) {
86- ListInit *CCActions = CC->getValueAsListInit (" Actions" );
86+ void CallingConvEmitter::EmitCallingConv (const Record *CC, raw_ostream &O) {
87+ const ListInit *CCActions = CC->getValueAsListInit (" Actions" );
8788 Counter = 0 ;
8889
8990 CurrentAction = CC->getName ().str ();
@@ -106,7 +107,7 @@ void CallingConvEmitter::EmitCallingConv(Record *CC, raw_ostream &O) {
106107 << std::string (Pad, ' ' ) << " ISD::ArgFlagsTy ArgFlags, CCState &State) {\n " ;
107108 // Emit all of the actions, in order.
108109 for (unsigned i = 0 , e = CCActions->size (); i != e; ++i) {
109- Record *Action = CCActions->getElementAsRecord (i);
110+ const Record *Action = CCActions->getElementAsRecord (i);
110111 SwiftAction =
111112 llvm::any_of (Action->getSuperClasses (),
112113 [](const std::pair<Record *, SMRange> &Class) {
@@ -122,7 +123,7 @@ void CallingConvEmitter::EmitCallingConv(Record *CC, raw_ostream &O) {
122123 O << " }\n " ;
123124}
124125
125- void CallingConvEmitter::EmitAction (Record *Action, unsigned Indent,
126+ void CallingConvEmitter::EmitAction (const Record *Action, unsigned Indent,
126127 raw_ostream &O) {
127128 std::string IndentStr = std::string (Indent, ' ' );
128129
@@ -150,14 +151,14 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
150151 O << IndentStr << " }\n " ;
151152 } else {
152153 if (Action->isSubClassOf (" CCDelegateTo" )) {
153- Record *CC = Action->getValueAsDef (" CC" );
154+ const Record *CC = Action->getValueAsDef (" CC" );
154155 O << IndentStr << " if (!" << CC->getName ()
155156 << " (ValNo, ValVT, LocVT, LocInfo, ArgFlags, State))\n "
156157 << IndentStr << " return false;\n " ;
157158 DelegateToMap[CurrentAction].insert (CC->getName ().str ());
158159 } else if (Action->isSubClassOf (" CCAssignToReg" ) ||
159160 Action->isSubClassOf (" CCAssignToRegAndStack" )) {
160- ListInit *RegList = Action->getValueAsListInit (" RegList" );
161+ const ListInit *RegList = Action->getValueAsListInit (" RegList" );
161162 if (RegList->size () == 1 ) {
162163 std::string Name = getQualifiedName (RegList->getElementAsRecord (0 ));
163164 O << IndentStr << " if (MCRegister Reg = State.AllocateReg(" << Name
@@ -210,8 +211,9 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
210211 O << IndentStr << " return false;\n " ;
211212 O << IndentStr << " }\n " ;
212213 } else if (Action->isSubClassOf (" CCAssignToRegWithShadow" )) {
213- ListInit *RegList = Action->getValueAsListInit (" RegList" );
214- ListInit *ShadowRegList = Action->getValueAsListInit (" ShadowRegList" );
214+ const ListInit *RegList = Action->getValueAsListInit (" RegList" );
215+ const ListInit *ShadowRegList =
216+ Action->getValueAsListInit (" ShadowRegList" );
215217 if (!ShadowRegList->empty () && ShadowRegList->size () != RegList->size ())
216218 PrintFatalError (Action->getLoc (),
217219 " Invalid length of list of shadowed registers" );
@@ -278,7 +280,8 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
278280 } else if (Action->isSubClassOf (" CCAssignToStackWithShadow" )) {
279281 int Size = Action->getValueAsInt (" Size" );
280282 int Align = Action->getValueAsInt (" Align" );
281- ListInit *ShadowRegList = Action->getValueAsListInit (" ShadowRegList" );
283+ const ListInit *ShadowRegList =
284+ Action->getValueAsListInit (" ShadowRegList" );
282285
283286 unsigned ShadowRegListNumber = ++Counter;
284287
@@ -297,7 +300,7 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
297300 << Counter << " , LocVT, LocInfo));\n " ;
298301 O << IndentStr << " return false;\n " ;
299302 } else if (Action->isSubClassOf (" CCPromoteToType" )) {
300- Record *DestTy = Action->getValueAsDef (" DestTy" );
303+ const Record *DestTy = Action->getValueAsDef (" DestTy" );
301304 MVT::SimpleValueType DestVT = getValueType (DestTy);
302305 O << IndentStr << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
303306 if (MVT (DestVT).isFloatingPoint ()) {
@@ -311,7 +314,7 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
311314 << IndentStr << " LocInfo = CCValAssign::AExt;\n " ;
312315 }
313316 } else if (Action->isSubClassOf (" CCPromoteToUpperBitsInType" )) {
314- Record *DestTy = Action->getValueAsDef (" DestTy" );
317+ const Record *DestTy = Action->getValueAsDef (" DestTy" );
315318 MVT::SimpleValueType DestVT = getValueType (DestTy);
316319 O << IndentStr << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
317320 if (MVT (DestVT).isFloatingPoint ()) {
@@ -327,17 +330,17 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
327330 << IndentStr << " LocInfo = CCValAssign::AExtUpper;\n " ;
328331 }
329332 } else if (Action->isSubClassOf (" CCBitConvertToType" )) {
330- Record *DestTy = Action->getValueAsDef (" DestTy" );
333+ const Record *DestTy = Action->getValueAsDef (" DestTy" );
331334 O << IndentStr << " LocVT = " << getEnumName (getValueType (DestTy))
332335 << " ;\n " ;
333336 O << IndentStr << " LocInfo = CCValAssign::BCvt;\n " ;
334337 } else if (Action->isSubClassOf (" CCTruncToType" )) {
335- Record *DestTy = Action->getValueAsDef (" DestTy" );
338+ const Record *DestTy = Action->getValueAsDef (" DestTy" );
336339 O << IndentStr << " LocVT = " << getEnumName (getValueType (DestTy))
337340 << " ;\n " ;
338341 O << IndentStr << " LocInfo = CCValAssign::Trunc;\n " ;
339342 } else if (Action->isSubClassOf (" CCPassIndirect" )) {
340- Record *DestTy = Action->getValueAsDef (" DestTy" );
343+ const Record *DestTy = Action->getValueAsDef (" DestTy" );
341344 O << IndentStr << " LocVT = " << getEnumName (getValueType (DestTy))
342345 << " ;\n " ;
343346 O << IndentStr << " LocInfo = CCValAssign::Indirect;\n " ;
0 commit comments