FLANG
OpenACC.h
1//===-- Lower/OpenACC.h -- lower OpenACC 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_OPENACC_H
14#define FORTRAN_LOWER_OPENACC_H
15
16#include "mlir/Dialect/OpenACC/OpenACC.h"
17
18namespace llvm {
19template <typename T, unsigned N>
21class StringRef;
22} // namespace llvm
23
24namespace mlir {
25namespace func {
26class FuncOp;
27} // namespace func
28class Location;
29class Type;
30class ModuleOp;
31class OpBuilder;
32class Value;
33} // namespace mlir
34
35namespace fir {
36class FirOpBuilder;
37} // namespace fir
38
39namespace Fortran {
40namespace evaluate {
42} // namespace evaluate
43
44namespace parser {
45struct AccClauseList;
46struct DoConstruct;
47struct OpenACCConstruct;
50} // namespace parser
51
52namespace semantics {
55class Symbol;
56} // namespace semantics
57
58namespace lower {
59
62class SymMap;
63
64namespace pft {
65struct Evaluation;
66} // namespace pft
67
68static constexpr llvm::StringRef declarePostAllocSuffix =
69 "_acc_declare_post_alloc";
70static constexpr llvm::StringRef declarePreDeallocSuffix =
71 "_acc_declare_pre_dealloc";
72static constexpr llvm::StringRef declarePostDeallocSuffix =
73 "_acc_declare_post_dealloc";
74
75static constexpr llvm::StringRef privatizationRecipePrefix = "privatization";
76
77mlir::Value genOpenACCConstruct(AbstractConverter &,
78 Fortran::semantics::SemanticsContext &,
80 const parser::OpenACCConstruct &,
81 Fortran::lower::SymMap &localSymbols);
82void genOpenACCDeclarativeConstruct(
83 AbstractConverter &, Fortran::semantics::SemanticsContext &,
84 StatementContext &, const parser::OpenACCDeclarativeConstruct &);
85void genOpenACCRoutineConstruct(
86 AbstractConverter &, mlir::ModuleOp, mlir::func::FuncOp,
87 const std::vector<Fortran::semantics::OpenACCRoutineInfo> &);
88
91mlir::acc::PrivateRecipeOp createOrGetPrivateRecipe(fir::FirOpBuilder &,
92 llvm::StringRef,
93 mlir::Location, mlir::Type);
94
97mlir::acc::ReductionRecipeOp
98createOrGetReductionRecipe(fir::FirOpBuilder &, llvm::StringRef, mlir::Location,
99 mlir::Type, mlir::acc::ReductionOperator,
100 llvm::SmallVector<mlir::Value> &);
101
104mlir::acc::FirstprivateRecipeOp
105createOrGetFirstprivateRecipe(fir::FirOpBuilder &, llvm::StringRef,
106 mlir::Location, mlir::Type,
107 llvm::SmallVector<mlir::Value> &);
108
109void attachDeclarePostAllocAction(AbstractConverter &, fir::FirOpBuilder &,
110 const Fortran::semantics::Symbol &);
111void attachDeclarePreDeallocAction(AbstractConverter &, fir::FirOpBuilder &,
112 mlir::Value beginOpValue,
113 const Fortran::semantics::Symbol &);
114void attachDeclarePostDeallocAction(AbstractConverter &, fir::FirOpBuilder &,
115 const Fortran::semantics::Symbol &);
116
117void genOpenACCTerminator(fir::FirOpBuilder &, mlir::Operation *,
118 mlir::Location);
119
123uint64_t getLoopCountForCollapseAndTile(const Fortran::parser::AccClauseList &);
124
127std::pair<uint64_t, bool>
128getCollapseSizeAndForce(const Fortran::parser::AccClauseList &);
129
131bool isInOpenACCLoop(fir::FirOpBuilder &);
132
135bool isInsideOpenACCComputeConstruct(fir::FirOpBuilder &);
136
137void setInsertionPointAfterOpenACCLoopIfInside(fir::FirOpBuilder &);
138
139void genEarlyReturnInOpenACCLoop(fir::FirOpBuilder &, mlir::Location);
140
145mlir::Operation *genOpenACCLoopFromDoConstruct(
146 AbstractConverter &converter,
147 Fortran::semantics::SemanticsContext &semanticsContext,
148 Fortran::lower::SymMap &localSymbols,
149 const Fortran::parser::DoConstruct &doConstruct, pft::Evaluation &eval);
150
151} // namespace lower
152} // namespace Fortran
153
154#endif // FORTRAN_LOWER_OPENACC_H
Definition AbstractConverter.h:85
Definition StatementContext.h:46
Definition SymbolMap.h:146
Definition semantics.h:67
Definition symbol.h:791
Definition FIRBuilder.h:55
Definition OpenACC.h:20
Definition call.h:34
Definition ParserActions.h:24
uint64_t getLoopCountForCollapseAndTile(const Fortran::parser::AccClauseList &)
Definition OpenACC.cpp:5248
bool isInsideOpenACCComputeConstruct(fir::FirOpBuilder &)
Definition OpenACC.cpp:5228
mlir::acc::FirstprivateRecipeOp createOrGetFirstprivateRecipe(fir::FirOpBuilder &, llvm::StringRef, mlir::Location, mlir::Type, llvm::SmallVector< mlir::Value > &)
Definition OpenACC.cpp:1265
std::pair< uint64_t, bool > getCollapseSizeAndForce(const Fortran::parser::AccClauseList &)
Definition OpenACC.cpp:5262
mlir::Operation * genOpenACCLoopFromDoConstruct(AbstractConverter &converter, Fortran::semantics::SemanticsContext &semanticsContext, Fortran::lower::SymMap &localSymbols, const Fortran::parser::DoConstruct &doConstruct, pft::Evaluation &eval)
Definition OpenACC.cpp:5283
mlir::acc::ReductionRecipeOp createOrGetReductionRecipe(fir::FirOpBuilder &, llvm::StringRef, mlir::Location, mlir::Type, mlir::acc::ReductionOperator, llvm::SmallVector< mlir::Value > &)
Definition OpenACC.cpp:1813
mlir::acc::PrivateRecipeOp createOrGetPrivateRecipe(fir::FirOpBuilder &, llvm::StringRef, mlir::Location, mlir::Type)
Definition OpenACC.cpp:1136
bool isInOpenACCLoop(fir::FirOpBuilder &)
Checks whether the current insertion point is inside OpenACC loop.
Definition OpenACC.cpp:5222
Definition check-expression.h:19
Definition bit-population-count.h:20
Definition AbstractConverter.h:34
Definition AbstractConverter.h:29
Definition PFTBuilder.h:221
Definition parse-tree.h:5432
Definition parse-tree.h:2340
Definition parse-tree.h:5575
Definition parse-tree.h:5437