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