Warning, /include/llvm/Frontend/Directive/DirectiveBase.td is written in an unsupported language. File is not indexed.
0001 //===-- DirectiveBase.td - Base directive definition file --*- tablegen -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This is the base definition file directives and clauses.
0010 //
0011 //===----------------------------------------------------------------------===//
0012
0013
0014 // General information about the directive language.
0015 class DirectiveLanguage {
0016 // Name of the directive language such as omp or acc.
0017 string name = ?;
0018
0019 // The C++ namespace that code of this directive language should be placed
0020 // into. This namespace is nested in llvm namespace.
0021 //
0022 // By default, uses the name of the directive language as the only namespace.
0023 // To avoid placing in any namespace, use "". To specify nested namespaces,
0024 // use "::" as the delimiter, e.g., given "A::B", ops will be placed in
0025 // `namespace A { namespace B { <directives-clauses> } }`.
0026 string cppNamespace = name;
0027
0028 // Optional prefix used for the generation of the enumerator in the Directive
0029 // enum.
0030 string directivePrefix = "";
0031
0032 // Optional prefix used for the generation of the enumerator in the Clause
0033 // enum.
0034 string clausePrefix = "";
0035
0036 // Make the enum values available in the namespace. This allows us to
0037 // write something like Enum_X if we have a `using namespace cppNamespace`.
0038 bit makeEnumAvailableInNamespace = false;
0039
0040 // Generate include and macro to enable LLVM BitmaskEnum.
0041 bit enableBitmaskEnumInNamespace = false;
0042
0043 // Header file included in the implementation code generated. Ususally the
0044 // output file of the declaration code generation. Can be left blank.
0045 string includeHeader = "";
0046
0047 // EnumSet class name used for clauses to generated the allowed clauses map.
0048 string clauseEnumSetClass = "";
0049
0050 // Class holding the clauses in the flang parse-tree.
0051 string flangClauseBaseClass = "";
0052 }
0053
0054 // Information about values accepted by enum-like clauses
0055 class ClauseVal<string n, int v, bit uv> {
0056 // Name of the clause value.
0057 string name = n;
0058
0059 // Integer value of the clause.
0060 int value = v;
0061
0062 // Can user specify this value?
0063 bit isUserValue = uv;
0064
0065 // Set clause value used by default when unknown.
0066 bit isDefault = false;
0067 }
0068
0069 // Information about a specific clause.
0070 class Clause<string c> {
0071 // Name of the clause.
0072 string name = c;
0073
0074 // Define an alternative name return in get<LanguageName>ClauseName function.
0075 string alternativeName = "";
0076
0077 // Define aliases used in the parser.
0078 list<string> aliases = [];
0079
0080 // Optional class holding value of the clause in clang AST.
0081 string clangClass = "";
0082
0083 // Optional class holding value of the clause in flang AST.
0084 string flangClass = "";
0085
0086 // If set to true, value is optional. Not optional by default.
0087 bit isValueOptional = false;
0088
0089 // Name of enum when there is a list of allowed clause values.
0090 string enumClauseValue = "";
0091
0092 // List of allowed clause values
0093 list<ClauseVal> allowedClauseValues = [];
0094
0095 // If set to true, value class is part of a list. Single class by default.
0096 bit isValueList = false;
0097
0098 // Define a default value such as "*".
0099 string defaultValue = "";
0100
0101 // Is clause implicit? If clause is set as implicit, the default kind will
0102 // be return in get<LanguageName>ClauseKind instead of their own kind.
0103 bit isImplicit = false;
0104
0105 // Set clause used by default when unknown. Function returning the kind
0106 // of enumeration will use this clause as the default.
0107 bit isDefault = false;
0108
0109 // Prefix before the actual value. Used in the parser generation.
0110 // `clause(prefix: value)`
0111 string prefix = "";
0112
0113 // Set the prefix as optional.
0114 // `clause([prefix]: value)`
0115 bit isPrefixOptional = true;
0116 }
0117
0118 // Hold information about clause validity by version.
0119 class VersionedClause<Clause c, int min = 1, int max = 0x7FFFFFFF> {
0120 // Actual clause.
0121 Clause clause = c;
0122
0123 // Mininum version number where this clause is valid.
0124 int minVersion = min;
0125
0126 // Maximum version number where this clause is valid.
0127 int maxVersion = max;
0128 }
0129
0130 // Kinds of directive associations.
0131 class Association<string n> {
0132 string name = n; // Name of the enum value in enum class Association.
0133 }
0134 // All of the AS_Xyz names are recognized by TableGen in order to calculate
0135 // the association in the AS_FromLeaves case.
0136 def AS_None : Association<"None"> {} // No association
0137 def AS_Block : Association<"Block"> {} // Block (incl. single
0138 // statement)
0139 def AS_Declaration : Association<"Declaration"> {} // Declaration
0140 def AS_Delimited : Association<"Delimited"> {} // Region delimited with
0141 // begin/end
0142 def AS_Loop : Association<"Loop"> {} // Loop
0143 def AS_Separating : Association<"Separating"> {} // Separates parts of a
0144 // construct
0145
0146 def AS_FromLeaves : Association<"FromLeaves"> {} // See below
0147 // AS_FromLeaves can be used for combined/composite directives, and the actual
0148 // association will be computed based on associations of the leaf constructs:
0149 // (x + y) + z = x + (y + z)
0150 // x + y = y + x
0151 // x + x = x
0152 // AS_None + x = x
0153 // AS_Block + AS_Loop = AS_Loop
0154 // Other combinations are not allowed.
0155 // This association is not valid for leaf constructs.
0156 // The name "AS_FromLeaves" is recognized by TableGen, and there is no enum
0157 // generated for it.
0158
0159 // Kinds of directive categories.
0160 class Category<string n> {
0161 string name = n; // Name of the enum value in enum class Category.
0162 }
0163
0164 def CA_Declarative: Category<"Declarative"> {}
0165 def CA_Executable: Category<"Executable"> {}
0166 def CA_Informational: Category<"Informational"> {}
0167 def CA_Meta: Category<"Meta"> {}
0168 def CA_Subsidiary: Category<"Subsidiary"> {}
0169 def CA_Utility: Category<"Utility"> {}
0170
0171 // Information about a specific directive.
0172 class Directive<string d> {
0173 // Name of the directive. Can be composite directive sepearted by whitespace.
0174 string name = d;
0175
0176 // Define an alternative name return in get<LanguageName>DirectiveName
0177 // function.
0178 string alternativeName = "";
0179
0180 // Clauses cannot appear twice in the three allowed lists below. Also, since
0181 // required implies allowed, the same clause cannot appear in both the
0182 // allowedClauses and requiredClauses lists.
0183
0184 // List of allowed clauses for the directive.
0185 list<VersionedClause> allowedClauses = [];
0186
0187 // List of clauses that are allowed to appear only once.
0188 list<VersionedClause> allowedOnceClauses = [];
0189
0190 // List of clauses that are allowed but mutually exclusive.
0191 list<VersionedClause> allowedExclusiveClauses = [];
0192
0193 // List of clauses that are required.
0194 list<VersionedClause> requiredClauses = [];
0195
0196 // List of leaf constituent directives in the order in which they appear
0197 // in the combined/composite directive.
0198 list<Directive> leafConstructs = [];
0199
0200 // Set directive used by default when unknown.
0201 bit isDefault = false;
0202
0203 // What the directive is associated with.
0204 Association association = AS_FromLeaves;
0205
0206 // The category of the directive.
0207 Category category = ?;
0208 }