[clang] [clang][OpenMP] Fix missing DI for __kmpc_global_thread_num (PR #73856)

2023-11-29 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov created 
https://github.com/llvm/llvm-project/pull/73856

None

>From 791afd6349aef7eee8b9f6c132a30f72c36a9efb Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Wed, 29 Nov 2023 13:22:46 -0800
Subject: [PATCH] [clang][OpenMP] Fix missing DI for __kmpc_global_thread_num

---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index aae1a0ea250eea2..b4a7eafd2eec70b 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1441,6 +1441,7 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction 
&CGF,
 setLocThreadIdInsertPt(CGF);
   CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
   CGF.Builder.SetInsertPoint(Elem.second.ServiceInsertPt);
+  auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
   llvm::CallInst *Call = CGF.Builder.CreateCall(
   OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
 OMPRTL___kmpc_global_thread_num),

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-11 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/06

>From e778fad3eafcd78924efd7aa233ac7ba9f4e6a49 Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 4 Oct 2024 16:20:36 +0900
Subject: [PATCH 01/13] [flang] Add frontend support for OpenMP extension bare
 clause

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  4 
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  1 +
 flang/lib/Lower/OpenMP/Clauses.h  |  2 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp |  2 ++
 flang/lib/Parser/openmp-parsers.cpp   |  1 +
 .../Frontend/OpenMP/ConstructDecompositionT.h |  9 +++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  1 +
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 24 +++
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  3 ++-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  3 ++-
 10 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index cf91b2638aecc3..84bfc40d977ce8 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -350,6 +350,10 @@ bool 
ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
   return markClauseOccurrence(result.nowait);
 }
 
+bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const {
+  return markClauseOccurrence(result.bare);
+}
+
 bool ClauseProcessor::processNumTeams(
 lower::StatementContext &stmtCtx,
 mlir::omp::NumTeamsClauseOps &result) const {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index f34121c70d0b44..0ad411af2f369d 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -72,6 +72,7 @@ class ClauseProcessor {
   bool processHint(mlir::omp::HintClauseOps &result) const;
   bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
   bool processNowait(mlir::omp::NowaitClauseOps &result) const;
+  bool processBare(mlir::omp::BareClauseOps &result) const;
   bool processNumTeams(lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const;
   bool processNumThreads(lower::StatementContext &stmtCtx,
diff --git a/flang/lib/Lower/OpenMP/Clauses.h b/flang/lib/Lower/OpenMP/Clauses.h
index 62f3df3e3ee952..4c40dbf186ef93 100644
--- a/flang/lib/Lower/OpenMP/Clauses.h
+++ b/flang/lib/Lower/OpenMP/Clauses.h
@@ -229,8 +229,8 @@ using NumTasks = tomp::clause::NumTasksT;
 using NumTeams = tomp::clause::NumTeamsT;
 using NumThreads = tomp::clause::NumThreadsT;
 using OmpxAttribute = tomp::clause::OmpxAttributeT;
-using OmpxBare = tomp::clause::OmpxBareT;
 using OmpxDynCgroupMem = tomp::clause::OmpxDynCgroupMemT;
+using OmpxBare = tomp::clause::OmpxBareT;
 using Ordered = tomp::clause::OrderedT;
 using Order = tomp::clause::OrderT;
 using Partial = tomp::clause::PartialT;
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index a89029b720e788..585b22fd7da502 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1241,6 +1241,7 @@ static void genTargetClauses(
 cp.processNowait(clauseOps);
 
   cp.processThreadLimit(stmtCtx, clauseOps);
+  cp.processBare(clauseOps);
 
   cp.processTODO(
@@ -2771,6 +2772,7 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
+!std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 214d6b4a91087b..fa014e0e9fae16 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -315,6 +315,7 @@ TYPE_PARSER(
parenthesized(scalarIntExpr))) ||
 "NUM_THREADS" >> construct(construct(
  parenthesized(scalarIntExpr))) ||
+"OMPX_BARE" >> construct(construct()) ||
 "ORDER" >> construct(construct(
parenthesized(Parser{}))) ||
 "ORDERED" >> construct(construct(
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h 
b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 4bdfa1cf4c1490..7c0dbe1aae1221 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -236,6 +236,8 @@ struct ConstructDecompositionT {
const ClauseTy *);
   bool applyClause(const tomp::clause::NowaitT &clause,
const ClauseTy *);
+  bool applyClause(const tomp::clause::OmpxBareT &clause,
+   const ClauseTy *);
   bool

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-08 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/06

>From e70fc69910083e4e6fb9f4e23f41e4eac6ae6c9b Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 4 Oct 2024 16:20:36 +0900
Subject: [PATCH 01/10] [flang] Add frontend support for OpenMP extension bare
 clause

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  4 
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  1 +
 flang/lib/Lower/OpenMP/Clauses.h  |  2 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp |  2 ++
 flang/lib/Parser/openmp-parsers.cpp   |  1 +
 .../Frontend/OpenMP/ConstructDecompositionT.h |  9 +++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  1 +
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 24 +++
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  3 ++-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  3 ++-
 10 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index a4d2524bccf5c3..c7f34b3d65f324 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -354,6 +354,10 @@ bool 
ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
   return markClauseOccurrence(result.nowait);
 }
 
+bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const {
+  return markClauseOccurrence(result.bare);
+}
+
 bool ClauseProcessor::processNumTeams(
 lower::StatementContext &stmtCtx,
 mlir::omp::NumTeamsClauseOps &result) const {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index 0c8e7bd47ab5a6..a04731f94ede37 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -74,6 +74,7 @@ class ClauseProcessor {
   bool processHint(mlir::omp::HintClauseOps &result) const;
   bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
   bool processNowait(mlir::omp::NowaitClauseOps &result) const;
+  bool processBare(mlir::omp::BareClauseOps &result) const;
   bool processNumTeams(lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const;
   bool processNumThreads(lower::StatementContext &stmtCtx,
diff --git a/flang/lib/Lower/OpenMP/Clauses.h b/flang/lib/Lower/OpenMP/Clauses.h
index 51bf0eab0f8d07..10bd1439563244 100644
--- a/flang/lib/Lower/OpenMP/Clauses.h
+++ b/flang/lib/Lower/OpenMP/Clauses.h
@@ -229,8 +229,8 @@ using NumTasks = tomp::clause::NumTasksT;
 using NumTeams = tomp::clause::NumTeamsT;
 using NumThreads = tomp::clause::NumThreadsT;
 using OmpxAttribute = tomp::clause::OmpxAttributeT;
-using OmpxBare = tomp::clause::OmpxBareT;
 using OmpxDynCgroupMem = tomp::clause::OmpxDynCgroupMemT;
+using OmpxBare = tomp::clause::OmpxBareT;
 using Ordered = tomp::clause::OrderedT;
 using Order = tomp::clause::OrderT;
 using Partial = tomp::clause::PartialT;
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 60c83586e468b6..b8b1a0ba2a69b7 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1180,6 +1180,7 @@ static void genTargetClauses(
 cp.processNowait(clauseOps);
 
   cp.processThreadLimit(stmtCtx, clauseOps);
+  cp.processBare(clauseOps);
 
   cp.processTODO(
@@ -2764,6 +2765,7 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
+!std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u)) {
   TODO(clauseLocation, "OpenMP Block construct clause");
 }
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index cc2930cbd7ded5..f18a9929aa75ef 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -315,6 +315,7 @@ TYPE_PARSER(
parenthesized(scalarIntExpr))) ||
 "NUM_THREADS" >> construct(construct(
  parenthesized(scalarIntExpr))) ||
+"OMPX_BARE" >> construct(construct()) ||
 "ORDER" >> construct(construct(
parenthesized(Parser{}))) ||
 "ORDERED" >> construct(construct(
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h 
b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 4bdfa1cf4c1490..7c0dbe1aae1221 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -236,6 +236,8 @@ struct ConstructDecompositionT {
const ClauseTy *);
   bool applyClause(const tomp::clause::NowaitT &clause,
const ClauseTy *);
+  bool applyClause(const tomp::clause::OmpxBareT &clause,
+   const ClauseTy *);
   bool
   applyClause(const t

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-09 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/06

>From 4326796699c6c28859c9445965443fdac4626864 Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 4 Oct 2024 16:20:36 +0900
Subject: [PATCH 01/11] [flang] Add frontend support for OpenMP extension bare
 clause

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  4 
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  1 +
 flang/lib/Lower/OpenMP/Clauses.h  |  2 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp |  2 ++
 flang/lib/Parser/openmp-parsers.cpp   |  1 +
 .../Frontend/OpenMP/ConstructDecompositionT.h |  9 +++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  1 +
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 24 +++
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  3 ++-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  3 ++-
 10 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index cf91b2638aecc3..84bfc40d977ce8 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -350,6 +350,10 @@ bool 
ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
   return markClauseOccurrence(result.nowait);
 }
 
+bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const {
+  return markClauseOccurrence(result.bare);
+}
+
 bool ClauseProcessor::processNumTeams(
 lower::StatementContext &stmtCtx,
 mlir::omp::NumTeamsClauseOps &result) const {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index f34121c70d0b44..0ad411af2f369d 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -72,6 +72,7 @@ class ClauseProcessor {
   bool processHint(mlir::omp::HintClauseOps &result) const;
   bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
   bool processNowait(mlir::omp::NowaitClauseOps &result) const;
+  bool processBare(mlir::omp::BareClauseOps &result) const;
   bool processNumTeams(lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const;
   bool processNumThreads(lower::StatementContext &stmtCtx,
diff --git a/flang/lib/Lower/OpenMP/Clauses.h b/flang/lib/Lower/OpenMP/Clauses.h
index 62f3df3e3ee952..4c40dbf186ef93 100644
--- a/flang/lib/Lower/OpenMP/Clauses.h
+++ b/flang/lib/Lower/OpenMP/Clauses.h
@@ -229,8 +229,8 @@ using NumTasks = tomp::clause::NumTasksT;
 using NumTeams = tomp::clause::NumTeamsT;
 using NumThreads = tomp::clause::NumThreadsT;
 using OmpxAttribute = tomp::clause::OmpxAttributeT;
-using OmpxBare = tomp::clause::OmpxBareT;
 using OmpxDynCgroupMem = tomp::clause::OmpxDynCgroupMemT;
+using OmpxBare = tomp::clause::OmpxBareT;
 using Ordered = tomp::clause::OrderedT;
 using Order = tomp::clause::OrderT;
 using Partial = tomp::clause::PartialT;
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 0735e40ea2ca7e..ebc36180c8ede2 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1241,6 +1241,7 @@ static void genTargetClauses(
 cp.processNowait(clauseOps);
 
   cp.processThreadLimit(stmtCtx, clauseOps);
+  cp.processBare(clauseOps);
 
   cp.processTODO(
@@ -2780,6 +2781,7 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
+!std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u)) {
   TODO(clauseLocation, "OpenMP Block construct clause");
 }
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 214d6b4a91087b..fa014e0e9fae16 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -315,6 +315,7 @@ TYPE_PARSER(
parenthesized(scalarIntExpr))) ||
 "NUM_THREADS" >> construct(construct(
  parenthesized(scalarIntExpr))) ||
+"OMPX_BARE" >> construct(construct()) ||
 "ORDER" >> construct(construct(
parenthesized(Parser{}))) ||
 "ORDERED" >> construct(construct(
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h 
b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 4bdfa1cf4c1490..7c0dbe1aae1221 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -236,6 +236,8 @@ struct ConstructDecompositionT {
const ClauseTy *);
   bool applyClause(const tomp::clause::NowaitT &clause,
const ClauseTy *);
+  bool applyClause(const tomp::clause::OmpxBareT &clause,
+   const ClauseTy *);
   bool
   applyClause(const t

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-11 Thread Ivan R. Ivanov via cfe-commits

ivanradanov wrote:

@jdoerfert Could you have a quick look at the clang-side change if that is 
acceptable?

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


[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-11 Thread Ivan R. Ivanov via cfe-commits


@@ -1103,6 +1105,13 @@ bool ConstructDecompositionT::applyClause(
   return applyToOutermost(node);
 }
 
+template 
+bool ConstructDecompositionT::applyClause(
+const tomp::clause::OmpxBareT &clause,
+const ClauseTy *node) {
+  return applyToAll(node);

ivanradanov wrote:

We need to know whether ompx_bare was present, because the runtime _must_ run 
the target region with the number of threads and teams specified (instead of 
`thread_limit` and `num_teams` being just mere hints otherwise). So I think the 
easiest way to do that is to represent the clause in the dialect. I am fine 
with having in on either `omp.target` or `omp.teams` (or both) and which one we 
have it on only has minor implications on the op verification and translation 
implementation and does not matter much in my opinion, so having it on the 
`omp.target` should be fine in my opinion?

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


[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-11 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/06

>From 4326796699c6c28859c9445965443fdac4626864 Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 4 Oct 2024 16:20:36 +0900
Subject: [PATCH 01/12] [flang] Add frontend support for OpenMP extension bare
 clause

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  4 
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  1 +
 flang/lib/Lower/OpenMP/Clauses.h  |  2 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp |  2 ++
 flang/lib/Parser/openmp-parsers.cpp   |  1 +
 .../Frontend/OpenMP/ConstructDecompositionT.h |  9 +++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  1 +
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 24 +++
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  3 ++-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  3 ++-
 10 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index cf91b2638aecc3..84bfc40d977ce8 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -350,6 +350,10 @@ bool 
ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
   return markClauseOccurrence(result.nowait);
 }
 
+bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const {
+  return markClauseOccurrence(result.bare);
+}
+
 bool ClauseProcessor::processNumTeams(
 lower::StatementContext &stmtCtx,
 mlir::omp::NumTeamsClauseOps &result) const {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index f34121c70d0b44..0ad411af2f369d 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -72,6 +72,7 @@ class ClauseProcessor {
   bool processHint(mlir::omp::HintClauseOps &result) const;
   bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
   bool processNowait(mlir::omp::NowaitClauseOps &result) const;
+  bool processBare(mlir::omp::BareClauseOps &result) const;
   bool processNumTeams(lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const;
   bool processNumThreads(lower::StatementContext &stmtCtx,
diff --git a/flang/lib/Lower/OpenMP/Clauses.h b/flang/lib/Lower/OpenMP/Clauses.h
index 62f3df3e3ee952..4c40dbf186ef93 100644
--- a/flang/lib/Lower/OpenMP/Clauses.h
+++ b/flang/lib/Lower/OpenMP/Clauses.h
@@ -229,8 +229,8 @@ using NumTasks = tomp::clause::NumTasksT;
 using NumTeams = tomp::clause::NumTeamsT;
 using NumThreads = tomp::clause::NumThreadsT;
 using OmpxAttribute = tomp::clause::OmpxAttributeT;
-using OmpxBare = tomp::clause::OmpxBareT;
 using OmpxDynCgroupMem = tomp::clause::OmpxDynCgroupMemT;
+using OmpxBare = tomp::clause::OmpxBareT;
 using Ordered = tomp::clause::OrderedT;
 using Order = tomp::clause::OrderT;
 using Partial = tomp::clause::PartialT;
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 0735e40ea2ca7e..ebc36180c8ede2 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1241,6 +1241,7 @@ static void genTargetClauses(
 cp.processNowait(clauseOps);
 
   cp.processThreadLimit(stmtCtx, clauseOps);
+  cp.processBare(clauseOps);
 
   cp.processTODO(
@@ -2780,6 +2781,7 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
+!std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u)) {
   TODO(clauseLocation, "OpenMP Block construct clause");
 }
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 214d6b4a91087b..fa014e0e9fae16 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -315,6 +315,7 @@ TYPE_PARSER(
parenthesized(scalarIntExpr))) ||
 "NUM_THREADS" >> construct(construct(
  parenthesized(scalarIntExpr))) ||
+"OMPX_BARE" >> construct(construct()) ||
 "ORDER" >> construct(construct(
parenthesized(Parser{}))) ||
 "ORDERED" >> construct(construct(
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h 
b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 4bdfa1cf4c1490..7c0dbe1aae1221 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -236,6 +236,8 @@ struct ConstructDecompositionT {
const ClauseTy *);
   bool applyClause(const tomp::clause::NowaitT &clause,
const ClauseTy *);
+  bool applyClause(const tomp::clause::OmpxBareT &clause,
+   const ClauseTy *);
   bool
   applyClause(const t

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-11 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/06

>From e778fad3eafcd78924efd7aa233ac7ba9f4e6a49 Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 4 Oct 2024 16:20:36 +0900
Subject: [PATCH 01/12] [flang] Add frontend support for OpenMP extension bare
 clause

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  4 
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  1 +
 flang/lib/Lower/OpenMP/Clauses.h  |  2 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp |  2 ++
 flang/lib/Parser/openmp-parsers.cpp   |  1 +
 .../Frontend/OpenMP/ConstructDecompositionT.h |  9 +++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  1 +
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 24 +++
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  3 ++-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  3 ++-
 10 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index cf91b2638aecc3..84bfc40d977ce8 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -350,6 +350,10 @@ bool 
ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
   return markClauseOccurrence(result.nowait);
 }
 
+bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const {
+  return markClauseOccurrence(result.bare);
+}
+
 bool ClauseProcessor::processNumTeams(
 lower::StatementContext &stmtCtx,
 mlir::omp::NumTeamsClauseOps &result) const {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index f34121c70d0b44..0ad411af2f369d 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -72,6 +72,7 @@ class ClauseProcessor {
   bool processHint(mlir::omp::HintClauseOps &result) const;
   bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
   bool processNowait(mlir::omp::NowaitClauseOps &result) const;
+  bool processBare(mlir::omp::BareClauseOps &result) const;
   bool processNumTeams(lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const;
   bool processNumThreads(lower::StatementContext &stmtCtx,
diff --git a/flang/lib/Lower/OpenMP/Clauses.h b/flang/lib/Lower/OpenMP/Clauses.h
index 62f3df3e3ee952..4c40dbf186ef93 100644
--- a/flang/lib/Lower/OpenMP/Clauses.h
+++ b/flang/lib/Lower/OpenMP/Clauses.h
@@ -229,8 +229,8 @@ using NumTasks = tomp::clause::NumTasksT;
 using NumTeams = tomp::clause::NumTeamsT;
 using NumThreads = tomp::clause::NumThreadsT;
 using OmpxAttribute = tomp::clause::OmpxAttributeT;
-using OmpxBare = tomp::clause::OmpxBareT;
 using OmpxDynCgroupMem = tomp::clause::OmpxDynCgroupMemT;
+using OmpxBare = tomp::clause::OmpxBareT;
 using Ordered = tomp::clause::OrderedT;
 using Order = tomp::clause::OrderT;
 using Partial = tomp::clause::PartialT;
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index a89029b720e788..585b22fd7da502 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1241,6 +1241,7 @@ static void genTargetClauses(
 cp.processNowait(clauseOps);
 
   cp.processThreadLimit(stmtCtx, clauseOps);
+  cp.processBare(clauseOps);
 
   cp.processTODO(
@@ -2771,6 +2772,7 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
+!std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 214d6b4a91087b..fa014e0e9fae16 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -315,6 +315,7 @@ TYPE_PARSER(
parenthesized(scalarIntExpr))) ||
 "NUM_THREADS" >> construct(construct(
  parenthesized(scalarIntExpr))) ||
+"OMPX_BARE" >> construct(construct()) ||
 "ORDER" >> construct(construct(
parenthesized(Parser{}))) ||
 "ORDERED" >> construct(construct(
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h 
b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 4bdfa1cf4c1490..7c0dbe1aae1221 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -236,6 +236,8 @@ struct ConstructDecompositionT {
const ClauseTy *);
   bool applyClause(const tomp::clause::NowaitT &clause,
const ClauseTy *);
+  bool applyClause(const tomp::clause::OmpxBareT &clause,
+   const ClauseTy *);
   bool

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-11 Thread Ivan R. Ivanov via cfe-commits

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


[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-11 Thread Ivan R. Ivanov via cfe-commits

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


[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-12-11 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/06

>From 85e1b6d318a4f11630588f95f964be645d6ddb9b Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 4 Oct 2024 16:20:36 +0900
Subject: [PATCH 01/15] [flang] Add frontend support for OpenMP extension bare
 clause

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  4 
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  1 +
 flang/lib/Lower/OpenMP/Clauses.h  |  2 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp |  2 ++
 flang/lib/Parser/openmp-parsers.cpp   |  1 +
 .../Frontend/OpenMP/ConstructDecompositionT.h |  9 +++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  1 +
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 24 +++
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  3 ++-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  2 +-
 10 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 48c559a78b9bc4..99049cee3ff909 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -382,6 +382,10 @@ bool 
ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
   return markClauseOccurrence(result.nowait);
 }
 
+bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const {
+  return markClauseOccurrence(result.bare);
+}
+
 bool ClauseProcessor::processNumTeams(
 lower::StatementContext &stmtCtx,
 mlir::omp::NumTeamsClauseOps &result) const {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index e0fe917c50e8f8..c309da99263f13 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -73,6 +73,7 @@ class ClauseProcessor {
   bool processHint(mlir::omp::HintClauseOps &result) const;
   bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
   bool processNowait(mlir::omp::NowaitClauseOps &result) const;
+  bool processBare(mlir::omp::BareClauseOps &result) const;
   bool processNumTeams(lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const;
   bool processNumThreads(lower::StatementContext &stmtCtx,
diff --git a/flang/lib/Lower/OpenMP/Clauses.h b/flang/lib/Lower/OpenMP/Clauses.h
index 65282d243d87af..e447989446a0e8 100644
--- a/flang/lib/Lower/OpenMP/Clauses.h
+++ b/flang/lib/Lower/OpenMP/Clauses.h
@@ -253,8 +253,8 @@ using NumTasks = tomp::clause::NumTasksT;
 using NumTeams = tomp::clause::NumTeamsT;
 using NumThreads = tomp::clause::NumThreadsT;
 using OmpxAttribute = tomp::clause::OmpxAttributeT;
-using OmpxBare = tomp::clause::OmpxBareT;
 using OmpxDynCgroupMem = tomp::clause::OmpxDynCgroupMemT;
+using OmpxBare = tomp::clause::OmpxBareT;
 using Ordered = tomp::clause::OrderedT;
 using Order = tomp::clause::OrderT;
 using Partial = tomp::clause::PartialT;
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 2ef4d184a6321f..ffe5213961ef03 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1194,6 +1194,7 @@ static void genTargetClauses(
 cp.processNowait(clauseOps);
 
   cp.processThreadLimit(stmtCtx, clauseOps);
+  cp.processBare(clauseOps);
 
   cp.processTODO(
@@ -2858,6 +2859,7 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
+!std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 86d475c1a15422..bfd6be646a066d 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -597,6 +597,7 @@ TYPE_PARSER(
parenthesized(scalarIntExpr))) ||
 "NUM_THREADS" >> construct(construct(
  parenthesized(scalarIntExpr))) ||
+"OMPX_BARE" >> construct(construct()) ||
 "ORDER" >> construct(construct(
parenthesized(Parser{}))) ||
 "ORDERED" >> construct(construct(
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h 
b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 4bdfa1cf4c1490..7c0dbe1aae1221 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -236,6 +236,8 @@ struct ConstructDecompositionT {
const ClauseTy *);
   bool applyClause(const tomp::clause::NowaitT &clause,
const ClauseTy *);
+  bool applyClause(const tomp::clause::OmpxBareT &clause,
+   const ClauseTy *);
   bool

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-12-11 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/06

>From 85e1b6d318a4f11630588f95f964be645d6ddb9b Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 4 Oct 2024 16:20:36 +0900
Subject: [PATCH 01/16] [flang] Add frontend support for OpenMP extension bare
 clause

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  4 
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  1 +
 flang/lib/Lower/OpenMP/Clauses.h  |  2 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp |  2 ++
 flang/lib/Parser/openmp-parsers.cpp   |  1 +
 .../Frontend/OpenMP/ConstructDecompositionT.h |  9 +++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  1 +
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 24 +++
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  3 ++-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  2 +-
 10 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 48c559a78b9bc4..99049cee3ff909 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -382,6 +382,10 @@ bool 
ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
   return markClauseOccurrence(result.nowait);
 }
 
+bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const {
+  return markClauseOccurrence(result.bare);
+}
+
 bool ClauseProcessor::processNumTeams(
 lower::StatementContext &stmtCtx,
 mlir::omp::NumTeamsClauseOps &result) const {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index e0fe917c50e8f8..c309da99263f13 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -73,6 +73,7 @@ class ClauseProcessor {
   bool processHint(mlir::omp::HintClauseOps &result) const;
   bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
   bool processNowait(mlir::omp::NowaitClauseOps &result) const;
+  bool processBare(mlir::omp::BareClauseOps &result) const;
   bool processNumTeams(lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const;
   bool processNumThreads(lower::StatementContext &stmtCtx,
diff --git a/flang/lib/Lower/OpenMP/Clauses.h b/flang/lib/Lower/OpenMP/Clauses.h
index 65282d243d87af..e447989446a0e8 100644
--- a/flang/lib/Lower/OpenMP/Clauses.h
+++ b/flang/lib/Lower/OpenMP/Clauses.h
@@ -253,8 +253,8 @@ using NumTasks = tomp::clause::NumTasksT;
 using NumTeams = tomp::clause::NumTeamsT;
 using NumThreads = tomp::clause::NumThreadsT;
 using OmpxAttribute = tomp::clause::OmpxAttributeT;
-using OmpxBare = tomp::clause::OmpxBareT;
 using OmpxDynCgroupMem = tomp::clause::OmpxDynCgroupMemT;
+using OmpxBare = tomp::clause::OmpxBareT;
 using Ordered = tomp::clause::OrderedT;
 using Order = tomp::clause::OrderT;
 using Partial = tomp::clause::PartialT;
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 2ef4d184a6321f..ffe5213961ef03 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1194,6 +1194,7 @@ static void genTargetClauses(
 cp.processNowait(clauseOps);
 
   cp.processThreadLimit(stmtCtx, clauseOps);
+  cp.processBare(clauseOps);
 
   cp.processTODO(
@@ -2858,6 +2859,7 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
+!std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 86d475c1a15422..bfd6be646a066d 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -597,6 +597,7 @@ TYPE_PARSER(
parenthesized(scalarIntExpr))) ||
 "NUM_THREADS" >> construct(construct(
  parenthesized(scalarIntExpr))) ||
+"OMPX_BARE" >> construct(construct()) ||
 "ORDER" >> construct(construct(
parenthesized(Parser{}))) ||
 "ORDERED" >> construct(construct(
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h 
b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 4bdfa1cf4c1490..7c0dbe1aae1221 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -236,6 +236,8 @@ struct ConstructDecompositionT {
const ClauseTy *);
   bool applyClause(const tomp::clause::NowaitT &clause,
const ClauseTy *);
+  bool applyClause(const tomp::clause::OmpxBareT &clause,
+   const ClauseTy *);
   bool

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-12-11 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/06

>From e778fad3eafcd78924efd7aa233ac7ba9f4e6a49 Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 4 Oct 2024 16:20:36 +0900
Subject: [PATCH 01/14] [flang] Add frontend support for OpenMP extension bare
 clause

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  4 
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  1 +
 flang/lib/Lower/OpenMP/Clauses.h  |  2 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp |  2 ++
 flang/lib/Parser/openmp-parsers.cpp   |  1 +
 .../Frontend/OpenMP/ConstructDecompositionT.h |  9 +++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  1 +
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 24 +++
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  3 ++-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  3 ++-
 10 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index cf91b2638aecc3..84bfc40d977ce8 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -350,6 +350,10 @@ bool 
ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
   return markClauseOccurrence(result.nowait);
 }
 
+bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const {
+  return markClauseOccurrence(result.bare);
+}
+
 bool ClauseProcessor::processNumTeams(
 lower::StatementContext &stmtCtx,
 mlir::omp::NumTeamsClauseOps &result) const {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index f34121c70d0b44..0ad411af2f369d 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -72,6 +72,7 @@ class ClauseProcessor {
   bool processHint(mlir::omp::HintClauseOps &result) const;
   bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
   bool processNowait(mlir::omp::NowaitClauseOps &result) const;
+  bool processBare(mlir::omp::BareClauseOps &result) const;
   bool processNumTeams(lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const;
   bool processNumThreads(lower::StatementContext &stmtCtx,
diff --git a/flang/lib/Lower/OpenMP/Clauses.h b/flang/lib/Lower/OpenMP/Clauses.h
index 62f3df3e3ee952..4c40dbf186ef93 100644
--- a/flang/lib/Lower/OpenMP/Clauses.h
+++ b/flang/lib/Lower/OpenMP/Clauses.h
@@ -229,8 +229,8 @@ using NumTasks = tomp::clause::NumTasksT;
 using NumTeams = tomp::clause::NumTeamsT;
 using NumThreads = tomp::clause::NumThreadsT;
 using OmpxAttribute = tomp::clause::OmpxAttributeT;
-using OmpxBare = tomp::clause::OmpxBareT;
 using OmpxDynCgroupMem = tomp::clause::OmpxDynCgroupMemT;
+using OmpxBare = tomp::clause::OmpxBareT;
 using Ordered = tomp::clause::OrderedT;
 using Order = tomp::clause::OrderT;
 using Partial = tomp::clause::PartialT;
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index a89029b720e788..585b22fd7da502 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1241,6 +1241,7 @@ static void genTargetClauses(
 cp.processNowait(clauseOps);
 
   cp.processThreadLimit(stmtCtx, clauseOps);
+  cp.processBare(clauseOps);
 
   cp.processTODO(
@@ -2771,6 +2772,7 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
+!std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 214d6b4a91087b..fa014e0e9fae16 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -315,6 +315,7 @@ TYPE_PARSER(
parenthesized(scalarIntExpr))) ||
 "NUM_THREADS" >> construct(construct(
  parenthesized(scalarIntExpr))) ||
+"OMPX_BARE" >> construct(construct()) ||
 "ORDER" >> construct(construct(
parenthesized(Parser{}))) ||
 "ORDERED" >> construct(construct(
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h 
b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 4bdfa1cf4c1490..7c0dbe1aae1221 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -236,6 +236,8 @@ struct ConstructDecompositionT {
const ClauseTy *);
   bool applyClause(const tomp::clause::NowaitT &clause,
const ClauseTy *);
+  bool applyClause(const tomp::clause::OmpxBareT &clause,
+   const ClauseTy *);
   bool

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-12-11 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/06

>From 85e1b6d318a4f11630588f95f964be645d6ddb9b Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 4 Oct 2024 16:20:36 +0900
Subject: [PATCH 01/16] [flang] Add frontend support for OpenMP extension bare
 clause

---
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  4 
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  1 +
 flang/lib/Lower/OpenMP/Clauses.h  |  2 +-
 flang/lib/Lower/OpenMP/OpenMP.cpp |  2 ++
 flang/lib/Parser/openmp-parsers.cpp   |  1 +
 .../Frontend/OpenMP/ConstructDecompositionT.h |  9 +++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  1 +
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 24 +++
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  3 ++-
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  |  2 +-
 10 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 48c559a78b9bc4..99049cee3ff909 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -382,6 +382,10 @@ bool 
ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
   return markClauseOccurrence(result.nowait);
 }
 
+bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const {
+  return markClauseOccurrence(result.bare);
+}
+
 bool ClauseProcessor::processNumTeams(
 lower::StatementContext &stmtCtx,
 mlir::omp::NumTeamsClauseOps &result) const {
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index e0fe917c50e8f8..c309da99263f13 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -73,6 +73,7 @@ class ClauseProcessor {
   bool processHint(mlir::omp::HintClauseOps &result) const;
   bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
   bool processNowait(mlir::omp::NowaitClauseOps &result) const;
+  bool processBare(mlir::omp::BareClauseOps &result) const;
   bool processNumTeams(lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const;
   bool processNumThreads(lower::StatementContext &stmtCtx,
diff --git a/flang/lib/Lower/OpenMP/Clauses.h b/flang/lib/Lower/OpenMP/Clauses.h
index 65282d243d87af..e447989446a0e8 100644
--- a/flang/lib/Lower/OpenMP/Clauses.h
+++ b/flang/lib/Lower/OpenMP/Clauses.h
@@ -253,8 +253,8 @@ using NumTasks = tomp::clause::NumTasksT;
 using NumTeams = tomp::clause::NumTeamsT;
 using NumThreads = tomp::clause::NumThreadsT;
 using OmpxAttribute = tomp::clause::OmpxAttributeT;
-using OmpxBare = tomp::clause::OmpxBareT;
 using OmpxDynCgroupMem = tomp::clause::OmpxDynCgroupMemT;
+using OmpxBare = tomp::clause::OmpxBareT;
 using Ordered = tomp::clause::OrderedT;
 using Order = tomp::clause::OrderT;
 using Partial = tomp::clause::PartialT;
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 2ef4d184a6321f..ffe5213961ef03 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1194,6 +1194,7 @@ static void genTargetClauses(
 cp.processNowait(clauseOps);
 
   cp.processThreadLimit(stmtCtx, clauseOps);
+  cp.processBare(clauseOps);
 
   cp.processTODO(
@@ -2858,6 +2859,7 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
+!std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
diff --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index 86d475c1a15422..bfd6be646a066d 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -597,6 +597,7 @@ TYPE_PARSER(
parenthesized(scalarIntExpr))) ||
 "NUM_THREADS" >> construct(construct(
  parenthesized(scalarIntExpr))) ||
+"OMPX_BARE" >> construct(construct()) ||
 "ORDER" >> construct(construct(
parenthesized(Parser{}))) ||
 "ORDERED" >> construct(construct(
diff --git a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h 
b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
index 4bdfa1cf4c1490..7c0dbe1aae1221 100644
--- a/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
+++ b/llvm/include/llvm/Frontend/OpenMP/ConstructDecompositionT.h
@@ -236,6 +236,8 @@ struct ConstructDecompositionT {
const ClauseTy *);
   bool applyClause(const tomp::clause::NowaitT &clause,
const ClauseTy *);
+  bool applyClause(const tomp::clause::OmpxBareT &clause,
+   const ClauseTy *);
   bool

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-12-13 Thread Ivan R. Ivanov via cfe-commits

https://github.com/ivanradanov updated 
https://github.com/llvm/llvm-project/pull/06

>From 4ac56a8ee42881f8abf60e69eb5ffdeb447fe910 Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov 
Date: Fri, 4 Oct 2024 16:20:36 +0900
Subject: [PATCH] [flang] Add frontend support for OpenMP extension bare clause

Fix ompx_bare printing

Add test

test

Order

Only accept ompx_bare on a combined "TARGET TEAMS" construct

Alphabetical ordering

Fail in the backend if we find ompx_bare

Fix test

Fix `omp target` error in clang

Add one more test

Fix rebase error

%openmp_flags is only available when omprt is built

Update mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Co-authored-by: Sergio Afonso 

Address review comments

fix rebase

Remove stray include
---
 clang/lib/Parse/ParseOpenMP.cpp   | 10 +++
 flang/lib/Lower/OpenMP/ClauseProcessor.cpp|  4 +++
 flang/lib/Lower/OpenMP/ClauseProcessor.h  |  1 +
 flang/lib/Lower/OpenMP/OpenMP.cpp |  2 ++
 flang/lib/Parser/openmp-parsers.cpp   |  1 +
 flang/lib/Semantics/check-omp-structure.cpp   | 12 +++-
 .../OpenMP/KernelLanguage/bare-clause.f90 | 10 +++
 flang/test/Semantics/OpenMP/ompx-bare.f90 | 30 +++
 .../Frontend/OpenMP/ConstructDecompositionT.h |  9 ++
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  1 +
 .../mlir/Dialect/OpenMP/OpenMPClauses.td  | 26 
 mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td |  9 +++---
 mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp  | 14 -
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  |  5 
 14 files changed, 122 insertions(+), 12 deletions(-)
 create mode 100644 flang/test/Lower/OpenMP/KernelLanguage/bare-clause.f90
 create mode 100644 flang/test/Semantics/OpenMP/ompx-bare.f90

diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index b91928063169ee3..b4e973bc84a7b0a 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -3474,6 +3474,16 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind 
DKind,
 Clause = ParseOpenMPOMPXAttributesClause(WrongDirective);
 break;
   case OMPC_ompx_bare:
+if (DKind == llvm::omp::Directive::OMPD_target) {
+  // Flang splits the combined directives which requires OMPD_target to be
+  // marked as accepting the `ompx_bare` clause in `OMP.td`. Thus, we need
+  // to explicitly check whether this clause is applied to an `omp target`
+  // without `teams` and emit an error.
+  Diag(Tok, diag::err_omp_unexpected_clause)
+  << getOpenMPClauseName(CKind) << getOpenMPDirectiveName(DKind);
+  ErrorFound = true;
+  WrongDirective = true;
+}
 if (WrongDirective)
   Diag(Tok, diag::note_ompx_bare_clause)
   << getOpenMPClauseName(CKind) << "target teams";
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp 
b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 48c559a78b9bc4f..3c9831120351ee8 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -220,6 +220,10 @@ static void convertLoopBounds(lower::AbstractConverter 
&converter,
 // ClauseProcessor unique clauses
 
//===--===//
 
+bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const {
+  return markClauseOccurrence(result.bare);
+}
+
 bool ClauseProcessor::processBind(mlir::omp::BindClauseOps &result) const {
   if (auto *clause = findUniqueClause()) {
 fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h 
b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index e0fe917c50e8f8b..3942c54e6e935dc 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -53,6 +53,7 @@ class ClauseProcessor {
   : converter(converter), semaCtx(semaCtx), clauses(clauses) {}
 
   // 'Unique' clauses: They can appear at most once in the clause list.
+  bool processBare(mlir::omp::BareClauseOps &result) const;
   bool processBind(mlir::omp::BindClauseOps &result) const;
   bool
   processCollapse(mlir::Location currentLocation, lower::pft::Evaluation &eval,
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index c167d347b43159a..f30d2687682c8df 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1184,6 +1184,7 @@ static void genTargetClauses(
 llvm::SmallVectorImpl &isDevicePtrSyms,
 llvm::SmallVectorImpl &mapSyms) {
   ClauseProcessor cp(converter, semaCtx, clauses);
+  cp.processBare(clauseOps);
   cp.processDepend(clauseOps);
   cp.processDevice(stmtCtx, clauseOps);
   cp.processHasDeviceAddr(clauseOps, hasDeviceAddrSyms);
@@ -2860,6 +2861,7 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
 !std::holds_alternative(clause.u) &&
 !std::holds_alternative(clause.u) &&
  

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-12-13 Thread Ivan R. Ivanov via cfe-commits

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