1!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefixes="FIRDialect,OMPDialect"
2!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | fir-opt --cfg-conversion | fir-opt --fir-to-llvm-ir | FileCheck %s --check-prefixes="OMPDialect,LLVMDialect"
3
4!===============================================================================
5! Parallel sections construct
6!===============================================================================
7
8!FIRDialect: func @_QPomp_parallel_sections
9subroutine omp_parallel_sections(x, y)
10  integer, intent(inout) :: x, y
11  !OMPDialect: omp.parallel {
12  !OMPDialect: omp.sections {
13  !$omp parallel sections
14    !OMPDialect: omp.section {
15    !$omp section
16      !FIRDialect: fir.load
17      !FIRDialect: arith.addi
18      !FIRDialect: fir.store
19      x = x + 12
20      !OMPDialect: omp.terminator
21    !OMPDialect: omp.section {
22    !$omp section
23      !FIRDialect: fir.load
24      !FIRDialect: arith.subi
25      !FIRDialect: fir.store
26      y = y - 5
27      !OMPDialect: omp.terminator
28  !OMPDialect: omp.terminator
29  !OMPDialect: omp.terminator
30  !$omp end parallel sections
31end subroutine omp_parallel_sections
32
33!===============================================================================
34! Parallel sections construct with allocate clause
35!===============================================================================
36
37!FIRDialect: func @_QPomp_parallel_sections
38subroutine omp_parallel_sections_allocate(x, y)
39  use omp_lib
40  integer, intent(inout) :: x, y
41  !FIRDialect: %[[allocator:.*]] = arith.constant 1 : i32
42  !LLVMDialect: %[[allocator:.*]] = llvm.mlir.constant(1 : i32) : i32
43  !OMPDialect: omp.parallel allocate(%[[allocator]] : i32 -> %{{.*}} : !fir.ref<i32>) {
44  !OMPDialect: omp.sections {
45  !$omp parallel sections allocate(omp_high_bw_mem_alloc: x)
46    !OMPDialect: omp.section {
47    !$omp section
48      x = x + 12
49      !OMPDialect: omp.terminator
50    !OMPDialect: omp.section {
51    !$omp section
52      y = y + 5
53      !OMPDialect: omp.terminator
54  !OMPDialect: omp.terminator
55  !OMPDialect: omp.terminator
56  !$omp end parallel sections
57end subroutine omp_parallel_sections_allocate
58