23#include "mlir/Dialect/OpenACC/OpenACC.h"
28 void makeAllocaCopy(mlir::Location loc, mlir::Type copyType,
29 mlir::Value numEltsToCopy, mlir::Value offsetPerSubarray,
30 mlir::Value destAlloca, mlir::Value srcAlloca);
33 mlir::Value makeBoundsAlloca(mlir::Block *block,
SourceRange exprRange,
34 mlir::Location loc, std::string_view allocaName,
38 void makeBoundsInit(mlir::Value alloca, mlir::Location loc,
39 mlir::Block *block,
const VarDecl *allocaDecl,
40 QualType origType,
bool isInitSection);
47 mlir::Location loc,
size_t numBounds,
52 std::pair<mlir::Value, mlir::Value>
53 createBoundsLoop(mlir::Value subscriptedValue, mlir::Value subscriptedValue2,
54 mlir::Value bound, mlir::Location loc,
bool inverse);
57 mlir::Location loc,
bool inverse) {
68 mlir::Location loc, mlir::Location locEnd, mlir::Value mainOp,
69 mlir::acc::ReductionRecipeOp recipe,
size_t numBounds,
QualType origType,
74 mlir::Region &recipeInitRegion,
size_t numBounds,
83 mlir::Region ©Region,
size_t numBounds);
89 mlir::Region &destroyRegion);
96template <
typename RecipeTy>
101 std::string recipeName;
103 llvm::raw_string_ostream stream(recipeName);
105 if constexpr (std::is_same_v<RecipeTy, mlir::acc::PrivateRecipeOp>) {
106 stream <<
"privatization_";
107 }
else if constexpr (std::is_same_v<RecipeTy,
108 mlir::acc::FirstprivateRecipeOp>) {
109 stream <<
"firstprivatization_";
111 }
else if constexpr (std::is_same_v<RecipeTy,
112 mlir::acc::ReductionRecipeOp>) {
113 stream <<
"reduction_";
117 switch (reductionOp) {
146 llvm_unreachable(
"invalid reduction operator");
149 static_assert(!
sizeof(RecipeTy),
"Unknown Recipe op kind");
155 stream <<
"_Bcnt" << numBounds <<
'_';
168 ASTContext &astCtx, mlir::OpBuilder::InsertPoint &insertLocation,
174 reductionCombinerRecipes) {
176 BuiltinType::ArraySection) &&
177 "array section shouldn't make it to recipe creation");
179 mlir::ModuleOp mod =
builder.getBlock()
181 ->template getParentOfType<mlir::ModuleOp>();
183 std::string recipeName = getRecipeName(varRef->
getSourceRange(), baseType,
184 numBounds, reductionOp);
185 if (
auto recipe = mod.lookupSymbol<RecipeTy>(recipeName))
189 mlir::Location locEnd =
cgf.cgm.getLoc(varRef->
getEndLoc());
191 mlir::OpBuilder modBuilder(mod.getBodyRegion());
192 if (insertLocation.isSet())
193 modBuilder.restoreInsertionPoint(insertLocation);
196 if constexpr (std::is_same_v<RecipeTy, mlir::acc::ReductionRecipeOp>) {
197 recipe = RecipeTy::create(modBuilder, loc, recipeName, mainOp.getType(),
200 recipe = RecipeTy::create(modBuilder, loc, recipeName, mainOp.getType());
202 insertLocation = modBuilder.saveInsertionPoint();
204 if constexpr (std::is_same_v<RecipeTy, mlir::acc::PrivateRecipeOp>) {
206 recipe.getInitRegion(), numBounds, boundTypes, varRecipe,
208 }
else if constexpr (std::is_same_v<RecipeTy,
209 mlir::acc::ReductionRecipeOp>) {
211 recipe.getInitRegion(), numBounds, boundTypes, varRecipe,
214 origType, reductionCombinerRecipes);
216 static_assert(std::is_same_v<RecipeTy, mlir::acc::FirstprivateRecipeOp>);
218 recipe.getInitRegion(), numBounds, boundTypes, varRecipe,
221 recipe.getCopyRegion(), numBounds);
226 loc, locEnd, mainOp,
cgf.getContext().getDeclAlign(varRecipe),
227 origType, numBounds, baseType, recipe.getDestroyRegion());
Defines the clang::ASTContext interface.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines some OpenACC-specific enums and functions.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void createReductionRecipeCombiner(mlir::Location loc, mlir::Location locEnd, mlir::Value mainOp, mlir::acc::ReductionRecipeOp recipe, size_t numBounds, QualType origType, llvm::ArrayRef< OpenACCReductionRecipe::CombinerRecipe > combinerRecipes)
OpenACCRecipeBuilderBase(CIRGen::CIRGenFunction &cgf, CIRGen::CIRGenBuilderTy &builder)
mlir::Value createBoundsLoop(mlir::Value subscriptedValue, mlir::Value bound, mlir::Location loc, bool inverse)
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, bool emitInitExpr)
CIRGen::CIRGenBuilderTy & builder
void createFirstprivateRecipeCopy(mlir::Location loc, mlir::Location locEnd, mlir::Value mainOp, const VarDecl *allocaDecl, const VarDecl *temporary, mlir::Region ©Region, size_t numBounds)
mlir::acc::ReductionOperator convertReductionOp(OpenACCReductionOperator op)
CIRGen::CIRGenFunction & cgf
std::pair< mlir::Value, mlir::Value > createBoundsLoop(mlir::Value subscriptedValue, mlir::Value subscriptedValue2, mlir::Value bound, mlir::Location loc, bool inverse)
void createRecipeDestroySection(mlir::Location loc, mlir::Location locEnd, mlir::Value mainOp, CharUnits alignment, QualType origType, size_t numBounds, QualType baseType, mlir::Region &destroyRegion)
mlir::Block * createRecipeBlock(mlir::Region ®ion, mlir::Type opTy, mlir::Location loc, size_t numBounds, bool isInit)
OpenACCRecipeBuilder(CIRGen::CIRGenFunction &cgf, CIRGen::CIRGenBuilderTy &builder)
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, llvm::ArrayRef< OpenACCReductionRecipe::CombinerRecipe > reductionCombinerRecipes)
CharUnits - This is an opaque type for sizes expressed in character units.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
This represents one expression.
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
virtual void mangleCanonicalTypeName(QualType T, raw_ostream &, bool NormalizeIntegers=false)=0
Generates a unique string for an externally visible type for use with TBAA or type uniquing.
A (possibly-)qualified type.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
A trivial tuple used to represent a source range.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Represents a variable declaration or definition.
@ Invalid
Invalid Reduction Clause Kind.