@@ -2177,6 +2177,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
21772177 mlir::BoolAttr t = mlir::BoolAttr::get (builder->getContext (), true );
21782178 mlir::LLVM::LoopVectorizeAttr va;
21792179 mlir::LLVM::LoopUnrollAttr ua;
2180+ mlir::LLVM::LoopUnrollAndJamAttr uja;
21802181 bool has_attrs = false ;
21812182 for (const auto *dir : dirs) {
21822183 Fortran::common::visit (
@@ -2198,12 +2199,23 @@ class FirConverter : public Fortran::lower::AbstractConverter {
21982199 {}, /* full*/ u.v .has_value () ? f : t, {}, {}, {});
21992200 has_attrs = true ;
22002201 },
2202+ [&](const Fortran::parser::CompilerDirective::UnrollAndJam &u) {
2203+ mlir::IntegerAttr countAttr;
2204+ if (u.v .has_value ()) {
2205+ countAttr = builder->getIntegerAttr (builder->getI64Type (),
2206+ u.v .value ());
2207+ }
2208+ uja = mlir::LLVM::LoopUnrollAndJamAttr::get (
2209+ builder->getContext (), /* disable=*/ f, /* count*/ countAttr,
2210+ {}, {}, {}, {}, {});
2211+ has_attrs = true ;
2212+ },
22012213 [&](const auto &) {}},
22022214 dir->u );
22032215 }
22042216 mlir::LLVM::LoopAnnotationAttr la = mlir::LLVM::LoopAnnotationAttr::get (
2205- builder->getContext (), {}, /* vectorize=*/ va, {}, /* unroll*/ ua, {}, {},
2206- {}, {}, {}, {}, {}, {}, {}, {}, {});
2217+ builder->getContext (), {}, /* vectorize=*/ va, {}, /* unroll*/ ua,
2218+ /* unroll_and_jam */ uja, {}, {}, {}, {}, {}, {}, {}, {}, {}, {});
22072219 if (has_attrs)
22082220 info.doLoop .setLoopAnnotationAttr (la);
22092221 }
@@ -2859,6 +2871,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
28592871 [&](const Fortran::parser::CompilerDirective::Unroll &) {
28602872 attachDirectiveToLoop (dir, &eval);
28612873 },
2874+ [&](const Fortran::parser::CompilerDirective::UnrollAndJam &) {
2875+ attachDirectiveToLoop (dir, &eval);
2876+ },
28622877 [&](const auto &) {}},
28632878 dir.u );
28642879 }
0 commit comments