diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -278,6 +278,8 @@ "SIMD"_id >> construct(construct()) || "SIMDLEN" >> construct(construct( parenthesized(scalarIntConstantExpr))) || + "SIZES" >> construct(construct( + parenthesized(nonemptyList(scalarIntExpr)))) || "THREADS" >> construct(construct()) || "THREAD_LIMIT" >> construct(construct( parenthesized(scalarIntExpr))) || @@ -334,7 +336,8 @@ pure(llvm::omp::Directive::OMPD_teams_distribute_parallel_do), "TEAMS DISTRIBUTE SIMD" >> pure(llvm::omp::Directive::OMPD_teams_distribute_simd), - "TEAMS DISTRIBUTE" >> pure(llvm::omp::Directive::OMPD_teams_distribute))))) + "TEAMS DISTRIBUTE" >> pure(llvm::omp::Directive::OMPD_teams_distribute), + "TILE" >> pure(llvm::omp::Directive::OMPD_tile))))) TYPE_PARSER(sourced(construct( sourced(Parser{}), Parser{}))) diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp --- a/flang/lib/Parser/unparse.cpp +++ b/flang/lib/Parser/unparse.cpp @@ -2150,6 +2150,9 @@ case llvm::omp::Directive::OMPD_teams_distribute_simd: Word("TEAMS DISTRIBUTE SIMD "); break; + case llvm::omp::Directive::OMPD_tile: + Word("TILE "); + break; default: break; } diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -1221,6 +1221,7 @@ case llvm::omp::Directive::OMPD_teams_distribute_parallel_do: case llvm::omp::Directive::OMPD_teams_distribute_parallel_do_simd: case llvm::omp::Directive::OMPD_teams_distribute_simd: + case llvm::omp::Directive::OMPD_tile: PushContext(beginDir.source, beginDir.v); break; default: diff --git a/flang/test/Parser/omp-tile-size.f90 b/flang/test/Parser/omp-tile-size.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Parser/omp-tile-size.f90 @@ -0,0 +1,23 @@ +! RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck --ignore-case %s +! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s + +subroutine openmp_tiles(x) + + integer, intent(inout)::x + +!CHECK: !$omp tile sizes +!$omp tile sizes(2) +!CHECK: do + do x = 1, 100 + call F1() +!CHECK: end do + end do +!CHECK: !$omp end tile +!$omp end tile + + +!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct +!PARSE-TREE: OmpBeginLoopDirective +!PARSE-TREE: OmpLoopDirective -> llvm::omp::Directive = tile +!PARSE-TREE: OmpClauseList -> OmpClause -> Sizes -> Scalar -> Integer -> Expr = '2_4' +END subroutine openmp_tiles diff --git a/flang/test/Parser/omp-tile.f90 b/flang/test/Parser/omp-tile.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Parser/omp-tile.f90 @@ -0,0 +1,23 @@ +! RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck --ignore-case %s +! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s + +subroutine openmp_tiles(x) + + integer, intent(inout)::x + +!CHECK: !$omp tile +!$omp tile +!CHECK: do + do x = 1, 100 + call F1() +!CHECK: end do + end do +!CHECK: !$omp end tile +!$omp end tile + +!PARSE-TREE: OpenMPConstruct -> OpenMPLoopConstruct +!PARSE-TREE: OmpBeginLoopDirective +!PARSE-TREE: OmpLoopDirective -> llvm::omp::Directive = tile + +END subroutine openmp_tiles + diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td --- a/llvm/include/llvm/Frontend/OpenMP/OMP.td +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -67,7 +67,11 @@ let clangClass = "OMPPrivateClause"; let flangClass = "OmpObjectList"; } -def OMPC_Sizes: Clause<"sizes"> { let clangClass = "OMPSizesClause"; } +def OMPC_Sizes: Clause<"sizes"> { + let clangClass = "OMPSizesClause"; + let flangClass = "ScalarIntExpr"; + let isValueList = true; + } def OMPC_Full: Clause<"full"> { let clangClass = "OMPFullClause"; } def OMPC_Partial: Clause<"partial"> { let clangClass = "OMPPartialClause"; } def OMPC_FirstPrivate : Clause<"firstprivate"> {