================ @@ -378,81 +374,138 @@ class OpenACCClauseCIREmitter final // We don't have the reduction operation here well enough to know how to // spell this correctly (+ == 'add', etc), so when we implement // 'reduction' we have to do that here. - cgf.cgm.errorNYI(varRef->getSourceRange(), - "OpeNACC reduction recipe creation"); + cgf.cgm.errorNYI(loc, "OpenACC reduction recipe name creation"); } else { static_assert(!sizeof(RecipeTy), "Unknown Recipe op kind"); } MangleContext &mc = cgf.cgm.getCXXABI().getMangleContext(); mc.mangleCanonicalTypeName(baseType, stream); } + return recipeName; + } - if (auto recipe = mod.lookupSymbol<RecipeTy>(recipeName)) - return recipe; - - mlir::Location loc = cgf.cgm.getLoc(varRef->getBeginLoc()); - mlir::Location locEnd = cgf.cgm.getLoc(varRef->getEndLoc()); + // Create the 'init' section of the recipe, including the 'copy' section for + // 'firstprivate'. + template <typename RecipeTy> + void createRecipeInitCopy(mlir::Location loc, mlir::Location locEnd, + SourceRange exprRange, mlir::Value mainOp, + RecipeTy recipe, const VarDecl *varRecipe, + const VarDecl *temporary) { + assert(varRecipe && "Required recipe variable not set?"); + if constexpr (std::is_same_v<RecipeTy, mlir::acc::ReductionRecipeOp>) { + // We haven't implemented the 'init' recipe for Reduction yet, so NYI + // it. + cgf.cgm.errorNYI(exprRange, "OpenACC Reduction recipe init"); + } - mlir::OpBuilder modBuilder(mod.getBodyRegion()); - auto recipe = - RecipeTy::create(modBuilder, loc, recipeName, mainOp.getType()); + if constexpr (std::is_same_v<RecipeTy, mlir::acc::FirstprivateRecipeOp>) { + // We haven't implemented the 'init'/copy recipe for firstprivate yet, so + // NYI it. + cgf.cgm.errorNYI(exprRange, "OpenACC firstprivate recipe init"); + } CIRGenFunction::AutoVarEmission tempDeclEmission{ CIRGenFunction::AutoVarEmission::invalid()}; - // Init section. - { - llvm::SmallVector<mlir::Type> argsTys{mainOp.getType()}; - llvm::SmallVector<mlir::Location> argsLocs{loc}; - builder.createBlock(&recipe.getInitRegion(), recipe.getInitRegion().end(), - argsTys, argsLocs); - builder.setInsertionPointToEnd(&recipe.getInitRegion().back()); - - if constexpr (!std::is_same_v<RecipeTy, mlir::acc::PrivateRecipeOp>) { - // We have only implemented 'init' for private, so make this NYI until - // we have explicitly implemented everything. - cgf.cgm.errorNYI(varRef->getSourceRange(), - "OpenACC non-private recipe init"); + // Do the 'init' section of the recipe IR, which does an alloca, then the + // initialization (except for firstprivate). + llvm::SmallVector<mlir::Type> argsTys{mainOp.getType()}; + llvm::SmallVector<mlir::Location> argsLocs{loc}; + builder.createBlock(&recipe.getInitRegion(), recipe.getInitRegion().end(), + argsTys, argsLocs); ---------------- erichkeane wrote:
Yep, that works! Works for the argsLocs too, so I changed it here and below. Thanks! https://github.com/llvm/llvm-project/pull/153610 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits