Krzysztof Parzyszek e75e28ad3c
[flang][OpenMP] Use OmpDirectiveSpecification in Omp[Begin|End]LoopDi… (#159087)
…rective

This makes accessing directive components, such as directive name or the
list of clauses simpler and more uniform across different directives. It
also makes the parser simpler, since it reuses existing parsing
functionality.

The changes are scattered over a number of files, but they all share the
same nature:
- getting the begin/end directive from OpenMPLoopConstruct,
- getting the llvm::omp::Directive enum, and the source location,
- getting the clause list.
2025-09-16 11:38:03 -05:00

42 lines
1.5 KiB
Fortran

! 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 parallel_work
integer :: i
!CHECK: !$OMP TASKLOOP GRAINSIZE(STRICT: 500_4)
!PARSE-TREE: OmpBeginLoopDirective
!PARSE-TREE-NEXT: OmpDirectiveName -> llvm::omp::Directive = taskloop
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Grainsize -> OmpGrainsizeClause
!PARSE-TREE-NEXT: Modifier -> OmpPrescriptiveness -> Value = Strict
!PARSE-TREE-NEXT: Scalar -> Integer -> Expr = '500_4'
!$omp taskloop grainsize(strict: 500)
do i=1,10000
call loop_body(i)
end do
!$omp end taskloop
!CHECK: !$OMP TASKLOOP GRAINSIZE(500_4)
!PARSE-TREE: OmpBeginLoopDirective
!PARSE-TREE-NEXT: OmpDirectiveName -> llvm::omp::Directive = taskloop
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> Grainsize -> OmpGrainsizeClause
!PARSE-TREE-NEXT: Scalar -> Integer -> Expr = '500_4'
!$omp taskloop grainsize(500)
do i=1,10000
call loop_body(i)
end do
!$omp end taskloop
!CHECK: !$OMP TASKLOOP NUM_TASKS(STRICT: 500_4)
!PARSE-TREE: OmpBeginLoopDirective
!PARSE-TREE-NEXT: OmpDirectiveName -> llvm::omp::Directive = taskloop
!PARSE-TREE-NEXT: OmpClauseList -> OmpClause -> NumTasks -> OmpNumTasksClause
!PARSE-TREE-NEXT: Modifier -> OmpPrescriptiveness -> Value = Strict
!PARSE-TREE-NEXT: Scalar -> Integer -> Expr = '500_4'
!$omp taskloop num_tasks(strict: 500)
do i=1,10000
call loop_body(i)
end do
!$omp end taskloop
end subroutine parallel_work