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>
131 template <
typename ImplT,
typename... Args>
133 decltype(std::declval<ImplT>().isValidSymbolUse(std::declval<Args>()...));
135 template <
typename ImplT>
140 template <
typename ImplT,
typename... Args>
143 decltype(std::declval<ImplT>().isValidValueUse(std::declval<Args>()...));
147 template <
typename ImplT>
152 template <
typename ImplT>
154 llvm::is_detected<isValidValueUse_t, ImplT, Value, Region &>;
156 template <
typename ImplT,
typename... Args>
158 decltype(std::declval<ImplT>().emitRemark(std::declval<Args>()...));
160 template <
typename ImplT>
163 std::function<std::string()>, llvm::StringRef>;
165 template <
typename ImplT,
typename... Args>
167 decltype(std::declval<ImplT>().getOrCreateGPUModule(
168 std::declval<Args>()...));
170 template <
typename ImplT>
175 template <
typename ImplT,
typename... Args>
177 decltype(std::declval<ImplT>().getTypeSizeAndAlignment(
178 std::declval<Args>()...));
180 template <
typename ImplT>
185 template <
typename ImplT,
typename... Args>
187 decltype(std::declval<ImplT>().isAddressNotCapturedByCalls(
188 std::declval<Args>()...));
190 template <
typename ImplT>
192 llvm::is_detected<isAddressNotCapturedByCalls_t, ImplT, Value>;
199 template <
typename ImplT>
206 return impl.getVariableName(v, config);
210 return impl.getRecipeName(kind, type, var);
214 return impl.emitNYI(loc, message);
219 llvm::StringRef category)
final {
221 return impl.emitRemark(op, std::move(messageFn), category);
229 return impl.isValidSymbolUse(user, symbol, definingOpPtr);
237 return impl.isValidValueUse(v, region, symbolTables);
239 return impl.isValidValueUse(v, region);
244 std::optional<gpu::GPUModuleOp>
246 llvm::StringRef name)
final {
248 return impl.getOrCreateGPUModule(mod, create, name);
253 std::optional<TypeSizeAndAlignment>
257 return impl.getTypeSizeAndAlignment(ty, module, support);
264 return impl.isAddressNotCapturedByCalls(v);
281 template <
typename ImplT>
291 template <
typename AnalysisT>
294 std::make_unique<Model<AnalysisT>>(std::forward<AnalysisT>(analysis));
325 return impl->emitNYI(loc, message);
342 llvm::StringRef category =
"openacc");
353 llvm::StringRef category =
"openacc") {
354 return emitRemark(op, std::function<std::string()>([msg = message.str()]() {
387 std::optional<gpu::GPUModuleOp>
389 llvm::StringRef name =
"");
395 if (
auto result =
impl->getTypeSizeAndAlignment(ty, module, *
this))
406 return impl->isAddressNotCapturedByCalls(v);
418 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.
bool isAddressNotCapturedByCalls(Value v)
Returns true when a call that receives v cannot use that address after it returns.
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 isAddressNotCapturedByCalls(Value v)=0
Returns true when a call that receives v cannot use that address after it returns.
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 isAddressNotCapturedByCalls(Value v) final
Returns true when a call that receives v cannot use that address after it returns.
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< isAddressNotCapturedByCalls_t, ImplT, Value > has_isAddressNotCapturedByCalls
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 >().isAddressNotCapturedByCalls( std::declval< Args >()...)) isAddressNotCapturedByCalls_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