Debian Codegraph @

flang/lib/Lower/OpenMP/Utils.h

raw
1 //===-- Lower/OpenMP/Utils.h ------------------------------------*- 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 #ifndef FORTRAN_LOWER_OPENMPUTILS_H
10 #define FORTRAN_LOWER_OPENMPUTILS_H
11
12 #include "Clauses.h"
13 #include "mlir/Dialect/OpenMP/OpenMPDialect.h"
14 #include "mlir/IR/Location.h"
15 #include "mlir/IR/Value.h"
16 #include "llvm/Support/CommandLine.h"
17
18 extern llvm::cl::opt<bool> treatIndexAsSection;
19 extern llvm::cl::opt<bool> enableDelayedPrivatization;
20 extern llvm::cl::opt<bool> enableDelayedPrivatizationStaging;
21
22 namespace fir {
23 class FirOpBuilder;
24 } // namespace fir
25 namespace Fortran {
26
27 namespace semantics {
28 class Symbol;
29 } // namespace semantics
30
31 namespace parser {
32 struct OmpObject;
33 struct OmpObjectList;
34 } // namespace parser
35
36 namespace lower {
37 namespace pft {
38 struct Evaluation;
39 }
40
41 class AbstractConverter;
42
43 namespace omp {
44
45 using DeclareTargetCapturePair =
46 std::pair<mlir::omp::DeclareTargetCaptureClause, const semantics::Symbol &>;
47
48 // A small helper structure for keeping track of a component members MapInfoOp
49 // and index data when lowering OpenMP map clauses. Keeps track of the
50 // placement of the component in the derived type hierarchy it rests within,
51 // alongside the generated mlir::omp::MapInfoOp for the mapped component.
52 struct OmpMapMemberIndicesData {
53 // The indices representing the component members placement in its derived
54 // type parents hierarchy.
55 llvm::SmallVector<int> memberPlacementIndices;
56
57 // Placement of the member in the member vector.
58 mlir::omp::MapInfoOp memberMap;
59 };
60
61 mlir::omp::MapInfoOp
62 createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc,
63 mlir::Value baseAddr, mlir::Value varPtrPtr, std::string name,
64 mlir::ArrayRef<mlir::Value> bounds,
65 mlir::ArrayRef<mlir::Value> members,
66 mlir::DenseIntElementsAttr membersIndex, uint64_t mapType,
67 mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy,
68 bool partialMap = false);
69
70 void addChildIndexAndMapToParent(
71 const omp::Object &object,
72 std::map<const semantics::Symbol *,
73 llvm::SmallVector<OmpMapMemberIndicesData>> &parentMemberIndices,
74 mlir::omp::MapInfoOp &mapOp, semantics::SemanticsContext &semaCtx);
75
76 void insertChildMapInfoIntoParent(
77 lower::AbstractConverter &converter,
78 std::map<const semantics::Symbol *,
79 llvm::SmallVector<OmpMapMemberIndicesData>> &parentMemberIndices,
80 llvm::SmallVectorImpl<mlir::Value> &mapOperands,
81 llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
82 llvm::SmallVectorImpl<mlir::Type> *mapSymTypes,
83 llvm::SmallVectorImpl<mlir::Location> *mapSymLocs);
84
85 mlir::Type getLoopVarType(lower::AbstractConverter &converter,
86 std::size_t loopVarTypeSize);
87
88 semantics::Symbol *
89 getIterationVariableSymbol(const lower::pft::Evaluation &eval);
90
91 void gatherFuncAndVarSyms(
92 const ObjectList &objects, mlir::omp::DeclareTargetCaptureClause clause,
93 llvm::SmallVectorImpl<DeclareTargetCapturePair> &symbolAndClause);
94
95 int64_t getCollapseValue(const List<Clause> &clauses);
96
97 semantics::Symbol *getOmpObjectSymbol(const parser::OmpObject &ompObject);
98
99 void genObjectList(const ObjectList &objects,
100 lower::AbstractConverter &converter,
101 llvm::SmallVectorImpl<mlir::Value> &operands);
102
103 } // namespace omp
104 } // namespace lower
105 } // namespace Fortran
106
107 #endif // FORTRAN_LOWER_OPENMPUTILS_H