50#ifndef MLIR_DIALECT_OPENACC_ANALYSIS_OPENACCSUPPORT_H
51#define MLIR_DIALECT_OPENACC_ANALYSIS_OPENACCSUPPORT_H
61#include "llvm/ADT/StringRef.h"
95 llvm::StringRef category) = 0;
105 virtual std::optional<gpu::GPUModuleOp>
109 virtual std::optional<TypeSizeAndAlignment>
115 template <
typename ImplT,
typename... Args>
117 decltype(std::declval<ImplT>().isValidSymbolUse(std::declval<Args>()...));
119 template <
typename ImplT>
124 template <
typename ImplT,
typename... Args>
127 decltype(std::declval<ImplT>().isValidValueUse(std::declval<Args>()...));
129 template <
typename ImplT>
131 llvm::is_detected<isValidValueUse_t, ImplT, Value, Region &>;
133 template <
typename ImplT,
typename... Args>
135 decltype(std::declval<ImplT>().emitRemark(std::declval<Args>()...));
137 template <
typename ImplT>
140 std::function<std::string()>, llvm::StringRef>;
142 template <
typename ImplT,
typename... Args>
144 decltype(std::declval<ImplT>().getOrCreateGPUModule(
145 std::declval<Args>()...));
147 template <
typename ImplT>
152 template <
typename ImplT,
typename... Args>
154 decltype(std::declval<ImplT>().getTypeSizeAndAlignment(
155 std::declval<Args>()...));
157 template <
typename ImplT>
167 template <
typename ImplT>
174 return impl.getVariableName(v);
178 return impl.getRecipeName(kind, type, var);
182 return impl.emitNYI(loc, message);
187 llvm::StringRef category)
final {
189 return impl.emitRemark(op, std::move(messageFn), category);
197 return impl.isValidSymbolUse(user, symbol, definingOpPtr);
204 return impl.isValidValueUse(v, region);
209 std::optional<gpu::GPUModuleOp>
211 llvm::StringRef name)
final {
213 return impl.getOrCreateGPUModule(mod, create, name);
218 std::optional<TypeSizeAndAlignment>
222 return impl.getTypeSizeAndAlignment(ty, module, support);
239 template <
typename ImplT>
249 template <
typename AnalysisT>
252 std::make_unique<Model<AnalysisT>>(std::forward<AnalysisT>(analysis));
292 llvm::StringRef category =
"openacc");
303 llvm::StringRef category =
"openacc") {
304 return emitRemark(op, std::function<std::string()>([msg = message.str()]() {
333 std::optional<gpu::GPUModuleOp>
335 llvm::StringRef name =
"");
341 if (
auto result =
impl->getTypeSizeAndAlignment(ty, module, *
this))
354 std::unique_ptr<Concept>
impl;
detail::PreservedAnalyses PreservedAnalyses
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...
Operation is the basic unit of execution within MLIR.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
remark::detail::InFlightRemark emitRemark(Operation *op, std::function< std::string()> messageFn, llvm::StringRef category="openacc")
Emit an OpenACC remark with lazy message generation.
remark::detail::InFlightRemark emitRemark(Operation *op, const Twine &message, llvm::StringRef category="openacc")
Emit an OpenACC remark.
void setImplementation(AnalysisT &&analysis)
Register a custom OpenACCSupport implementation.
InFlightDiagnostic emitNYI(Location loc, const Twine &message)
Report a case that is not yet supported by the implementation.
bool isValidValueUse(Value v, Region ®ion)
Check if a value use is legal in an OpenACC region.
OpenACCSupport(Operation *op)
bool isValidSymbolUse(Operation *user, SymbolRefAttr symbol, Operation **definingOpPtr=nullptr)
Check if a symbol use is valid for use in an OpenACC region.
bool isInvalidated(const AnalysisManager::PreservedAnalyses &pa)
Signal that this analysis should always be preserved so that underlying implementation registration i...
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::optional< TypeSizeAndAlignment > getTypeSizeAndAlignment(Type ty, ModuleOp module)
Returns the size and ABI alignment in bytes for ty.
std::string getRecipeName(RecipeKind kind, Type type, Value var)
Get the recipe name for a given type and value.
virtual std::string getRecipeName(RecipeKind kind, Type type, Value var)=0
Get the recipe name for a given kind, type and value.
virtual std::string getVariableName(Value v)=0
Get the variable name for a given MLIR value.
virtual std::optional< TypeSizeAndAlignment > getTypeSizeAndAlignment(Type ty, ModuleOp module, OpenACCSupport &support)=0
Returns the size and ABI alignment in bytes for ty.
virtual bool isValidValueUse(Value v, mlir::Region ®ion)=0
Check if a value use is legal in an OpenACC region.
virtual InFlightDiagnostic emitNYI(Location loc, const Twine &message)=0
virtual ~Concept()=default
virtual bool isValidSymbolUse(Operation *user, SymbolRefAttr symbol, Operation **definingOpPtr)=0
Check if a symbol use is valid for use in an OpenACC region.
virtual remark::detail::InFlightRemark emitRemark(Operation *op, std::function< std::string()> messageFn, llvm::StringRef category)=0
virtual std::optional< gpu::GPUModuleOp > getOrCreateGPUModule(ModuleOp mod, bool create, llvm::StringRef name)=0
Get or optionally create a GPU module in the given module.
This class wraps a concrete OpenACCSupport implementation and forwards interface calls to it.
remark::detail::InFlightRemark emitRemark(Operation *op, std::function< std::string()> messageFn, llvm::StringRef category) final
bool isValidValueUse(Value v, Region ®ion) final
Check if a value use is legal in an OpenACC region.
std::optional< gpu::GPUModuleOp > getOrCreateGPUModule(ModuleOp mod, bool create, llvm::StringRef name) final
Get or optionally create a GPU module in the given module.
InFlightDiagnostic emitNYI(Location loc, const Twine &message) final
std::string getRecipeName(RecipeKind kind, Type type, Value var) final
Get the recipe name for a given kind, type and value.
bool isValidSymbolUse(Operation *user, SymbolRefAttr symbol, Operation **definingOpPtr) final
Check if a symbol use is valid for use in an OpenACC region.
~Model() override=default
std::optional< TypeSizeAndAlignment > getTypeSizeAndAlignment(Type ty, ModuleOp module, OpenACCSupport &support) final
Returns the size and ABI alignment in bytes for ty.
std::string getVariableName(Value v) final
Get the variable name for a given MLIR value.
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.
std::optional< TypeSizeAndAlignment > getTypeSizeAndAlignment(Type ty, ModuleOp module, const DataLayout &dl, OpenACCSupport *support=nullptr)
Returns the size and ABI alignment in bytes.
bool isValidValueUse(mlir::Value val, mlir::Region ®ion)
Check if a value use is valid in an OpenACC region.
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.
This class contains internal trait classes used by OpenACCSupport.
llvm::is_detected< getOrCreateGPUModule_t, ImplT, ModuleOp, bool, llvm::StringRef > has_getOrCreateGPUModule
decltype(std::declval< ImplT >().getTypeSizeAndAlignment( std::declval< Args >()...)) getTypeSizeAndAlignment_t
llvm::is_detected< emitRemark_t, ImplT, Operation *, std::function< std::string()>, llvm::StringRef > has_emitRemark
decltype(std::declval< ImplT >().isValidValueUse(std::declval< Args >()...)) isValidValueUse_t
llvm::is_detected< isValidValueUse_t, ImplT, Value, Region & > has_isValidValueUse
llvm::is_detected< isValidSymbolUse_t, ImplT, Operation *, SymbolRefAttr, Operation ** > has_isValidSymbolUse
decltype(std::declval< ImplT >().emitRemark(std::declval< Args >()...)) emitRemark_t
decltype(std::declval< ImplT >().getOrCreateGPUModule( std::declval< Args >()...)) getOrCreateGPUModule_t
decltype(std::declval< ImplT >().isValidSymbolUse(std::declval< Args >()...)) isValidSymbolUse_t
SFINAE helpers to detect if implementation has optional methods.
llvm::is_detected< getTypeSizeAndAlignment_t, ImplT, Type, ModuleOp, OpenACCSupport & > has_getTypeSizeAndAlignment