MLIR 23.0.0git
OpenACCSupport.cpp
Go to the documentation of this file.
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
16
17namespace mlir {
18namespace acc {
19
21 if (impl)
22 return impl->getVariableName(v);
23 return acc::getVariableName(v);
24}
25
26std::string OpenACCSupport::getRecipeName(RecipeKind kind, Type type,
27 Value var) {
28 if (impl)
29 return impl->getRecipeName(kind, type, var);
30 // The default implementation assumes that only type matters
31 // and the actual instance of variable is not relevant.
32 auto recipeName = acc::getRecipeName(kind, type);
33 if (recipeName.empty())
34 emitNYI(var ? var.getLoc() : UnknownLoc::get(type.getContext()),
35 "variable privatization (incomplete recipe name handling)");
36 return recipeName;
37}
38
40 if (impl)
41 return impl->emitNYI(loc, message);
42 return mlir::emitError(loc, "not yet implemented: " + message);
43}
44
47 std::function<std::string()> messageFn,
48 llvm::StringRef category) {
49 if (impl)
50 return impl->emitRemark(op, std::move(messageFn), category);
51 return acc::emitRemark(op, messageFn(), category);
52}
53
54bool OpenACCSupport::isValidSymbolUse(Operation *user, SymbolRefAttr symbol,
55 Operation **definingOpPtr) {
56 if (impl)
57 return impl->isValidSymbolUse(user, symbol, definingOpPtr);
58 return acc::isValidSymbolUse(user, symbol, definingOpPtr);
59}
60
62 if (impl)
63 return impl->isValidValueUse(v, region);
64 return acc::isValidValueUse(v, region);
65}
66
67std::optional<gpu::GPUModuleOp>
68OpenACCSupport::getOrCreateGPUModule(ModuleOp mod, bool create,
69 llvm::StringRef name) {
70 if (impl)
71 return impl->getOrCreateGPUModule(mod, create, name);
72 return acc::getOrCreateGPUModule(mod, create, name);
73}
74
75} // namespace acc
76} // namespace mlir
This class represents a diagnostic that is inflight and set to be reported.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition Location.h:76
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Definition Region.h:26
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition Types.h:74
MLIRContext * getContext() const
Return the MLIRContext in which this type was uniqued.
Definition Types.cpp:35
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
Location getLoc() const
Return the location of this value.
Definition Value.cpp:24
remark::detail::InFlightRemark emitRemark(Operation *op, std::function< std::string()> messageFn, llvm::StringRef category="openacc")
Emit an OpenACC remark with lazy message generation.
InFlightDiagnostic emitNYI(Location loc, const Twine &message)
Report a case that is not yet supported by the implementation.
bool isValidValueUse(Value v, Region &region)
Check if a value use is legal in an OpenACC region.
bool isValidSymbolUse(Operation *user, SymbolRefAttr symbol, Operation **definingOpPtr=nullptr)
Check if a symbol use is valid for use in an OpenACC region.
std::optional< gpu::GPUModuleOp > getOrCreateGPUModule(ModuleOp mod, bool create=true, llvm::StringRef name="")
Get or optionally create a GPU module in the given module.
std::string getVariableName(Value v)
Get the variable name for a given value.
std::string getRecipeName(RecipeKind kind, Type type, Value var)
Get the recipe name for a given type and value.
A wrapper for linking remarks by query - searches the engine's registry at stream time and links to a...
Definition Remarks.h:402
std::string getVariableName(mlir::Value v)
Attempts to extract the variable name from a value by walking through view-like operations until an a...
bool isValidSymbolUse(mlir::Operation *user, mlir::SymbolRefAttr symbol, mlir::Operation **definingOpPtr=nullptr)
Check if a symbol use is valid for use in an OpenACC region.
std::optional< gpu::GPUModuleOp > getOrCreateGPUModule(ModuleOp mod, bool create=true, llvm::StringRef name=kDefaultGPUModuleName)
Get or create a GPU module in the given module.
bool isValidValueUse(mlir::Value val, mlir::Region &region)
Check if a value use is valid in an OpenACC region.
std::string getRecipeName(mlir::acc::RecipeKind kind, mlir::Type type)
Get the recipe name for a given recipe kind and type.
remark::detail::InFlightRemark emitRemark(mlir::Operation *op, const std::function< std::string()> &messageFn, llvm::StringRef category="openacc")
Emit an OpenACC remark with lazy message generation.
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.