MLIR 22.0.0git
OpenACCUtils.h
Go to the documentation of this file.
1//===- OpenACCUtils.h - OpenACC Utilities -----------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef MLIR_DIALECT_OPENACC_OPENACCUTILS_H_
10#define MLIR_DIALECT_OPENACC_OPENACCUTILS_H_
11
13
14namespace mlir {
15namespace acc {
16
17/// Used to obtain the enclosing compute construct operation that contains
18/// the provided `region`. Returns nullptr if no compute construct operation
19/// is found. The returned operation is one of types defined by
20/// `ACC_COMPUTE_CONSTRUCT_OPS`.
21mlir::Operation *getEnclosingComputeOp(mlir::Region &region);
22
23/// Returns true if this value is only used by `acc.private` operations in the
24/// `region`.
25bool isOnlyUsedByPrivateClauses(mlir::Value val, mlir::Region &region);
26
27/// Returns true if this value is only used by `acc.reduction` operations in
28/// the `region`.
29bool isOnlyUsedByReductionClauses(mlir::Value val, mlir::Region &region);
30
31/// Looks for an OpenACC default attribute on the current operation `op` or in
32/// a parent operation which encloses `op`. This is useful because OpenACC
33/// specification notes that a visible default clause is the nearest default
34/// clause appearing on the compute construct or a lexically containing data
35/// construct.
36std::optional<ClauseDefaultValue> getDefaultAttr(mlir::Operation *op);
37
38/// Get the type category of an OpenACC variable.
39mlir::acc::VariableTypeCategory getTypeCategory(mlir::Value var);
40
41/// Attempts to extract the variable name from a value by walking through
42/// view-like operations until an `acc.var_name` attribute is found. Returns
43/// empty string if no name is found.
44std::string getVariableName(mlir::Value v);
45
46/// Get the recipe name for a given recipe kind and type.
47/// Returns an empty string if not possible to generate a recipe name.
48std::string getRecipeName(mlir::acc::RecipeKind kind, mlir::Type type);
49
50// Get the base entity from partial entity access. This is used for getting
51// the base `struct` from an operation that only accesses a field or the
52// base `array` from an operation that only accesses a subarray.
53mlir::Value getBaseEntity(mlir::Value val);
54
55} // namespace acc
56} // namespace mlir
57
58#endif // MLIR_DIALECT_OPENACC_OPENACCUTILS_H_
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 &region)
Returns true if this value is only used by acc.reduction operations in the region.
mlir::Operation * getEnclosingComputeOp(mlir::Region &region)
Used to obtain the enclosing compute construct operation that contains the provided region.
std::string getRecipeName(mlir::acc::RecipeKind kind, mlir::Type type)
Get the recipe name for a given recipe kind and type.
mlir::Value getBaseEntity(mlir::Value val)
bool isOnlyUsedByPrivateClauses(mlir::Value val, mlir::Region &region)
Returns true if this value is only used by acc.private operations in the region.
Include the generated interface declarations.