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;
25class Value;
26class OpBuilder;
27namespace omp {
28enum class DeclareTargetDeviceType : uint32_t;
29enum class DeclareTargetCaptureClause : uint32_t;
30} // namespace omp
31} // namespace mlir
32
33namespace fir {
34class FirOpBuilder;
35} // namespace fir
36
37namespace Fortran {
38namespace evaluate {
39class ProcedureRef;
40} // namespace evaluate
41
42namespace parser {
43struct OpenMPConstruct;
45struct OmpClauseList;
46} // namespace parser
47
48namespace semantics {
49class Symbol;
50class Scope;
52} // namespace semantics
53
54namespace lower {
55
57class SymMap;
58
59namespace pft {
60struct Evaluation;
61struct Variable;
62} // namespace pft
63
65 mlir::omp::DeclareTargetCaptureClause declareTargetCaptureClause;
66 mlir::omp::DeclareTargetDeviceType declareTargetDeviceType;
67 bool automap = false;
69};
70
71// Generate the OpenMP terminator for Operation at Location.
72mlir::Operation *genOpenMPTerminator(fir::FirOpBuilder &, mlir::Operation *,
73 mlir::Location);
74
75void genOpenMPConstruct(AbstractConverter &, Fortran::lower::SymMap &,
78void genOpenMPDeclarativeConstruct(AbstractConverter &,
88 const pft::Variable &var);
89
90void genGroupprivateOp(AbstractConverter &, const pft::Variable &);
91void genThreadprivateOp(AbstractConverter &, const pft::Variable &);
92void genDeclareTargetIntGlobal(AbstractConverter &, const pft::Variable &);
93bool isOpenMPTargetConstruct(const parser::OpenMPConstruct &);
94bool isOpenMPDeviceDeclareTarget(Fortran::lower::AbstractConverter &,
98void gatherOpenMPDeferredDeclareTargets(
103bool markOpenMPDeferredDeclareTargetFunctions(
106void genOpenMPRequires(mlir::Operation *, const Fortran::semantics::Symbol *);
107
108// Materialize omp.declare_mapper ops for mapper declarations found in
109// imported modules. If \p scope is null, materialize for the whole
110// semantics global scope; otherwise, operate recursively starting at \p scope.
111void materializeOpenMPDeclareMappers(
113 const Fortran::semantics::Scope *scope = nullptr);
114
115// Mark declare target globals and functions that were imported from a
116// module file.
117void markOpenMPImportedDeclareTargets(
120
121namespace omp {
122bool isDispatchTargetCall(const Fortran::evaluate::ProcedureRef &proc,
123 AbstractConverter &converter);
124
131resolveDeclareVariantCallee(const Fortran::semantics::Symbol &base,
132 AbstractConverter &converter,
133 bool excludeDispatchContext = false);
134
137mlir::Value getEnclosingDispatchNovariants(mlir::OpBuilder &builder);
138
141mlir::Value getEnclosingDispatchNocontext(mlir::OpBuilder &builder);
142} // namespace omp
143
144// Materialize (idempotently) the omp.declare_reduction op for one already-
145// resolved imported user reduction and one requested element type, at module
146// scope, for separate compilation. Only the per-type instance whose scoped op
147// name equals \p requestedOpName is emitted, so a multi-type declaration's
148// other listed types (and any unsupported sibling type) are left alone. No-op
149// if the requested type's shape is not lowerable (a combiner-in-clause form or
150// an unsupported element type) or the op already exists. Safe to call
151// mid-function (uses createDeclareReductionHelper's InsertionGuard). \p
152// isByRef selects the by-ref/by-value naming variant used by the clause.
153void materializeUserReduction(
155 const Fortran::semantics::Symbol &resolvedReduction,
156 llvm::StringRef requestedOpName, mlir::Type requestedType, bool isByRef);
157
158} // namespace lower
159} // namespace Fortran
160
161#endif // FORTRAN_LOWER_OPENMP_H
Definition call.h:348
Definition AbstractConverter.h:87
Definition SymbolMap.h:181
Definition scope.h:69
Definition semantics.h:71
Definition symbol.h:918
Definition FIRBuilder.h:66
Definition OpenACC.h:22
Definition call.h:34
Definition ParserActions.h:24
void genOpenMPSymbolProperties(AbstractConverter &converter, const pft::Variable &var)
Definition OpenMP.cpp:8664
Definition check-expression.h:19
Definition bit-population-count.h:20
Definition AbstractConverter.h:37
Definition AbstractConverter.h:32
Definition PFTBuilder.h:222
Definition PFTBuilder.h:469
Definition parse-tree.h:5287
Definition parse-tree.h:5681