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
18namespace mlir {
19namespace acc {
20
21std::string OpenACCSupport::getVariableName(Value v,
22 VariableNameConfig config) {
23 if (impl)
24 return impl->getVariableName(v, config);
25 return acc::getVariableName(v);
26}
27
28std::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
41remark::detail::InFlightRemark
42OpenACCSupport::emitRemark(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
50bool 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
57bool OpenACCSupport::isValidValueUse(Value v, Region &region,
58 SymbolTableCollection *symbolTables) {
59 if (impl)
60 return impl->isValidValueUse(v, region, symbolTables);
61 return acc::isValidValueUse(val: v, region, symbolTables);
62}
63
64std::optional<gpu::GPUModuleOp>
65OpenACCSupport::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