[clang] [OpenACC] 'reduction' 'one-init' lowering, */&& operators. (PR #156122)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 2 06:39:51 PDT 2025
================
@@ -2589,6 +2589,59 @@ SemaOpenACC::ActOnOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc) {
return BuildOpenACCAsteriskSizeExpr(AsteriskLoc);
}
+/// Loops through a type and generates an appropriate InitListExpr to generate
+/// type initialization.
+static Expr *GenerateReductionInitRecipeExpr(ASTContext &Context,
+ SourceRange ExprRange,
+ QualType Ty) {
+ Ty = Ty.getCanonicalType();
+ llvm::SmallVector<Expr *> Exprs;
+
+ if (const RecordDecl *RD = Ty->getAsRecordDecl()) {
+ for (auto *F : RD->fields()) {
+ if (Expr *NewExpr =
+ GenerateReductionInitRecipeExpr(Context, ExprRange, F->getType()))
+ Exprs.push_back(NewExpr);
+ else
+ return nullptr;
+ }
+ } else if (const ConstantArrayType *AT = Context.getAsConstantArrayType(Ty)) {
----------------
erichkeane wrote:
`ConstantArrayType` means 'not a VLA' in this context (not that it is constant, it is that it is a constant size).
At the moment, we CAN get here with a pointer/VLA, but I haven't figured out how to implement that yet, and will probably do so next (for a few things). I probably could use a NYI in the normal init generation for pointer types at the moment. BUT since that is not Reduction specific, I'll do that in a separate patch if thats OK.
https://github.com/llvm/llvm-project/pull/156122
More information about the cfe-commits
mailing list