llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-clangir

Author: Jan Leyonberg (jsjodin)

<details>
<summary>Changes</summary>

This patch replaces the OMP specific pointer like type interface with the 
interface defined in core MLIR. This will make the code more uniform and will 
eliminate the dependence of the interface between OMP-&gt;CIR and OMP-&gt;Flang.

Assisted-by: Cursor / claude-opus-4.6-thinking

---

Patch is 21.21 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/197946.diff


18 Files Affected:

- (modified) clang/lib/CIR/Dialect/OpenMP/RegisterOpenMPExtensions.cpp (+21-4) 
- (modified) flang/include/flang/Tools/PointerModels.h (+13-4) 
- (modified) flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp (+1-1) 
- (modified) flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp (+2-2) 
- (modified) flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp (+1-1) 
- (modified) flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp (+4-4) 
- (modified) flang/lib/Utils/OpenMP.cpp (+1-1) 
- (modified) mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt (-5) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPAttrDefs.td (-1) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOpBase.td (+3-3) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td (+3-3) 
- (removed) mlir/include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td (-33) 
- (modified) mlir/lib/Dialect/OpenMP/IR/CMakeLists.txt (-1) 
- (modified) mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp (+25-16) 
- (modified) mlir/lib/Dialect/OpenMP/Transforms/CMakeLists.txt (-1) 
- (modified) utils/bazel/llvm-project-overlay/mlir/BUILD.bazel (-13) 
- (modified) utils/bazel/llvm-project-overlay/mlir/test/mlir-tblgen/BUILD.bazel 
(-1) 


``````````diff
diff --git a/clang/lib/CIR/Dialect/OpenMP/RegisterOpenMPExtensions.cpp 
b/clang/lib/CIR/Dialect/OpenMP/RegisterOpenMPExtensions.cpp
index 3a66f93238808..21f611c7ee1af 100644
--- a/clang/lib/CIR/Dialect/OpenMP/RegisterOpenMPExtensions.cpp
+++ b/clang/lib/CIR/Dialect/OpenMP/RegisterOpenMPExtensions.cpp
@@ -13,16 +13,33 @@
 #include "clang/CIR/Dialect/OpenMP/RegisterOpenMPExtensions.h"
 #include "mlir/Dialect/OpenMP/OpenMPDialect.h"
 #include "mlir/Dialect/OpenMP/OpenMPInterfaces.h"
+#include "mlir/IR/BuiltinTypeInterfaces.h"
 #include "clang/CIR/Dialect/IR/CIRDialect.h"
 #include "clang/CIR/Dialect/IR/CIRTypes.h"
 
 namespace {
-struct OpenMPPointerLikeModel
-    : public mlir::omp::PointerLikeType::ExternalModel<OpenMPPointerLikeModel,
-                                                       cir::PointerType> {
+struct CIRPointerPtrLikeModel
+    : public mlir::PtrLikeTypeInterface::ExternalModel<
+          CIRPointerPtrLikeModel, cir::PointerType> {
+  mlir::Attribute getMemorySpace(mlir::Type pointer) const {
+    auto addrSpace = mlir::cast<cir::PointerType>(pointer).getAddrSpace();
+    return addrSpace ? mlir::Attribute(addrSpace) : mlir::Attribute();
+  }
   mlir::Type getElementType(mlir::Type pointer) const {
     return mlir::cast<cir::PointerType>(pointer).getPointee();
   }
+  bool hasPtrMetadata(mlir::Type pointer) const { return false; }
+  mlir::FailureOr<mlir::PtrLikeTypeInterface>
+  clonePtrWith(mlir::Type pointer, mlir::Attribute memorySpace,
+               std::optional<mlir::Type> elementType) const {
+    auto ptrTy = mlir::cast<cir::PointerType>(pointer);
+    mlir::Type eTy = elementType ? *elementType : ptrTy.getPointee();
+    auto addrSpace =
+        mlir::dyn_cast_or_null<mlir::ptr::MemorySpaceAttrInterface>(
+            memorySpace);
+    return mlir::cast<mlir::PtrLikeTypeInterface>(
+        cir::PointerType::get(eTy, addrSpace));
+  }
 };
 } // namespace
 
@@ -32,7 +49,7 @@ void registerOpenMPExtensions(mlir::DialectRegistry 
&registry) {
   registry.addExtension(+[](mlir::MLIRContext *ctx, cir::CIRDialect *dialect) {
     cir::FuncOp::attachInterface<
         mlir::omp::DeclareTargetDefaultModel<cir::FuncOp>>(*ctx);
-    cir::PointerType::attachInterface<OpenMPPointerLikeModel>(*ctx);
+    cir::PointerType::attachInterface<CIRPointerPtrLikeModel>(*ctx);
   });
 }
 
diff --git a/flang/include/flang/Tools/PointerModels.h 
b/flang/include/flang/Tools/PointerModels.h
index 0d22ed3ca7f4f..1e609f43fed74 100644
--- a/flang/include/flang/Tools/PointerModels.h
+++ b/flang/include/flang/Tools/PointerModels.h
@@ -9,18 +9,27 @@
 #ifndef FORTRAN_TOOLS_POINTER_MODELS_H
 #define FORTRAN_TOOLS_POINTER_MODELS_H
 
-#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
+#include "mlir/IR/BuiltinTypeInterfaces.h"
 
-/// models for FIR pointer like types that already provide a `getElementType`
-/// method
+/// Models for FIR pointer like types that already provide a `getElementType`
+/// method. These implement the core MLIR PtrLikeTypeInterface.
 
 template <typename T>
 struct OpenMPPointerLikeModel
-    : public mlir::omp::PointerLikeType::ExternalModel<
+    : public mlir::PtrLikeTypeInterface::ExternalModel<
           OpenMPPointerLikeModel<T>, T> {
+  mlir::Attribute getMemorySpace(mlir::Type pointer) const {
+    return mlir::Attribute();
+  }
   mlir::Type getElementType(mlir::Type pointer) const {
     return mlir::cast<T>(pointer).getElementType();
   }
+  bool hasPtrMetadata(mlir::Type pointer) const { return false; }
+  mlir::FailureOr<mlir::PtrLikeTypeInterface>
+  clonePtrWith(mlir::Type pointer, mlir::Attribute memorySpace,
+               std::optional<mlir::Type> elementType) const {
+    return mlir::failure();
+  }
 };
 
 #endif // FORTRAN_TOOLS_POINTER_MODELS_H
diff --git a/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp 
b/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
index 5793d46a192a7..278e0deac43de 100644
--- a/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
+++ b/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
@@ -35,7 +35,7 @@ class AutomapToTargetDataPass
   // Returns true if the variable has a dynamic size and therefore requires
   // bounds operations to describe its extents.
   inline bool needsBoundsOps(mlir::Value var) {
-    assert(mlir::isa<mlir::omp::PointerLikeType>(var.getType()) &&
+    assert(mlir::isa<mlir::PtrLikeTypeInterface>(var.getType()) &&
            "only pointer like types expected");
     mlir::Type t = fir::unwrapRefType(var.getType());
     if (mlir::Type inner = fir::dyn_cast_ptrOrBoxEleTy(t))
diff --git a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp 
b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
index 5066c480141d0..dfb883cfe2702 100644
--- a/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
+++ b/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
@@ -560,7 +560,7 @@ class DoConcurrentConversion
       name = declareOp.getUniqName();
     }
 
-    if (!llvm::isa<mlir::omp::PointerLikeType>(rawAddr.getType())) {
+    if (!llvm::isa<mlir::PtrLikeTypeInterface>(rawAddr.getType())) {
       mlir::OpBuilder::InsertionGuard guard(builder);
       builder.setInsertionPointAfter(liveInDefiningOp);
       auto copyVal = builder.createTemporary(liveIn.getLoc(), 
liveIn.getType());
@@ -678,7 +678,7 @@ class DoConcurrentConversion
 
       auto mapHostValueToDevice = [&](mlir::Value hostValue,
                                       mlir::Value deviceValue) {
-        if (!llvm::isa<mlir::omp::PointerLikeType>(hostValue.getType()))
+        if (!llvm::isa<mlir::PtrLikeTypeInterface>(hostValue.getType()))
           mapper.map(hostValue,
                      builder.loadIfRef(hostValue.getLoc(), deviceValue));
         else
diff --git a/flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp 
b/flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp
index 3bd9a7eb9d2ab..c1388d14403ac 100644
--- a/flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp
+++ b/flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp
@@ -361,7 +361,7 @@ class MapInfoFinalizationPass
         builder, mapInfoOpLoc, descriptor, fir::BoxFieldAttr::base_addr);
 
     mlir::Type underlyingVarType =
-        llvm::cast<mlir::omp::PointerLikeType>(
+        llvm::cast<mlir::PtrLikeTypeInterface>(
             fir::unwrapRefType(baseAddrAddr.getType()))
             .getElementType();
     if (auto seqType = llvm::dyn_cast<fir::SequenceType>(underlyingVarType))
diff --git a/flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp 
b/flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp
index 6404e1892ca5d..0228ff423ef60 100644
--- a/flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp
+++ b/flang/lib/Optimizer/OpenMP/MapsForPrivatizedSymbols.cpp
@@ -96,8 +96,8 @@ class MapsForPrivatizedSymbolsPass
       fir::StoreOp::create(builder, loc, varPtr, alloca);
       varPtr = alloca;
     }
-    assert(mlir::isa<omp::PointerLikeType>(varPtr.getType()) &&
-           "Dealing with a varPtr that is not a PointerLikeType");
+    assert(mlir::isa<mlir::PtrLikeTypeInterface>(varPtr.getType()) &&
+           "Dealing with a varPtr that is not a PtrLikeTypeInterface");
 
     // Figure out the bounds because knowing the bounds will help the 
subsequent
     // MapInfoFinalizationPass map the underlying data of the descriptor.
@@ -127,7 +127,7 @@ class MapsForPrivatizedSymbolsPass
     return omp::MapInfoOp::create(
         builder, loc, varType, varPtr,
         TypeAttr::get(
-            llvm::cast<omp::PointerLikeType>(varType).getElementType()),
+            llvm::cast<mlir::PtrLikeTypeInterface>(varType).getElementType()),
         builder.getAttr<omp::ClauseMapFlagsAttr>(mapFlag),
         builder.getAttr<omp::VariableCaptureKindAttr>(captureKind),
         /*varPtrPtr=*/Value{},
@@ -204,7 +204,7 @@ class MapsForPrivatizedSymbolsPass
   // bounds from descriptor of var and add the bounds to the resultant
   // MapInfoOp.
   bool needsBoundsOps(mlir::Value var) {
-    assert(mlir::isa<omp::PointerLikeType>(var.getType()) &&
+    assert(mlir::isa<mlir::PtrLikeTypeInterface>(var.getType()) &&
            "needsBoundsOps can deal only with pointer types");
     mlir::Type t = fir::unwrapRefType(var.getType());
     // t could be a box, so look inside the box
diff --git a/flang/lib/Utils/OpenMP.cpp b/flang/lib/Utils/OpenMP.cpp
index cd6b7f310dd75..3ebef261f7f42 100644
--- a/flang/lib/Utils/OpenMP.cpp
+++ b/flang/lib/Utils/OpenMP.cpp
@@ -32,7 +32,7 @@ mlir::omp::MapInfoOp createMapInfoOp(mlir::OpBuilder &builder,
   }
 
   mlir::TypeAttr varType = mlir::TypeAttr::get(
-      llvm::cast<mlir::omp::PointerLikeType>(retTy).getElementType());
+      llvm::cast<mlir::PtrLikeTypeInterface>(retTy).getElementType());
 
   // For types with unknown extents such as <2x?xi32> we discard the incomplete
   // type info and only retain the base type. The correct dimensions are later
diff --git a/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt 
b/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt
index 691163d9ce9ac..016c685dd157d 100644
--- a/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/OpenMP/CMakeLists.txt
@@ -30,8 +30,3 @@ add_mlir_doc(OpenMPOps OpenMPDialect Dialects/ 
-gen-dialect-doc -dialect=omp)
 add_mlir_dialect_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_mlir_generic_tablegen_target(MLIROpenMPTypeInterfacesIncGen)
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPAttrDefs.td 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPAttrDefs.td
index c9e6764e7d634..4f1faa3f203eb 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPAttrDefs.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPAttrDefs.td
@@ -12,7 +12,6 @@
 include "mlir/Dialect/OpenMP/OpenMPDialect.td"
 include "mlir/Dialect/OpenMP/OpenMPEnums.td"
 include "mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td"
-include "mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td"
 include "mlir/IR/AttrTypeBase.td"
 include "mlir/IR/CommonAttrConstraints.td"
 
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h
index d7bccb133e02c..5a59e1d9b370a 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPDialect.h
@@ -33,7 +33,7 @@
 
 #include "mlir/Dialect/OpenMP/OpenMPClauseOperands.h"
 
-#include "mlir/Dialect/OpenMP/OpenMPTypeInterfaces.h.inc"
+#include "mlir/IR/BuiltinTypeInterfaces.h"
 
 #define GET_OP_CLASSES
 #include "mlir/Dialect/OpenMP/OpenMPOps.h.inc"
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOpBase.td 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPOpBase.td
index c1017826ab0c9..5720c090ed75c 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOpBase.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOpBase.td
@@ -16,7 +16,7 @@
 include "mlir/Dialect/OpenMP/OpenMPAttrDefs.td"
 include "mlir/Dialect/OpenMP/OpenMPDialect.td"
 include "mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td"
-include "mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td"
+include "mlir/IR/BuiltinTypeInterfaces.td"
 include "mlir/IR/OpBase.td"
 
 
//===----------------------------------------------------------------------===//
@@ -31,8 +31,8 @@ class OpenMP_Type<string name, string typeMnemonic> :
 // Type which can be constraint accepting standard integers and indices.
 def IntLikeType : AnyTypeOf<[AnyInteger, Index]>;
 
-def OpenMP_PointerLikeType : TypeAlias<OpenMP_PointerLikeTypeInterface,
-       "OpenMP-compatible variable type">;
+def OpenMP_PointerLikeType
+    : TypeAlias<PtrLikeTypeInterface, "OpenMP-compatible variable type">;
 
 def OpenMP_MapBoundsType : OpenMP_Type<"MapBounds", "map_bounds_ty"> {
   let summary = "Type for representing omp map clause bounds information";
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index c8c233477c174..3b21c68e1e289 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -1292,7 +1292,7 @@ def MapBoundsOp : OpenMP_Op<"map.bounds",
     ```
 
     This operation records the bounds information in a normalized fashion
-    (zero-based). This works well with the `PointerLikeType`
+    (zero-based). This works well with the `PtrLikeTypeInterface`
     requirement in data clauses - since a `lower_bound` of 0 means looking
     at data at the zero offset from pointer.
 
@@ -2205,11 +2205,11 @@ def DeclareReductionOp : OpenMP_Op<"declare_reduction", 
[IsolatedFromAbove,
       return region.empty() ? nullptr : region.getArgument(0);
     }
 
-    PointerLikeType getAccumulatorType() {
+    PtrLikeTypeInterface getAccumulatorType() {
       if (getAtomicReductionRegion().empty())
         return {};
 
-      return cast<PointerLikeType>(getAtomicReductionLhsArg().getType());
+      return cast<PtrLikeTypeInterface>(getAtomicReductionLhsArg().getType());
     }
   }];
   let hasRegionVerifier = 1;
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td 
b/mlir/include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td
deleted file mode 100644
index 1a38a23c9f180..0000000000000
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td
+++ /dev/null
@@ -1,33 +0,0 @@
-//===-- 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 or null if the pointer has no pointee type
-      }],
-      /*retTy=*/"::mlir::Type",
-      /*methodName=*/"getElementType"
-    >,
-  ];
-}
-
-#endif // OPENMP_TYPE_INTERFACES
diff --git a/mlir/lib/Dialect/OpenMP/IR/CMakeLists.txt 
b/mlir/lib/Dialect/OpenMP/IR/CMakeLists.txt
index 1beea2098d3bb..5a34774768f08 100644
--- a/mlir/lib/Dialect/OpenMP/IR/CMakeLists.txt
+++ b/mlir/lib/Dialect/OpenMP/IR/CMakeLists.txt
@@ -8,7 +8,6 @@ add_mlir_dialect_library(MLIROpenMPDialect
   omp_gen
   MLIROpenMPOpsIncGen
   MLIROpenMPOpsInterfacesIncGen
-  MLIROpenMPTypeInterfacesIncGen
 
   LINK_COMPONENTS
   TargetParser
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp 
b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index 89a104b2df67c..3f6c22d0623d9 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -13,6 +13,7 @@
 #include "mlir/Dialect/OpenMP/OpenMPDialect.h"
 #include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
+#include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
 #include "mlir/Dialect/LLVMIR/LLVMTypes.h"
 #include "mlir/Dialect/OpenMP/OpenMPClauseOperands.h"
 #include "mlir/IR/Attributes.h"
@@ -43,7 +44,6 @@
 #include "mlir/Dialect/OpenMP/OpenMPOpsDialect.cpp.inc"
 #include "mlir/Dialect/OpenMP/OpenMPOpsEnums.cpp.inc"
 #include "mlir/Dialect/OpenMP/OpenMPOpsInterfaces.cpp.inc"
-#include "mlir/Dialect/OpenMP/OpenMPTypeInterfaces.cpp.inc"
 
 using namespace mlir;
 using namespace mlir::omp;
@@ -64,18 +64,28 @@ makeDenseI64ArrayAttr(MLIRContext *ctx, const 
ArrayRef<int64_t> intArray) {
 }
 
 namespace {
-struct MemRefPointerLikeModel
-    : public PointerLikeType::ExternalModel<MemRefPointerLikeModel,
-                                            MemRefType> {
-  Type getElementType(Type pointer) const {
-    return llvm::cast<MemRefType>(pointer).getElementType();
+struct LLVMPointerPtrLikeModel
+    : public PtrLikeTypeInterface::ExternalModel<LLVMPointerPtrLikeModel,
+                                                 LLVM::LLVMPointerType> {
+  Attribute getMemorySpace(Type pointer) const {
+    return LLVM::AddressSpaceAttr::get(
+        pointer.getContext(),
+        llvm::cast<LLVM::LLVMPointerType>(pointer).getAddressSpace());
   }
-};
-
-struct LLVMPointerPointerLikeModel
-    : public PointerLikeType::ExternalModel<LLVMPointerPointerLikeModel,
-                                            LLVM::LLVMPointerType> {
   Type getElementType(Type pointer) const { return Type(); }
+  bool hasPtrMetadata(Type pointer) const { return false; }
+  FailureOr<PtrLikeTypeInterface>
+  clonePtrWith(Type pointer, Attribute memorySpace,
+               std::optional<Type> elementType) const {
+    if (elementType)
+      return failure();
+    auto addrSpaceAttr = dyn_cast<LLVM::AddressSpaceAttr>(memorySpace);
+    if (!addrSpaceAttr)
+      return failure();
+    return cast<PtrLikeTypeInterface>(
+        LLVM::LLVMPointerType::get(pointer.getContext(),
+                                   addrSpaceAttr.getAddressSpace()));
+  }
 };
 } // namespace
 
@@ -321,8 +331,7 @@ void OpenMPDialect::initialize() {
 
   declarePromisedInterface<ConvertToLLVMPatternInterface, OpenMPDialect>();
 
-  MemRefType::attachInterface<MemRefPointerLikeModel>(*getContext());
-  LLVM::LLVMPointerType::attachInterface<LLVMPointerPointerLikeModel>(
+  LLVM::LLVMPointerType::attachInterface<LLVMPointerPtrLikeModel>(
       *getContext());
 
   // Attach default offload module interface to module op to access
@@ -2314,8 +2323,8 @@ static ParseResult parseCaptureType(OpAsmParser &parser,
 }
 
 static LogicalResult verifyMapClause(Operation *op, OperandRange mapVars) {
-  llvm::DenseSet<mlir::TypedValue<mlir::omp::PointerLikeType>> updateToVars;
-  llvm::DenseSet<mlir::TypedValue<mlir::omp::PointerLikeType>> updateFromVars;
+  llvm::DenseSet<mlir::TypedValue<mlir::PtrLikeTypeInterface>> updateToVars;
+  llvm::DenseSet<mlir::TypedValue<mlir::PtrLikeTypeInterface>> updateFromVars;
 
   for (auto mapOp : mapVars) {
     if (!mapOp.getDefiningOp())
@@ -3500,7 +3509,7 @@ LogicalResult DeclareReductionOp::verifyRegions() {
             atomicReductionEntryBlock.getArgumentTypes()[1])
       return emitOpError() << "expects atomic reduction region with two "
                               "arguments of the same type";
-    auto ptrType = llvm::dyn_cast<PointerLikeType>(
+    auto ptrType = llvm::dyn_cast<PtrLikeTypeInterface>(
         atomicReductionEntryBlock.getArgumentTypes()[0]);
     if (!ptrType ||
         (ptrType.getElementType() && ptrType.getElementType() != getType()))
diff --git a/mlir/lib/Dialect/OpenMP/Transforms/CMakeLists.txt 
b/mlir/lib/Dialect/OpenMP/Transforms/CMakeLists.txt
index 569786fe95cf3..c67bd2b509bf6 100644
--- a/mlir/lib/Dialect/OpenMP/Transforms/CMakeLists.txt
+++ b/mlir/lib/Dialect/OpenMP/Transforms/CMakeLists.txt
@@ -11,7 +11,6 @@ add_mlir_dialect_library(MLIROpenMPTransforms
   MLIROpenMPPassIncGen
   MLIROpenMPOpsIncGen
   MLIROpenMPOpsInterfacesIncGen
-  MLIROpenMPTypeInterfacesIncGen
 
   LINK_LIBS PUBLIC
   MLIRFunctionInterfaces
diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel 
b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index 456cf1e06f539..c94e9c0458c07 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -10562,7 +10562,6 @@ td_library(
         "include/mlir/Dialect/OpenMP/OpenMPOpBase.td",
         "include/mlir/Dialect/OpenMP/OpenMPOps.td",
         "include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td",
-        "include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td",
     ],
     deps = [
         ":AtomicInterfacesTdFiles",
@@ -10613,17 +10612,6 @@ gentbl_cc_library(
     deps = [":OpenMPOpsTdFiles"],
 )
 
-gentbl_cc_library(
-    name = "OpenMPTypeInterfacesIncGen",
-    tbl_outs = {
-        "include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.h.inc": 
["-gen-type-interface-decls"],
-        "include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.cpp.inc": 
["-gen-type-interface-defs"],
-    },
-    tblgen = ":mlir-tblgen",
-    td_file = "include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td",
-    deps = [":OpenMPOpsTdFiles"],
-)
-
 gentb...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/197946
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to