FLANG
FIROpenACCTypeInterfaces.h
1//===- FIROpenACCTypeInterfaces.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// This file contains external dialect interfaces for FIR.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef FLANG_OPTIMIZER_OPENACC_FIROPENACCTYPEINTERFACES_H_
14#define FLANG_OPTIMIZER_OPENACC_FIROPENACCTYPEINTERFACES_H_
15
16#include "flang/Optimizer/Dialect/FIRType.h"
17#include "mlir/Dialect/OpenACC/OpenACC.h"
18
19namespace fir::acc {
20
21template <typename T>
23 : public mlir::acc::PointerLikeType::ExternalModel<
24 OpenACCPointerLikeModel<T>, T> {
25 mlir::Type getElementType(mlir::Type pointer) const {
26 return mlir::cast<T>(pointer).getElementType();
27 }
28 mlir::acc::VariableTypeCategory
29 getPointeeTypeCategory(mlir::Type pointer,
30 mlir::TypedValue<mlir::acc::PointerLikeType> varPtr,
31 mlir::Type varType) const;
32
33 mlir::Value genAllocate(mlir::Type pointer, mlir::OpBuilder &builder,
34 mlir::Location loc, llvm::StringRef varName,
35 mlir::Type varType, mlir::Value originalVar,
36 bool &needsFree) const;
37
38 bool genFree(mlir::Type pointer, mlir::OpBuilder &builder, mlir::Location loc,
39 mlir::TypedValue<mlir::acc::PointerLikeType> varToFree,
40 mlir::Value allocRes, mlir::Type varType) const;
41
42 bool genCopy(mlir::Type pointer, mlir::OpBuilder &builder, mlir::Location loc,
43 mlir::TypedValue<mlir::acc::PointerLikeType> destination,
44 mlir::TypedValue<mlir::acc::PointerLikeType> source,
45 mlir::Type varType) const;
46};
47
48template <typename T>
50 : public mlir::acc::MappableType::ExternalModel<OpenACCMappableModel<T>,
51 T> {
52 mlir::TypedValue<mlir::acc::PointerLikeType> getVarPtr(::mlir::Type type,
53 mlir::Value var) const;
54
55 std::optional<llvm::TypeSize>
56 getSizeInBytes(mlir::Type type, mlir::Value var, mlir::ValueRange accBounds,
57 const mlir::DataLayout &dataLayout) const;
58
59 std::optional<int64_t>
60 getOffsetInBytes(mlir::Type type, mlir::Value var, mlir::ValueRange accBounds,
61 const mlir::DataLayout &dataLayout) const;
62
63 bool hasUnknownDimensions(mlir::Type type) const;
64
66 generateAccBounds(mlir::Type type, mlir::Value var,
67 mlir::OpBuilder &builder) const;
68
69 mlir::acc::VariableTypeCategory getTypeCategory(mlir::Type type,
70 mlir::Value var) const;
71
72 mlir::Value generatePrivateInit(mlir::Type type, mlir::OpBuilder &builder,
73 mlir::Location loc,
74 mlir::TypedValue<mlir::acc::MappableType> var,
75 llvm::StringRef varName,
76 mlir::ValueRange extents, mlir::Value initVal,
77 bool &needsDestroy) const;
78
79 bool generatePrivateDestroy(mlir::Type type, mlir::OpBuilder &builder,
80 mlir::Location loc, mlir::Value privatized) const;
81};
82
83} // namespace fir::acc
84
85#endif // FLANG_OPTIMIZER_OPENACC_FIROPENACCTYPEINTERFACES_H_
Definition OpenACC.h:20
Definition FIROpenACCTypeInterfaces.h:51
Definition FIROpenACCTypeInterfaces.h:24