diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td @@ -14,6 +14,7 @@ #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" @@ -141,18 +142,11 @@ 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_PointerElementType.predicate]>, + LLVM_PointerElementTypeInterface.predicate]>, "LLVM type with size">; // Type constraint accepting any LLVM aggregate type, i.e. structure or array. diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -14,7 +14,6 @@ #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" diff --git a/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt b/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt --- a/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt @@ -9,11 +9,15 @@ 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) diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td --- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td +++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -21,6 +21,7 @@ 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"; @@ -38,26 +39,8 @@ // 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; //===----------------------------------------------------------------------===// // 2.6 parallel Construct diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td new file mode 100644 --- /dev/null +++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td @@ -0,0 +1,31 @@ +//===-- 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 diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -274,7 +274,7 @@ // Allows providing an alternative name and summary to an existing type def. class TypeAlias : - Type { + Type { let description = t.description; let builderCall = t.builderCall; } diff --git a/mlir/lib/Dialect/OpenMP/CMakeLists.txt b/mlir/lib/Dialect/OpenMP/CMakeLists.txt --- a/mlir/lib/Dialect/OpenMP/CMakeLists.txt +++ b/mlir/lib/Dialect/OpenMP/CMakeLists.txt @@ -7,6 +7,7 @@ DEPENDS MLIROpenMPOpsIncGen MLIROpenMPOpsInterfacesIncGen + MLIROpenMPTypeInterfacesIncGen LINK_LIBS PUBLIC MLIRIR