[Mlir-commits] [flang] [mlir] [mlir][acc] add VariableInfo class to thread langauge specific information about privatized variables (PR #186368)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Mar 23 06:37:22 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
@llvm/pr-subscribers-mlir
Author: None (jeanPerier)
<details>
<summary>Changes</summary>
This is a proposal for a new data structure that allows threading language specific information into the OpenACC interfaces.
The language front-ends can implement their extension like done for Fortran in flang in this patch.
The language information is created from the hostVar value via a new interface.
The advantage is that this allows not threading the hostVar mlir::Value into the methods that are already taking the block arguments as values and where threading an additional Value just for the sake of retrieving information could be confusing.
This also allows controlling and limiting the places where information is obtained via getDefiningOp with the idea that this should be limited and replace with Attribute and Type information in the IR instead as much as possible in the future.
The current motivation is to detect OPTIONAL inside the generatePrivateInit, generateCopy, and generatePrivateDestroy APIs implementation for Fortran.
---
Patch is 33.60 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/186368.diff
13 Files Affected:
- (modified) flang/include/flang/Optimizer/Dialect/FIRAttr.h (+1)
- (modified) flang/include/flang/Optimizer/Dialect/FIRAttr.td (+13)
- (modified) flang/include/flang/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.h (+9-2)
- (modified) flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp (+54-16)
- (modified) flang/lib/Optimizer/OpenACC/Support/FIROpenACCUtils.cpp (+10-5)
- (modified) mlir/include/mlir/Dialect/OpenACC/OpenACC.h (+1)
- (added) mlir/include/mlir/Dialect/OpenACC/OpenACCAttributes.td (+24)
- (modified) mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td (+7-2)
- (modified) mlir/include/mlir/Dialect/OpenACC/OpenACCTypeInterfaces.td (+40-3)
- (added) mlir/include/mlir/Dialect/OpenACC/OpenACCVariableInfo.h (+46)
- (modified) mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp (+31-13)
- (modified) mlir/lib/Dialect/OpenACC/Transforms/ACCImplicitData.cpp (+2-2)
- (modified) mlir/test/lib/Dialect/OpenACC/TestRecipePopulate.cpp (+4-4)
``````````diff
diff --git a/flang/include/flang/Optimizer/Dialect/FIRAttr.h b/flang/include/flang/Optimizer/Dialect/FIRAttr.h
index 06ec1f57173c3..ec6b7ff48329e 100644
--- a/flang/include/flang/Optimizer/Dialect/FIRAttr.h
+++ b/flang/include/flang/Optimizer/Dialect/FIRAttr.h
@@ -13,6 +13,7 @@
#ifndef FORTRAN_OPTIMIZER_DIALECT_FIRATTR_H
#define FORTRAN_OPTIMIZER_DIALECT_FIRATTR_H
+#include "mlir/Dialect/OpenACC/OpenACCVariableInfo.h"
#include "mlir/IR/BuiltinAttributes.h"
namespace mlir {
diff --git a/flang/include/flang/Optimizer/Dialect/FIRAttr.td b/flang/include/flang/Optimizer/Dialect/FIRAttr.td
index b23d28fdde55c..3bb1f443f3a5d 100644
--- a/flang/include/flang/Optimizer/Dialect/FIRAttr.td
+++ b/flang/include/flang/Optimizer/Dialect/FIRAttr.td
@@ -14,6 +14,7 @@
#define FIR_DIALECT_FIR_ATTRS
include "flang/Optimizer/Dialect/FIRDialect.td"
+include "mlir/Dialect/OpenACC/OpenACCAttributes.td"
include "mlir/IR/EnumAttr.td"
class fir_Attr<string name> : AttrDef<FIROpsDialect, name>;
@@ -262,4 +263,16 @@ def fir_UseRenameAttr : fir_Attr<"UseRename"> {
let assemblyFormat = "`<` $local_name `,` $symbol `>`";
}
+// Fortran-specific variable information for OpenACC.
+// Carries metadata that cannot be recovered from the FIR type system alone
+// and is required in the FIR implementation of OpenACC type interfaces.
+def fir_OpenACCFortranVariableInfoAttr
+ : AttrDef<FIROpsDialect, "OpenACCFortranVariableInfo",
+ [OpenACC_IsVariableInfoAttr],
+ "::mlir::acc::VariableInfoAttr"> {
+ let mnemonic = "acc_var_info";
+ let parameters = (ins "bool":$mayBeOptional);
+ let assemblyFormat = "`<` struct(params) `>`";
+}
+
#endif // FIR_DIALECT_FIR_ATTRS
diff --git a/flang/include/flang/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.h b/flang/include/flang/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.h
index 9d952a6130f0e..01a1e19afd74b 100644
--- a/flang/include/flang/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.h
+++ b/flang/include/flang/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.h
@@ -80,22 +80,29 @@ struct OpenACCMappableModel
mlir::acc::VariableTypeCategory getTypeCategory(mlir::Type type,
mlir::Value var) const;
+ mlir::acc::VariableInfoAttr
+ genPrivateVariableInfo(mlir::Type type,
+ mlir::TypedValue<mlir::acc::MappableType> var) const;
+
mlir::Value generatePrivateInit(mlir::Type type, mlir::OpBuilder &builder,
mlir::Location loc,
mlir::TypedValue<mlir::acc::MappableType> var,
llvm::StringRef varName,
mlir::ValueRange extents, mlir::Value initVal,
+ mlir::acc::VariableInfoAttr varInfo,
bool &needsDestroy) const;
bool generatePrivateDestroy(mlir::Type type, mlir::OpBuilder &builder,
mlir::Location loc, mlir::Value privatized,
- mlir::ValueRange bounds) const;
+ mlir::ValueRange bounds,
+ mlir::acc::VariableInfoAttr varInfo) const;
bool generateCopy(mlir::Type type, mlir::OpBuilder &mlirBuilder,
mlir::Location loc,
mlir::TypedValue<mlir::acc::MappableType> source,
mlir::TypedValue<mlir::acc::MappableType> dest,
- mlir::ValueRange bounds) const;
+ mlir::ValueRange bounds,
+ mlir::acc::VariableInfoAttr varInfo) const;
bool generateCombiner(mlir::Type type, mlir::OpBuilder &mlirBuilder,
mlir::Location loc,
diff --git a/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp b/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp
index 5d427c9aab8ab..5526dad0bffce 100644
--- a/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp
+++ b/flang/lib/Optimizer/OpenACC/Support/FIROpenACCTypeInterfaces.cpp
@@ -542,6 +542,30 @@ template mlir::acc::VariableTypeCategory
OpenACCMappableModel<fir::PointerType>::getTypeCategory(mlir::Type type,
mlir::Value var) const;
+template <typename Ty>
+mlir::acc::VariableInfoAttr OpenACCMappableModel<Ty>::genPrivateVariableInfo(
+ mlir::Type type, mlir::TypedValue<mlir::acc::MappableType> var) const {
+ hlfir::Entity entity{var};
+ return fir::OpenACCFortranVariableInfoAttr::get(var.getContext(),
+ entity.mayBeOptional());
+}
+
+template mlir::acc::VariableInfoAttr
+OpenACCMappableModel<fir::BaseBoxType>::genPrivateVariableInfo(
+ mlir::Type type, mlir::TypedValue<mlir::acc::MappableType> var) const;
+
+template mlir::acc::VariableInfoAttr
+OpenACCMappableModel<fir::ReferenceType>::genPrivateVariableInfo(
+ mlir::Type type, mlir::TypedValue<mlir::acc::MappableType> var) const;
+
+template mlir::acc::VariableInfoAttr
+OpenACCMappableModel<fir::HeapType>::genPrivateVariableInfo(
+ mlir::Type type, mlir::TypedValue<mlir::acc::MappableType> var) const;
+
+template mlir::acc::VariableInfoAttr
+OpenACCMappableModel<fir::PointerType>::genPrivateVariableInfo(
+ mlir::Type type, mlir::TypedValue<mlir::acc::MappableType> var) const;
+
static mlir::acc::VariableTypeCategory
categorizePointee(mlir::Type pointer,
mlir::TypedValue<mlir::acc::PointerLikeType> varPtr,
@@ -717,7 +741,8 @@ template <typename Ty>
mlir::Value OpenACCMappableModel<Ty>::generatePrivateInit(
mlir::Type type, mlir::OpBuilder &mlirBuilder, mlir::Location loc,
mlir::TypedValue<mlir::acc::MappableType> var, llvm::StringRef varName,
- mlir::ValueRange bounds, mlir::Value initVal, bool &needsDestroy) const {
+ mlir::ValueRange bounds, mlir::Value initVal,
+ mlir::acc::VariableInfoAttr varInfo, bool &needsDestroy) const {
mlir::ModuleOp mod = mlirBuilder.getInsertionBlock()
->getParent()
->getParentOfType<mlir::ModuleOp>();
@@ -900,31 +925,35 @@ template mlir::Value
OpenACCMappableModel<fir::BaseBoxType>::generatePrivateInit(
mlir::Type type, mlir::OpBuilder &builder, mlir::Location loc,
mlir::TypedValue<mlir::acc::MappableType> var, llvm::StringRef varName,
- mlir::ValueRange extents, mlir::Value initVal, bool &needsDestroy) const;
+ mlir::ValueRange extents, mlir::Value initVal,
+ mlir::acc::VariableInfoAttr varInfo, bool &needsDestroy) const;
template mlir::Value
OpenACCMappableModel<fir::ReferenceType>::generatePrivateInit(
mlir::Type type, mlir::OpBuilder &builder, mlir::Location loc,
mlir::TypedValue<mlir::acc::MappableType> var, llvm::StringRef varName,
- mlir::ValueRange extents, mlir::Value initVal, bool &needsDestroy) const;
+ mlir::ValueRange extents, mlir::Value initVal,
+ mlir::acc::VariableInfoAttr varInfo, bool &needsDestroy) const;
template mlir::Value OpenACCMappableModel<fir::HeapType>::generatePrivateInit(
mlir::Type type, mlir::OpBuilder &builder, mlir::Location loc,
mlir::TypedValue<mlir::acc::MappableType> var, llvm::StringRef varName,
- mlir::ValueRange extents, mlir::Value initVal, bool &needsDestroy) const;
+ mlir::ValueRange extents, mlir::Value initVal,
+ mlir::acc::VariableInfoAttr varInfo, bool &needsDestroy) const;
template mlir::Value
OpenACCMappableModel<fir::PointerType>::generatePrivateInit(
mlir::Type type, mlir::OpBuilder &builder, mlir::Location loc,
mlir::TypedValue<mlir::acc::MappableType> var, llvm::StringRef varName,
- mlir::ValueRange extents, mlir::Value initVal, bool &needsDestroy) const;
+ mlir::ValueRange extents, mlir::Value initVal,
+ mlir::acc::VariableInfoAttr varInfo, bool &needsDestroy) const;
template <typename Ty>
bool OpenACCMappableModel<Ty>::generateCopy(
mlir::Type type, mlir::OpBuilder &mlirBuilder, mlir::Location loc,
mlir::TypedValue<mlir::acc::MappableType> src,
- mlir::TypedValue<mlir::acc::MappableType> dest,
- mlir::ValueRange bounds) const {
+ mlir::TypedValue<mlir::acc::MappableType> dest, mlir::ValueRange bounds,
+ mlir::acc::VariableInfoAttr varInfo) const {
mlir::ModuleOp mod =
mlirBuilder.getBlock()->getParent()->getParentOfType<mlir::ModuleOp>();
assert(mod && "failed to retrieve parent module");
@@ -961,19 +990,23 @@ bool OpenACCMappableModel<Ty>::generateCopy(
template bool OpenACCMappableModel<fir::BaseBoxType>::generateCopy(
mlir::Type, mlir::OpBuilder &, mlir::Location,
mlir::TypedValue<mlir::acc::MappableType>,
- mlir::TypedValue<mlir::acc::MappableType>, mlir::ValueRange) const;
+ mlir::TypedValue<mlir::acc::MappableType>, mlir::ValueRange,
+ mlir::acc::VariableInfoAttr) const;
template bool OpenACCMappableModel<fir::ReferenceType>::generateCopy(
mlir::Type, mlir::OpBuilder &, mlir::Location,
mlir::TypedValue<mlir::acc::MappableType>,
- mlir::TypedValue<mlir::acc::MappableType>, mlir::ValueRange) const;
+ mlir::TypedValue<mlir::acc::MappableType>, mlir::ValueRange,
+ mlir::acc::VariableInfoAttr) const;
template bool OpenACCMappableModel<fir::PointerType>::generateCopy(
mlir::Type, mlir::OpBuilder &, mlir::Location,
mlir::TypedValue<mlir::acc::MappableType>,
- mlir::TypedValue<mlir::acc::MappableType>, mlir::ValueRange) const;
+ mlir::TypedValue<mlir::acc::MappableType>, mlir::ValueRange,
+ mlir::acc::VariableInfoAttr) const;
template bool OpenACCMappableModel<fir::HeapType>::generateCopy(
mlir::Type, mlir::OpBuilder &, mlir::Location,
mlir::TypedValue<mlir::acc::MappableType>,
- mlir::TypedValue<mlir::acc::MappableType>, mlir::ValueRange) const;
+ mlir::TypedValue<mlir::acc::MappableType>, mlir::ValueRange,
+ mlir::acc::VariableInfoAttr) const;
template <typename Op>
static mlir::Value genLogicalCombiner(fir::FirOpBuilder &builder,
@@ -1175,7 +1208,8 @@ template bool OpenACCMappableModel<fir::HeapType>::generateCombiner(
template <typename Ty>
bool OpenACCMappableModel<Ty>::generatePrivateDestroy(
mlir::Type type, mlir::OpBuilder &mlirBuilder, mlir::Location loc,
- mlir::Value privatized, mlir::ValueRange bounds) const {
+ mlir::Value privatized, mlir::ValueRange bounds,
+ mlir::acc::VariableInfoAttr varInfo) const {
hlfir::Entity inputVar = hlfir::Entity{privatized};
mlir::ModuleOp mod =
mlirBuilder.getBlock()->getParent()->getParentOfType<mlir::ModuleOp>();
@@ -1210,16 +1244,20 @@ bool OpenACCMappableModel<Ty>::generatePrivateDestroy(
template bool OpenACCMappableModel<fir::BaseBoxType>::generatePrivateDestroy(
mlir::Type type, mlir::OpBuilder &builder, mlir::Location loc,
- mlir::Value privatized, mlir::ValueRange bounds) const;
+ mlir::Value privatized, mlir::ValueRange bounds,
+ mlir::acc::VariableInfoAttr varInfo) const;
template bool OpenACCMappableModel<fir::ReferenceType>::generatePrivateDestroy(
mlir::Type type, mlir::OpBuilder &builder, mlir::Location loc,
- mlir::Value privatized, mlir::ValueRange bounds) const;
+ mlir::Value privatized, mlir::ValueRange bounds,
+ mlir::acc::VariableInfoAttr varInfo) const;
template bool OpenACCMappableModel<fir::HeapType>::generatePrivateDestroy(
mlir::Type type, mlir::OpBuilder &builder, mlir::Location loc,
- mlir::Value privatized, mlir::ValueRange bounds) const;
+ mlir::Value privatized, mlir::ValueRange bounds,
+ mlir::acc::VariableInfoAttr varInfo) const;
template bool OpenACCMappableModel<fir::PointerType>::generatePrivateDestroy(
mlir::Type type, mlir::OpBuilder &builder, mlir::Location loc,
- mlir::Value privatized, mlir::ValueRange bounds) const;
+ mlir::Value privatized, mlir::ValueRange bounds,
+ mlir::acc::VariableInfoAttr varInfo) const;
template <typename Ty>
mlir::Value OpenACCPointerLikeModel<Ty>::genAllocate(
diff --git a/flang/lib/Optimizer/OpenACC/Support/FIROpenACCUtils.cpp b/flang/lib/Optimizer/OpenACC/Support/FIROpenACCUtils.cpp
index 3a8f548fefdf6..3f35d3a796d82 100644
--- a/flang/lib/Optimizer/OpenACC/Support/FIROpenACCUtils.cpp
+++ b/flang/lib/Optimizer/OpenACC/Support/FIROpenACCUtils.cpp
@@ -459,13 +459,16 @@ static RecipeOp genRecipeOp(
auto mappableTy = mlir::dyn_cast<mlir::acc::MappableType>(ty);
assert(mappableTy &&
"Expected that all variable types are considered mappable");
+ auto initArg = mlir::cast<MappableValue>(initBlock->getArgument(0));
+ mlir::acc::VariableInfoAttr varInfo =
+ mappableTy.genPrivateVariableInfo(initArg);
bool needsDestroy = false;
llvm::SmallVector<mlir::Value> initBounds =
getRecipeBounds(builder, loc, dataOperationBounds,
initBlock->getArguments().drop_front(1));
mlir::Value retVal = mappableTy.generatePrivateInit(
- builder, loc, mlir::cast<MappableValue>(initBlock->getArgument(0)),
- initName, initBounds, initValue, needsDestroy);
+ builder, loc, initArg, initName, initBounds, initValue, varInfo,
+ needsDestroy);
mlir::acc::YieldOp::create(builder, loc, retVal);
// Create destroy region and generate destruction if requested.
if (needsDestroy) {
@@ -491,7 +494,7 @@ static RecipeOp genRecipeOp(
getRecipeBounds(builder, loc, dataOperationBounds,
destroyBlock->getArguments().drop_front(2));
[[maybe_unused]] bool success = mappableTy.generatePrivateDestroy(
- builder, loc, destroyBlock->getArgument(1), destroyBounds);
+ builder, loc, destroyBlock->getArgument(1), destroyBounds, varInfo);
assert(success && "failed to generate destroy region");
mlir::acc::TerminatorOp::create(builder, loc);
}
@@ -543,8 +546,10 @@ mlir::SymbolRefAttr fir::acc::createOrGetFirstprivateRecipe(
auto mappableTy = mlir::dyn_cast<mlir::acc::MappableType>(ty);
assert(mappableTy &&
"Expected that all variable types are considered mappable");
- [[maybe_unused]] bool success =
- mappableTy.generateCopy(builder, loc, source, destination, copyBounds);
+ mlir::acc::VariableInfoAttr copyVarInfo =
+ mappableTy.genPrivateVariableInfo(source);
+ [[maybe_unused]] bool success = mappableTy.generateCopy(
+ builder, loc, source, destination, copyBounds, copyVarInfo);
assert(success && "failed to generate copy");
mlir::acc::TerminatorOp::create(builder, loc);
return mlir::SymbolRefAttr::get(builder.getContext(), recipe.getSymName());
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACC.h b/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
index 55fc8251a9bbd..9e7a15feb2e70 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACC.h
@@ -13,6 +13,7 @@
#ifndef MLIR_DIALECT_OPENACC_OPENACC_H_
#define MLIR_DIALECT_OPENACC_OPENACC_H_
+#include "mlir/Dialect/OpenACC/OpenACCVariableInfo.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCAttributes.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCAttributes.td
new file mode 100644
index 0000000000000..4c2efba461184
--- /dev/null
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCAttributes.td
@@ -0,0 +1,24 @@
+//===- OpenACCAttributes.td - OpenACC Attributes -----------*- tablegen -*-===//
+//
+// Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Defines OpenACC Attributes than can be extended by the dialects outside of
+// of OpenACC.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef OPENACC_ATTRIBUTES
+#define OPENACC_ATTRIBUTES
+
+include "mlir/IR/AttrTypeBase.td"
+
+// Trait for attributes that carry OpenACC variable information.
+def OpenACC_IsVariableInfoAttr : NativeAttrTrait<"IsVariableInfo"> {
+ let cppNamespace = "::mlir::acc::AttributeTrait";
+}
+
+#endif // OPENACC_ATTRIBUTES
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
index c8030b14e96c1..32ecaa6bc2d42 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
@@ -20,6 +20,7 @@ include "mlir/IR/BuiltinTypes.td"
include "mlir/IR/EnumAttr.td"
include "mlir/IR/OpBase.td"
include "mlir/IR/SymbolInterfaces.td"
+include "mlir/Dialect/OpenACC/OpenACCAttributes.td"
include "mlir/Dialect/OpenACC/OpenACCBase.td"
include "mlir/Dialect/OpenACC/OpenACCOpsTypes.td"
include "mlir/Dialect/OpenACC/OpenACCOpsInterfaces.td"
@@ -1444,11 +1445,13 @@ def OpenACC_PrivateRecipeOp
/// and it must be a valid place for this operation to be inserted. The
/// `recipeName` must be a unique name to prevent "redefinition of symbol"
/// IR errors.
+ /// The `hostVar` is the original host variable from which the type and
+ /// language-specific metadata are derived.
static std::optional<PrivateRecipeOp> createAndPopulate(
::mlir::OpBuilder &builder,
::mlir::Location loc,
::llvm::StringRef recipeName,
- ::mlir::Type varType,
+ ::mlir::Value hostVar,
::llvm::StringRef varName = "",
::mlir::ValueRange bounds = {});
@@ -1569,11 +1572,13 @@ def OpenACC_FirstprivateRecipeOp
/// and it must be a valid place for this operation to be inserted. The
/// `recipeName` must be a unique name to prevent "redefinition of symbol"
/// IR errors.
+ /// The `hostVar` is the original host variable from which the type and
+ /// language-specific metadata are derived.
static std::optional<FirstprivateRecipeOp> createAndPopulate(
::mlir::OpBuilder &builder,
::mlir::Location loc,
::llvm::StringRef recipeName,
- ::mlir::Type varType,
+ ::mlir::Value hostVar,
::llvm::StringRef varName = "",
::mlir::ValueRange bounds = {});
}];
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCTypeInterfaces.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCTypeInterfaces.td
index 97def012990c0..3bd4e5c679659 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACCTypeInterfaces.td
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCTypeInterfaces.td
@@ -354,6 +354,26 @@ def OpenACC_MappableTypeInterface : TypeInterface<"MappableType"> {
return ::mlir::acc::VariableTypeCategory::uncategorized;
}]
>,
+ InterfaceMethod<
+ /*description=*/[{
+ Produces a `VariableInfo` for a host variable. This enables passing
+ language-specific metadata (that is not captured in the type system)
+ to recipe code-generation helpers such as `generatePrivateInit`,
+ `generateCopy`, and `generatePrivateDestroy`.
+
+ The `var` is the host variable from which to extract information.
+ Implementations may use `getDefiningOp()` on this value.
+
+ The default implementation returns a null `VariableInfo`.
+ }],
+ /*retTy=*/"::mlir::acc::VariableInfoAttr",
+ /*methodName=*/"genPrivateVariableInfo",
+ /*args=*/(ins "::mlir::TypedValue<::mlir::acc::MappableType>":$var),
+ /*methodBody=*/"",
+ /*defaultImplementation=*/[{
+ return ::mlir::acc::VariableInfoAttr();
+ }]
+ >,
InterfaceMethod<
/*description=*/[{
Generates the operations that would be normally placed in a recipe's
@@ -368,6 +388,10 @@ def OpenACC_MappableTypeInterface : TypeInterface<"MappableType"> {
The `initVal` can be empty - it is primarily needed for reductions
to ensure the variable is also initialized with appropriate value.
+ The `varInfo` carries language-specific metadata about the original
+ host variable (produced by `genPrivateVariableInfo`). Implementations
+ can `dyn_cast` to their language-specific subclass.
+
The `needsDestroy` out-parameter is set by implementations to indicate
that destruction code must be generated after the returned private
variable usages, typically in the destroy region of recipe operations
@@ -387,6 +411,7 @@ def OpenACC_MappableTypeInterface : TypeInterface<"MappableType"> {
...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/186368
More information about the Mlir-commits
mailing list