This patch makes use of TypeInterface implementing Type to remove instances of Type that simply checked whether a type implemented a given interface.
As part of this refactoring, some changes had to be done in the OpenMP Dialect files. In particular, they assumed that OpenMPOps.td to only ever include OpenMP TypeInterfaces, which did not hold anymore with a moved include in LLVMOpBase.td. For that reason, the type interface defintions were moved into a new file as is convention.
Differential Revision: https://reviews.llvm.org/D129210
#ifndef LLVMIR_OP_BASE
#define LLVMIR_OP_BASE
+include "mlir/Dialect/LLVMIR/LLVMOpsInterfaces.td"
include "mlir/IR/EnumAttr.td"
include "mlir/IR/OpBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
And<[LLVM_AnyStruct.predicate,
CPred<"$_self.cast<::mlir::LLVM::LLVMStructType>().isOpaque()">]>>;
-// Type constraint accepting types that implement that pointer element
-// interface.
-def LLVM_PointerElementType : Type<
- CPred<"$_self.isa<::mlir::LLVM::PointerElementTypeInterface>()">,
- "LLVM-compatible pointer element type">;
-
-
// Type constraint accepting any LLVM type that can be loaded or stored, i.e. a
// type that has size (not void, function or opaque struct type).
def LLVM_LoadableType : Type<
Or<[And<[LLVM_PrimitiveType.predicate, Neg<LLVM_OpaqueStruct.predicate>]>,
- LLVM_PointerElementType.predicate]>,
+ LLVM_PointerElementTypeInterface.predicate]>,
"LLVM type with size">;
// Type constraint accepting any LLVM aggregate type, i.e. structure or array.
#define LLVMIR_OPS
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
-include "mlir/Dialect/LLVMIR/LLVMOpsInterfaces.td"
include "mlir/IR/FunctionInterfaces.td"
include "mlir/IR/SymbolInterfaces.td"
include "mlir/Interfaces/CallInterfaces.td"
mlir_tablegen(OpenMPOps.cpp.inc -gen-op-defs)
mlir_tablegen(OpenMPOpsEnums.h.inc -gen-enum-decls)
mlir_tablegen(OpenMPOpsEnums.cpp.inc -gen-enum-defs)
-mlir_tablegen(OpenMPTypeInterfaces.h.inc -gen-type-interface-decls)
-mlir_tablegen(OpenMPTypeInterfaces.cpp.inc -gen-type-interface-defs)
mlir_tablegen(OpenMPOpsAttributes.h.inc -gen-attrdef-decls -attrdefs-dialect=omp)
mlir_tablegen(OpenMPOpsAttributes.cpp.inc -gen-attrdef-defs -attrdefs-dialect=omp)
add_mlir_doc(OpenMPOps OpenMPDialect Dialects/ -gen-dialect-doc -dialect=omp)
add_public_tablegen_target(MLIROpenMPOpsIncGen)
add_dependencies(OpenMPDialectDocGen omp_common_td)
add_mlir_interface(OpenMPOpsInterfaces)
+
+set(LLVM_TARGET_DEFINITIONS OpenMPTypeInterfaces.td)
+mlir_tablegen(OpenMPTypeInterfaces.h.inc -gen-type-interface-decls)
+mlir_tablegen(OpenMPTypeInterfaces.cpp.inc -gen-type-interface-defs)
+add_public_tablegen_target(MLIROpenMPTypeInterfacesIncGen)
+add_dependencies(mlir-generic-headers MLIROpenMPTypeInterfacesIncGen)
include "mlir/IR/SymbolInterfaces.td"
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
include "mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td"
+include "mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td"
def OpenMP_Dialect : Dialect {
let name = "omp";
// Type which can be constraint accepting standard integers and indices.
def IntLikeType : AnyTypeOf<[AnyInteger, Index]>;
-def OpenMP_PointerLikeTypeInterface : TypeInterface<"PointerLikeType"> {
- let cppNamespace = "::mlir::omp";
-
- let description = [{
- An interface for pointer-like types suitable to contain a value that OpenMP
- specification refers to as variable.
- }];
-
- let methods = [
- InterfaceMethod<
- /*description=*/"Returns the pointee type.",
- /*retTy=*/"::mlir::Type",
- /*methodName=*/"getElementType"
- >,
- ];
-}
-
-def OpenMP_PointerLikeType : Type<
- CPred<"$_self.isa<::mlir::omp::PointerLikeType>()">,
- "OpenMP-compatible variable type", "::mlir::omp::PointerLikeType">;
+def OpenMP_PointerLikeType : TypeAlias<OpenMP_PointerLikeTypeInterface,
+ "OpenMP-compatible variable type">;
//===----------------------------------------------------------------------===//
// 2.6 parallel Construct
--- /dev/null
+//===-- OpenMPTypeInterfaces.td - OpenMP type interfaces ---*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef OPENMP_TYPE_INTERFACES
+#define OPENMP_TYPE_INTERFACES
+
+include "mlir/IR/OpBase.td"
+
+def OpenMP_PointerLikeTypeInterface : TypeInterface<"PointerLikeType"> {
+ let cppNamespace = "::mlir::omp";
+
+ let description = [{
+ An interface for pointer-like types suitable to contain a value that OpenMP
+ specification refers to as variable.
+ }];
+
+ let methods = [
+ InterfaceMethod<
+ /*description=*/"Returns the pointee type.",
+ /*retTy=*/"::mlir::Type",
+ /*methodName=*/"getElementType"
+ >,
+ ];
+}
+
+#endif // OPENMP_TYPE_INTERFACES
// Allows providing an alternative name and summary to an existing type def.
class TypeAlias<Type t, string summary = t.summary> :
- Type<t.predicate, summary> {
+ Type<t.predicate, summary, t.cppClassName> {
let description = t.description;
let builderCall = t.builderCall;
}
DEPENDS
MLIROpenMPOpsIncGen
MLIROpenMPOpsInterfacesIncGen
+ MLIROpenMPTypeInterfacesIncGen
LINK_LIBS PUBLIC
MLIRIR