1 //===-- Decomposer.h -- Compound directive decomposition ------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 #ifndef FORTRAN_LOWER_OPENMP_DECOMPOSER_H 9 #define FORTRAN_LOWER_OPENMP_DECOMPOSER_H 10 11 #include "Clauses.h" 12 #include "mlir/IR/BuiltinOps.h" 13 #include "llvm/Frontend/OpenMP/ConstructDecompositionT.h" 14 #include "llvm/Frontend/OpenMP/OMP.h" 15 #include "llvm/Support/Compiler.h" 16 17 namespace llvm { 18 class raw_ostream; 19 } 20 21 namespace Fortran { 22 namespace semantics { 23 class SemanticsContext; 24 } 25 namespace lower::pft { 26 struct Evaluation; 27 } 28 } // namespace Fortran 29 30 namespace Fortran::lower::omp { 31 using UnitConstruct = tomp::DirectiveWithClauses<lower::omp::Clause>; 32 using ConstructQueue = List<UnitConstruct>; 33 34 LLVM_DUMP_METHOD llvm::raw_ostream &operator<<(llvm::raw_ostream &os, 35 const UnitConstruct &uc); 36 37 // Given a potentially compound construct with a list of clauses that 38 // apply to it, break it up into individual sub-constructs each with 39 // the subset of applicable clauses (plus implicit clauses, if any). 40 // From that create a work queue where each work item corresponds to 41 // the sub-construct with its clauses. 42 ConstructQueue buildConstructQueue(mlir::ModuleOp modOp, 43 semantics::SemanticsContext &semaCtx, 44 lower::pft::Evaluation &eval, 45 const parser::CharBlock &source, 46 llvm::omp::Directive compound, 47 const List<Clause> &clauses); 48 49 bool isLastItemInQueue(ConstructQueue::const_iterator item, 50 const ConstructQueue &queue); 51 52 /// Try to match the leaf constructs conforming the given \c directive to the 53 /// range of leaf constructs starting from \c item to the end of the \c queue. 54 /// If \c directive doesn't represent a compound directive, check that \c item 55 /// matches that directive and is the only element before the end of the 56 /// \c queue. 57 bool matchLeafSequence(ConstructQueue::const_iterator item, 58 const ConstructQueue &queue, 59 llvm::omp::Directive directive); 60 } // namespace Fortran::lower::omp 61 62 #endif // FORTRAN_LOWER_OPENMP_DECOMPOSER_H 63