15ffd83dbSDimitry Andric//===-- DirectiveBase.td - Base directive definition file --*- tablegen -*-===// 25ffd83dbSDimitry Andric// 35ffd83dbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 45ffd83dbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 55ffd83dbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 65ffd83dbSDimitry Andric// 75ffd83dbSDimitry Andric//===----------------------------------------------------------------------===// 85ffd83dbSDimitry Andric// 95ffd83dbSDimitry Andric// This is the base definition file directives and clauses. 105ffd83dbSDimitry Andric// 115ffd83dbSDimitry Andric//===----------------------------------------------------------------------===// 125ffd83dbSDimitry Andric 135ffd83dbSDimitry Andric 145ffd83dbSDimitry Andric// General information about the directive language. 155ffd83dbSDimitry Andricclass DirectiveLanguage { 165ffd83dbSDimitry Andric // Name of the directive language such as omp or acc. 175ffd83dbSDimitry Andric string name = ?; 185ffd83dbSDimitry Andric 195ffd83dbSDimitry Andric // The C++ namespace that code of this directive language should be placed 205ffd83dbSDimitry Andric // into. This namespace is nested in llvm namespace. 215ffd83dbSDimitry Andric // 225ffd83dbSDimitry Andric // By default, uses the name of the directive language as the only namespace. 235ffd83dbSDimitry Andric // To avoid placing in any namespace, use "". To specify nested namespaces, 245ffd83dbSDimitry Andric // use "::" as the delimiter, e.g., given "A::B", ops will be placed in 255ffd83dbSDimitry Andric // `namespace A { namespace B { <directives-clauses> } }`. 265ffd83dbSDimitry Andric string cppNamespace = name; 275ffd83dbSDimitry Andric 285ffd83dbSDimitry Andric // Optional prefix used for the generation of the enumerator in the Directive 295ffd83dbSDimitry Andric // enum. 305ffd83dbSDimitry Andric string directivePrefix = ""; 315ffd83dbSDimitry Andric 325ffd83dbSDimitry Andric // Optional prefix used for the generation of the enumerator in the Clause 335ffd83dbSDimitry Andric // enum. 345ffd83dbSDimitry Andric string clausePrefix = ""; 355ffd83dbSDimitry Andric 365ffd83dbSDimitry Andric // Make the enum values available in the namespace. This allows us to 375ffd83dbSDimitry Andric // write something like Enum_X if we have a `using namespace cppNamespace`. 38e8d8bef9SDimitry Andric bit makeEnumAvailableInNamespace = false; 395ffd83dbSDimitry Andric 405ffd83dbSDimitry Andric // Generate include and macro to enable LLVM BitmaskEnum. 41e8d8bef9SDimitry Andric bit enableBitmaskEnumInNamespace = false; 425ffd83dbSDimitry Andric 435ffd83dbSDimitry Andric // Header file included in the implementation code generated. Ususally the 445ffd83dbSDimitry Andric // output file of the declaration code generation. Can be left blank. 455ffd83dbSDimitry Andric string includeHeader = ""; 465ffd83dbSDimitry Andric 475ffd83dbSDimitry Andric // EnumSet class name used for clauses to generated the allowed clauses map. 485ffd83dbSDimitry Andric string clauseEnumSetClass = ""; 49e8d8bef9SDimitry Andric 50e8d8bef9SDimitry Andric // Class holding the clauses in the flang parse-tree. 51e8d8bef9SDimitry Andric string flangClauseBaseClass = ""; 52e8d8bef9SDimitry Andric} 53e8d8bef9SDimitry Andric 54e8d8bef9SDimitry Andric// Information about values accepted by enum-like clauses 55e8d8bef9SDimitry Andricclass ClauseVal<string n, int v, bit uv> { 56e8d8bef9SDimitry Andric // Name of the clause value. 57e8d8bef9SDimitry Andric string name = n; 58e8d8bef9SDimitry Andric 59e8d8bef9SDimitry Andric // Integer value of the clause. 60e8d8bef9SDimitry Andric int value = v; 61e8d8bef9SDimitry Andric 62e8d8bef9SDimitry Andric // Can user specify this value? 63e8d8bef9SDimitry Andric bit isUserValue = uv; 64e8d8bef9SDimitry Andric 65e8d8bef9SDimitry Andric // Set clause value used by default when unknown. 66e8d8bef9SDimitry Andric bit isDefault = false; 675ffd83dbSDimitry Andric} 685ffd83dbSDimitry Andric 695ffd83dbSDimitry Andric// Information about a specific clause. 705ffd83dbSDimitry Andricclass Clause<string c> { 715ffd83dbSDimitry Andric // Name of the clause. 725ffd83dbSDimitry Andric string name = c; 735ffd83dbSDimitry Andric 745ffd83dbSDimitry Andric // Define an alternative name return in get<LanguageName>ClauseName function. 755ffd83dbSDimitry Andric string alternativeName = ""; 765ffd83dbSDimitry Andric 77*fcaf7f86SDimitry Andric // Define aliases used in the parser. 78*fcaf7f86SDimitry Andric list<string> aliases = []; 79*fcaf7f86SDimitry Andric 805ffd83dbSDimitry Andric // Optional class holding value of the clause in clang AST. 81e8d8bef9SDimitry Andric string clangClass = ""; 825ffd83dbSDimitry Andric 835ffd83dbSDimitry Andric // Optional class holding value of the clause in flang AST. 84e8d8bef9SDimitry Andric string flangClass = ""; 85e8d8bef9SDimitry Andric 86e8d8bef9SDimitry Andric // If set to true, value is optional. Not optional by default. 87e8d8bef9SDimitry Andric bit isValueOptional = false; 88e8d8bef9SDimitry Andric 89e8d8bef9SDimitry Andric // Name of enum when there is a list of allowed clause values. 90e8d8bef9SDimitry Andric string enumClauseValue = ""; 91e8d8bef9SDimitry Andric 92e8d8bef9SDimitry Andric // List of allowed clause values 93e8d8bef9SDimitry Andric list<ClauseVal> allowedClauseValues = []; 94*fcaf7f86SDimitry Andric 95e8d8bef9SDimitry Andric // If set to true, value class is part of a list. Single class by default. 96e8d8bef9SDimitry Andric bit isValueList = false; 97e8d8bef9SDimitry Andric 98e8d8bef9SDimitry Andric // Define a default value such as "*". 99e8d8bef9SDimitry Andric string defaultValue = ""; 1005ffd83dbSDimitry Andric 1015ffd83dbSDimitry Andric // Is clause implicit? If clause is set as implicit, the default kind will 1025ffd83dbSDimitry Andric // be return in get<LanguageName>ClauseKind instead of their own kind. 103e8d8bef9SDimitry Andric bit isImplicit = false; 1045ffd83dbSDimitry Andric 105e8d8bef9SDimitry Andric // Set clause used by default when unknown. Function returning the kind 1065ffd83dbSDimitry Andric // of enumeration will use this clause as the default. 107e8d8bef9SDimitry Andric bit isDefault = false; 108*fcaf7f86SDimitry Andric 109*fcaf7f86SDimitry Andric // Prefix before the actual value. Used in the parser generation. 110*fcaf7f86SDimitry Andric // `clause(prefix: value)` 111*fcaf7f86SDimitry Andric string prefix = ""; 112*fcaf7f86SDimitry Andric 113*fcaf7f86SDimitry Andric // Set the prefix as optional. 114*fcaf7f86SDimitry Andric // `clause([prefix]: value)` 115*fcaf7f86SDimitry Andric bit isPrefixOptional = true; 1165ffd83dbSDimitry Andric} 1175ffd83dbSDimitry Andric 1185ffd83dbSDimitry Andric// Hold information about clause validity by version. 1195ffd83dbSDimitry Andricclass VersionedClause<Clause c, int min = 1, int max = 0x7FFFFFFF> { 1205ffd83dbSDimitry Andric // Actual clause. 1215ffd83dbSDimitry Andric Clause clause = c; 1225ffd83dbSDimitry Andric 1235ffd83dbSDimitry Andric // Mininum version number where this clause is valid. 1245ffd83dbSDimitry Andric int minVersion = min; 1255ffd83dbSDimitry Andric 1265ffd83dbSDimitry Andric // Maximum version number where this clause is valid. 1275ffd83dbSDimitry Andric int maxVersion = max; 1285ffd83dbSDimitry Andric} 1295ffd83dbSDimitry Andric 1305ffd83dbSDimitry Andric// Information about a specific directive. 1315ffd83dbSDimitry Andricclass Directive<string d> { 1325ffd83dbSDimitry Andric // Name of the directive. Can be composite directive sepearted by whitespace. 1335ffd83dbSDimitry Andric string name = d; 1345ffd83dbSDimitry Andric 1355ffd83dbSDimitry Andric // Define an alternative name return in get<LanguageName>DirectiveName 1365ffd83dbSDimitry Andric // function. 1375ffd83dbSDimitry Andric string alternativeName = ""; 1385ffd83dbSDimitry Andric 139e8d8bef9SDimitry Andric // Clauses cannot appear twice in the three allowed lists below. Also, since 140e8d8bef9SDimitry Andric // required implies allowed, the same clause cannot appear in both the 141e8d8bef9SDimitry Andric // allowedClauses and requiredClauses lists. 142e8d8bef9SDimitry Andric 1435ffd83dbSDimitry Andric // List of allowed clauses for the directive. 1445ffd83dbSDimitry Andric list<VersionedClause> allowedClauses = []; 1455ffd83dbSDimitry Andric 1465ffd83dbSDimitry Andric // List of clauses that are allowed to appear only once. 1475ffd83dbSDimitry Andric list<VersionedClause> allowedOnceClauses = []; 1485ffd83dbSDimitry Andric 1495ffd83dbSDimitry Andric // List of clauses that are allowed but mutually exclusive. 1505ffd83dbSDimitry Andric list<VersionedClause> allowedExclusiveClauses = []; 1515ffd83dbSDimitry Andric 1525ffd83dbSDimitry Andric // List of clauses that are required. 1535ffd83dbSDimitry Andric list<VersionedClause> requiredClauses = []; 1545ffd83dbSDimitry Andric 1555ffd83dbSDimitry Andric // Set directive used by default when unknown. 156e8d8bef9SDimitry Andric bit isDefault = false; 1575ffd83dbSDimitry Andric} 158