1//===-- DirectiveBase.td - Base directive definition file --*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// This is the base definition file directives and clauses. 10// 11//===----------------------------------------------------------------------===// 12 13 14// General information about the directive language. 15class DirectiveLanguage { 16 // Name of the directive language such as omp or acc. 17 string name = ?; 18 19 // The C++ namespace that code of this directive language should be placed 20 // into. This namespace is nested in llvm namespace. 21 // 22 // By default, uses the name of the directive language as the only namespace. 23 // To avoid placing in any namespace, use "". To specify nested namespaces, 24 // use "::" as the delimiter, e.g., given "A::B", ops will be placed in 25 // `namespace A { namespace B { <directives-clauses> } }`. 26 string cppNamespace = name; 27 28 // Optional prefix used for the generation of the enumerator in the Directive 29 // enum. 30 string directivePrefix = ""; 31 32 // Optional prefix used for the generation of the enumerator in the Clause 33 // enum. 34 string clausePrefix = ""; 35 36 // Make the enum values available in the namespace. This allows us to 37 // write something like Enum_X if we have a `using namespace cppNamespace`. 38 bit makeEnumAvailableInNamespace = false; 39 40 // Generate include and macro to enable LLVM BitmaskEnum. 41 bit enableBitmaskEnumInNamespace = false; 42 43 // Header file included in the implementation code generated. Ususally the 44 // output file of the declaration code generation. Can be left blank. 45 string includeHeader = ""; 46 47 // EnumSet class name used for clauses to generated the allowed clauses map. 48 string clauseEnumSetClass = ""; 49 50 // Class holding the clauses in the flang parse-tree. 51 string flangClauseBaseClass = ""; 52} 53 54// Information about values accepted by enum-like clauses 55class ClauseVal<string n, int v, bit uv> { 56 // Name of the clause value. 57 string name = n; 58 59 // Integer value of the clause. 60 int value = v; 61 62 // Can user specify this value? 63 bit isUserValue = uv; 64 65 // Set clause value used by default when unknown. 66 bit isDefault = false; 67} 68 69// Information about a specific clause. 70class Clause<string c> { 71 // Name of the clause. 72 string name = c; 73 74 // Define an alternative name return in get<LanguageName>ClauseName function. 75 string alternativeName = ""; 76 77 // Define aliases used in the parser. 78 list<string> aliases = []; 79 80 // Optional class holding value of the clause in clang AST. 81 string clangClass = ""; 82 83 // Optional class holding value of the clause in flang AST. 84 string flangClass = ""; 85 86 // If set to true, value is optional. Not optional by default. 87 bit isValueOptional = false; 88 89 // Name of enum when there is a list of allowed clause values. 90 string enumClauseValue = ""; 91 92 // List of allowed clause values 93 list<ClauseVal> allowedClauseValues = []; 94 95 // If set to true, value class is part of a list. Single class by default. 96 bit isValueList = false; 97 98 // Define a default value such as "*". 99 string defaultValue = ""; 100 101 // Is clause implicit? If clause is set as implicit, the default kind will 102 // be return in get<LanguageName>ClauseKind instead of their own kind. 103 bit isImplicit = false; 104 105 // Set clause used by default when unknown. Function returning the kind 106 // of enumeration will use this clause as the default. 107 bit isDefault = false; 108 109 // Prefix before the actual value. Used in the parser generation. 110 // `clause(prefix: value)` 111 string prefix = ""; 112 113 // Set the prefix as optional. 114 // `clause([prefix]: value)` 115 bit isPrefixOptional = true; 116} 117 118// Hold information about clause validity by version. 119class VersionedClause<Clause c, int min = 1, int max = 0x7FFFFFFF> { 120 // Actual clause. 121 Clause clause = c; 122 123 // Mininum version number where this clause is valid. 124 int minVersion = min; 125 126 // Maximum version number where this clause is valid. 127 int maxVersion = max; 128} 129 130// Information about a specific directive. 131class Directive<string d> { 132 // Name of the directive. Can be composite directive sepearted by whitespace. 133 string name = d; 134 135 // Define an alternative name return in get<LanguageName>DirectiveName 136 // function. 137 string alternativeName = ""; 138 139 // Clauses cannot appear twice in the three allowed lists below. Also, since 140 // required implies allowed, the same clause cannot appear in both the 141 // allowedClauses and requiredClauses lists. 142 143 // List of allowed clauses for the directive. 144 list<VersionedClause> allowedClauses = []; 145 146 // List of clauses that are allowed to appear only once. 147 list<VersionedClause> allowedOnceClauses = []; 148 149 // List of clauses that are allowed but mutually exclusive. 150 list<VersionedClause> allowedExclusiveClauses = []; 151 152 // List of clauses that are required. 153 list<VersionedClause> requiredClauses = []; 154 155 // Set directive used by default when unknown. 156 bit isDefault = false; 157} 158