[flang] Re-write OpenMP 4.5 grammar doc with BNF
authorJinxin Yang <jinxiny@nvidia.com>
Fri, 24 May 2019 00:13:52 +0000 (17:13 -0700)
committerJinxin Yang <jinxiny@nvidia.com>
Fri, 24 May 2019 00:13:52 +0000 (17:13 -0700)
Original-commit: flang-compiler/f18@fe06ea9f607ab608cceaae762b2c92f37c136ee2
Reviewed-on: https://github.com/flang-compiler/f18/pull/470
Tree-same-pre-rewrite: false

flang/documentation/OpenMP-4.5-grammar.txt

index 1210dfd..0af5182 100644 (file)
-# Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
+# Copyright (c) 2018-2019, NVIDIA CORPORATION.  All rights reserved.
 # OpenMP 4.5 Specifications
 
-2 omp-directive -> sentinel directive-name [clause [,] clause...]
+2 omp-directive -> sentinel directive-name [clause[ [,] clause]...]
 2.1.1 sentinel -> !$omp | c$omp | *$omp
 2.1.2 sentinel -> !$omp
-# directive-name(constructs)
-2.5 parallel -> PARALLEL
-2.7.1 do -> DO
-2.7.2 sections -> SECTIONS
-2.7.3 workshare -> WORKSHARE
-2.7.4 single-construct -> SINGLE
-2.8.1 simd-construct -> SIMD
-2.8.2 declare-simd -> DECLARE SIMD
-2.8.3 do-simd-construct -> DO SIMD
-2.9.1 task-construct -> TASK
-2.9.2 taskloop -> TASKLOOP
-2.9.3 taskloop-simd -> TASKLOOP SIMD
+
+# directive-name
+2.5 parallel -> PARALLEL [parallel-clause[ [,] parallel-clause]...]
+    parallel-clause -> if-clause |
+                       num-threads-clause |
+                       default-clause |
+                       private-clause |
+                       firstprivate-clause |
+                       shared-clause |
+                       copyin-clause |
+                       reduction-clause |
+                       proc-bind-clause
+
+2.7.1 do -> DO [do-clause[ [,] do-clause]...]
+      do-clause -> private-clause |
+                   firstprivate-clause |
+                   lastprivate-clause |
+                   linear-clause |
+                   reduction-clause |
+                   schedule-clause |
+                   collapse-clause |
+                   ordered-clause
+
+2.7.1 end-do -> END DO [nowait-clause]
+
+2.7.2 sections -> SECTIONS [sections-clause[ [,] sections-clause]...]
+      sections-clause -> private-clause |
+                         firstprivate-clause |
+                         lastprivate-clause |
+                         reduction-clause
+
+2.7.2 end-sections -> END SECTIONS [nowait-clause]
+
+2.7.3 single -> SINGLE [single-clause[ [,] single-clause]...]
+      single-clause -> private-clause |
+                       firstprivate-clause
+
+2.7.3 end-single -> END SINGLE [end-single-clause[ [,] end-single-clause]...]
+      end-single-clause -> copyprivate-clause |
+                           nowait-clause
+
+2.7.4 workshare -> WORKSHARE
+
+2.7.4 end-workshare -> END WORKSHARE [nowait-clause]
+
+2.8.1 simd -> SIMD [simd-clause[ [,] simd-clause]...]
+      simd-clause -> safelen-clause |
+                     simdlen-clause |
+                     linear-clause |
+                     aligned-clause |
+                     private-clause |
+                     lastprivate-clause |
+                     reduction-clause |
+                     collapse-clause
+
+2.8.2 declare-simd -> DECLARE SIMD [(proc-name)] [declare-simd-clause[ [,] declare-simd-clause]...]
+      declare-simd-clause -> simdlen-clause |
+                             linear-clause |
+                             aligned-clause |
+                             uniform-clause |
+                             inbranch-clause |
+                             notinbranch-clause
+
+2.8.3 do-simd -> DO SIMD [do-simd-clause[ [,] do-simd-clause]...]
+      do-simd-clause -> do-clause |
+                        simd-clause
+
+2.8.4 end-do-simd -> END DO SIMD [nowait-clause]
+
+2.9.1 task -> TASK [task-clause[ [,] task-clause]...]
+      task-clause -> if-clause |
+                     final-clause |
+                     untied-clause |
+                     default-clause |
+                     mergeable-clause |
+                     private-clause |
+                     firstprivate-clause |
+                     shared-clause |
+                     depend-clause |
+                     priority-clause
+
+2.9.2 taskloop -> TASKLOOP [taskloop-clause[ [,] taskloop-clause]...]
+      taskloop-clause -> if-clause |
+                         shared-clause |
+                         private-clause |
+                         firstprivate-clause |
+                         lastprivate-clause |
+                         default-clause |
+                         grainsize-clause |
+                         num-tasks-clause |
+                         collapse-clause |
+                         final-clause |
+                         priority-clause |
+                         untied-clause |
+                         mergeable-clause |
+                         nogroup-clause
+
+2.9.3 taskloop-simd -> TASKLOOP SIMD [taskloop-simd-clause[ [,] taskloop-simd-clause]...]
+      taskloop-simd-clause -> taskloop-clause |
+                              simd-clause
+
 2.9.4 taskyield -> TASKYIELD
-2.10.1 target-data -> TARGET DATA
-2.10.2 target-enter-data -> TARGET ENTER DATA
-2.10.3 target-exit-data -> TARGET EXIT DATA
-2.10.4 target -> TARGET
-2.10.5 target-update -> TARGET UPDATE
-2.10.6 declare-target -> DECLARE TARGET
-2.10.7 teams -> TEAMS
-2.10.8 distribute -> DISTRIBUTE
-2.10.9 distribute-simd -> DISTRIBUTE SIMD
-2.10.10 distribute-parellel-do -> DISTRIBUTE PARALLEL DO
-2.10.11 distribute-parallel-do-simd ->DISTRIBUTE PARALLEL DO SIMD
-2.11.1 parallel-do -> PARALLEL DO
-2.11.2 parallel-sections -> PARALLEL SECTIONS
-2.11.3 parallel-workshare -> PARALLEL WORKSHARE
-2.11.4 parallel-do-simd -> PARALLEL DO SIMD
-2.11.5 target-parallel -> TARGET PARALLEL
-2.11.6 target-parallel-do -> TARGET PARALLEL DO
-2.11.7 target-parallel-do-simd -> TARGET PARALLEL DO SIMD
-2.11.8 target-simd -> TARGET SIMD
-2.11.9 target-teams -> TARGET TEAMS
-2.11.10 teams-distribute -> TEAMS DISTRIBUTE
-2.11.11 teams distribute-simd -> TEAMS DISTRIBUTE SIMD
-2.11.12 target-teams-distribute -> TARGET TEAMS DISTRIBUTE
-2.11.13 target-teams-distribute-simd -> TARGET TEAMS DISTRIBUTE SIMD
-2.11.14 teams-distribute-parallel-do -> TEAMS DISTRIBUTE PARALLEL DO
+
+2.10.1 target-data -> TARGET DATA target-data-clause[ [ [,] target-data-clause]...]
+       target-data-clause -> if-clause |
+                             device-clause |
+                             map-clause |
+                             use-device-ptr-clause
+
+2.10.2 target-enter-data -> TARGET ENTER DATA [ target-enter-data-clause[ [,] target-enter-data-clause]...]
+       target-enter-data-clause -> if-clause |
+                                   device-clause |
+                                   map-clause |
+                                   depend-clause |
+                                   nowait-clause
+
+2.10.3 target-exit-data -> TARGET EXIT DATA [ target-exit-data-clause[ [,] target-exit-data-clause]...]
+       target-exit-data-clause -> if-clause |
+                                  device-clause |
+                                  map-clause |
+                                  depend-clause |
+                                  nowait-clause
+
+2.10.4 target -> TARGET [target-clause[ [,] target-clause]...]
+       target-clause -> if-clause |
+                        device-clause |
+                        private-clause |
+                        firstprivate-clause |
+                        map-clause |
+                        is-device-ptr-clause |
+                        defaultmap-clause |
+                        nowait-clause |
+                        depend-clause
+
+2.10.5 target-update -> TARGET UPDATE target-update-clause[ [ [,] target-update-clause]...]
+       target-update-clause -> motion-clause |
+                               if-clause |
+                               device-clause |
+                               nowait-clause |
+                               depend-clause
+       motion-clause -> to-clause |
+                        from-clause
+
+2.10.6 declare-target -> DECLARE TARGET (extended-list)
+2.10.6 declare-target -> DECLARE TARGET [declare-target-clause[ [,] declare-target-clause]...]
+       declare-target-clause -> to-clause |
+                                link-clause
+
+2.10.7 teams -> TEAMS [teams-clause[ [,] teams-clause]...]
+       teams-clause -> num-teams-clause |
+                       thread-limit-clause |
+                       default-clause |
+                       private-clause |
+                       firstprivate-clause |
+                       shared-clause |
+                       reduction-clause
+
+2.10.8 distribute -> DISTRIBUTE [distribute-clause[ [,] distribute-clause]...]
+       distribute-clause -> private-clause |
+                            firstprivate-clause |
+                            lastprivate-clause |
+                            collapse-clause |
+                            dist-schedule-clause
+
+2.10.9 distribute-simd -> DISTRIBUTE SIMD [distribute-simd-clause[ [,] distribute-simd-clause]...]
+       distribute-simd-clause -> distribute-clause |
+                                 simd-clause
+
+2.10.10 distribute-parellel-do ->
+           DISTRIBUTE PARALLEL DO [distribute-parallel-do-clause[ [,] distribute-parallel-do-clause]...]
+        distribute-parallel-do-clause -> distribute-clause |
+                                         parallel-do-clause
+
+2.10.11 distribute-parallel-do-simd ->
+           DISTRIBUTE PARALLEL DO SIMD [distribute-parallel-do-simd-clause[ [,] distribute-parallel-do-simd-clause]...]
+        distribute-parallel-do-simd-clause -> distribute-clause |
+                                              parallel-do-simd-clause
+
+2.11.1 parallel-do -> PARALLEL DO [parallel-do-clause[ [,] parallel-do-clause]...]
+       parallel-do-clause -> parallel-clause |
+                             do-clause
+
+2.11.1 end-parallel-do -> END PARALLEL DO
+
+2.11.2 parallel-sections -> PARALLEL SECTIONS [parallel-sections-clause[ [,] parallel-sections-clause]...]
+       parallel-sections-clause -> parallel-clause |
+                                   sections-clause
+
+2.11.2 end-parallel-sections -> END PARALLEL SECTIONS
+
+2.11.3 parallel-workshare -> PARALLEL WORKSHARE [parallel-workshare-clause[ [,] parallel-workshare-clause]...]
+       parallel-workshare-clause -> parallel-clause
+
+2.11.3 end-parallel-workshare -> END PARALLEL WORKSHARE
+
+2.11.4 parallel-do-simd -> PARALLEL DO SIMD [parallel-do-simd-clause[ [,] parallel-do-simd-clause]...]
+       parallel-do-simd-clause -> parallel-clause |
+                                  do-simd-clause
+
+2.11.4 end-parallel-do-simd -> END PARALLEL DO SIMD
+
+2.11.5 target-parallel -> TARGET PARALLEL [target-parallel-clause[ [,] target-parallel-clause]...]
+       target-parallel-clause -> target-clause |
+                                 parallel-clause
+
+2.11.6 target-parallel-do -> TARGET PARALLEL DO [target-parallel-do-clause[ [,] target-parallel-do-clause]...]
+       target-parallel-do-clause -> target-clause |
+                                    parallel-do-clause
+
+2.11.7 target-parallel-do-simd ->
+          TARGET PARALLEL DO SIMD [target-parallel-do-simd-clause[ [,] target-parallel-do-simd-clause]...]
+       target-parallel-do-simd-clause -> target-clause |
+                                         parallel-do-simd-clause
+
+2.11.8 target-simd -> TARGET SIMD [target-simd-clause[ [,] target-simd-clause]...]
+       target-simd-clause -> target-clause |
+                             simd-clause
+
+2.11.9 target-teams -> TARGET TEAMS [target-teams-clause[ [,] target-teams-clause]...]
+       target-teams-clause -> target-clause |
+                              teams-clause
+
+2.11.10 teams-distribute -> TEAMS DISTRIBUTE [teams-distribute-clause[ [,] teams-distribute-clause]...]
+        teams-distribute-clause -> teams-clause |
+                                   distribute-clause
+
+2.11.11 teams-distribute-simd ->
+           TEAMS DISTRIBUTE SIMD [teams-distribute-simd-clause[ [,] teams-distribute-simd-clause]...]
+        teams-distribute-simd-clause -> teams-clause |
+                                        distribute-simd-clause
+
+2.11.12 target-teams-distribute ->
+           TARGET TEAMS DISTRIBUTE [target-teams-distribute-clause[ [,] target-teams-distribute-clause]...]
+        target-teams-distribute-clause -> target-clause |
+                                          teams-distribute-clause
+
+2.11.13 target-teams-distribute-simd ->
+           TARGET TEAMS DISTRIBUTE SIMD [target-teams-distribute-simd-clause[ [,] target-teams-distribute-simd-clause]...]
+        target-teams-distribute-simd-clause -> target-clause |
+                                               teams-distribute-simd-clause
+
+2.11.14 teams-distribute-parallel-do ->
+           TEAMS DISTRIBUTE PARALLEL DO [teams-distribute-parallel-do-clause[ [,] teams-distribute-parallel-do-clause]...]
+        teams-distribute-parallel-do-clause -> teams-clause |
+                                               distribute-parallel-do-clause
+
 2.11.15 target-teams-distribute-parallel-do ->
-                             TARGET TEAMS DISTRIBUTE PARALLEL DO
+           TARGET TEAMS DISTRIBUTE PARALLEL DO [target-teams-distribute-parallel-do-clause[ [,] target-teams-distribute-parallel-do-clause]...]
+        target-teams-distribute-parallel-do-clause -> target-clause |
+                                                      teams-distribute-parallel-do-clause
+
 2.11.16 teams-distribute-parallel-do-simd ->
-                             TEAMS DISTRIBUTE PARALLEL DO SIMD
+           TEAMS DISTRIBUTE PARALLEL DO SIMD [teams-distribute-parallel-do-simd-clause[ [,] teams-distribute-parallel-do-simd-clause]...]
+        teams-distribute-parallel-do-simd-clause -> teams-clause |
+                                                    distribute-parallel-do-simd-clause
+
 2.11.17 target-teams-distribute-parallel-do-simd ->
-                             TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
+           TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD [target-teams-distribute-parallel-do-simd-clause[ [,] target-teams-distribute-parallel-do-simd-clause]...]
+        target-teams-distribute-parallel-do-simd-clause -> target-clause |
+                                                           teams-distribute-parallel-do-simd-clause
+
 2.13.1 master -> MASTER
-2.13.2 critical -> CRITICAL
+
+2.13.2 critical -> CRITICAL [(name) [HINT(hint-expr)]]
+
+2.13.2 end-critical -> END CRITICAL [(name)]
+
 2.13.3 barrier -> BARRIER
+
 2.13.4 taskwait -> TASKWAIT
+
 2.13.5 taskgroup -> TASKGROUP
-2.13.6 atomic -> ATOMIC
-2.13.7 flush -> FLUSH
-2.13.8 ordered -> ORDERED
-2.14.1 cancel -> CANCEL
-2.14.2 cancellation-point -> CANCELLATION POINT
-2.15.2 threadprivate -> THREADPRIVATE
-2.16 declare-reduction -> DECLARE REDUCTION
+
+2.13.6 atomic -> ATOMIC [seq_cst[,]] READ | WRITE | UPDATE | CAPTURE [[,]seq_cst]
+2.13.6 atomic -> ATOMIC [seq_cst]
+
+2.13.7 flush -> FLUSH [(variable-name-list)]
+
+2.13.8 ordered -> ORDERED ordered-construct-clause [[[,] ordered-construct-clause]...]
+       ordered-construct-clause -> depend-clause
+
+2.14.1 cancel -> CANCEL construct-type-clause [ [,] if-clause]
+       construct-type-clause -> PARALLEL |
+                                SECTIONS |
+                                DO |
+                                TASKGROUP
+
+2.14.2 cancellation-point -> CANCELLATION POINT construct-type-clause
+
+2.15.2 threadprivate -> THREADPRIVATE (variable-name-list)
+
+2.16 declare-reduction -> DECLARE REDUCTION (reduction-identifier : type-list : combiner)
 
 # Clauses
-2.5 proc_bind -> PROC_BIND ( MASTER | CLOSE | SPREAD )
-2.5 num_threads -> NUM_THREADS(scalar-int-expr)
-2.7.1 schedule -> SCHEDULE ([sched-modifier] [, sched-modifier]:]
-                  kind[, chunk_size])
+2.5 proc-bind-clause -> PROC_BIND (MASTER | CLOSE | SPREAD)
+
+2.5 num-threads-clause -> NUM_THREADS (scalar-int-expr)
+
+2.7.1 schedule-clause -> SCHEDULE ([sched-modifier] [, sched-modifier]:]
+                                   kind[, chunk_size])
+
 2.7.1 kind -> STATIC | DYNAMIC | GUIDED | AUTO | RUNTIME
+
 2.7.1 sched-modifier -> MONOTONIC | NONMONOTONIC | SIMD
+
 2.7.1 chunk_size -> scalar-int-expr
-2.7.1 collapse -> COLLAPSE(scalar-constant)
-2.7.1 ordered -> ORDERED [ (scalar-constant) ]
-2.7.1 nowait -> NOWAIT
-2.8.1 aligned -> ALIGNED ( variable-name-list [ : scalar-constant])
-2.8.1 safelen -> SAFELEN ( scalar-constant )
-2.8.1 simdlen -> SIMDLEN ( scalar-contant )
-2.8.2 uniform -> UNIFORM (dummy-arg-name-list)
-2.8.2 inbranch -> INBRANCH
-2.8.2 notinbranch -> NOTINBRANCH
-2.13.9 depend -> DEPEND (((IN | OUT | INOUT) : variable-name-list) |
-                          SOURCE |
-                          SINK : vec)
-         vec -> iterator [ +/- scalar-int-expr:scalar-int-expr],..., iterator[...]
-2.9.2 num_tasks -> NUM_TASKS (scalar-int-expr)
-2.9.2 grainsize -> GRAINSIZE (scalar-int-expr)
-2.9.2 nogroup -> NOGROUP
-2.9.2 untied -> UNTIED
-2.9.2 priority -> PRIORITY (scalar-int-expr)
-2.9.2 mergeable -> MERGEABLE
-2.9.2 final -> FINAL (scalar-int-expr)
-2.10.1 use_device_ptr -> USE_DEVICE_PTR (variable-name-list)
-2.10.1 device -> DEVICE (scalar-integer-expr)
-2.10.5 to -> TO (variable-name-list)
-2.10.5 from -> FROM (variable-name-list)
-2.10.6 link -> LINK (variable-name-list)
-2.10.7 num_teams -> NUM_TEAMS (scalar-integer-expr)
-2.10.7 thread_limit -> THREAD_LIMIT (scalar-integer-expr)
-2.10.8 dist_schedule -> DIST_SCHEDULE (STATIC [ , chunk_size])
-2.12 if -> IF ([ directive-name-modifier ':' ] scalar-logical-expr)
-2.15.3.1 default -> DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE)
-2.15.3.2 shared -> SHARED (variable-name-list)
-2.15.3.3 private -> PRIVATE (variable-name-list)
-2.15.3.4 firstprivate -> FIRSTPRIVATE (variable-name-list)
-2.15.3.5 lastprivate -> LASTPRIVATE (variable-name-list)
-2.15.3.6 reduction -> REDUCTION(reduction-identifier: variable-name-list)
-2.15.3.7 linear -> LINEAR(linear-list [:linear-step])
-           linear-list -> list | modifier(list)
-           modifier -> REF | VAL | UVAL
-2.15.4.1 copyin -> COPYIN (variable-name-list)
-2.15.4.2 copyprivate -> COPYPRIVATE (variable-name-list)
-2.15.5.1 map -> MAP ([[ALWAYS[,]] (TO | FROM | TOFROM | ALLOC | RELEASE |
+
+2.7.1 collapse-clause -> COLLAPSE (scalar-constant)
+
+2.7.1 ordered-clause -> ORDERED [(scalar-constant)]
+
+2.7.1 nowait-clause -> NOWAIT
+
+2.8.1 aligned-clause -> ALIGNED (variable-name-list[ : scalar-constant])
+
+2.8.1 safelen-clause -> SAFELEN (scalar-constant)
+
+2.8.1 simdlen-clause -> SIMDLEN (scalar-contant)
+
+2.8.2 uniform-clause -> UNIFORM (dummy-arg-name-list)
+
+2.8.2 inbranch-clause -> INBRANCH
+
+2.8.2 notinbranch-clause -> NOTINBRANCH
+
+2.13.9 depend-clause -> DEPEND (((IN | OUT | INOUT) : variable-name-list) |
+                                SOURCE |
+                                SINK : vec)
+                 vec -> iterator [+/- scalar-int-expr],..., iterator[...]
+
+2.9.2 num-tasks-clause -> NUM_TASKS (scalar-int-expr)
+
+2.9.2 grainsize-clause -> GRAINSIZE (scalar-int-expr)
+
+2.9.2 nogroup-clause -> NOGROUP
+
+2.9.2 untied-clause -> UNTIED
+
+2.9.2 priority-clause -> PRIORITY (scalar-int-expr)
+
+2.9.2 mergeable-clause -> MERGEABLE
+
+2.9.2 final-clause -> FINAL (scalar-int-expr)
+
+2.10.1 use-device-ptr-clause -> USE_DEVICE_PTR (variable-name-list)
+
+2.10.1 device-clause -> DEVICE (scalar-integer-expr)
+
+2.10.4 is-device-ptr-clause -> IS_DEVICE_PTR (variable-name-list)
+
+2.10.5 to-clause -> TO (variable-name-list)
+
+2.10.5 from-clause -> FROM (variable-name-list)
+
+2.10.6 link-clause -> LINK (variable-name-list)
+
+2.10.7 num-teams-clause -> NUM_TEAMS (scalar-integer-expr)
+
+2.10.7 thread-limit-clause -> THREAD_LIMIT (scalar-integer-expr)
+
+2.10.8 dist-schedule-clause -> DIST_SCHEDULE (STATIC [ , chunk_size])
+
+2.12 if-clause -> IF ([ directive-name-modifier :] scalar-logical-expr)
+
+2.15.3.1 default-clause -> DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE)
+
+2.15.3.2 shared-clause -> SHARED (variable-name-list)
+
+2.15.3.3 private-clause -> PRIVATE (variable-name-list)
+
+2.15.3.4 firstprivate-clause -> FIRSTPRIVATE (variable-name-list)
+
+2.15.3.5 lastprivate-clause -> LASTPRIVATE (variable-name-list)
+
+2.15.3.6 reduction-clause -> REDUCTION (reduction-identifier: variable-name-list)
+         reduction-identifier -> + | - | * | .AND. | .OR. | .EQV. | .NEQV. |
+                                 MAX | MIN | IAND | IOR | IEOR
+
+2.15.3.7 linear-clause -> LINEAR (linear-list[ : linear-step])
+         linear-list -> list | modifier(list)
+         modifier -> REF | VAL | UVAL
+
+2.15.4.1 copyin-clause -> COPYIN (variable-name-list)
+
+2.15.4.2 copyprivate-clause -> COPYPRIVATE (variable-name-list)
+
+2.15.5.1 map -> MAP ([ [ALWAYS[,]] (TO | FROM | TOFROM | ALLOC | RELEASE |
                                   DELETE) : ] variable-name-list)
-2.15.5.2 defaultmap -> DEFAULTMAP(TOFROM:SCALAR)
+
+2.15.5.2 defaultmap -> DEFAULTMAP (TOFROM:SCALAR)