|
| 1 | +//===-- FIROpenACCOpsInterfaces.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 | +// |
| 9 | +// Implementation of external operation interfaces for FIR. |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +#include "flang/Optimizer/OpenACC/Support/FIROpenACCOpsInterfaces.h" |
| 14 | + |
| 15 | +#include "flang/Optimizer/Dialect/FIROps.h" |
| 16 | +#include "flang/Optimizer/HLFIR/HLFIROps.h" |
| 17 | + |
| 18 | +namespace fir::acc { |
| 19 | + |
| 20 | +template <> |
| 21 | +mlir::Value PartialEntityAccessModel<fir::ArrayCoorOp>::getBaseEntity( |
| 22 | + mlir::Operation *op) const { |
| 23 | + return mlir::cast<fir::ArrayCoorOp>(op).getMemref(); |
| 24 | +} |
| 25 | + |
| 26 | +template <> |
| 27 | +mlir::Value PartialEntityAccessModel<fir::CoordinateOp>::getBaseEntity( |
| 28 | + mlir::Operation *op) const { |
| 29 | + return mlir::cast<fir::CoordinateOp>(op).getRef(); |
| 30 | +} |
| 31 | + |
| 32 | +template <> |
| 33 | +mlir::Value PartialEntityAccessModel<hlfir::DesignateOp>::getBaseEntity( |
| 34 | + mlir::Operation *op) const { |
| 35 | + return mlir::cast<hlfir::DesignateOp>(op).getMemref(); |
| 36 | +} |
| 37 | + |
| 38 | +mlir::Value PartialEntityAccessModel<fir::DeclareOp>::getBaseEntity( |
| 39 | + mlir::Operation *op) const { |
| 40 | + return mlir::cast<fir::DeclareOp>(op).getStorage(); |
| 41 | +} |
| 42 | + |
| 43 | +bool PartialEntityAccessModel<fir::DeclareOp>::isCompleteView( |
| 44 | + mlir::Operation *op) const { |
| 45 | + // Return false (partial view) only if storage is present |
| 46 | + // Return true (complete view) if storage is absent |
| 47 | + return !getBaseEntity(op); |
| 48 | +} |
| 49 | + |
| 50 | +mlir::Value PartialEntityAccessModel<hlfir::DeclareOp>::getBaseEntity( |
| 51 | + mlir::Operation *op) const { |
| 52 | + return mlir::cast<hlfir::DeclareOp>(op).getStorage(); |
| 53 | +} |
| 54 | + |
| 55 | +bool PartialEntityAccessModel<hlfir::DeclareOp>::isCompleteView( |
| 56 | + mlir::Operation *op) const { |
| 57 | + // Return false (partial view) only if storage is present |
| 58 | + // Return true (complete view) if storage is absent |
| 59 | + return !getBaseEntity(op); |
| 60 | +} |
| 61 | + |
| 62 | +} // namespace fir::acc |
0 commit comments