forked from OSchip/llvm-project
[NFC][MLIR][OpenMP] Add comments and test for OpenMP enum declaration utility
Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D85857
This commit is contained in:
parent
62ef1cb207
commit
fc544dcf2d
|
@ -0,0 +1,26 @@
|
|||
// RUN: mlir-tblgen -gen-directive-decl -I %S/../../../llvm/include %s | FileCheck -match-full-lines %s
|
||||
|
||||
include "llvm/Frontend/Directive/DirectiveBase.td"
|
||||
|
||||
def TDLCV_vala : ClauseVal<"vala",1,1> {}
|
||||
def TDLCV_valb : ClauseVal<"valb",2,1> {}
|
||||
def TDLCV_valc : ClauseVal<"valc",3,0> { let isDefault = 1; }
|
||||
|
||||
def TDLC_ClauseA : Clause<"clausea"> {
|
||||
let flangClass = "TdlClauseA";
|
||||
let enumClauseValue = "AKind";
|
||||
let allowedClauseValues = [
|
||||
TDLCV_vala,
|
||||
TDLCV_valb,
|
||||
TDLCV_valc
|
||||
];
|
||||
}
|
||||
|
||||
// CHECK: def AKindvala : StrEnumAttrCase<"vala">;
|
||||
// CHECK: def AKindvalb : StrEnumAttrCase<"valb">;
|
||||
// CHECK: def AKind: StrEnumAttr<
|
||||
// CHECK: "ClauseAKind",
|
||||
// CHECK: "AKind Clause",
|
||||
// CHECK: [AKindvala,AKindvalb]> {
|
||||
// CHECK: let cppNamespace = "::mlir::omp";
|
||||
// CHECK: }
|
|
@ -24,6 +24,21 @@ using llvm::raw_ostream;
|
|||
using llvm::RecordKeeper;
|
||||
using llvm::Twine;
|
||||
|
||||
// LLVM has multiple places (Clang, Flang, MLIR) where information about
|
||||
// the OpenMP directives, and clauses are needed. It is good software
|
||||
// engineering to keep the common information in a single place to avoid
|
||||
// duplication, reduce engineering effort and prevent mistakes.
|
||||
// Currently that common place is llvm/include/llvm/Frontend/OpenMP/OMP.td.
|
||||
// We plan to use this tablegen source to generate all the required
|
||||
// declarations, functions etc.
|
||||
//
|
||||
// Some OpenMP clauses accept only a fixed set of values as inputs. These
|
||||
// can be represented as a String Enum Attribute (StrEnumAttr) in MLIR ODS.
|
||||
// The emitDecls function below currently generates these enumerations. The
|
||||
// name of the enumeration is specified in the enumClauseValue field of
|
||||
// Clause record in OMP.td. This name can be used to specify the type of the
|
||||
// OpenMP operation's operand. The allowedClauseValues field provides the list
|
||||
// of ClauseValues which are part of the enumeration.
|
||||
static bool emitDecls(const RecordKeeper &recordKeeper, raw_ostream &os) {
|
||||
const auto &clauses = recordKeeper.getAllDerivedDefinitions("Clause");
|
||||
|
||||
|
|
Loading…
Reference in New Issue