Skip to content

Commit dc39fa3

Browse files
authored
[OpenACC][CIR] copyout clause lowering on func-local declare (#169350)
This is identical to 'copy' and 'copyin', except it uses 'create' and 'copyout' as its entry/exit op. This patch adds the same tests, and similar code for all of it.
1 parent e442c67 commit dc39fa3

File tree

3 files changed

+216
-3
lines changed

3 files changed

+216
-3
lines changed

clang/lib/CIR/CodeGen/CIRGenDeclOpenACC.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ struct OpenACCDeclareCleanup final : EHScopeStack::Cleanup {
6565
createOutOp<mlir::acc::DeleteOp>(cgf, copyin);
6666
break;
6767
}
68+
} else if (auto create = val.getDefiningOp<mlir::acc::CreateOp>()) {
69+
switch (create.getDataClause()) {
70+
default:
71+
cgf.cgm.errorNYI(declareRange,
72+
"OpenACC local declare clause create cleanup");
73+
break;
74+
case mlir::acc::DataClause::acc_copyout:
75+
createOutOp<mlir::acc::CopyoutOp>(cgf, create);
76+
break;
77+
}
6878
} else if (val.getDefiningOp<mlir::acc::DeclareLinkOp>()) {
6979
// Link has no exit clauses, and shouldn't be copied.
7080
continue;

clang/lib/CIR/CodeGen/CIRGenOpenACCClause.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,12 +853,16 @@ class OpenACCClauseCIREmitter final
853853
var, mlir::acc::DataClause::acc_copyout, clause.getModifierList(),
854854
/*structured=*/false,
855855
/*implicit=*/false);
856+
} else if constexpr (isOneOfTypes<OpTy, mlir::acc::DeclareEnterOp>) {
857+
for (const Expr *var : clause.getVarList())
858+
addDataOperand<mlir::acc::CreateOp>(
859+
var, mlir::acc::DataClause::acc_copyout, clause.getModifierList(),
860+
/*structured=*/true,
861+
/*implicit=*/false);
856862
} else if constexpr (isCombinedType<OpTy>) {
857863
applyToComputeOp(clause);
858864
} else {
859-
// TODO: When we've implemented this for everything, switch this to an
860-
// unreachable. declare construct remains.
861-
return clauseNotImplemented(clause);
865+
llvm_unreachable("Unknown construct kind in VisitCopyOutClause");
862866
}
863867
}
864868

0 commit comments

Comments
 (0)