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) {
69 mlir::acc::ReductionRecipeOp recipe,
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,
172 mlir::Value mainOp) {
174 BuiltinType::ArraySection) &&
175 "array section shouldn't make it to recipe creation");
177 mlir::ModuleOp mod =
builder.getBlock()
179 ->template getParentOfType<mlir::ModuleOp>();
181 std::string recipeName = getRecipeName(varRef->
getSourceRange(), baseType,
182 numBounds, reductionOp);
183 if (
auto recipe = mod.lookupSymbol<RecipeTy>(recipeName))
187 mlir::Location locEnd =
cgf.cgm.getLoc(varRef->
getEndLoc());
189 mlir::OpBuilder modBuilder(mod.getBodyRegion());
190 if (insertLocation.isSet())
191 modBuilder.restoreInsertionPoint(insertLocation);
194 if constexpr (std::is_same_v<RecipeTy, mlir::acc::ReductionRecipeOp>) {
195 recipe = RecipeTy::create(modBuilder, loc, recipeName, mainOp.getType(),
198 recipe = RecipeTy::create(modBuilder, loc, recipeName, mainOp.getType());
200 insertLocation = modBuilder.saveInsertionPoint();
202 if constexpr (std::is_same_v<RecipeTy, mlir::acc::PrivateRecipeOp>) {
204 recipe.getInitRegion(), numBounds, boundTypes, varRecipe,
206 }
else if constexpr (std::is_same_v<RecipeTy,
207 mlir::acc::ReductionRecipeOp>) {
209 recipe.getInitRegion(), numBounds, boundTypes, varRecipe,
213 static_assert(std::is_same_v<RecipeTy, mlir::acc::FirstprivateRecipeOp>);
215 recipe.getInitRegion(), numBounds, boundTypes, varRecipe,
218 recipe.getCopyRegion(), numBounds);
223 loc, locEnd, mainOp,
cgf.getContext().getDeclAlign(varRecipe),
224 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 ...
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)
void createReductionRecipeCombiner(mlir::Location loc, mlir::Location locEnd, mlir::Value mainOp, mlir::acc::ReductionRecipeOp recipe, size_t numBounds)
mlir::Block * createRecipeBlock(mlir::Region ®ion, mlir::Type opTy, mlir::Location loc, size_t numBounds, bool isInit)
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)
OpenACCRecipeBuilder(CIRGen::CIRGenFunction &cgf, CIRGen::CIRGenBuilderTy &builder)
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.