aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h')
-rw-r--r--clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h63
1 files changed, 37 insertions, 26 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h b/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h
index acd187b..21707ad 100644
--- a/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h
+++ b/clang/lib/CIR/CodeGen/CIRGenOpenACCRecipe.h
@@ -24,6 +24,10 @@
namespace clang::CIRGen {
class OpenACCRecipeBuilderBase {
+ // makes the copy of the addresses of an alloca to the previous allocation.
+ void makeAllocaCopy(mlir::Location loc, mlir::Type copyType,
+ mlir::Value numEltsToCopy, mlir::Value offsetPerSubarray,
+ mlir::Value destAlloca, mlir::Value srcAlloca);
// This function generates the required alloca, similar to
// 'emitAutoVarAlloca', except for the OpenACC array/pointer types.
mlir::Value makeBoundsAlloca(mlir::Block *block, SourceRange exprRange,
@@ -31,6 +35,10 @@ class OpenACCRecipeBuilderBase {
size_t numBounds,
llvm::ArrayRef<QualType> boundTypes);
+ void makeBoundsInit(mlir::Value alloca, mlir::Location loc,
+ mlir::Block *block, const VarDecl *allocaDecl,
+ QualType origType, bool isInitSection);
+
protected:
CIRGen::CIRGenFunction &cgf;
CIRGen::CIRGenBuilderTy &builder;
@@ -56,14 +64,13 @@ protected:
// doesn't restore it aftewards.
void createReductionRecipeCombiner(mlir::Location loc, mlir::Location locEnd,
mlir::Value mainOp,
- mlir::acc::ReductionRecipeOp recipe);
- void createPrivateInitRecipe(mlir::Location loc, mlir::Location locEnd,
- SourceRange exprRange, mlir::Value mainOp,
- mlir::acc::PrivateRecipeOp recipe,
- size_t numBounds,
- llvm::ArrayRef<QualType> boundTypes,
- const VarDecl *allocaDecl, QualType origType,
- const Expr *initExpr);
+ mlir::acc::ReductionRecipeOp recipe,
+ size_t numBounds);
+ void createInitRecipe(mlir::Location loc, mlir::Location locEnd,
+ SourceRange exprRange, mlir::Value mainOp,
+ mlir::Region &recipeInitRegion, size_t numBounds,
+ llvm::ArrayRef<QualType> boundTypes,
+ const VarDecl *allocaDecl, QualType origType);
void createRecipeDestroySection(mlir::Location loc, mlir::Location locEnd,
mlir::Value mainOp, CharUnits alignment,
@@ -204,15 +211,12 @@ public:
OpenACCRecipeBuilder(CIRGen::CIRGenFunction &cgf,
CIRGen::CIRGenBuilderTy &builder)
: OpenACCRecipeBuilderBase(cgf, builder) {}
- RecipeTy getOrCreateRecipe(ASTContext &astCtx,
- mlir::OpBuilder::InsertPoint &insertLocation,
- const Expr *varRef, const VarDecl *varRecipe,
- const Expr *initExpr, const VarDecl *temporary,
- OpenACCReductionOperator reductionOp,
- DeclContext *dc, QualType origType,
- size_t numBounds,
- llvm::ArrayRef<QualType> boundTypes,
- QualType baseType, mlir::Value mainOp) {
+ RecipeTy getOrCreateRecipe(
+ ASTContext &astCtx, mlir::OpBuilder::InsertPoint &insertLocation,
+ const Expr *varRef, const VarDecl *varRecipe, const VarDecl *temporary,
+ OpenACCReductionOperator reductionOp, DeclContext *dc, QualType origType,
+ size_t numBounds, llvm::ArrayRef<QualType> boundTypes, QualType baseType,
+ mlir::Value mainOp) {
assert(!varRecipe->getType()->isSpecificBuiltinType(
BuiltinType::ArraySection) &&
"array section shouldn't make it to recipe creation");
@@ -220,10 +224,10 @@ public:
// TODO: OpenACC: This is a bit of a hackery to get this to not change for
// the non-private recipes. This will be removed soon, when we get this
// 'right' for firstprivate and reduction.
- if constexpr (!std::is_same_v<RecipeTy, mlir::acc::PrivateRecipeOp>) {
+ if constexpr (std::is_same_v<RecipeTy, mlir::acc::FirstprivateRecipeOp>) {
if (numBounds) {
cgf.cgm.errorNYI(varRef->getSourceRange(),
- "firstprivate/reduction-init with bounds");
+ "firstprivate-init with bounds");
}
boundTypes = {};
numBounds = 0;
@@ -256,18 +260,25 @@ public:
insertLocation = modBuilder.saveInsertionPoint();
if constexpr (std::is_same_v<RecipeTy, mlir::acc::PrivateRecipeOp>) {
- createPrivateInitRecipe(loc, locEnd, varRef->getSourceRange(), mainOp,
- recipe, numBounds, boundTypes, varRecipe,
- origType, initExpr);
+ createInitRecipe(loc, locEnd, varRef->getSourceRange(), mainOp,
+ recipe.getInitRegion(), numBounds, boundTypes, varRecipe,
+ origType);
+ } else if constexpr (std::is_same_v<RecipeTy,
+ mlir::acc::ReductionRecipeOp>) {
+ createInitRecipe(loc, locEnd, varRef->getSourceRange(), mainOp,
+ recipe.getInitRegion(), numBounds, boundTypes, varRecipe,
+ origType);
+ createReductionRecipeCombiner(loc, locEnd, mainOp, recipe, numBounds);
} else {
+ static_assert(std::is_same_v<RecipeTy, mlir::acc::FirstprivateRecipeOp>);
+ // TODO: OpenACC: we probably want this to call createInitRecipe as well,
+ // but do so in a way that omits the 'initialization', so that we can do
+ // it separately, since it belongs in the 'copy' region. It also might
+ // need a way of getting the tempDeclEmission out of it for that purpose.
createRecipeInitCopy(loc, locEnd, varRef->getSourceRange(), mainOp,
recipe, varRecipe, temporary);
}
- if constexpr (std::is_same_v<RecipeTy, mlir::acc::ReductionRecipeOp>) {
- createReductionRecipeCombiner(loc, locEnd, mainOp, recipe);
- }
-
if (origType.isDestructedType())
createRecipeDestroySection(
loc, locEnd, mainOp, cgf.getContext().getDeclAlign(varRecipe),