Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / associate-construct-2.f90
blob1d0adb86e7690f068d9132c49c662931f88f2468
1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
3 ! CHECK-LABEL: func @_QPtest1(
4 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_3:.*]]: !fir.ref<i32>{{.*}}) {
5 ! CHECK: %[[VAL_4:.*]] = arith.constant 100 : index
6 ! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
7 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i32) -> i64
8 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
9 ! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
10 ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (i32) -> i64
11 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i64) -> index
12 ! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
13 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (i32) -> i64
14 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i64) -> index
15 ! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
16 ! CHECK: %[[VAL_15:.*]] = fir.slice %[[VAL_7]], %[[VAL_13]], %[[VAL_10]] : (index, index, index) -> !fir.slice<1>
17 ! CHECK: %[[VAL_16:.*]] = fir.embox %[[VAL_0]](%[[VAL_14]]) {{\[}}%[[VAL_15]]] : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<?xf32>>
18 ! CHECK: fir.call @_QPbob(%[[VAL_16]]) {{.*}}: (!fir.box<!fir.array<?xf32>>) -> ()
19 ! CHECK: return
20 ! CHECK: }
22 subroutine test1(a,i,j,k)
24 real a(100)
25 integer i, j, k
26 interface
27 subroutine bob(a)
28 real :: a(:)
29 end subroutine bob
30 end interface
32 associate (name => a(i:j:k))
33 call bob(name)
34 end associate
35 end subroutine test1
37 ! CHECK-LABEL: func @_QPtest2(
38 ! CHECK-SAME: %[[nadd:.*]]: !fir.ref<i32>{{.*}})
39 subroutine test2(n)
40 integer :: n
41 integer, external :: foo
42 ! CHECK: %[[n:.*]] = fir.load %[[nadd]] : !fir.ref<i32>
43 ! CHECK: %[[n10:.*]] = arith.addi %[[n]], %c10{{.*}} : i32
44 ! CHECK: fir.store %[[n10]] to %{{.*}} : !fir.ref<i32>
45 ! CHECK: %[[foo:.*]] = fir.call @_QPfoo(%{{.*}}) {{.*}}: (!fir.ref<i32>) -> i32
46 ! CHECK: fir.store %[[foo]] to %{{.*}} : !fir.ref<i32>
47 associate (i => n, j => n + 10, k => foo(20))
48 print *, i, j, k, n
49 end associate
50 end subroutine test2