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>
21template <typename T>
23class StringRef;
24} // namespace llvm
25
26namespace mlir {
27namespace func {
28class FuncOp;
29} // namespace func
30class Location;
31class Type;
32class ModuleOp;
33class OpBuilder;
34class Value;
35} // namespace mlir
36
37namespace fir {
38class FirOpBuilder;
39} // namespace fir
40
41namespace Fortran {
42namespace evaluate {
44} // namespace evaluate
45
46namespace parser {
47struct AccClauseList;
48struct DoConstruct;
49struct OpenACCConstruct;
52} // namespace parser
53
54namespace semantics {
57class Symbol;
58} // namespace semantics
59
60namespace lower {
61
64class SymMap;
65
66namespace pft {
67struct Evaluation;
68} // namespace pft
69
70static constexpr llvm::StringRef declarePostAllocSuffix =
71 "_acc_declare_post_alloc";
72static constexpr llvm::StringRef declarePreDeallocSuffix =
73 "_acc_declare_pre_dealloc";
74static constexpr llvm::StringRef declarePostDeallocSuffix =
75 "_acc_declare_post_dealloc";
76
77static constexpr llvm::StringRef privatizationRecipePrefix = "privatization";
78
79mlir::Value genOpenACCConstruct(AbstractConverter &,
80 Fortran::semantics::SemanticsContext &,
82 const parser::OpenACCConstruct &,
83 Fortran::lower::SymMap &localSymbols);
84void genOpenACCDeclarativeConstruct(
85 AbstractConverter &, Fortran::semantics::SemanticsContext &,
86 StatementContext &, const parser::OpenACCDeclarativeConstruct &);
87void genOpenACCRoutineConstruct(
88 AbstractConverter &, mlir::ModuleOp, mlir::func::FuncOp,
89 const std::vector<Fortran::semantics::OpenACCRoutineInfo> &);
90
91void declareExternalAccModuleDeclareActionRecipes(
92 AbstractConverter &, fir::FirOpBuilder &,
93 const Fortran::semantics::Symbol &);
94
99
100void attachDeclarePostAllocAction(AbstractConverter &, fir::FirOpBuilder &,
101 const Fortran::semantics::Symbol &);
102void attachDeclarePreDeallocAction(AbstractConverter &, fir::FirOpBuilder &,
103 mlir::Value beginOpValue,
104 const Fortran::semantics::Symbol &);
105void attachDeclarePostDeallocAction(AbstractConverter &, fir::FirOpBuilder &,
106 const Fortran::semantics::Symbol &);
107
108void genOpenACCTerminator(fir::FirOpBuilder &, mlir::Operation *,
109 mlir::Location);
110
114uint64_t getLoopCountForCollapseAndTile(const Fortran::parser::AccClauseList &);
115
118std::pair<uint64_t, bool>
119getCollapseSizeAndForce(const Fortran::parser::AccClauseList &);
120
122bool isInOpenACCLoop(fir::FirOpBuilder &);
123
126void markDoConstructAsCollapsed(const Fortran::parser::DoConstruct &);
127
129bool isCollapsedDoConstruct(const Fortran::parser::DoConstruct &);
130
133
141 pft::Evaluation &eval,
142 llvm::SmallVectorImpl<pft::Evaluation *> *skipped = nullptr);
143
146bool isInsideOpenACCComputeConstruct(fir::FirOpBuilder &);
147
150bool isInsideOpenACCRoutine(fir::FirOpBuilder &);
151
154bool shouldLowerDoConstructAsAccLoop(fir::FirOpBuilder &);
155
156void setInsertionPointAfterOpenACCLoopIfInside(fir::FirOpBuilder &);
157
158void genEarlyReturnInOpenACCLoop(fir::FirOpBuilder &, mlir::Location);
159
165bool genOpenACCRegionExitBranch(fir::FirOpBuilder &, mlir::Location,
166 mlir::Block *targetBlock);
167
172mlir::Operation *genOpenACCLoopFromDoConstruct(
173 AbstractConverter &converter,
174 Fortran::semantics::SemanticsContext &semanticsContext,
175 Fortran::lower::SymMap &localSymbols,
176 const Fortran::parser::DoConstruct &doConstruct, pft::Evaluation &eval);
177
178} // namespace lower
179} // namespace Fortran
180
181#endif // FORTRAN_LOWER_OPENACC_H
Definition AbstractConverter.h:87
Definition StatementContext.h:46
Definition SymbolMap.h:181
Definition semantics.h:67
Definition symbol.h:916
Definition FIRBuilder.h:66
Definition OpenACC.h:22
Definition OpenACC.h:20
Definition call.h:34
Definition ParserActions.h:24
pft::Evaluation * findNestedDoConstructEvaluation(pft::Evaluation &eval, llvm::SmallVectorImpl< pft::Evaluation * > *skipped=nullptr)
Definition OpenACC.cpp:5501
uint64_t getLoopCountForCollapseAndTile(const Fortran::parser::AccClauseList &)
Definition OpenACC.cpp:5592
bool isInsideOpenACCRoutine(fir::FirOpBuilder &)
Definition OpenACC.cpp:5521
bool isInsideOpenACCComputeConstruct(fir::FirOpBuilder &)
Definition OpenACC.cpp:5515
void materializeOpenACCRoutineBindTargets(AbstractConverter &, mlir::ModuleOp)
Definition OpenACC.cpp:4964
bool isCollapsedDoConstruct(const Fortran::parser::DoConstruct &)
Check whether a DoConstruct was absorbed by a collapse clause.
Definition OpenACC.cpp:5491
std::pair< uint64_t, bool > getCollapseSizeAndForce(const Fortran::parser::AccClauseList &)
Definition OpenACC.cpp:5606
bool genOpenACCRegionExitBranch(fir::FirOpBuilder &, mlir::Location, mlir::Block *targetBlock)
Definition OpenACC.cpp:5563
void clearCollapsedDoConstructs()
Clear the collapsed DoConstruct tracking set.
Definition OpenACC.cpp:5496
void markDoConstructAsCollapsed(const Fortran::parser::DoConstruct &)
Definition OpenACC.cpp:5486
mlir::Operation * genOpenACCLoopFromDoConstruct(AbstractConverter &converter, Fortran::semantics::SemanticsContext &semanticsContext, Fortran::lower::SymMap &localSymbols, const Fortran::parser::DoConstruct &doConstruct, pft::Evaluation &eval)
Definition OpenACC.cpp:5627
bool shouldLowerDoConstructAsAccLoop(fir::FirOpBuilder &)
Definition OpenACC.cpp:5543
bool isInOpenACCLoop(fir::FirOpBuilder &)
Checks whether the current insertion point is inside OpenACC loop.
Definition OpenACC.cpp:5477
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:5852
Definition parse-tree.h:2379
Definition parse-tree.h:5995
Definition parse-tree.h:5857