[flang][OpenMP] Added parser support for Tile Construct ( OpenMP 5.1)
authorAbid Malik <abidmuslim@gmail.com>
Mon, 16 Jan 2023 17:41:30 +0000 (17:41 +0000)
committerKiran Chandramohan <kiran.chandramohan@arm.com>
Tue, 17 Jan 2023 11:50:22 +0000 (11:50 +0000)
Added parser support for Tile Construct .

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D136359

flang/lib/Parser/openmp-parsers.cpp
flang/lib/Parser/unparse.cpp
flang/lib/Semantics/resolve-directives.cpp
flang/test/Parser/omp-tile-size.f90 [new file with mode: 0644]
flang/test/Parser/omp-tile.f90 [new file with mode: 0644]
llvm/include/llvm/Frontend/OpenMP/OMP.td

index 0e9f742..49d6ef0 100644 (file)
@@ -278,6 +278,8 @@ TYPE_PARSER(
     "SIMD"_id >> construct<OmpClause>(construct<OmpClause::Simd>()) ||
     "SIMDLEN" >> construct<OmpClause>(construct<OmpClause::Simdlen>(
                      parenthesized(scalarIntConstantExpr))) ||
+    "SIZES" >> construct<OmpClause>(construct<OmpClause::Sizes>(
+                   parenthesized(nonemptyList(scalarIntExpr)))) ||
     "THREADS" >> construct<OmpClause>(construct<OmpClause::Threads>()) ||
     "THREAD_LIMIT" >> construct<OmpClause>(construct<OmpClause::ThreadLimit>(
                           parenthesized(scalarIntExpr))) ||
@@ -334,7 +336,8 @@ TYPE_PARSER(sourced(construct<OmpLoopDirective>(first(
         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<OmpBeginLoopDirective>(
     sourced(Parser<OmpLoopDirective>{}), Parser<OmpClauseList>{})))
index a8fb667..892d34b 100644 (file)
@@ -2150,6 +2150,9 @@ public:
     case llvm::omp::Directive::OMPD_teams_distribute_simd:
       Word("TEAMS DISTRIBUTE SIMD ");
       break;
+    case llvm::omp::Directive::OMPD_tile:
+      Word("TILE ");
+      break;
     default:
       break;
     }
index 82623ac..ec66f7d 100644 (file)
@@ -1221,6 +1221,7 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPLoopConstruct &x) {
   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 (file)
index 0000000..f40dc38
--- /dev/null
@@ -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 (file)
index 0000000..ee9b6aa
--- /dev/null
@@ -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
+
index 0b90aff..9c55f0f 100644 (file)
@@ -67,7 +67,11 @@ def OMPC_Private : Clause<"private"> {
   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"> {