1 | //===-- FIROpenACCAttributes.cpp ------------------------------------------===// |
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 | /// \file |
9 | /// This file implements attribute interfaces that are promised by FIR |
10 | /// dialect attributes related to OpenACC. |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #include "flang/Optimizer/Builder/FIRBuilder.h" |
14 | #include "flang/Optimizer/Builder/Todo.h" |
15 | #include "flang/Optimizer/Dialect/FIRAttr.h" |
16 | #include "flang/Optimizer/Dialect/FIRDialect.h" |
17 | #include "mlir/Dialect/OpenACC/OpenACC.h" |
18 | |
19 | namespace fir::acc { |
20 | class FortranSafeTempArrayCopyAttrImpl |
21 | : public fir::SafeTempArrayCopyAttrInterface::FallbackModel< |
22 | FortranSafeTempArrayCopyAttrImpl> { |
23 | public: |
24 | // SafeTempArrayCopyAttrInterface interface methods. |
25 | static bool isDynamicallySafe() { return false; } |
26 | static mlir::Value genDynamicCheck(mlir::Location loc, |
27 | fir::FirOpBuilder &builder, |
28 | mlir::Value array) { |
29 | TODO(loc, "fir::acc::FortranSafeTempArrayCopyAttrImpl::genDynamicCheck()" ); |
30 | return nullptr; |
31 | } |
32 | static void registerTempDeallocation(mlir::Location loc, |
33 | fir::FirOpBuilder &builder, |
34 | mlir::Value array, mlir::Value temp) { |
35 | TODO(loc, "fir::acc::FortranSafeTempArrayCopyAttrImpl::" |
36 | "registerTempDeallocation()" ); |
37 | } |
38 | |
39 | // Extra helper methods. |
40 | |
41 | /// Attach the implementation to fir::OpenACCSafeTempArrayCopyAttr. |
42 | static void registerExternalModel(mlir::DialectRegistry ®istry); |
43 | |
44 | /// If the methods above create any new operations, this method |
45 | /// must register all the corresponding dialect. |
46 | static void getDependentDialects(mlir::DialectRegistry ®istry) {} |
47 | }; |
48 | |
49 | void FortranSafeTempArrayCopyAttrImpl::registerExternalModel( |
50 | mlir::DialectRegistry ®istry) { |
51 | registry.addExtension( |
52 | +[](mlir::MLIRContext *ctx, fir::FIROpsDialect *dialect) { |
53 | fir::OpenACCSafeTempArrayCopyAttr::attachInterface< |
54 | FortranSafeTempArrayCopyAttrImpl>(*ctx); |
55 | }); |
56 | } |
57 | |
58 | void registerAttrsExtensions(mlir::DialectRegistry ®istry) { |
59 | FortranSafeTempArrayCopyAttrImpl::registerExternalModel(registry); |
60 | } |
61 | |
62 | void registerTransformationalAttrsDependentDialects( |
63 | mlir::DialectRegistry ®istry) { |
64 | FortranSafeTempArrayCopyAttrImpl::getDependentDialects(registry); |
65 | } |
66 | |
67 | } // namespace fir::acc |
68 | |