@@ -64,13 +64,13 @@ class OpenACCRecipeBuilderBase {
64
64
// doesn't restore it aftewards.
65
65
void createReductionRecipeCombiner (mlir::Location loc, mlir::Location locEnd,
66
66
mlir::Value mainOp,
67
- mlir::acc::ReductionRecipeOp recipe);
68
- void createPrivateInitRecipe (mlir::Location loc, mlir::Location locEnd,
69
- SourceRange exprRange , mlir::Value mainOp ,
70
- mlir::acc::PrivateRecipeOp recipe ,
71
- size_t numBounds,
72
- llvm::ArrayRef<QualType> boundTypes,
73
- const VarDecl *allocaDecl, QualType origType);
67
+ mlir::acc::ReductionRecipeOp recipe,
68
+ size_t numBounds);
69
+ void createInitRecipe (mlir::Location loc , mlir::Location locEnd ,
70
+ SourceRange exprRange, mlir::Value mainOp ,
71
+ mlir::Region &recipeInitRegion, size_t numBounds,
72
+ llvm::ArrayRef<QualType> boundTypes,
73
+ const VarDecl *allocaDecl, QualType origType);
74
74
75
75
void createRecipeDestroySection (mlir::Location loc, mlir::Location locEnd,
76
76
mlir::Value mainOp, CharUnits alignment,
@@ -224,10 +224,10 @@ class OpenACCRecipeBuilder : OpenACCRecipeBuilderBase {
224
224
// TODO: OpenACC: This is a bit of a hackery to get this to not change for
225
225
// the non-private recipes. This will be removed soon, when we get this
226
226
// 'right' for firstprivate and reduction.
227
- if constexpr (! std::is_same_v<RecipeTy, mlir::acc::PrivateRecipeOp >) {
227
+ if constexpr (std::is_same_v<RecipeTy, mlir::acc::FirstprivateRecipeOp >) {
228
228
if (numBounds) {
229
229
cgf.cgm .errorNYI (varRef->getSourceRange (),
230
- " firstprivate/reduction -init with bounds" );
230
+ " firstprivate-init with bounds" );
231
231
}
232
232
boundTypes = {};
233
233
numBounds = 0 ;
@@ -260,18 +260,25 @@ class OpenACCRecipeBuilder : OpenACCRecipeBuilderBase {
260
260
insertLocation = modBuilder.saveInsertionPoint ();
261
261
262
262
if constexpr (std::is_same_v<RecipeTy, mlir::acc::PrivateRecipeOp>) {
263
- createPrivateInitRecipe (loc, locEnd, varRef->getSourceRange (), mainOp,
264
- recipe, numBounds, boundTypes, varRecipe,
265
- origType);
263
+ createInitRecipe (loc, locEnd, varRef->getSourceRange (), mainOp,
264
+ recipe.getInitRegion (), numBounds, boundTypes, varRecipe,
265
+ origType);
266
+ } else if constexpr (std::is_same_v<RecipeTy,
267
+ mlir::acc::ReductionRecipeOp>) {
268
+ createInitRecipe (loc, locEnd, varRef->getSourceRange (), mainOp,
269
+ recipe.getInitRegion (), numBounds, boundTypes, varRecipe,
270
+ origType);
271
+ createReductionRecipeCombiner (loc, locEnd, mainOp, recipe, numBounds);
266
272
} else {
273
+ static_assert (std::is_same_v<RecipeTy, mlir::acc::FirstprivateRecipeOp>);
274
+ // TODO: OpenACC: we probably want this to call createInitRecipe as well,
275
+ // but do so in a way that omits the 'initialization', so that we can do
276
+ // it separately, since it belongs in the 'copy' region. It also might
277
+ // need a way of getting the tempDeclEmission out of it for that purpose.
267
278
createRecipeInitCopy (loc, locEnd, varRef->getSourceRange (), mainOp,
268
279
recipe, varRecipe, temporary);
269
280
}
270
281
271
- if constexpr (std::is_same_v<RecipeTy, mlir::acc::ReductionRecipeOp>) {
272
- createReductionRecipeCombiner (loc, locEnd, mainOp, recipe);
273
- }
274
-
275
282
if (origType.isDestructedType ())
276
283
createRecipeDestroySection (
277
284
loc, locEnd, mainOp, cgf.getContext ().getDeclAlign (varRecipe),
0 commit comments