LLVM: include/llvm/TableGen/DirectiveEmitter.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_TABLEGEN_DIRECTIVEEMITTER_H
15#define LLVM_TABLEGEN_DIRECTIVEEMITTER_H
16
23#include
24#include
25
26namespace llvm {
27
28
29
31public:
33 const auto &DirectiveLanguages = getDirectiveLanguages();
34 Def = DirectiveLanguages[0];
35 }
36
38
40 return Def->getValueAsString("cppNamespace");
41 }
42
44 return Def->getValueAsString("directivePrefix");
45 }
46
48 return Def->getValueAsString("clausePrefix");
49 }
50
52 return Def->getValueAsString("clauseEnumSetClass");
53 }
54
56 return Def->getValueAsString("flangClauseBaseClass");
57 }
58
60 return Def->getValueAsBit("makeEnumAvailableInNamespace");
61 }
62
64 return Def->getValueAsBit("enableBitmaskEnumInNamespace");
65 }
66
68 return Records.getAllDerivedDefinitions("Association");
69 }
70
72 return Records.getAllDerivedDefinitions("Category");
73 }
74
76 return Records.getAllDerivedDefinitions("SourceLanguage");
77 }
78
80 return Records.getAllDerivedDefinitions("Directive");
81 }
82
84 return Records.getAllDerivedDefinitions("Clause");
85 }
86
88
89private:
92
94 return Records.getAllDerivedDefinitions("DirectiveLanguage");
95 }
96};
97
99public:
101 int64_t Min = R->getValueAsInt("minVersion");
103 return Min;
104 }
105
107 int64_t Max = R->getValueAsInt("maxVersion");
109 return Max;
110 }
111
112private:
113 constexpr static int IntWidth = 8 * sizeof(int);
114};
115
117public:
119
121
127
129
130private:
132};
133
134
135
136
137
138
139
140
141
142
143
144
146public:
148
150 std::vectorSpelling::Value List;
152 std::back_inserter(List),
153 [](const Record *R) { return Spelling(R).get(); });
155 }
156
158
159
160
161
162
163
164
165
166
167
168 Spelling::Value Oldest{"not found", {INT_MAX, 0}};
170 if (V.Versions.Min < Oldest.Versions.Min)
171 Oldest = V;
172 return Oldest.Name;
173 }
174
175
176
178 std::string N = Name.str();
180 return N;
181 }
182
183
184
185
186
188 std::string Camel = Name.str();
189
190 bool Cap = true;
192 if (Sep.contains(C)) {
193 assert(!Cap && "No initial or repeated separators");
194 Cap = true;
195 } else if (Cap) {
197 Cap = false;
198 }
199 return C;
200 });
201 size_t Out = 0;
202
203 for (size_t In = 0, End = Camel.size(); In != End; ++In) {
204 unsigned char C = Camel[In];
205 if (!Sep.contains(C))
206 Camel[Out++] = C;
207 }
208 Camel.resize(Out);
209 return Camel;
210 }
211
213 if (auto maybeName = Def->getValueAsOptionalString("name"))
216 }
217
218 bool isDefault() const { return Def->getValueAsBit("isDefault"); }
219
220
222
224
225protected:
227};
228
229
230
232public:
234
236 return Def->getValueAsListOfDefs("allowedClauses");
237 }
238
240 return Def->getValueAsListOfDefs("allowedOnceClauses");
241 }
242
244 return Def->getValueAsListOfDefs("allowedExclusiveClauses");
245 }
246
248 return Def->getValueAsListOfDefs("requiredClauses");
249 }
250
252 return Def->getValueAsListOfDefs("leafConstructs");
253 }
254
256 return Def->getValueAsDef("association");
257 }
258
260
262 return Def->getValueAsListOfDefs("languages");
263 }
264
265
268
269
270 if (Name == "unknown")
271 return "Invalid";
272
274 }
275};
276
277
278
280public:
282
283
285 return Def->getValueAsString("clangClass");
286 }
287
288
290 return Def->getValueAsString("flangClass");
291 }
292
293
294
295
296
297
302
303
304
305
307 if (StringRef ClangSpelling = Def->getValueAsString("clangAccSpelling");
308 !ClangSpelling.empty())
309 return ClangSpelling.str();
310
313 }
314
315
317 return Def->getValueAsString("enumClauseValue");
318 }
319
321 return Def->getValueAsListOfDefs("allowedClauseValues");
322 }
323
325 return Def->getValueAsBit("skipFlangUnparser");
326 }
327
329
330 bool isValueList() const { return Def->getValueAsBit("isValueList"); }
331
333 return Def->getValueAsString("defaultValue");
334 }
335
336 bool isImplicit() const { return Def->getValueAsBit("isImplicit"); }
337
339 return Def->getValueAsListOfStrings("aliases");
340 }
341
343
345 return Def->getValueAsBit("isPrefixOptional");
346 }
347};
348
349
350
352public:
354
355
357
358 int64_t getMinVersion() const { return Def->getValueAsInt("minVersion"); }
359
360 int64_t getMaxVersion() const { return Def->getValueAsInt("maxVersion"); }
361
362private:
364};
365
367public:
369
370 int getValue() const { return Def->getValueAsInt("value"); }
371
373};
374
375}
376
377#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef getSpellingForIdentifier() const
Definition DirectiveEmitter.h:157
static std::string getSnakeName(StringRef Name)
Definition DirectiveEmitter.h:177
StringRef getRecordName() const
Definition DirectiveEmitter.h:221
static std::string getUpperCamelName(StringRef Name, StringRef Sep)
Definition DirectiveEmitter.h:187
bool isDefault() const
Definition DirectiveEmitter.h:218
std::string getFormattedName() const
Definition DirectiveEmitter.h:212
const Record * Def
Definition DirectiveEmitter.h:226
std::vector< Spelling::Value > getSpellings() const
Definition DirectiveEmitter.h:149
BaseRecord(const Record *Def)
Definition DirectiveEmitter.h:147
const Record * getRecord() const
Definition DirectiveEmitter.h:223
Definition DirectiveEmitter.h:279
StringRef getClangClass() const
Definition DirectiveEmitter.h:284
std::vector< const Record * > getClauseVals() const
Definition DirectiveEmitter.h:320
bool skipFlangUnparser() const
Definition DirectiveEmitter.h:324
Clause(const Record *Def)
Definition DirectiveEmitter.h:281
bool isImplicit() const
Definition DirectiveEmitter.h:336
StringRef getDefaultValue() const
Definition DirectiveEmitter.h:332
bool isValueOptional() const
Definition DirectiveEmitter.h:328
bool isValueList() const
Definition DirectiveEmitter.h:330
StringRef getFlangClass() const
Definition DirectiveEmitter.h:289
std::vector< StringRef > getAliases() const
Definition DirectiveEmitter.h:338
std::string getClangAccSpelling() const
Definition DirectiveEmitter.h:306
StringRef getEnumName() const
Definition DirectiveEmitter.h:316
bool isPrefixOptional() const
Definition DirectiveEmitter.h:344
std::string getFormattedParserClassName() const
Definition DirectiveEmitter.h:298
StringRef getPrefix() const
Definition DirectiveEmitter.h:342
bool hasMakeEnumAvailableInNamespace() const
Definition DirectiveEmitter.h:59
bool HasValidityErrors() const
StringRef getClausePrefix() const
Definition DirectiveEmitter.h:47
StringRef getClauseEnumSetClass() const
Definition DirectiveEmitter.h:51
DirectiveLanguage(const RecordKeeper &Records)
Definition DirectiveEmitter.h:32
ArrayRef< const Record * > getAssociations() const
Definition DirectiveEmitter.h:67
ArrayRef< const Record * > getDirectives() const
Definition DirectiveEmitter.h:79
ArrayRef< const Record * > getClauses() const
Definition DirectiveEmitter.h:83
StringRef getName() const
Definition DirectiveEmitter.h:37
ArrayRef< const Record * > getCategories() const
Definition DirectiveEmitter.h:71
StringRef getDirectivePrefix() const
Definition DirectiveEmitter.h:43
bool hasEnableBitmaskEnumInNamespace() const
Definition DirectiveEmitter.h:63
StringRef getCppNamespace() const
Definition DirectiveEmitter.h:39
ArrayRef< const Record * > getSourceLanguages() const
Definition DirectiveEmitter.h:75
StringRef getFlangClauseBaseClass() const
Definition DirectiveEmitter.h:55
const Record * getAssociation() const
Definition DirectiveEmitter.h:255
std::vector< const Record * > getLeafConstructs() const
Definition DirectiveEmitter.h:251
const Record * getCategory() const
Definition DirectiveEmitter.h:259
std::vector< const Record * > getAllowedClauses() const
Definition DirectiveEmitter.h:235
Directive(const Record *Def)
Definition DirectiveEmitter.h:233
std::vector< const Record * > getAllowedOnceClauses() const
Definition DirectiveEmitter.h:239
std::vector< const Record * > getRequiredClauses() const
Definition DirectiveEmitter.h:247
std::vector< const Record * > getSourceLanguages() const
Definition DirectiveEmitter.h:261
std::string getClangAccSpelling() const
Definition DirectiveEmitter.h:266
std::vector< const Record * > getAllowedExclusiveClauses() const
Definition DirectiveEmitter.h:243
bool isUserVisible() const
Definition DirectiveEmitter.h:372
int getValue() const
Definition DirectiveEmitter.h:370
EnumVal(const Record *Def)
Definition DirectiveEmitter.h:368
Spelling(const Record *Def)
Definition DirectiveEmitter.h:120
StringRef getText() const
Definition DirectiveEmitter.h:122
Value get() const
Definition DirectiveEmitter.h:128
directive::Spelling Value
Definition DirectiveEmitter.h:118
llvm::directive::VersionRange getVersions() const
Definition DirectiveEmitter.h:123
StringRef - Represent a constant reference to a string, i.e.
int64_t getMinVersion() const
Definition DirectiveEmitter.h:358
Clause getClause() const
Definition DirectiveEmitter.h:356
int64_t getMaxVersion() const
Definition DirectiveEmitter.h:360
VersionedClause(const Record *Def)
Definition DirectiveEmitter.h:353
Definition DirectiveEmitter.h:98
int getMinVersion(const Record *R) const
Definition DirectiveEmitter.h:100
int getMaxVersion(const Record *R) const
Definition DirectiveEmitter.h:106
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
OutputIt transform(R &&Range, OutputIt d_first, UnaryFunction F)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere.
void replace(R &&Range, const T &OldValue, const T &NewValue)
Provide wrappers to std::replace which take ranges instead of having to pass begin/end explicitly.
char toUpper(char x)
Returns the corresponding uppercase character if x is lowercase.