@@ -64,13 +64,13 @@ class OpenACCRecipeBuilderBase {
6464 // doesn't restore it aftewards.
6565 void createReductionRecipeCombiner (mlir::Location loc, mlir::Location locEnd,
6666 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);
7474
7575 void createRecipeDestroySection (mlir::Location loc, mlir::Location locEnd,
7676 mlir::Value mainOp, CharUnits alignment,
@@ -224,10 +224,10 @@ class OpenACCRecipeBuilder : OpenACCRecipeBuilderBase {
224224 // TODO: OpenACC: This is a bit of a hackery to get this to not change for
225225 // the non-private recipes. This will be removed soon, when we get this
226226 // '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 >) {
228228 if (numBounds) {
229229 cgf.cgm .errorNYI (varRef->getSourceRange (),
230- " firstprivate/reduction -init with bounds" );
230+ " firstprivate-init with bounds" );
231231 }
232232 boundTypes = {};
233233 numBounds = 0 ;
@@ -260,18 +260,25 @@ class OpenACCRecipeBuilder : OpenACCRecipeBuilderBase {
260260 insertLocation = modBuilder.saveInsertionPoint ();
261261
262262 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);
266272 } 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.
267278 createRecipeInitCopy (loc, locEnd, varRef->getSourceRange (), mainOp,
268279 recipe, varRecipe, temporary);
269280 }
270281
271- if constexpr (std::is_same_v<RecipeTy, mlir::acc::ReductionRecipeOp>) {
272- createReductionRecipeCombiner (loc, locEnd, mainOp, recipe);
273- }
274-
275282 if (origType.isDestructedType ())
276283 createRecipeDestroySection (
277284 loc, locEnd, mainOp, cgf.getContext ().getDeclAlign (varRecipe),
0 commit comments