@@ -18,17 +18,17 @@ namespace tblgen {
18
18
19
19
class HandleRec {
20
20
public:
21
- explicit HandleRec (Record *rec) : rec(rec) {}
21
+ explicit HandleRec (const Record *rec) : rec(rec) {}
22
22
StringRef getName () const { return rec->getValueAsString (" name" ); }
23
23
StringRef getDesc () const { return rec->getValueAsString (" desc" ); }
24
24
25
25
private:
26
- Record *rec;
26
+ const Record *rec;
27
27
};
28
28
29
29
class MacroRec {
30
30
public:
31
- explicit MacroRec (Record *rec) : rec(rec) {
31
+ explicit MacroRec (const Record *rec) : rec(rec) {
32
32
auto Name = rec->getValueAsString (" name" );
33
33
auto OpenBrace = Name.find_first_of (" (" );
34
34
nameWithoutArgs = Name.substr (0 , OpenBrace);
@@ -46,38 +46,38 @@ class MacroRec {
46
46
}
47
47
48
48
private:
49
- Record *rec;
49
+ const Record *rec;
50
50
std::string nameWithoutArgs;
51
51
};
52
52
53
53
class TypedefRec {
54
54
public:
55
- explicit TypedefRec (Record *rec) : rec(rec) {}
55
+ explicit TypedefRec (const Record *rec) : rec(rec) {}
56
56
StringRef getName () const { return rec->getValueAsString (" name" ); }
57
57
StringRef getDesc () const { return rec->getValueAsString (" desc" ); }
58
58
StringRef getValue () const { return rec->getValueAsString (" value" ); }
59
59
60
60
private:
61
- Record *rec;
61
+ const Record *rec;
62
62
};
63
63
64
64
class EnumValueRec {
65
65
public:
66
- explicit EnumValueRec (Record *rec) : rec(rec) {}
66
+ explicit EnumValueRec (const Record *rec) : rec(rec) {}
67
67
std::string getName () const { return rec->getValueAsString (" name" ).upper (); }
68
68
StringRef getDesc () const { return rec->getValueAsString (" desc" ); }
69
69
StringRef getTaggedType () const {
70
70
return rec->getValueAsString (" tagged_type" );
71
71
}
72
72
73
73
private:
74
- Record *rec;
74
+ const Record *rec;
75
75
};
76
76
77
77
class EnumRec {
78
78
public:
79
- explicit EnumRec (Record *rec) : rec(rec) {
80
- for (auto *Val : rec->getValueAsListOfDefs (" etors" )) {
79
+ explicit EnumRec (const Record *rec) : rec(rec) {
80
+ for (const auto *Val : rec->getValueAsListOfDefs (" etors" )) {
81
81
vals.emplace_back (EnumValueRec{Val});
82
82
}
83
83
}
@@ -93,24 +93,24 @@ class EnumRec {
93
93
bool isTyped () const { return rec->getValueAsBit (" is_typed" ); }
94
94
95
95
private:
96
- Record *rec;
96
+ const Record *rec;
97
97
std::vector<EnumValueRec> vals;
98
98
};
99
99
100
100
class StructMemberRec {
101
101
public:
102
- explicit StructMemberRec (Record *rec) : rec(rec) {}
102
+ explicit StructMemberRec (const Record *rec) : rec(rec) {}
103
103
StringRef getType () const { return rec->getValueAsString (" type" ); }
104
104
StringRef getName () const { return rec->getValueAsString (" name" ); }
105
105
StringRef getDesc () const { return rec->getValueAsString (" desc" ); }
106
106
107
107
private:
108
- Record *rec;
108
+ const Record *rec;
109
109
};
110
110
111
111
class StructRec {
112
112
public:
113
- explicit StructRec (Record *rec) : rec(rec) {
113
+ explicit StructRec (const Record *rec) : rec(rec) {
114
114
for (auto *Member : rec->getValueAsListOfDefs (" all_members" )) {
115
115
members.emplace_back (StructMemberRec (Member));
116
116
}
@@ -123,13 +123,13 @@ class StructRec {
123
123
const std::vector<StructMemberRec> &getMembers () const { return members; }
124
124
125
125
private:
126
- Record *rec;
126
+ const Record *rec;
127
127
std::vector<StructMemberRec> members;
128
128
};
129
129
130
130
class ParamRec {
131
131
public:
132
- explicit ParamRec (Record *rec) : rec(rec) {
132
+ explicit ParamRec (const Record *rec) : rec(rec) {
133
133
flags = rec->getValueAsBitsInit (" flags" );
134
134
auto *Range = rec->getValueAsDef (" range" );
135
135
auto RangeBegin = Range->getValueAsString (" begin" );
@@ -158,7 +158,7 @@ class ParamRec {
158
158
bool isOut () const { return dyn_cast<BitInit>(flags->getBit (1 ))->getValue (); }
159
159
bool isOpt () const { return dyn_cast<BitInit>(flags->getBit (2 ))->getValue (); }
160
160
161
- Record *getRec () const { return rec; }
161
+ const Record *getRec () const { return rec; }
162
162
std::optional<std::pair<StringRef, StringRef>> getRange () const {
163
163
return range;
164
164
}
@@ -171,27 +171,27 @@ class ParamRec {
171
171
bool operator !=(const ParamRec &p) const { return rec != p.getRec (); }
172
172
173
173
private:
174
- Record *rec;
175
- BitsInit *flags;
174
+ const Record *rec;
175
+ const BitsInit *flags;
176
176
std::optional<std::pair<StringRef, StringRef>> range;
177
177
std::optional<std::pair<StringRef, StringRef>> typeinfo;
178
178
};
179
179
180
180
class ReturnRec {
181
181
public:
182
- ReturnRec (Record *rec) : rec(rec) {}
182
+ ReturnRec (const Record *rec) : rec(rec) {}
183
183
StringRef getValue () const { return rec->getValueAsString (" value" ); }
184
184
std::vector<StringRef> getConditions () const {
185
185
return rec->getValueAsListOfStrings (" conditions" );
186
186
}
187
187
188
188
private:
189
- Record *rec;
189
+ const Record *rec;
190
190
};
191
191
192
192
class FunctionRec {
193
193
public:
194
- FunctionRec (Record *rec) : rec(rec) {
194
+ FunctionRec (const Record *rec) : rec(rec) {
195
195
for (auto &Ret : rec->getValueAsListOfDefs (" all_returns" ))
196
196
rets.emplace_back (Ret);
197
197
for (auto &Param : rec->getValueAsListOfDefs (" params" ))
@@ -219,7 +219,7 @@ class FunctionRec {
219
219
std::vector<ReturnRec> rets;
220
220
std::vector<ParamRec> params;
221
221
222
- Record *rec;
222
+ const Record *rec;
223
223
};
224
224
225
225
} // namespace tblgen
0 commit comments