FLANG
OpenMP.h
1//===-- Lower/OpenMP.h -- lower Open MP directives --------------*- C++ -*-===//
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//
9// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef FORTRAN_LOWER_OPENMP_H
14#define FORTRAN_LOWER_OPENMP_H
15
16#include "llvm/ADT/SmallVector.h"
17#include "llvm/ADT/StringRef.h"
18
19#include <cinttypes>
20
21namespace mlir {
22class Operation;
23class Location;
24class Type;
25namespace omp {
26enum class DeclareTargetDeviceType : uint32_t;
27enum class DeclareTargetCaptureClause : uint32_t;
28} // namespace omp
29} // namespace mlir
30
31namespace fir {
32class FirOpBuilder;
33} // namespace fir
34
35namespace Fortran {
36namespace parser {
37struct OpenMPConstruct;
39struct OmpClauseList;
40} // namespace parser
41
42namespace semantics {
43class Symbol;
44class Scope;
46} // namespace semantics
47
48namespace lower {
49
51class SymMap;
52
53namespace pft {
54struct Evaluation;
55struct Variable;
56} // namespace pft
57
59 mlir::omp::DeclareTargetCaptureClause declareTargetCaptureClause;
60 mlir::omp::DeclareTargetDeviceType declareTargetDeviceType;
61 bool automap = false;
63};
64
65// Generate the OpenMP terminator for Operation at Location.
66mlir::Operation *genOpenMPTerminator(fir::FirOpBuilder &, mlir::Operation *,
67 mlir::Location);
68
69void genOpenMPConstruct(AbstractConverter &, Fortran::lower::SymMap &,
72void genOpenMPDeclarativeConstruct(AbstractConverter &,
82 const pft::Variable &var);
83
84void genGroupprivateOp(AbstractConverter &, const pft::Variable &);
85void genThreadprivateOp(AbstractConverter &, const pft::Variable &);
86void genDeclareTargetIntGlobal(AbstractConverter &, const pft::Variable &);
87bool isOpenMPTargetConstruct(const parser::OpenMPConstruct &);
88bool isOpenMPDeviceDeclareTarget(Fortran::lower::AbstractConverter &,
92void gatherOpenMPDeferredDeclareTargets(
96 llvm::SmallVectorImpl<OMPDeferredDeclareTargetInfo> &);
97bool markOpenMPDeferredDeclareTargetFunctions(
98 mlir::Operation *, llvm::SmallVectorImpl<OMPDeferredDeclareTargetInfo> &,
100void genOpenMPRequires(mlir::Operation *, const Fortran::semantics::Symbol *);
101
102// Materialize omp.declare_mapper ops for mapper declarations found in
103// imported modules. If \p scope is null, materialize for the whole
104// semantics global scope; otherwise, operate recursively starting at \p scope.
105void materializeOpenMPDeclareMappers(
107 const Fortran::semantics::Scope *scope = nullptr);
108
109namespace omp {
114resolveDeclareVariantCallee(const Fortran::semantics::Symbol &base,
115 AbstractConverter &converter);
116} // namespace omp
117
118// Materialize (idempotently) the omp.declare_reduction op for one already-
119// resolved imported user reduction and one requested element type, at module
120// scope, for separate compilation. Only the per-type instance whose scoped op
121// name equals \p requestedOpName is emitted, so a multi-type declaration's
122// other listed types (and any unsupported sibling type) are left alone. No-op
123// if the requested type's shape is not lowerable (a combiner-in-clause form or
124// an unsupported element type) or the op already exists. Safe to call
125// mid-function (uses createDeclareReductionHelper's InsertionGuard). \p
126// isByRef selects the by-ref/by-value naming variant used by the clause.
127void materializeUserReduction(
129 const Fortran::semantics::Symbol &resolvedReduction,
130 llvm::StringRef requestedOpName, mlir::Type requestedType, bool isByRef);
131
132} // namespace lower
133} // namespace Fortran
134
135#endif // FORTRAN_LOWER_OPENMP_H
Definition AbstractConverter.h:87
Definition SymbolMap.h:181
Definition scope.h:68
Definition semantics.h:67
Definition symbol.h:896
Definition FIRBuilder.h:59
Definition ParserActions.h:24
void genOpenMPSymbolProperties(AbstractConverter &converter, const pft::Variable &var)
Definition OpenMP.cpp:6830
Definition check-expression.h:19
Definition bit-population-count.h:20
Definition AbstractConverter.h:37
Definition AbstractConverter.h:32
Definition PFTBuilder.h:221
Definition PFTBuilder.h:417
Definition parse-tree.h:5159
Definition parse-tree.h:5553