| 1 | //===- OpenACCSupport.cpp - OpenACCSupport Implementation -----------------===// |
| 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 implements the OpenACCSupport analysis interface. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "mlir/Dialect/OpenACC/Analysis/OpenACCSupport.h" |
| 14 | #include "mlir/Dialect/OpenACC/OpenACCUtils.h" |
| 15 | #include "mlir/Dialect/OpenACC/OpenACCUtilsGPU.h" |
| 16 | #include "mlir/Dialect/OpenACC/OpenACCUtilsType.h" |
| 17 | |
| 18 | namespace mlir { |
| 19 | namespace acc { |
| 20 | |
| 21 | std::string OpenACCSupport::getVariableName(Value v, |
| 22 | VariableNameConfig config) { |
| 23 | if (impl) |
| 24 | return impl->getVariableName(v, config); |
| 25 | return acc::getVariableName(v); |
| 26 | } |
| 27 | |
| 28 | std::string OpenACCSupport::getRecipeName(RecipeKind kind, Type type, |
| 29 | Value var) { |
| 30 | if (impl) |
| 31 | return impl->getRecipeName(kind, type, var); |
| 32 | // The default implementation assumes that only type matters |
| 33 | // and the actual instance of variable is not relevant. |
| 34 | auto recipeName = acc::getRecipeName(kind, type); |
| 35 | if (recipeName.empty()) |
| 36 | emitNYI(loc: var ? var.getLoc() : UnknownLoc::get(context: type.getContext()), |
| 37 | message: "variable privatization (incomplete recipe name handling)" ); |
| 38 | return recipeName; |
| 39 | } |
| 40 | |
| 41 | remark::detail::InFlightRemark |
| 42 | OpenACCSupport::(Operation *op, |
| 43 | std::function<std::string()> messageFn, |
| 44 | llvm::StringRef category) { |
| 45 | if (impl) |
| 46 | return impl->emitRemark(op, messageFn: std::move(messageFn), category); |
| 47 | return acc::emitRemark(op, message: messageFn(), category); |
| 48 | } |
| 49 | |
| 50 | bool OpenACCSupport::isValidSymbolUse(Operation *user, SymbolRefAttr symbol, |
| 51 | Operation **definingOpPtr) { |
| 52 | if (impl) |
| 53 | return impl->isValidSymbolUse(user, symbol, definingOpPtr); |
| 54 | return acc::isValidSymbolUse(user, symbol, definingOpPtr); |
| 55 | } |
| 56 | |
| 57 | bool OpenACCSupport::isValidValueUse(Value v, Region ®ion, |
| 58 | SymbolTableCollection *symbolTables) { |
| 59 | if (impl) |
| 60 | return impl->isValidValueUse(v, region, symbolTables); |
| 61 | return acc::isValidValueUse(val: v, region, symbolTables); |
| 62 | } |
| 63 | |
| 64 | std::optional<gpu::GPUModuleOp> |
| 65 | OpenACCSupport::getOrCreateGPUModule(ModuleOp mod, bool create, |
| 66 | llvm::StringRef name) { |
| 67 | if (impl) |
| 68 | return impl->getOrCreateGPUModule(mod, create, name); |
| 69 | return acc::getOrCreateGPUModule(mod, create, name); |
| 70 | } |
| 71 | |
| 72 | } // namespace acc |
| 73 | } // namespace mlir |
| 74 | |