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
92createOrGetPrivateRecipe(fir::FirOpBuilder &, llvm::StringRef, mlir::Location,
93 mlir::Type,
94 llvm::SmallVector<mlir::Value> &dataOperationBounds);
95
98mlir::acc::ReductionRecipeOp
99createOrGetReductionRecipe(fir::FirOpBuilder &, llvm::StringRef, mlir::Location,
100 mlir::Type, mlir::acc::ReductionOperator,
101 llvm::SmallVector<mlir::Value> &dataOperationBounds);
102
105mlir::acc::FirstprivateRecipeOp createOrGetFirstprivateRecipe(
106 fir::FirOpBuilder &, llvm::StringRef, mlir::Location, mlir::Type,
107 llvm::SmallVector<mlir::Value> &dataOperationBounds);
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:87
Definition StatementContext.h:46
Definition SymbolMap.h:182
Definition semantics.h:67
Definition symbol.h:809
Definition FIRBuilder.h:55
Definition OpenACC.h:20
Definition call.h:34
Definition ParserActions.h:24
mlir::acc::PrivateRecipeOp createOrGetPrivateRecipe(fir::FirOpBuilder &, llvm::StringRef, mlir::Location, mlir::Type, llvm::SmallVector< mlir::Value > &dataOperationBounds)
Definition OpenACC.cpp:1345
uint64_t getLoopCountForCollapseAndTile(const Fortran::parser::AccClauseList &)
Definition OpenACC.cpp:4883
bool isInsideOpenACCComputeConstruct(fir::FirOpBuilder &)
Definition OpenACC.cpp:4863
std::pair< uint64_t, bool > getCollapseSizeAndForce(const Fortran::parser::AccClauseList &)
Definition OpenACC.cpp:4897
mlir::Operation * genOpenACCLoopFromDoConstruct(AbstractConverter &converter, Fortran::semantics::SemanticsContext &semanticsContext, Fortran::lower::SymMap &localSymbols, const Fortran::parser::DoConstruct &doConstruct, pft::Evaluation &eval)
Definition OpenACC.cpp:4918
mlir::acc::ReductionRecipeOp createOrGetReductionRecipe(fir::FirOpBuilder &, llvm::StringRef, mlir::Location, mlir::Type, mlir::acc::ReductionOperator, llvm::SmallVector< mlir::Value > &dataOperationBounds)
Definition OpenACC.cpp:1439
mlir::acc::FirstprivateRecipeOp createOrGetFirstprivateRecipe(fir::FirOpBuilder &, llvm::StringRef, mlir::Location, mlir::Type, llvm::SmallVector< mlir::Value > &dataOperationBounds)
Definition OpenACC.cpp:1379
bool isInOpenACCLoop(fir::FirOpBuilder &)
Checks whether the current insertion point is inside OpenACC loop.
Definition OpenACC.cpp:4857
Definition check-expression.h:19
Definition bit-population-count.h:20
Definition AbstractConverter.h:37
Definition AbstractConverter.h:32
Definition PFTBuilder.h:221
Definition parse-tree.h:5612
Definition parse-tree.h:2326
Definition parse-tree.h:5755
Definition parse-tree.h:5617