FLANG
FIROpenACCUtils.h
1//===- FIROpenACCUtils.h - FIR OpenACC Utilities ----------------*- 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// This file declares utility functions for FIR OpenACC support.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef FORTRAN_OPTIMIZER_OPENACC_SUPPORT_FIROPENACCUTILS_H
14#define FORTRAN_OPTIMIZER_OPENACC_SUPPORT_FIROPENACCUTILS_H
15
16#include "mlir/Dialect/OpenACC/OpenACC.h"
17#include "mlir/IR/Builders.h"
18#include "mlir/IR/Operation.h"
19#include "mlir/IR/Region.h"
20#include "mlir/IR/Value.h"
21#include <string>
22
23namespace fir {
24namespace acc {
25
35std::string getVariableName(mlir::Value v, bool preferDemangledName = true);
36
49std::string getRecipeName(mlir::acc::RecipeKind kind, mlir::Type type,
50 mlir::Value var = nullptr,
51 llvm::ArrayRef<mlir::Value> bounds = {},
52 mlir::acc::ReductionOperator reductionOp =
53 mlir::acc::ReductionOperator::AccNone);
54
58bool areAllBoundsConstant(llvm::ArrayRef<mlir::Value> bounds);
59
66mlir::SymbolRefAttr
67createOrGetPrivateRecipe(mlir::OpBuilder &builder, mlir::Location loc,
68 mlir::Value var,
69 llvm::SmallVector<mlir::Value> &dataBoundOps);
70
77mlir::SymbolRefAttr
78createOrGetFirstprivateRecipe(mlir::OpBuilder &builder, mlir::Location loc,
79 mlir::Value var,
80 llvm::SmallVector<mlir::Value> &dataBoundOps);
81
90mlir::SymbolRefAttr
91createOrGetReductionRecipe(mlir::OpBuilder &builder, mlir::Location loc,
92 mlir::Value var, mlir::acc::ReductionOperator op,
93 llvm::SmallVector<mlir::Value> &dataBoundOps,
94 mlir::Attribute fastMathAttr = {});
95
104mlir::Value getOriginalDef(mlir::Value value, bool stripDeclare = true);
105
109bool isValidSymbolUse(mlir::Operation *user, mlir::SymbolRefAttr symbol,
110 mlir::Operation **definingOpPtr = nullptr);
111
114bool isValidValueUse(mlir::Value val, mlir::Region &region);
115
116} // namespace acc
117} // namespace fir
118
119#endif // FORTRAN_OPTIMIZER_OPENACC_SUPPORT_FIROPENACCUTILS_H
Definition AbstractConverter.h:37