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 // Optional class holding value of the clause in clang AST. 78 string clangClass = ""; 79 80 // Optional class holding value of the clause in flang AST. 81 string flangClass = ""; 82 83 // If set to true, value is optional. Not optional by default. 84 bit isValueOptional = false; 85 86 // Name of enum when there is a list of allowed clause values. 87 string enumClauseValue = ""; 88 89 // List of allowed clause values 90 list<ClauseVal> allowedClauseValues = []; 91 // If set to true, value class is part of a list. Single class by default. 92 bit isValueList = false; 93 94 // Define a default value such as "*". 95 string defaultValue = ""; 96 97 // Is clause implicit? If clause is set as implicit, the default kind will 98 // be return in get<LanguageName>ClauseKind instead of their own kind. 99 bit isImplicit = false; 100 101 // Set clause used by default when unknown. Function returning the kind 102 // of enumeration will use this clause as the default. 103 bit isDefault = false; 104} 105 106// Hold information about clause validity by version. 107class VersionedClause<Clause c, int min = 1, int max = 0x7FFFFFFF> { 108 // Actual clause. 109 Clause clause = c; 110 111 // Mininum version number where this clause is valid. 112 int minVersion = min; 113 114 // Maximum version number where this clause is valid. 115 int maxVersion = max; 116} 117 118// Information about a specific directive. 119class Directive<string d> { 120 // Name of the directive. Can be composite directive sepearted by whitespace. 121 string name = d; 122 123 // Define an alternative name return in get<LanguageName>DirectiveName 124 // function. 125 string alternativeName = ""; 126 127 // Clauses cannot appear twice in the three allowed lists below. Also, since 128 // required implies allowed, the same clause cannot appear in both the 129 // allowedClauses and requiredClauses lists. 130 131 // List of allowed clauses for the directive. 132 list<VersionedClause> allowedClauses = []; 133 134 // List of clauses that are allowed to appear only once. 135 list<VersionedClause> allowedOnceClauses = []; 136 137 // List of clauses that are allowed but mutually exclusive. 138 list<VersionedClause> allowedExclusiveClauses = []; 139 140 // List of clauses that are required. 141 list<VersionedClause> requiredClauses = []; 142 143 // Set directive used by default when unknown. 144 bit isDefault = false; 145} 146