Warning: This file is not a C or C++ file. It does not have highlighting.

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>
20class SmallVector;
21class StringRef;
22}
23
24namespace mlir {
25class Location;
26class Type;
27class ModuleOp;
28class OpBuilder;
29class Value;
30} // namespace mlir
31
32namespace fir {
33class FirOpBuilder;
34}
35
36namespace Fortran {
37namespace parser {
38struct AccClauseList;
39struct OpenACCConstruct;
40struct OpenACCDeclarativeConstruct;
41struct OpenACCRoutineConstruct;
42} // namespace parser
43
44namespace semantics {
45class SemanticsContext;
46class Symbol;
47}
48
49namespace lower {
50
51class AbstractConverter;
52class StatementContext;
53
54namespace pft {
55struct Evaluation;
56} // namespace pft
57
58using AccRoutineInfoMappingList =
59 llvm::SmallVector<std::pair<std::string, mlir::SymbolRefAttr>>;
60
61static constexpr llvm::StringRef declarePostAllocSuffix =
62 "_acc_declare_update_desc_post_alloc";
63static constexpr llvm::StringRef declarePreDeallocSuffix =
64 "_acc_declare_update_desc_pre_dealloc";
65static constexpr llvm::StringRef declarePostDeallocSuffix =
66 "_acc_declare_update_desc_post_dealloc";
67
68static constexpr llvm::StringRef privatizationRecipePrefix = "privatization";
69
70mlir::Value genOpenACCConstruct(AbstractConverter &,
71 Fortran::semantics::SemanticsContext &,
72 pft::Evaluation &,
73 const parser::OpenACCConstruct &);
74void genOpenACCDeclarativeConstruct(AbstractConverter &,
75 Fortran::semantics::SemanticsContext &,
76 StatementContext &,
77 const parser::OpenACCDeclarativeConstruct &,
78 AccRoutineInfoMappingList &);
79void genOpenACCRoutineConstruct(AbstractConverter &,
80 Fortran::semantics::SemanticsContext &,
81 mlir::ModuleOp &,
82 const parser::OpenACCRoutineConstruct &,
83 AccRoutineInfoMappingList &);
84
85void finalizeOpenACCRoutineAttachment(mlir::ModuleOp &,
86 AccRoutineInfoMappingList &);
87
88/// Get a acc.private.recipe op for the given type or create it if it does not
89/// exist yet.
90mlir::acc::PrivateRecipeOp createOrGetPrivateRecipe(mlir::OpBuilder &,
91 llvm::StringRef,
92 mlir::Location, mlir::Type);
93
94/// Get a acc.reduction.recipe op for the given type or create it if it does not
95/// exist yet.
96mlir::acc::ReductionRecipeOp
97createOrGetReductionRecipe(fir::FirOpBuilder &, llvm::StringRef, mlir::Location,
98 mlir::Type, mlir::acc::ReductionOperator,
99 llvm::SmallVector<mlir::Value> &);
100
101/// Get a acc.firstprivate.recipe op for the given type or create it if it does
102/// not exist yet.
103mlir::acc::FirstprivateRecipeOp
104createOrGetFirstprivateRecipe(mlir::OpBuilder &, llvm::StringRef,
105 mlir::Location, mlir::Type,
106 llvm::SmallVector<mlir::Value> &);
107
108void attachDeclarePostAllocAction(AbstractConverter &, fir::FirOpBuilder &,
109 const Fortran::semantics::Symbol &);
110void attachDeclarePreDeallocAction(AbstractConverter &, fir::FirOpBuilder &,
111 mlir::Value beginOpValue,
112 const Fortran::semantics::Symbol &);
113void attachDeclarePostDeallocAction(AbstractConverter &, fir::FirOpBuilder &,
114 const Fortran::semantics::Symbol &);
115
116void genOpenACCTerminator(fir::FirOpBuilder &, mlir::Operation *,
117 mlir::Location);
118
119int64_t getCollapseValue(const Fortran::parser::AccClauseList &);
120
121bool isInOpenACCLoop(fir::FirOpBuilder &);
122
123void setInsertionPointAfterOpenACCLoopIfInside(fir::FirOpBuilder &);
124
125void genEarlyReturnInOpenACCLoop(fir::FirOpBuilder &, mlir::Location);
126
127} // namespace lower
128} // namespace Fortran
129
130#endif // FORTRAN_LOWER_OPENACC_H
131

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of flang/include/flang/Lower/OpenACC.h