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="LLVMDialect,OMPDialect" 3 4!=============================================================================== 5! Single construct 6!=============================================================================== 7 8!FIRDialect-LABEL: func @_QPomp_single 9!FIRDialect-SAME: (%[[x:.*]]: !fir.ref<i32> {fir.bindc_name = "x"}) 10subroutine omp_single(x) 11 integer, intent(inout) :: x 12 !OMPDialect: omp.parallel 13 !$omp parallel 14 !OMPDialect: omp.single 15 !$omp single 16 !FIRDialect: %[[xval:.*]] = fir.load %[[x]] : !fir.ref<i32> 17 !FIRDialect: %[[res:.*]] = arith.addi %[[xval]], %{{.*}} : i32 18 !FIRDialect: fir.store %[[res]] to %[[x]] : !fir.ref<i32> 19 x = x + 12 20 !OMPDialect: omp.terminator 21 !$omp end single 22 !OMPDialect: omp.terminator 23 !$omp end parallel 24end subroutine omp_single 25 26!=============================================================================== 27! Single construct with nowait 28!=============================================================================== 29 30!FIRDialect-LABEL: func @_QPomp_single_nowait 31!FIRDialect-SAME: (%[[x:.*]]: !fir.ref<i32> {fir.bindc_name = "x"}) 32subroutine omp_single_nowait(x) 33 integer, intent(inout) :: x 34 !OMPDialect: omp.parallel 35 !$omp parallel 36 !OMPDialect: omp.single nowait 37 !$omp single 38 !FIRDialect: %[[xval:.*]] = fir.load %[[x]] : !fir.ref<i32> 39 !FIRDialect: %[[res:.*]] = arith.addi %[[xval]], %{{.*}} : i32 40 !FIRDialect: fir.store %[[res]] to %[[x]] : !fir.ref<i32> 41 x = x + 12 42 !OMPDialect: omp.terminator 43 !$omp end single nowait 44 !OMPDialect: omp.terminator 45 !$omp end parallel 46end subroutine omp_single_nowait 47 48!=============================================================================== 49! Single construct with allocate 50!=============================================================================== 51 52!FIRDialect-LABEL: func @_QPsingle_allocate 53subroutine single_allocate() 54 use omp_lib 55 integer :: x 56 !OMPDialect: omp.parallel { 57 !$omp parallel 58 !OMPDialect: omp.single allocate( 59 !FIRDialect: %{{.+}} : i32 -> %{{.+}} : !fir.ref<i32> 60 !LLVMDialect: %{{.+}} : i32 -> %{{.+}} : !llvm.ptr<i32> 61 !OMPDialect: ) { 62 !$omp single allocate(omp_high_bw_mem_alloc: x) private(x) 63 !FIRDialect: arith.addi 64 x = x + 12 65 !OMPDialect: omp.terminator 66 !$omp end single 67 !OMPDialect: omp.terminator 68 !$omp end parallel 69end subroutine single_allocate 70