Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / OpenMP / parallel-sections.f90
blob0b04bfadfb84902b244e52273baca916be0267ee
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"
4 !===============================================================================
5 ! Parallel sections construct
6 !===============================================================================
8 !FIRDialect: func @_QPomp_parallel_sections
9 subroutine 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
31 end subroutine omp_parallel_sections
33 !===============================================================================
34 ! Parallel sections construct with allocate clause
35 !===============================================================================
37 !FIRDialect: func @_QPomp_parallel_sections
38 subroutine 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 {
44 !OMPDialect: omp.sections allocate(
45 !FIRDialect: %[[allocator]] : i32 -> %{{.*}} : !fir.ref<i32>) {
46 !LLVMDialect: %[[allocator]] : i32 -> %{{.*}} : !llvm.ptr<i32>) {
47 !$omp parallel sections allocate(omp_high_bw_mem_alloc: x)
48 !OMPDialect: omp.section {
49 !$omp section
50 x = x + 12
51 !OMPDialect: omp.terminator
52 !OMPDialect: omp.section {
53 !$omp section
54 y = y + 5
55 !OMPDialect: omp.terminator
56 !OMPDialect: omp.terminator
57 !OMPDialect: omp.terminator
58 !$omp end parallel sections
59 end subroutine omp_parallel_sections_allocate