50#ifndef MLIR_DIALECT_OPENACC_ANALYSIS_OPENACCSUPPORT_H
51#define MLIR_DIALECT_OPENACC_ANALYSIS_OPENACCSUPPORT_H
61#include "llvm/ADT/StringRef.h"
106 llvm::StringRef category) = 0;
117 virtual std::optional<gpu::GPUModuleOp>
121 virtual std::optional<TypeSizeAndAlignment>
127 template <
typename ImplT,
typename... Args>
129 decltype(std::declval<ImplT>().isValidSymbolUse(std::declval<Args>()...));
131 template <
typename ImplT>
136 template <
typename ImplT,
typename... Args>
139 decltype(std::declval<ImplT>().isValidValueUse(std::declval<Args>()...));
143 template <
typename ImplT>
148 template <
typename ImplT>
150 llvm::is_detected<isValidValueUse_t, ImplT, Value, Region &>;
152 template <
typename ImplT,
typename... Args>
154 decltype(std::declval<ImplT>().emitRemark(std::declval<Args>()...));
156 template <
typename ImplT>
159 std::function<std::string()>, llvm::StringRef>;
161 template <
typename ImplT,
typename... Args>
163 decltype(std::declval<ImplT>().getOrCreateGPUModule(
164 std::declval<Args>()...));
166 template <
typename ImplT>
171 template <
typename ImplT,
typename... Args>
173 decltype(std::declval<ImplT>().getTypeSizeAndAlignment(
174 std::declval<Args>()...));
176 template <
typename ImplT>
186 template <
typename ImplT>
193 return impl.getVariableName(v, config);
197 return impl.getRecipeName(kind, type, var);
201 return impl.emitNYI(loc, message);
206 llvm::StringRef category)
final {
208 return impl.emitRemark(op, std::move(messageFn), category);
216 return impl.isValidSymbolUse(user, symbol, definingOpPtr);
224 return impl.isValidValueUse(v, region, symbolTables);
226 return impl.isValidValueUse(v, region);
231 std::optional<gpu::GPUModuleOp>
233 llvm::StringRef name)
final {
235 return impl.getOrCreateGPUModule(mod, create, name);
240 std::optional<TypeSizeAndAlignment>
244 return impl.getTypeSizeAndAlignment(ty, module, support);
261 template <
typename ImplT>
271 template <
typename AnalysisT>
274 std::make_unique<Model<AnalysisT>>(std::forward<AnalysisT>(analysis));
305 return impl->emitNYI(loc, message);
322 llvm::StringRef category =
"openacc");
333 llvm::StringRef category =
"openacc") {
334 return emitRemark(op, std::function<std::string()>([msg = message.str()]() {
367 std::optional<gpu::GPUModuleOp>
369 llvm::StringRef name =
"");
375 if (
auto result =
impl->getTypeSizeAndAlignment(ty, module, *
this))
388 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.
This class represents a collection of SymbolTables.
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.
std::string getVariableName(Value v, VariableNameConfig config={})
Get the variable name for a given value.
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.
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::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.
bool isValidValueUse(Value v, Region ®ion, SymbolTableCollection *symbolTables=nullptr)
Check if a value use is legal in an OpenACC region.
virtual std::string getRecipeName(RecipeKind kind, Type type, Value var)=0
Get the recipe name for a given kind, type and value.
virtual std::optional< TypeSizeAndAlignment > getTypeSizeAndAlignment(Type ty, ModuleOp module, OpenACCSupport &support)=0
Returns the size and ABI alignment in bytes for ty.
virtual std::string getVariableName(Value v, VariableNameConfig config)=0
Get the variable name for a given MLIR value.
virtual bool isValidValueUse(Value v, mlir::Region ®ion, SymbolTableCollection *symbolTables)=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.
bool isValidValueUse(Value v, Region ®ion, SymbolTableCollection *symbolTables) final
Check if a value use is legal in an OpenACC region.
std::string getVariableName(Value v, VariableNameConfig config) final
Get the variable name for a given MLIR value.
remark::detail::InFlightRemark emitRemark(Operation *op, std::function< std::string()> messageFn, llvm::StringRef category) final
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.
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 ®ion, mlir::SymbolTableCollection *symbolTables=nullptr)
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.
std::optional< TypeSizeAndAlignment > getTypeSizeAndAlignment(Type ty, ModuleOp module, const DataLayout &dl, OpenACCSupport *support=nullptr, Value var={})
Returns the size and ABI alignment in bytes.
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
How the name of a variable is to be rendered.
bool preferDemangledName
Render the name the source language spells, which is the name a message to the user states.
This class contains internal trait classes used by OpenACCSupport.
llvm::is_detected< getOrCreateGPUModule_t, ImplT, ModuleOp, bool, llvm::StringRef > has_getOrCreateGPUModule
llvm::is_detected< isValidValueUse_t, ImplT, Value, Region & > has_isValidValueUseNoSymbolTables
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 &, SymbolTableCollection * > has_isValidValueUse
An implementation may take the symbol table cache or, for compatibility, only the value and the regio...
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