MLIR 22.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
15
16namespace mlir {
17namespace acc {
18
20 if (impl)
21 return impl->getVariableName(v);
22 return acc::getVariableName(v);
23}
24
25std::string OpenACCSupport::getRecipeName(RecipeKind kind, Type type,
26 Value var) {
27 if (impl)
28 return impl->getRecipeName(kind, type, var);
29 // The default implementation assumes that only type matters
30 // and the actual instance of variable is not relevant.
31 auto recipeName = acc::getRecipeName(kind, type);
32 if (recipeName.empty())
33 emitNYI(var ? var.getLoc() : UnknownLoc::get(type.getContext()),
34 "variable privatization (incomplete recipe name handling)");
35 return recipeName;
36}
37
39 if (impl)
40 return impl->emitNYI(loc, message);
41 return mlir::emitError(loc, "not yet implemented: " + message);
42}
43
45OpenACCSupport::emitRemark(Operation *op, const Twine &message,
46 llvm::StringRef category) {
47 if (impl)
48 return impl->emitRemark(op, message, category);
49 return acc::emitRemark(op, message, category);
50}
51
52bool OpenACCSupport::isValidSymbolUse(Operation *user, SymbolRefAttr symbol,
53 Operation **definingOpPtr) {
54 if (impl)
55 return impl->isValidSymbolUse(user, symbol, definingOpPtr);
56 return acc::isValidSymbolUse(user, symbol, definingOpPtr);
57}
58
60 if (impl)
61 return impl->isValidValueUse(v, region);
62 return false;
63}
64
65} // namespace acc
66} // 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, const Twine &message, llvm::StringRef category="openacc")
Emit an OpenACC remark.
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::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.
InFlightRemark is a RAII class that holds a reference to a Remark instance and allows to build the re...
Definition Remarks.h:292
std::string getVariableName(mlir::Value v)
Attempts to extract the variable name from a value by walking through view-like operations until an a...
remark::detail::InFlightRemark emitRemark(Operation *op, const Twine &message, llvm::StringRef category)
std::string getRecipeName(mlir::acc::RecipeKind kind, mlir::Type type)
Get the recipe name for a given recipe kind and type.
bool isValidSymbolUse(Operation *user, SymbolRefAttr symbol, Operation **definingOpPtr)
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.