14#ifndef LLVM_TABLEGEN_DIRECTIVEEMITTER_H
15#define LLVM_TABLEGEN_DIRECTIVEEMITTER_H
34 const auto &DirectiveLanguages = getDirectiveLanguages();
35 Def = DirectiveLanguages[0];
95 return Records.getAllDerivedDefinitions(
"DirectiveLanguage");
102 int64_t Min = R->getValueAsInt(
"minVersion");
103 assert(llvm::isInt<IntWidth>(Min) &&
"Value out of range of 'int'");
108 int64_t Max = R->getValueAsInt(
"maxVersion");
109 assert(llvm::isInt<IntWidth>(Max) &&
"Value out of range of 'int'");
114 constexpr static int IntWidth = 8 *
sizeof(int);
151 std::vector<Spelling::Value>
List;
153 std::back_inserter(
List),
154 [](
const Record *R) { return Spelling(R).get(); });
171 if (V.Versions.Min < Oldest.Versions.Min)
179 std::string
N =
Name.str();
189 std::string Camel =
Name.str();
193 if (Sep.contains(C)) {
194 assert(!Cap &&
"No initial or repeated separators");
197 C = llvm::toUpper(
C);
204 for (
size_t In = 0,
End = Camel.size(); In !=
End; ++In) {
205 unsigned char C = Camel[In];
206 if (!Sep.contains(
C))
214 if (
auto maybeName = Def->getValueAsOptionalString(
"name"))
215 return getSnakeName(*maybeName);
216 return getSnakeName(getSpellingForIdentifier());
219 bool isDefault()
const {
return Def->getValueAsBit(
"isDefault"); }
237 return Def->getValueAsListOfDefs(
"allowedClauses");
241 return Def->getValueAsListOfDefs(
"allowedOnceClauses");
245 return Def->getValueAsListOfDefs(
"allowedExclusiveClauses");
249 return Def->getValueAsListOfDefs(
"requiredClauses");
253 return Def->getValueAsListOfDefs(
"leafConstructs");
257 return Def->getValueAsDef(
"association");
263 return Def->getValueAsListOfDefs(
"languages");
271 if (
Name ==
"unknown")
274 return BaseRecord::getUpperCamelName(
Name,
" _");
286 return Def->getValueAsString(
"clangClass");
291 return Def->getValueAsString(
"flangClass");
301 return BaseRecord::getUpperCamelName(
Name,
"_");
308 if (
StringRef ClangSpelling = Def->getValueAsString(
"clangAccSpelling");
309 !ClangSpelling.empty())
310 return ClangSpelling.str();
313 return BaseRecord::getUpperCamelName(
Name,
"_");
318 return Def->getValueAsString(
"enumClauseValue");
322 return Def->getValueAsListOfDefs(
"allowedClauseValues");
326 return Def->getValueAsBit(
"skipFlangUnparser");
331 bool isValueList()
const {
return Def->getValueAsBit(
"isValueList"); }
334 return Def->getValueAsString(
"defaultValue");
337 bool isImplicit()
const {
return Def->getValueAsBit(
"isImplicit"); }
340 return Def->getValueAsListOfStrings(
"aliases");
346 return Def->getValueAsBit(
"isPrefixOptional");
371 int getValue()
const {
return Def->getValueAsInt(
"value"); }
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
static std::string getSnakeName(StringRef Name)
StringRef getRecordName() const
static std::string getUpperCamelName(StringRef Name, StringRef Sep)
std::string getFormattedName() const
std::vector< Spelling::Value > getSpellings() const
BaseRecord(const Record *Def)
const Record * getRecord() const
StringRef getClangClass() const
std::vector< const Record * > getClauseVals() const
bool skipFlangUnparser() const
Clause(const Record *Def)
StringRef getDefaultValue() const
bool isValueOptional() const
StringRef getFlangClass() const
std::vector< StringRef > getAliases() const
std::string getClangAccSpelling() const
StringRef getEnumName() const
bool isPrefixOptional() const
std::string getFormattedParserClassName() const
StringRef getPrefix() const
bool hasMakeEnumAvailableInNamespace() const
bool HasValidityErrors() const
StringRef getClausePrefix() const
StringRef getClauseEnumSetClass() const
DirectiveLanguage(const RecordKeeper &Records)
ArrayRef< const Record * > getAssociations() const
ArrayRef< const Record * > getDirectives() const
ArrayRef< const Record * > getClauses() const
StringRef getName() const
ArrayRef< const Record * > getCategories() const
StringRef getDirectivePrefix() const
bool hasEnableBitmaskEnumInNamespace() const
StringRef getCppNamespace() const
ArrayRef< const Record * > getSourceLanguages() const
StringRef getFlangClauseBaseClass() const
const Record * getAssociation() const
std::vector< const Record * > getLeafConstructs() const
const Record * getCategory() const
std::vector< const Record * > getAllowedClauses() const
Directive(const Record *Def)
std::vector< const Record * > getAllowedOnceClauses() const
std::vector< const Record * > getRequiredClauses() const
std::vector< const Record * > getSourceLanguages() const
std::string getClangAccSpelling() const
std::vector< const Record * > getAllowedExclusiveClauses() const
bool isUserVisible() const
EnumVal(const Record *Def)
ArrayRef< const Record * > getAllDerivedDefinitions(StringRef ClassName) const
Get all the concrete records that inherit from the one specified class.
bool getValueAsBit(StringRef FieldName) const
This method looks up the specified field and returns its value as a bit, throwing an exception if the...
std::vector< const Record * > getValueAsListOfDefs(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of records,...
StringRef getValueAsString(StringRef FieldName) const
This method looks up the specified field and returns its value as a string, throwing an exception if ...
Spelling(const Record *Def)
StringRef getText() const
llvm::directive::VersionRange getVersions() const
StringRef - Represent a constant reference to a string, i.e.
int64_t getMinVersion() const
int64_t getMaxVersion() const
VersionedClause(const Record *Def)
int getMinVersion(const Record *R) const
int getMaxVersion(const Record *R) const
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
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.