13 #include "llvm/ADT/TypeSwitch.h"
18 if (mlir::isa<ACC_COMPUTE_CONSTRUCT_OPS>(parentOp))
25 template <
typename OpTy>
30 if (!region.
isAncestor(user->getParentRegion()))
32 return mlir::isa<OpTy>(user);
35 return llvm::all_of(val.
getUsers(), checkIfUsedOnlyByOpInside);
40 return isOnlyUsedByOpClauses<mlir::acc::PrivateOp>(val, region);
45 return isOnlyUsedByOpClauses<mlir::acc::ReductionOp>(val, region);
48 std::optional<mlir::acc::ClauseDefaultValue>
50 std::optional<mlir::acc::ClauseDefaultValue> defaultAttr;
57 while (!defaultAttr.has_value() && currOp) {
60 std::optional<mlir::acc::ClauseDefaultValue>>(currOp)
61 .Case<ACC_COMPUTE_CONSTRUCT_OPS, mlir::acc::DataOp>(
62 [&](
auto op) {
return op.getDefaultAttr(); })
63 .Default([&](
Operation *) {
return std::nullopt; });
71 mlir::acc::VariableTypeCategory typeCategory =
72 mlir::acc::VariableTypeCategory::uncategorized;
73 if (
auto mappableTy = dyn_cast<mlir::acc::MappableType>(var.
getType()))
74 typeCategory = mappableTy.getTypeCategory(var);
75 else if (
auto pointerLikeTy =
76 dyn_cast<mlir::acc::PointerLikeType>(var.
getType()))
77 typeCategory = pointerLikeTy.getPointeeTypeCategory(
79 pointerLikeTy.getElementType());
89 if (
auto varNameAttr =
91 return varNameAttr.getName().str();
94 if (isa<ACC_DATA_ENTRY_OPS>(definingOp))
99 if (
auto viewOp = dyn_cast<ViewLikeOpInterface>(definingOp)) {
100 current = viewOp.getViewSource();
static bool isOnlyUsedByOpClauses(mlir::Value val, mlir::Region ®ion)
Operation is the basic unit of execution within MLIR.
Operation * getParentOp()
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...
This class contains a list of basic blocks and a link to the parent operation it is attached to.
bool isAncestor(Region *other)
Return true if this region is ancestor of the other region.
Operation * getParentOp()
Return the parent operation this region is attached to.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
user_range getUsers() const
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.
std::string getVariableName(mlir::Value v)
Attempts to extract the variable name from a value by walking through view-like operations until an a...
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.
std::optional< llvm::StringRef > getVarName(mlir::Operation *accOp)
Used to obtain the name from an acc operation.
mlir::Operation * getEnclosingComputeOp(mlir::Region ®ion)
Used to obtain the enclosing compute construct operation that contains the provided region.
static constexpr StringLiteral getVarNameAttrName()
bool isOnlyUsedByPrivateClauses(mlir::Value val, mlir::Region ®ion)
Returns true if this value is only used by acc.private operations in the region.
std::conditional_t< std::is_same_v< Ty, mlir::Type >, mlir::Value, detail::TypedValue< Ty > > TypedValue
If Ty is mlir::Type this will select Value instead of having a wrapper around it.