@@ -2862,14 +2862,11 @@ class FirConverter : public Fortran::lower::AbstractConverter {
28622862 if (nestedLoops > 1 )
28632863 n = builder->getIntegerAttr (builder->getI64Type (), nestedLoops);
28642864
2865- const std::list<Fortran::parser::CUFKernelDoConstruct::StarOrExpr> &grid =
2866- std::get<1 >(dir.t );
2867- const std::list<Fortran::parser::CUFKernelDoConstruct::StarOrExpr> &block =
2868- std::get<2 >(dir.t );
2869- const std::optional<Fortran::parser::ScalarIntExpr> &stream =
2870- std::get<3 >(dir.t );
2865+ const auto &launchConfig = std::get<std::optional<
2866+ Fortran::parser::CUFKernelDoConstruct::LaunchConfiguration>>(dir.t );
2867+
28712868 const std::list<Fortran::parser::CUFReduction> &cufreds =
2872- std::get<4 >(dir.t );
2869+ std::get<2 >(dir.t );
28732870
28742871 llvm::SmallVector<mlir::Value> reduceOperands;
28752872 llvm::SmallVector<mlir::Attribute> reduceAttrs;
@@ -2913,35 +2910,45 @@ class FirConverter : public Fortran::lower::AbstractConverter {
29132910 builder->createIntegerConstant (loc, builder->getI32Type (), 0 );
29142911
29152912 llvm::SmallVector<mlir::Value> gridValues;
2916- if (!isOnlyStars (grid)) {
2917- for (const Fortran::parser::CUFKernelDoConstruct::StarOrExpr &expr :
2918- grid) {
2919- if (expr.v ) {
2920- gridValues.push_back (fir::getBase (
2921- genExprValue (*Fortran::semantics::GetExpr (*expr.v ), stmtCtx)));
2922- } else {
2923- gridValues.push_back (zero);
2913+ llvm::SmallVector<mlir::Value> blockValues;
2914+ mlir::Value streamValue;
2915+
2916+ if (launchConfig) {
2917+ const std::list<Fortran::parser::CUFKernelDoConstruct::StarOrExpr> &grid =
2918+ std::get<0 >(launchConfig->t );
2919+ const std::list<Fortran::parser::CUFKernelDoConstruct::StarOrExpr>
2920+ &block = std::get<1 >(launchConfig->t );
2921+ const std::optional<Fortran::parser::ScalarIntExpr> &stream =
2922+ std::get<2 >(launchConfig->t );
2923+ if (!isOnlyStars (grid)) {
2924+ for (const Fortran::parser::CUFKernelDoConstruct::StarOrExpr &expr :
2925+ grid) {
2926+ if (expr.v ) {
2927+ gridValues.push_back (fir::getBase (
2928+ genExprValue (*Fortran::semantics::GetExpr (*expr.v ), stmtCtx)));
2929+ } else {
2930+ gridValues.push_back (zero);
2931+ }
29242932 }
29252933 }
2926- }
2927- llvm::SmallVector<mlir::Value> blockValues;
2928- if (!isOnlyStars (block)) {
2929- for (const Fortran::parser::CUFKernelDoConstruct::StarOrExpr &expr :
2930- block) {
2931- if (expr.v ) {
2932- blockValues.push_back (fir::getBase (
2933- genExprValue (*Fortran::semantics::GetExpr (*expr.v ), stmtCtx)));
2934- } else {
2935- blockValues.push_back (zero);
2934+ if (!isOnlyStars (block)) {
2935+ for (const Fortran::parser::CUFKernelDoConstruct::StarOrExpr &expr :
2936+ block) {
2937+ if (expr.v ) {
2938+ blockValues.push_back (fir::getBase (
2939+ genExprValue (*Fortran::semantics::GetExpr (*expr.v ), stmtCtx)));
2940+ } else {
2941+ blockValues.push_back (zero);
2942+ }
29362943 }
29372944 }
2945+
2946+ if (stream)
2947+ streamValue = builder->createConvert (
2948+ loc, builder->getI32Type (),
2949+ fir::getBase (
2950+ genExprValue (*Fortran::semantics::GetExpr (*stream), stmtCtx)));
29382951 }
2939- mlir::Value streamValue;
2940- if (stream)
2941- streamValue = builder->createConvert (
2942- loc, builder->getI32Type (),
2943- fir::getBase (
2944- genExprValue (*Fortran::semantics::GetExpr (*stream), stmtCtx)));
29452952
29462953 const auto &outerDoConstruct =
29472954 std::get<std::optional<Fortran::parser::DoConstruct>>(kernel.t );
0 commit comments