[flang-commits] [flang] [llvm] [flang][OpenMP] Decompose compound constructs, do recursive lowering (PR #90098)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Mon May 6 16:58:48 PDT 2024
================
@@ -0,0 +1,1002 @@
+//===- ConstructDecompositionT.h -- Decomposing compound constructs -------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+// Given a compound construct with a set of clauses, generate the list of
+// constituent leaf constructs, each with a list of clauses that apply to it.
+//
+// Note: Clauses that are not originally present, but that are implied by the
+// OpenMP spec are materialized, and are present in the output.
+//
+// Note: Composite constructs will also be broken up into leaf constructs.
+// If composite constructs require processing as a whole, the lists of clauses
+// for each leaf constituent should be concatenated.
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_FRONTEND_OPENMP_CONSTRUCTDECOMPOSITIONT_H
+#define LLVM_FRONTEND_OPENMP_CONSTRUCTDECOMPOSITIONT_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Frontend/OpenMP/ClauseT.h"
+#include "llvm/Frontend/OpenMP/OMP.h"
+
+#include <iterator>
+#include <list>
+#include <optional>
+#include <tuple>
+#include <type_traits>
+#include <utility>
+#include <variant>
+
+static inline llvm::ArrayRef<llvm::omp::Directive> getWorksharing() {
+ static llvm::omp::Directive worksharing[] = {
+ llvm::omp::Directive::OMPD_do, llvm::omp::Directive::OMPD_for,
+ llvm::omp::Directive::OMPD_scope, llvm::omp::Directive::OMPD_sections,
+ llvm::omp::Directive::OMPD_single, llvm::omp::Directive::OMPD_workshare,
+ };
+ return worksharing;
+}
+
+static inline llvm::ArrayRef<llvm::omp::Directive> getWorksharingLoop() {
+ static llvm::omp::Directive worksharingLoop[] = {
+ llvm::omp::Directive::OMPD_do,
+ llvm::omp::Directive::OMPD_for,
+ };
+ return worksharingLoop;
+}
+
+namespace detail {
+template <typename Container, typename Predicate>
+typename std::remove_reference_t<Container>::iterator
+find_unique(Container &&container, Predicate &&pred) {
+ auto first = std::find_if(container.begin(), container.end(), pred);
+ if (first == container.end())
+ return first;
+ auto second = std::find_if(std::next(first), container.end(), pred);
+ if (second == container.end())
+ return first;
+ return container.end();
+}
+} // namespace detail
+
+namespace tomp {
+
+template <typename ClauseType> struct DirectiveWithClauses {
+ llvm::omp::Directive id = llvm::omp::Directive::OMPD_unknown;
+ tomp::type::ListT<ClauseType> clauses;
+};
+
+template <typename ClauseType, typename HelperType>
----------------
kparzysz wrote:
Done.
Yes, this is a class that does language-specific things that this code can't do on its own.
https://github.com/llvm/llvm-project/pull/90098
More information about the flang-commits
mailing list