24#include "mlir/Dialect/OpenACC/OpenACC.h"
29 void makeAllocaCopy(mlir::Location loc, mlir::Type copyType,
30 mlir::Value numEltsToCopy, mlir::Value offsetPerSubarray,
31 mlir::Value destAlloca, mlir::Value srcAlloca);
34 mlir::Value makeBoundsAlloca(mlir::Block *block,
SourceRange exprRange,
35 mlir::Location loc, std::string_view allocaName,
39 void makeBoundsInit(mlir::Value alloca, mlir::Location loc,
40 mlir::Block *block,
const VarDecl *allocaDecl,
41 QualType origType,
bool isInitSection);
48 mlir::Location loc,
size_t numBounds,
53 std::pair<mlir::Value, mlir::Value>
54 createBoundsLoop(mlir::Value subscriptedValue, mlir::Value subscriptedValue2,
55 mlir::Value bound, mlir::Location loc,
bool inverse);
58 mlir::Location loc,
bool inverse) {
69 mlir::Location loc, mlir::Location locEnd, mlir::Value mainOp,
70 mlir::acc::ReductionRecipeOp recipe,
size_t numBounds,
QualType origType,
75 mlir::Region &recipeInitRegion,
size_t numBounds,
84 mlir::Region ©Region,
size_t numBounds);
90 mlir::Region &destroyRegion);
97template <
typename RecipeTy>
102 std::string recipeName;
104 llvm::raw_string_ostream stream(recipeName);
106 if constexpr (std::is_same_v<RecipeTy, mlir::acc::PrivateRecipeOp>) {
107 stream <<
"privatization_";
108 }
else if constexpr (std::is_same_v<RecipeTy,
109 mlir::acc::FirstprivateRecipeOp>) {
110 stream <<
"firstprivatization_";
112 }
else if constexpr (std::is_same_v<RecipeTy,
113 mlir::acc::ReductionRecipeOp>) {
114 stream <<
"reduction_";
118 switch (reductionOp) {
147 llvm_unreachable(
"invalid reduction operator");
150 static_assert(!
sizeof(RecipeTy),
"Unknown Recipe op kind");
156 stream <<
"_Bcnt" << numBounds <<
'_';
169 ASTContext &astCtx, mlir::OpBuilder::InsertPoint &insertLocation,
175 reductionCombinerRecipes) {
177 BuiltinType::ArraySection) &&
178 "array section shouldn't make it to recipe creation");
180 mlir::ModuleOp mod =
builder.getBlock()
182 ->template getParentOfType<mlir::ModuleOp>();
184 std::string recipeName = getRecipeName(varRef->
getSourceRange(), baseType,
185 numBounds, reductionOp);
186 if (
auto recipe = mod.lookupSymbol<RecipeTy>(recipeName))
190 mlir::Location locEnd =
cgf.cgm.getLoc(varRef->
getEndLoc());
192 mlir::OpBuilder modBuilder(mod.getBodyRegion());
193 if (insertLocation.isSet())
194 modBuilder.restoreInsertionPoint(insertLocation);
197 if constexpr (std::is_same_v<RecipeTy, mlir::acc::ReductionRecipeOp>) {
198 recipe = RecipeTy::create(modBuilder, loc, recipeName,
199 nullptr, mainOp.getType(),
202 recipe = RecipeTy::create(modBuilder, loc, recipeName,
203 nullptr, mainOp.getType());
205 insertLocation = modBuilder.saveInsertionPoint();
207 if constexpr (std::is_same_v<RecipeTy, mlir::acc::PrivateRecipeOp>) {
209 recipe.getInitRegion(), numBounds, boundTypes, varRecipe,
211 }
else if constexpr (std::is_same_v<RecipeTy,
212 mlir::acc::ReductionRecipeOp>) {
214 recipe.getInitRegion(), numBounds, boundTypes, varRecipe,
217 origType, reductionCombinerRecipes);
219 static_assert(std::is_same_v<RecipeTy, mlir::acc::FirstprivateRecipeOp>);
221 recipe.getInitRegion(), numBounds, boundTypes, varRecipe,
224 recipe.getCopyRegion(), numBounds);
229 loc, locEnd, mainOp,
cgf.getContext().getDeclAlign(varRecipe),
230 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.