@@ -22,7 +22,7 @@ using namespace llvm;
22
22
23
23
namespace {
24
24
class CallingConvEmitter {
25
- RecordKeeper &Records;
25
+ const RecordKeeper &Records;
26
26
unsigned Counter = 0u ;
27
27
std::string CurrentAction;
28
28
bool SwiftAction = false ;
@@ -32,27 +32,28 @@ class CallingConvEmitter {
32
32
std::map<std::string, std::set<std::string>> DelegateToMap;
33
33
34
34
public:
35
- explicit CallingConvEmitter (RecordKeeper &R) : Records(R) {}
35
+ explicit CallingConvEmitter (const RecordKeeper &R) : Records(R) {}
36
36
37
37
void run (raw_ostream &o);
38
38
39
39
private:
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);
42
42
void EmitArgRegisterLists (raw_ostream &O);
43
43
};
44
44
} // End anonymous namespace
45
45
46
46
void CallingConvEmitter::run (raw_ostream &O) {
47
47
emitSourceFileHeader (" Calling Convention Implementation Fragment" , O);
48
48
49
- std::vector<Record *> CCs = Records.getAllDerivedDefinitions (" CallingConv" );
49
+ ArrayRef<const Record *> CCs =
50
+ Records.getAllDerivedDefinitions (" CallingConv" );
50
51
51
52
// Emit prototypes for all of the non-custom CC's so that they can forward ref
52
53
// each other.
53
54
Records.startTimer (" Emit prototypes" );
54
55
O << " #ifndef GET_CC_REGISTER_LISTS\n\n " ;
55
- for (Record *CC : CCs) {
56
+ for (const Record *CC : CCs) {
56
57
if (!CC->getValueAsBit (" Custom" )) {
57
58
unsigned Pad = CC->getName ().size ();
58
59
if (CC->getValueAsBit (" Entry" )) {
@@ -71,7 +72,7 @@ void CallingConvEmitter::run(raw_ostream &O) {
71
72
72
73
// Emit each non-custom calling convention description in full.
73
74
Records.startTimer (" Emit full descriptions" );
74
- for (Record *CC : CCs) {
75
+ for (const Record *CC : CCs) {
75
76
if (!CC->getValueAsBit (" Custom" )) {
76
77
EmitCallingConv (CC, O);
77
78
}
@@ -82,8 +83,8 @@ void CallingConvEmitter::run(raw_ostream &O) {
82
83
O << " \n #endif // CC_REGISTER_LIST\n " ;
83
84
}
84
85
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" );
87
88
Counter = 0 ;
88
89
89
90
CurrentAction = CC->getName ().str ();
@@ -106,7 +107,7 @@ void CallingConvEmitter::EmitCallingConv(Record *CC, raw_ostream &O) {
106
107
<< std::string (Pad, ' ' ) << " ISD::ArgFlagsTy ArgFlags, CCState &State) {\n " ;
107
108
// Emit all of the actions, in order.
108
109
for (unsigned i = 0 , e = CCActions->size (); i != e; ++i) {
109
- Record *Action = CCActions->getElementAsRecord (i);
110
+ const Record *Action = CCActions->getElementAsRecord (i);
110
111
SwiftAction =
111
112
llvm::any_of (Action->getSuperClasses (),
112
113
[](const std::pair<Record *, SMRange> &Class) {
@@ -122,7 +123,7 @@ void CallingConvEmitter::EmitCallingConv(Record *CC, raw_ostream &O) {
122
123
O << " }\n " ;
123
124
}
124
125
125
- void CallingConvEmitter::EmitAction (Record *Action, unsigned Indent,
126
+ void CallingConvEmitter::EmitAction (const Record *Action, unsigned Indent,
126
127
raw_ostream &O) {
127
128
std::string IndentStr = std::string (Indent, ' ' );
128
129
@@ -150,14 +151,14 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
150
151
O << IndentStr << " }\n " ;
151
152
} else {
152
153
if (Action->isSubClassOf (" CCDelegateTo" )) {
153
- Record *CC = Action->getValueAsDef (" CC" );
154
+ const Record *CC = Action->getValueAsDef (" CC" );
154
155
O << IndentStr << " if (!" << CC->getName ()
155
156
<< " (ValNo, ValVT, LocVT, LocInfo, ArgFlags, State))\n "
156
157
<< IndentStr << " return false;\n " ;
157
158
DelegateToMap[CurrentAction].insert (CC->getName ().str ());
158
159
} else if (Action->isSubClassOf (" CCAssignToReg" ) ||
159
160
Action->isSubClassOf (" CCAssignToRegAndStack" )) {
160
- ListInit *RegList = Action->getValueAsListInit (" RegList" );
161
+ const ListInit *RegList = Action->getValueAsListInit (" RegList" );
161
162
if (RegList->size () == 1 ) {
162
163
std::string Name = getQualifiedName (RegList->getElementAsRecord (0 ));
163
164
O << IndentStr << " if (MCRegister Reg = State.AllocateReg(" << Name
@@ -210,8 +211,9 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
210
211
O << IndentStr << " return false;\n " ;
211
212
O << IndentStr << " }\n " ;
212
213
} 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" );
215
217
if (!ShadowRegList->empty () && ShadowRegList->size () != RegList->size ())
216
218
PrintFatalError (Action->getLoc (),
217
219
" Invalid length of list of shadowed registers" );
@@ -278,7 +280,8 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
278
280
} else if (Action->isSubClassOf (" CCAssignToStackWithShadow" )) {
279
281
int Size = Action->getValueAsInt (" Size" );
280
282
int Align = Action->getValueAsInt (" Align" );
281
- ListInit *ShadowRegList = Action->getValueAsListInit (" ShadowRegList" );
283
+ const ListInit *ShadowRegList =
284
+ Action->getValueAsListInit (" ShadowRegList" );
282
285
283
286
unsigned ShadowRegListNumber = ++Counter;
284
287
@@ -297,7 +300,7 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
297
300
<< Counter << " , LocVT, LocInfo));\n " ;
298
301
O << IndentStr << " return false;\n " ;
299
302
} else if (Action->isSubClassOf (" CCPromoteToType" )) {
300
- Record *DestTy = Action->getValueAsDef (" DestTy" );
303
+ const Record *DestTy = Action->getValueAsDef (" DestTy" );
301
304
MVT::SimpleValueType DestVT = getValueType (DestTy);
302
305
O << IndentStr << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
303
306
if (MVT (DestVT).isFloatingPoint ()) {
@@ -311,7 +314,7 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
311
314
<< IndentStr << " LocInfo = CCValAssign::AExt;\n " ;
312
315
}
313
316
} else if (Action->isSubClassOf (" CCPromoteToUpperBitsInType" )) {
314
- Record *DestTy = Action->getValueAsDef (" DestTy" );
317
+ const Record *DestTy = Action->getValueAsDef (" DestTy" );
315
318
MVT::SimpleValueType DestVT = getValueType (DestTy);
316
319
O << IndentStr << " LocVT = " << getEnumName (DestVT) << " ;\n " ;
317
320
if (MVT (DestVT).isFloatingPoint ()) {
@@ -327,17 +330,17 @@ void CallingConvEmitter::EmitAction(Record *Action, unsigned Indent,
327
330
<< IndentStr << " LocInfo = CCValAssign::AExtUpper;\n " ;
328
331
}
329
332
} else if (Action->isSubClassOf (" CCBitConvertToType" )) {
330
- Record *DestTy = Action->getValueAsDef (" DestTy" );
333
+ const Record *DestTy = Action->getValueAsDef (" DestTy" );
331
334
O << IndentStr << " LocVT = " << getEnumName (getValueType (DestTy))
332
335
<< " ;\n " ;
333
336
O << IndentStr << " LocInfo = CCValAssign::BCvt;\n " ;
334
337
} else if (Action->isSubClassOf (" CCTruncToType" )) {
335
- Record *DestTy = Action->getValueAsDef (" DestTy" );
338
+ const Record *DestTy = Action->getValueAsDef (" DestTy" );
336
339
O << IndentStr << " LocVT = " << getEnumName (getValueType (DestTy))
337
340
<< " ;\n " ;
338
341
O << IndentStr << " LocInfo = CCValAssign::Trunc;\n " ;
339
342
} else if (Action->isSubClassOf (" CCPassIndirect" )) {
340
- Record *DestTy = Action->getValueAsDef (" DestTy" );
343
+ const Record *DestTy = Action->getValueAsDef (" DestTy" );
341
344
O << IndentStr << " LocVT = " << getEnumName (getValueType (DestTy))
342
345
<< " ;\n " ;
343
346
O << IndentStr << " LocInfo = CCValAssign::Indirect;\n " ;
0 commit comments