FLANG
FIROpenACCOpsInterfaces.h
1//===- FIROpenACCOpsInterfaces.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 operation interfaces for FIR.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef FLANG_OPTIMIZER_OPENACC_FIROPENACC_OPS_INTERFACES_H_
14#define FLANG_OPTIMIZER_OPENACC_FIROPENACC_OPS_INTERFACES_H_
15
16#include "flang/Optimizer/Dialect/FIROperationMoveOpInterface.h"
17#include "mlir/Dialect/OpenACC/OpenACC.h"
18
19namespace fir {
20class AddrOfOp;
21class DeclareOp;
22class GlobalOp;
23} // namespace fir
24
25namespace hlfir {
26class DeclareOp;
27class DesignateOp;
28} // namespace hlfir
29
30namespace fir::acc {
31
32template <typename Op>
34 : public mlir::acc::PartialEntityAccessOpInterface::ExternalModel<
35 PartialEntityAccessModel<Op>, Op> {
36 mlir::Value getBaseEntity(mlir::Operation *op) const;
37
38 // Default implementation - returns false (partial view)
39 bool isCompleteView(mlir::Operation *op) const { return false; }
40};
41
42// Full specializations for declare operations
43template <>
44struct PartialEntityAccessModel<fir::DeclareOp>
45 : public mlir::acc::PartialEntityAccessOpInterface::ExternalModel<
46 PartialEntityAccessModel<fir::DeclareOp>, fir::DeclareOp> {
47 mlir::Value getBaseEntity(mlir::Operation *op) const;
48 bool isCompleteView(mlir::Operation *op) const;
49};
50
51template <>
52struct PartialEntityAccessModel<hlfir::DeclareOp>
53 : public mlir::acc::PartialEntityAccessOpInterface::ExternalModel<
54 PartialEntityAccessModel<hlfir::DeclareOp>, hlfir::DeclareOp> {
55 mlir::Value getBaseEntity(mlir::Operation *op) const;
56 bool isCompleteView(mlir::Operation *op) const;
57};
58
60 : public mlir::acc::AddressOfGlobalOpInterface::ExternalModel<
61 AddressOfGlobalModel, fir::AddrOfOp> {
62 mlir::SymbolRefAttr getSymbol(mlir::Operation *op) const;
63};
64
66 : public mlir::acc::GlobalVariableOpInterface::ExternalModel<
67 GlobalVariableModel, fir::GlobalOp> {
68 bool isConstant(mlir::Operation *op) const;
69 mlir::Region *getInitRegion(mlir::Operation *op) const;
70 bool isDeviceData(mlir::Operation *op) const;
71};
72
73template <typename Op>
75 : public mlir::acc::IndirectGlobalAccessOpInterface::ExternalModel<
76 IndirectGlobalAccessModel<Op>, Op> {
77 void getReferencedSymbols(mlir::Operation *op,
78 llvm::SmallVectorImpl<mlir::SymbolRefAttr> &symbols,
79 mlir::SymbolTable *symbolTable) const;
80};
81
86template <typename Op>
88 : public mlir::acc::OutlineRematerializationOpInterface::ExternalModel<
89 OutlineRematerializationModel<Op>, Op> {};
90
94template <typename Op>
96 : public mlir::acc::OffloadRegionOpInterface::ExternalModel<
97 OffloadRegionModel<Op>, Op> {};
98
103template <typename Op>
104struct OperationMoveModel : public fir::OperationMoveOpInterface::ExternalModel<
105 OperationMoveModel<Op>, Op> {
106 // Returns true if it is allowed to move the given 'candidate'
107 // operation from the 'descendant' operation into 'op' operation.
108 // If 'candidate' is nullptr, then the caller is querying whether
109 // any operation from any descendant can be moved into 'op' operation.
110 bool canMoveFromDescendant(mlir::Operation *op, mlir::Operation *descendant,
111 mlir::Operation *candidate) const;
112
113 // Returns true if it is allowed to move the given 'candidate'
114 // operation out of 'op' operation. If 'candidate' is nullptr,
115 // then the caller is querying whether any operation can be moved
116 // out of 'op' operation.
117 bool canMoveOutOf(mlir::Operation *op, mlir::Operation *candidate) const;
118};
119
120} // namespace fir::acc
121
122#endif // FLANG_OPTIMIZER_OPENACC_FIROPENACC_OPS_INTERFACES_H_
Definition AbstractConverter.h:37
Definition FIROpenACCOpsInterfaces.h:61
Definition FIROpenACCOpsInterfaces.h:67
Definition FIROpenACCOpsInterfaces.h:76
Definition FIROpenACCOpsInterfaces.h:97
Definition FIROpenACCOpsInterfaces.h:105
Definition FIROpenACCOpsInterfaces.h:89
Definition FIROpenACCOpsInterfaces.h:35