|
11 | 11 | //===----------------------------------------------------------------------===//
|
12 | 12 |
|
13 | 13 | #include "Utils.h"
|
14 |
| -#include "Clauses.h" |
15 | 14 |
|
| 15 | +#include "Clauses.h" |
16 | 16 | #include <flang/Lower/AbstractConverter.h>
|
17 | 17 | #include <flang/Lower/ConvertType.h>
|
| 18 | +#include <flang/Lower/PFTBuilder.h> |
18 | 19 | #include <flang/Optimizer/Builder/FIRBuilder.h>
|
19 | 20 | #include <flang/Parser/parse-tree.h>
|
20 | 21 | #include <flang/Parser/tools.h>
|
@@ -47,6 +48,12 @@ int64_t getCollapseValue(const List<Clause> &clauses) {
|
47 | 48 | return 1;
|
48 | 49 | }
|
49 | 50 |
|
| 51 | +uint32_t getOpenMPVersion(mlir::ModuleOp mod) { |
| 52 | + if (mlir::Attribute verAttr = mod->getAttr("omp.version")) |
| 53 | + return llvm::cast<mlir::omp::VersionAttr>(verAttr).getVersion(); |
| 54 | + llvm_unreachable("Expecting OpenMP version attribute in module"); |
| 55 | +} |
| 56 | + |
50 | 57 | void genObjectList(const ObjectList &objects,
|
51 | 58 | Fortran::lower::AbstractConverter &converter,
|
52 | 59 | llvm::SmallVectorImpl<mlir::Value> &operands) {
|
@@ -81,6 +88,27 @@ mlir::Type getLoopVarType(Fortran::lower::AbstractConverter &converter,
|
81 | 88 | return converter.getFirOpBuilder().getIntegerType(loopVarTypeSize);
|
82 | 89 | }
|
83 | 90 |
|
| 91 | +Fortran::semantics::Symbol * |
| 92 | +getIterationVariableSymbol(const Fortran::lower::pft::Evaluation &eval) { |
| 93 | + return eval.visit(Fortran::common::visitors{ |
| 94 | + [&](const Fortran::parser::DoConstruct &doLoop) { |
| 95 | + if (const auto &maybeCtrl = doLoop.GetLoopControl()) { |
| 96 | + using LoopControl = Fortran::parser::LoopControl; |
| 97 | + if (auto *bounds = std::get_if<LoopControl::Bounds>(&maybeCtrl->u)) { |
| 98 | + static_assert( |
| 99 | + std::is_same_v<decltype(bounds->name), |
| 100 | + Fortran::parser::Scalar<Fortran::parser::Name>>); |
| 101 | + return bounds->name.thing.symbol; |
| 102 | + } |
| 103 | + } |
| 104 | + return static_cast<Fortran::semantics::Symbol *>(nullptr); |
| 105 | + }, |
| 106 | + [](auto &&) { |
| 107 | + return static_cast<Fortran::semantics::Symbol *>(nullptr); |
| 108 | + }, |
| 109 | + }); |
| 110 | +} |
| 111 | + |
84 | 112 | void gatherFuncAndVarSyms(
|
85 | 113 | const ObjectList &objects, mlir::omp::DeclareTargetCaptureClause clause,
|
86 | 114 | llvm::SmallVectorImpl<DeclareTargetCapturePair> &symbolAndClause) {
|
|
0 commit comments