File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: mlir-tblgen -gen-directive-decl -I %S/../../../llvm/include %s | FileCheck -match-full-lines %s
2
+
3
+ include "llvm/Frontend/Directive/DirectiveBase.td"
4
+
5
+ def TDLCV_vala : ClauseVal<"vala",1,1> {}
6
+ def TDLCV_valb : ClauseVal<"valb",2,1> {}
7
+ def TDLCV_valc : ClauseVal<"valc",3,0> { let isDefault = 1; }
8
+
9
+ def TDLC_ClauseA : Clause<"clausea"> {
10
+ let flangClass = "TdlClauseA";
11
+ let enumClauseValue = "AKind";
12
+ let allowedClauseValues = [
13
+ TDLCV_vala,
14
+ TDLCV_valb,
15
+ TDLCV_valc
16
+ ];
17
+ }
18
+
19
+ // CHECK: def AKindvala : StrEnumAttrCase<"vala">;
20
+ // CHECK: def AKindvalb : StrEnumAttrCase<"valb">;
21
+ // CHECK: def AKind: StrEnumAttr<
22
+ // CHECK: "ClauseAKind",
23
+ // CHECK: "AKind Clause",
24
+ // CHECK: [AKindvala,AKindvalb]> {
25
+ // CHECK: let cppNamespace = "::mlir::omp";
26
+ // CHECK: }
Original file line number Diff line number Diff line change @@ -24,6 +24,21 @@ using llvm::raw_ostream;
24
24
using llvm::RecordKeeper;
25
25
using llvm::Twine;
26
26
27
+ // LLVM has multiple places (Clang, Flang, MLIR) where information about
28
+ // the OpenMP directives, and clauses are needed. It is good software
29
+ // engineering to keep the common information in a single place to avoid
30
+ // duplication, reduce engineering effort and prevent mistakes.
31
+ // Currently that common place is llvm/include/llvm/Frontend/OpenMP/OMP.td.
32
+ // We plan to use this tablegen source to generate all the required
33
+ // declarations, functions etc.
34
+ //
35
+ // Some OpenMP clauses accept only a fixed set of values as inputs. These
36
+ // can be represented as a String Enum Attribute (StrEnumAttr) in MLIR ODS.
37
+ // The emitDecls function below currently generates these enumerations. The
38
+ // name of the enumeration is specified in the enumClauseValue field of
39
+ // Clause record in OMP.td. This name can be used to specify the type of the
40
+ // OpenMP operation's operand. The allowedClauseValues field provides the list
41
+ // of ClauseValues which are part of the enumeration.
27
42
static bool emitDecls (const RecordKeeper &recordKeeper, raw_ostream &os) {
28
43
const auto &clauses = recordKeeper.getAllDerivedDefinitions (" Clause" );
29
44
You can’t perform that action at this time.
0 commit comments