9#ifndef MLIR_DIALECT_OPENACC_OPENACCUTILS_H_
10#define MLIR_DIALECT_OPENACC_OPENACCUTILS_H_
16#include "llvm/ADT/SmallVector.h"
17#include "llvm/ADT/StringRef.h"
18#include "llvm/ADT/Twine.h"
60std::optional<ClauseDefaultValue>
getDefaultAttr(mlir::Operation *op);
83std::string
getRecipeName(mlir::acc::RecipeKind kind, mlir::Type type);
98 mlir::Operation **definingOpPtr =
nullptr);
111 mlir::Value val, mlir::SymbolTableCollection *symbolTables =
nullptr);
128 mlir::SymbolTableCollection *symbolTables =
nullptr);
141 mlir::SymbolTableCollection *symbolTables =
nullptr);
154llvm::SmallVector<mlir::Value>
156 mlir::DominanceInfo &domInfo,
157 mlir::PostDominanceInfo &postDomInfo);
165 llvm::ArrayRef<int64_t> deviceTypes);
177remark::detail::InFlightRemark
178emitRemark(mlir::Operation *op,
const std::function<std::string()> &messageFn,
179 llvm::StringRef category =
"openacc");
188inline remark::detail::InFlightRemark
190 llvm::StringRef category =
"openacc") {
192 op, std::function<std::string()>([msg = message.str()]() { return msg; }),
198 while (mlir::isa_and_nonnull<arith::IndexCastOp, arith::IndexCastUIOp>(
206template <
typename ComputeOpT>
208 auto numGangs = op.getNumGangsValues();
209 if (numGangs.empty())
218 mlir::Value vectorLength = op.getVectorLengthValue();
A class for computing basic dominance information.
Operation is the basic unit of execution within MLIR.
Value getOperand(unsigned idx)
A class for computing basic postdominance information.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
mlir::acc::VariableTypeCategory getTypeCategory(mlir::Value var)
Get the type category of an OpenACC variable.
mlir::BlockArgument getACCBlockArgForOperand(mlir::OpOperand &operand)
If operand is a launch or ins operand of an acc.compute_region, returns the body block argument it is...
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.
mlir::Value getACCOperandForBlockArg(mlir::Value v)
If v is not a block argument of an acc.compute_region body, returns nullptr.
mlir::Operation * getACCDataClauseOpForBlockArg(mlir::Value v)
If v is not a block argument of an acc.compute_region body, returns nullptr.
mlir::Value stripIndexCasts(mlir::Value value)
Follow arith.index_cast and arith.index_castui to the value being cast.
std::optional< ClauseDefaultValue > getDefaultAttr(mlir::Operation *op)
Looks for an OpenACC default attribute on the current operation op or in a parent operation which enc...
bool isOnlyUsedByReductionClauses(mlir::Value val, mlir::Region ®ion)
Returns true if this value is only used by acc.reduction operations in the region.
bool isGangWorkerVectorAllOne(ComputeOpT op)
Return true when every gang, worker, and vector size on op is the constant 1.
mlir::Operation * getEnclosingComputeOp(mlir::Region ®ion)
Used to obtain the enclosing compute construct operation that contains the provided region.
bool isValidValueUse(mlir::Value val, mlir::Region ®ion, mlir::SymbolTableCollection *symbolTables=nullptr)
Check if a value use is valid in an OpenACC region.
llvm::StringLiteral getVarNamePlaceholder()
Returns a placeholder string for use as an acc.var_name attribute value when the actual variable name...
llvm::SmallVector< mlir::Value > getDominatingDataClauses(mlir::Operation *computeConstructOp, mlir::DominanceInfo &domInfo, mlir::PostDominanceInfo &postDomInfo)
Collects all data clauses that dominate the compute construct.
bool isInDeviceMemoryValue(mlir::Value val, mlir::SymbolTableCollection *symbolTables=nullptr)
Check if a value is backed by memory that is residing in the current device, and therefore requires n...
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.
bool isDeviceAccessibleValue(mlir::Value val, mlir::SymbolTableCollection *symbolTables=nullptr)
Check if a value represents device data.
bool isInOffTargetBranch(mlir::Operation *op, llvm::ArrayRef< int64_t > deviceTypes)
Returns true if op is in a branch that does not execute on the target.
mlir::Value getBaseEntity(mlir::Value val)
bool isOnlyUsedByPrivateClauses(mlir::Value val, mlir::Region ®ion)
Returns true if this value is only used by acc.private operations in the region.
Include the generated interface declarations.
bool isConstantIntValue(OpFoldResult ofr, int64_t value)
Return true if ofr is constant integer equal to value.