[clang] [Clang][OpenMP][OMPIRBuilder] Move Clang's OpenMP Member/MemberOf flag helpers into the OMPIRBuilder (PR #67844)

2023-10-03 Thread via cfe-commits

https://github.com/agozillon closed 
https://github.com/llvm/llvm-project/pull/67844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP][OMPIRBuilder] Move Clang's OpenMP Member/MemberOf flag helpers into the OMPIRBuilder (PR #67844)

2023-10-02 Thread via cfe-commits

shraiysh wrote:

> I'll see what I can do about adding an OpenMPIRBuilderTest.cpp to the patch.

I think it’s okay if it’s tested by clang tests (as Johannes mentioned). In 
case you decide to add tests for this, there is already an 
OpenMPIRBuilderTest.cpp in `llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp`. 
You can add one there if you’d like to. 

https://github.com/llvm/llvm-project/pull/67844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP][OMPIRBuilder] Move Clang's OpenMP Member/MemberOf flag helpers into the OMPIRBuilder (PR #67844)

2023-10-01 Thread via cfe-commits

agozillon wrote:

Thank you all very much, I'll land this on Tuesday afternoon/evening provided 
no one has anything else to add in the time between. And I'll see what I can do 
about adding an OpenMPIRBuilderTest.cpp to the patch. 

https://github.com/llvm/llvm-project/pull/67844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP][OMPIRBuilder] Move Clang's OpenMP Member/MemberOf flag helpers into the OMPIRBuilder (PR #67844)

2023-09-30 Thread Johannes Doerfert via cfe-commits

https://github.com/jdoerfert approved this pull request.

LG, tested via the clang tests.

https://github.com/llvm/llvm-project/pull/67844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP][OMPIRBuilder] Move Clang's OpenMP Member/MemberOf flag helpers into the OMPIRBuilder (PR #67844)

2023-09-30 Thread via cfe-commits

shraiysh wrote:

LGTM. Is it possible to add some tests for this? I think we might be able to 
add some in OpenMPIRBuilderTest.cpp. 

https://github.com/llvm/llvm-project/pull/67844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP][OMPIRBuilder] Move Clang's OpenMP Member/MemberOf flag helpers into the OMPIRBuilder (PR #67844)

2023-09-29 Thread Raghu Maddhipatla via cfe-commits

https://github.com/raghavendhra approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/67844
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][OpenMP][OMPIRBuilder] Move Clang's OpenMP Member/MemberOf flag helpers into the OMPIRBuilder (PR #67844)

2023-09-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang


Changes

This patch seeks to move the following functions to the OMPIRBuilder:
 - getFlagMemberOffset
 - getMemberOfFlag
 - setCorrectMemberOfFlag

These small helper functions help set the end bits of the 
OpenMPOffloadMappingFlags flag that correspond to the reserved segment for 
OMP_MAP_MEMBER_OF.

They will be of use in the future for lowering MLIR types/values that can 
contian members and can be lowered similarly to a structure or class type 
within the OpenMPToLLVMIRTranslation step of the OpenMP dialects lowering to 
LLVM-IR. In particular for Flang which currently uses this flow. Types with 
descriptors like pointers/allocatables, and likely derived types in certain 
cases can be lowered as if they were structures with explicitly mapped members.

---
Full diff: https://github.com/llvm/llvm-project/pull/67844.diff


3 Files Affected:

- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+24-40) 
- (modified) llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h (+24) 
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+36) 


``diff
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index b4e482ca5cba6ee..572fa9691b813c0 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7734,30 +7734,6 @@ class MappableExprsHandler {
OpenMPOffloadMappingFlags::OMP_MAP_FROM;
   }
 
-  static OpenMPOffloadMappingFlags getMemberOfFlag(unsigned Position) {
-// Rotate by getFlagMemberOffset() bits.
-return static_cast(((uint64_t)Position + 1)
-  << getFlagMemberOffset());
-  }
-
-  static void setCorrectMemberOfFlag(OpenMPOffloadMappingFlags &Flags,
- OpenMPOffloadMappingFlags MemberOfFlag) {
-// If the entry is PTR_AND_OBJ but has not been marked with the special
-// placeholder value 0x in the MEMBER_OF field, then it should not be
-// marked as MEMBER_OF.
-if (static_cast>(
-Flags & OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ) &&
-static_cast>(
-(Flags & OpenMPOffloadMappingFlags::OMP_MAP_MEMBER_OF) !=
-OpenMPOffloadMappingFlags::OMP_MAP_MEMBER_OF))
-  return;
-
-// Reset the placeholder value to prepare the flag for the assignment of 
the
-// proper MEMBER_OF value.
-Flags &= ~OpenMPOffloadMappingFlags::OMP_MAP_MEMBER_OF;
-Flags |= MemberOfFlag;
-  }
-
   void getPlainLayout(const CXXRecordDecl *RD,
   llvm::SmallVectorImpl &Layout,
   bool AsBase) const {
@@ -7825,6 +7801,7 @@ class MappableExprsHandler {
   /// the device pointers info array.
   void generateAllInfoForClauses(
   ArrayRef Clauses, MapCombinedInfoTy &CombinedInfo,
+  llvm::OpenMPIRBuilder &OMPBuilder,
   const llvm::DenseSet> &SkipVarSet =
   llvm::DenseSet>()) const {
 // We have to process the component lists that relate with the same
@@ -8159,7 +8136,7 @@ class MappableExprsHandler {
   if (PartialStruct.Base.isValid()) {
 CurInfo.NonContigInfo.Dims.push_back(0);
 emitCombinedEntry(CombinedInfo, CurInfo.Types, PartialStruct,
-  /*IsMapThis*/ !VD, VD);
+  /*IsMapThis*/ !VD, OMPBuilder, VD);
   }
 
   // We need to append the results of this capture to what we already
@@ -8226,6 +8203,7 @@ class MappableExprsHandler {
   void emitCombinedEntry(MapCombinedInfoTy &CombinedInfo,
  MapFlagsArrayTy &CurTypes,
  const StructRangeInfoTy &PartialStruct, bool 
IsMapThis,
+ llvm::OpenMPIRBuilder &OMPBuilder,
  const ValueDecl *VD = nullptr,
  bool NotTargetParams = true) const {
 if (CurTypes.size() == 1 &&
@@ -8313,9 +8291,9 @@ class MappableExprsHandler {
 // (except for PTR_AND_OBJ entries which do not have a placeholder value
 // 0x in the MEMBER_OF field).
 OpenMPOffloadMappingFlags MemberOfFlag =
-getMemberOfFlag(CombinedInfo.BasePointers.size() - 1);
+OMPBuilder.getMemberOfFlag(CombinedInfo.BasePointers.size() - 1);
 for (auto &M : CurTypes)
-  setCorrectMemberOfFlag(M, MemberOfFlag);
+  OMPBuilder.setCorrectMemberOfFlag(M, MemberOfFlag);
   }
 
   /// Generate all the base pointers, section pointers, sizes, map types, and
@@ -8324,23 +8302,26 @@ class MappableExprsHandler {
   /// pair of the relevant declaration and index where it occurs is appended to
   /// the device pointers info array.
   void generateAllInfo(
-  MapCombinedInfoTy &CombinedInfo,
+  MapCombinedInfoTy &CombinedInfo, llvm::OpenMPIRBuilder &OMPBuilder,
   const llvm::DenseSet> &SkipVarSet =
   llvm::DenseSet>()) const {
 assert(CurDir.is() &&
"Expect a executable directive");
 const auto *CurExecDir = CurDir.

[clang] [Clang][OpenMP][OMPIRBuilder] Move Clang's OpenMP Member/MemberOf flag helpers into the OMPIRBuilder (PR #67844)

2023-09-29 Thread via cfe-commits

https://github.com/agozillon created 
https://github.com/llvm/llvm-project/pull/67844

This patch seeks to move the following functions to the OMPIRBuilder:
 - getFlagMemberOffset
 - getMemberOfFlag
 - setCorrectMemberOfFlag

These small helper functions help set the end bits of the 
OpenMPOffloadMappingFlags flag that correspond to the reserved segment for 
OMP_MAP_MEMBER_OF.

They will be of use in the future for lowering MLIR types/values that can 
contian members and can be lowered similarly to a structure or class type 
within the OpenMPToLLVMIRTranslation step of the OpenMP dialects lowering to 
LLVM-IR. In particular for Flang which currently uses this flow. Types with 
descriptors like pointers/allocatables, and likely derived types in certain 
cases can be lowered as if they were structures with explicitly mapped members.

>From 5b40828db80b078225b953ca16b9f575d6f7799f Mon Sep 17 00:00:00 2001
From: Andrew Gozillon 
Date: Fri, 29 Sep 2023 12:44:22 -0500
Subject: [PATCH] [Clang][OpenMP][OMPIRBuilder] Move OpenMP Member/MemberOf
 flag helpers into the OMPIRBuilder

This patch seeks to move the following functions to the OMPIRBuilder:
 - getFlagMemberOffset
 - getMemberOfFlag
 - setCorrectMemberOfFlag

These small helper functions help set the end bits of
the OpenMPOffloadMappingFlags flag that correspond
to the reserved segment for OMP_MAP_MEMBER_OF.

They will be of use in the future for lowering MLIR types/values
that can contian members and can be lowered similarly to a
structure or class type within the OpenMPToLLVMIRTranslation
step of the OpenMP dialects lowering to LLVM-IR. In particular
for Flang which currently uses this flow. Types with descriptors
like pointers/allocatables, and likely derived types in certain
cases can be lowered as if they were structures with explicitly
mapped members.
---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp | 64 +++
 .../llvm/Frontend/OpenMP/OMPIRBuilder.h   | 24 +++
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 36 +++
 3 files changed, 84 insertions(+), 40 deletions(-)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index b4e482ca5cba6ee..572fa9691b813c0 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7734,30 +7734,6 @@ class MappableExprsHandler {
OpenMPOffloadMappingFlags::OMP_MAP_FROM;
   }
 
-  static OpenMPOffloadMappingFlags getMemberOfFlag(unsigned Position) {
-// Rotate by getFlagMemberOffset() bits.
-return static_cast(((uint64_t)Position + 1)
-  << getFlagMemberOffset());
-  }
-
-  static void setCorrectMemberOfFlag(OpenMPOffloadMappingFlags &Flags,
- OpenMPOffloadMappingFlags MemberOfFlag) {
-// If the entry is PTR_AND_OBJ but has not been marked with the special
-// placeholder value 0x in the MEMBER_OF field, then it should not be
-// marked as MEMBER_OF.
-if (static_cast>(
-Flags & OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ) &&
-static_cast>(
-(Flags & OpenMPOffloadMappingFlags::OMP_MAP_MEMBER_OF) !=
-OpenMPOffloadMappingFlags::OMP_MAP_MEMBER_OF))
-  return;
-
-// Reset the placeholder value to prepare the flag for the assignment of 
the
-// proper MEMBER_OF value.
-Flags &= ~OpenMPOffloadMappingFlags::OMP_MAP_MEMBER_OF;
-Flags |= MemberOfFlag;
-  }
-
   void getPlainLayout(const CXXRecordDecl *RD,
   llvm::SmallVectorImpl &Layout,
   bool AsBase) const {
@@ -7825,6 +7801,7 @@ class MappableExprsHandler {
   /// the device pointers info array.
   void generateAllInfoForClauses(
   ArrayRef Clauses, MapCombinedInfoTy &CombinedInfo,
+  llvm::OpenMPIRBuilder &OMPBuilder,
   const llvm::DenseSet> &SkipVarSet =
   llvm::DenseSet>()) const {
 // We have to process the component lists that relate with the same
@@ -8159,7 +8136,7 @@ class MappableExprsHandler {
   if (PartialStruct.Base.isValid()) {
 CurInfo.NonContigInfo.Dims.push_back(0);
 emitCombinedEntry(CombinedInfo, CurInfo.Types, PartialStruct,
-  /*IsMapThis*/ !VD, VD);
+  /*IsMapThis*/ !VD, OMPBuilder, VD);
   }
 
   // We need to append the results of this capture to what we already
@@ -8226,6 +8203,7 @@ class MappableExprsHandler {
   void emitCombinedEntry(MapCombinedInfoTy &CombinedInfo,
  MapFlagsArrayTy &CurTypes,
  const StructRangeInfoTy &PartialStruct, bool 
IsMapThis,
+ llvm::OpenMPIRBuilder &OMPBuilder,
  const ValueDecl *VD = nullptr,
  bool NotTargetParams = true) const {
 if (CurTypes.size() == 1 &&
@@ -8313,9 +8291,9 @@ class MappableExprsHandler {
 // (except for PTR_AND_OBJ entries which do no