1
- ! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefixes HOST
1
+ ! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes HOST
2
2
3
3
4
4
! HOST-LABEL: func.func @_QPread_write_section() {
5
5
! HOST: %0 = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFread_write_sectionEi"}
6
6
! HOST: %[[READ:.*]] = fir.address_of(@_QFread_write_sectionEsp_read) : !fir.ref<!fir.array<10xi32>>
7
+ ! HOST: %[[C10:.*]] = arith.constant 10 : index
8
+ ! HOST: %[[READ_SHAPE:.*]] = fir.shape %[[C10]] : (index) -> !fir.shape<1>
9
+ ! HOST: %[[READ_DECL:.*]]:2 = hlfir.declare %[[READ]](%[[READ_SHAPE]]) {uniq_name = "_QFread_write_sectionEsp_read"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
7
10
! HOST: %[[WRITE:.*]] = fir.address_of(@_QFread_write_sectionEsp_write) : !fir.ref<!fir.array<10xi32>>
11
+ ! HOST: %[[C10:.*]] = arith.constant 10 : index
12
+ ! HOST: %[[WRITE_SHAPE:.*]] = fir.shape %[[C10]] : (index) -> !fir.shape<1>
13
+ ! HOST: %[[WRITE_DECL:.*]]:2 = hlfir.declare %[[WRITE]](%[[WRITE_SHAPE]]) {uniq_name = "_QFread_write_sectionEsp_write"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
14
+
8
15
! HOST: %[[C1:.*]] = arith.constant 1 : index
9
16
! HOST: %[[C2:.*]] = arith.constant 1 : index
10
17
! HOST: %[[C3:.*]] = arith.constant 4 : index
11
18
! HOST: %[[BOUNDS0:.*]] = omp.bounds lower_bound(%[[C2]] : index) upper_bound(%[[C3]] : index) stride(%[[C1]] : index) start_idx(%[[C1]] : index)
12
- ! HOST: %[[MAP0:.*]] = omp.map_info var_ptr(%[[READ]] : !fir.ref<!fir.array<10xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS0]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_read(2:5)"}
19
+ ! HOST: %[[MAP0:.*]] = omp.map_info var_ptr(%[[READ_DECL]]#1 : !fir.ref<!fir.array<10xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS0]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_read(2:5)"}
13
20
! HOST: %[[C4:.*]] = arith.constant 1 : index
14
21
! HOST: %[[C5:.*]] = arith.constant 1 : index
15
22
! HOST: %[[C6:.*]] = arith.constant 4 : index
16
23
! HOST: %[[BOUNDS1:.*]] = omp.bounds lower_bound(%[[C5]] : index) upper_bound(%[[C6]] : index) stride(%[[C4]] : index) start_idx(%[[C4]] : index)
17
- ! HOST: %[[MAP1:.*]] = omp.map_info var_ptr(%[[WRITE]] : !fir.ref<!fir.array<10xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS1]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_write(2:5)"}
24
+ ! HOST: %[[MAP1:.*]] = omp.map_info var_ptr(%[[WRITE_DECL]]#1 : !fir.ref<!fir.array<10xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS1]]) -> !fir.ref<!fir.array<10xi32>> {name = "sp_write(2:5)"}
18
25
! HOST: omp.target map_entries(%[[MAP0]], %[[MAP1]] : !fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>) {
19
26
20
27
subroutine read_write_section ()
@@ -34,14 +41,14 @@ module assumed_array_routines
34
41
35
42
! HOST-LABEL: func.func @_QMassumed_array_routinesPassumed_shape_array(
36
43
! HOST-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) {
37
- ! HOST: %[[ALLOCA :.*]] = fir.alloca i32 {bindc_name = "i" , uniq_name = "_QMassumed_array_routinesFassumed_shape_arrayEi"}
44
+ ! HOST: %[[ARG0_DECL :.*]]:2 = hlfir.declare %[[ARG0]] {fortran_attrs = #fir.var_attrs<intent_inout> , uniq_name = "_QMassumed_array_routinesFassumed_shape_arrayEarr_read_write"} : (!fir.box<!fir.array<?xi32>>) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
38
45
! HOST: %[[C0:.*]] = arith.constant 1 : index
39
46
! HOST: %[[C1:.*]] = arith.constant 0 : index
40
- ! HOST: %[[C2:.*]]:3 = fir.box_dims %arg0 , %[[C1]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
47
+ ! HOST: %[[C2:.*]]:3 = fir.box_dims %[[ARG0_DECL]]#1 , %[[C1]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
41
48
! HOST: %[[C3:.*]] = arith.constant 1 : index
42
49
! HOST: %[[C4:.*]] = arith.constant 4 : index
43
50
! HOST: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C3]] : index) upper_bound(%[[C4]] : index) stride(%[[C2]]#2 : index) start_idx(%[[C0]] : index) {stride_in_bytes = true}
44
- ! HOST: %[[ADDROF:.*]] = fir.box_addr %arg0 : (!fir.box<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
51
+ ! HOST: %[[ADDROF:.*]] = fir.box_addr %[[ARG0_DECL]]#1 : (!fir.box<!fir.array<?xi32>>) -> !fir.ref<!fir.array<?xi32>>
45
52
! HOST: %[[MAP:.*]] = omp.map_info var_ptr(%[[ADDROF]] : !fir.ref<!fir.array<?xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
46
53
! HOST: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) {
47
54
subroutine assumed_shape_array (arr_read_write )
@@ -54,14 +61,18 @@ subroutine assumed_shape_array(arr_read_write)
54
61
! $omp end target
55
62
end subroutine assumed_shape_array
56
63
64
+
57
65
! HOST-LABEL: func.func @_QMassumed_array_routinesPassumed_size_array(
58
66
! HOST-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<?xi32>> {fir.bindc_name = "arr_read_write"}) {
67
+ ! HOST: %[[UNDEF:.*]] = fir.undefined index
68
+ ! HOST: %[[ARG0_SHAPE:.*]] = fir.shape %[[UNDEF]] : (index) -> !fir.shape<1>
69
+ ! HOST: %[[ARG0_DECL:.*]]:2 = hlfir.declare %[[ARG0]](%[[ARG0_SHAPE]]) {fortran_attrs = #fir.var_attrs<intent_inout>, uniq_name = "_QMassumed_array_routinesFassumed_size_arrayEarr_read_write"} : (!fir.ref<!fir.array<?xi32>>, !fir.shape<1>) -> (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?xi32>>)
59
70
! HOST: %[[ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QMassumed_array_routinesFassumed_size_arrayEi"}
60
71
! HOST: %[[C0:.*]] = arith.constant 1 : index
61
72
! HOST: %[[C1:.*]] = arith.constant 1 : index
62
73
! HOST: %[[C2:.*]] = arith.constant 4 : index
63
74
! HOST: %[[BOUNDS:.*]] = omp.bounds lower_bound(%[[C1]] : index) upper_bound(%[[C2]] : index) stride(%[[C0]] : index) start_idx(%[[C0]] : index)
64
- ! HOST: %[[MAP:.*]] = omp.map_info var_ptr(%[[ARG0]] : !fir.ref<!fir.array<?xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
75
+ ! HOST: %[[MAP:.*]] = omp.map_info var_ptr(%[[ARG0_DECL]]#1 : !fir.ref<!fir.array<?xi32>>) map_clauses(tofrom) capture(ByRef) bounds(%[[BOUNDS]]) -> !fir.ref<!fir.array<?xi32>> {name = "arr_read_write(2:5)"}
65
76
! HOST: omp.target map_entries(%[[MAP]] : !fir.ref<!fir.array<?xi32>>) {
66
77
subroutine assumed_size_array (arr_read_write )
67
78
integer , intent (inout ) :: arr_read_write(* )
@@ -76,32 +87,28 @@ end module assumed_array_routines
76
87
77
88
78
89
! HOST-LABEL:func.func @_QPcall_assumed_shape_and_size_array() {
79
- ! HOST:%{{.*}} = arith.constant 20 : index
80
- ! HOST:%[[ALLOCA:.*]] = fir.alloca !fir.array<20xi32> {bindc_name = "arr_read_write", uniq_name = "_QFcall_assumed_shape_and_size_arrayEarr_read_write"}
81
- ! HOST:%{{.*}} = arith.constant 1 : i64
82
- ! HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index
83
- ! HOST:%{{.*}} = arith.constant 1 : i64
84
- ! HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index
85
- ! HOST:%{{.*}} = arith.constant 10 : i64
86
- ! HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index
87
- ! HOST:%[[SHAPE0:.*]] = fir.shape %{{.*}} : (index) -> !fir.shape<1>
88
- ! HOST:%[[SLICE0:.*]] = fir.slice %{{.*}}, %{{.*}}, %{{.*}} : (index, index, index) -> !fir.slice<1>
89
- ! HOST:%[[ARG0EMB:.*]] = fir.embox %[[ALLOCA]](%[[SHAPE0]]) [%[[SLICE0]]] : (!fir.ref<!fir.array<20xi32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<10xi32>>
90
- ! HOST:%[[ARG0:.*]] = fir.convert %[[ARG0EMB]] : (!fir.box<!fir.array<10xi32>>) -> !fir.box<!fir.array<?xi32>>
91
- ! HOST:fir.call @_QMassumed_array_routinesPassumed_shape_array(%[[ARG0]]) fastmath<contract> : (!fir.box<!fir.array<?xi32>>) -> ()
92
- ! HOST:%{{.*}} = arith.constant 10 : i64
93
- ! HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index
94
- ! HOST:%{{.*}} = arith.constant 1 : i64
95
- ! HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index
96
- ! HOST:%{{.*}} = arith.constant 20 : i64
97
- ! HOST:%{{.*}} = fir.convert %{{.*}} : (i64) -> index
98
- ! HOST:%[[SHAPE1:.*]] = fir.shape %{{.*}} : (index) -> !fir.shape<1>
99
- ! HOST:%[[SLICE1:.*]] = fir.slice %{{.*}}, %{{.*}}, %{{.*}} : (index, index, index) -> !fir.slice<1>
100
- ! HOST:%[[ARG1EMB:.*]] = fir.embox %[[ALLOCA]](%[[SHAPE1]]) [%[[SLICE1]]] : (!fir.ref<!fir.array<20xi32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<11xi32>>
101
- ! HOST:%[[ADDROF:.*]] = fir.box_addr %[[ARG1EMB]] : (!fir.box<!fir.array<11xi32>>) -> !fir.ref<!fir.array<11xi32>>
102
- ! HOST:%[[ARG1:.*]] = fir.convert %[[ADDROF]] : (!fir.ref<!fir.array<11xi32>>) -> !fir.ref<!fir.array<?xi32>>
103
- ! HOST:fir.call @_QMassumed_array_routinesPassumed_size_array(%[[ARG1]]) fastmath<contract> : (!fir.ref<!fir.array<?xi32>>) -> ()
104
- ! HOST:return
90
+ ! HOST: %[[C20:.*]] = arith.constant 20 : index
91
+ ! HOST: %[[READ_WRITE:.*]] = fir.alloca !fir.array<20xi32> {bindc_name = "arr_read_write", uniq_name = "_QFcall_assumed_shape_and_size_arrayEarr_read_write"}
92
+ ! HOST: %[[SHAPE_READ_WRITE:.*]] = fir.shape %[[C20]] : (index) -> !fir.shape<1>
93
+ ! HOST: %[[READ_WRITE_DECL:.*]]:2 = hlfir.declare %[[READ_WRITE]](%[[SHAPE_READ_WRITE]]) {uniq_name = "_QFcall_assumed_shape_and_size_arrayEarr_read_write"} : (!fir.ref<!fir.array<20xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<20xi32>>, !fir.ref<!fir.array<20xi32>>)
94
+ ! HOST: %[[LB:.*]] = arith.constant 1 : index
95
+ ! HOST: %[[UB:.*]] = arith.constant 10 : index
96
+ ! HOST: %[[STEP:.*]] = arith.constant 1 : index
97
+ ! HOST: %[[SHAPE_VAL10:.*]] = arith.constant 10 : index
98
+ ! HOST: %[[SHAPE:.*]] = fir.shape %[[SHAPE_VAL10]] : (index) -> !fir.shape<1>
99
+ ! HOST: %[[READ_WRITE_DESIGNATE:.*]] = hlfir.designate %[[READ_WRITE_DECL]]#0 (%[[LB]]:%[[UB]]:%[[STEP]]) shape %[[SHAPE]] : (!fir.ref<!fir.array<20xi32>>, index, index, index, !fir.shape<1>) -> !fir.ref<!fir.array<10xi32>>
100
+ ! HOST: %[[READ_WRITE_EMBOX:.*]] = fir.embox %[[READ_WRITE_DESIGNATE]](%[[SHAPE]]) : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<10xi32>>
101
+ ! HOST: %[[ARG0:.*]] = fir.convert %[[READ_WRITE_EMBOX]] : (!fir.box<!fir.array<10xi32>>) -> !fir.box<!fir.array<?xi32>>
102
+ ! HOST: fir.call @_QMassumed_array_routinesPassumed_shape_array(%[[ARG0]]) fastmath<contract> : (!fir.box<!fir.array<?xi32>>) -> ()
103
+ ! HOST: %[[LB:.*]] = arith.constant 10 : index
104
+ ! HOST: %[[UB:.*]] = arith.constant 20 : index
105
+ ! HOST: %[[STEP:.*]] = arith.constant 1 : index
106
+ ! HOST: %[[SHAPE_VAL11:.*]] = arith.constant 11 : index
107
+ ! HOST: %[[SHAPE:.*]] = fir.shape %[[SHAPE_VAL11]] : (index) -> !fir.shape<1>
108
+ ! HOST: %[[READ_WRITE_EMBOX:.*]] = hlfir.designate %[[READ_WRITE_DECL]]#0 (%[[LB]]:%[[UB]]:%[[STEP]]) shape %[[SHAPE]] : (!fir.ref<!fir.array<20xi32>>, index, index, index, !fir.shape<1>) -> !fir.ref<!fir.array<11xi32>>
109
+ ! HOST: %[[ARG1:.*]] = fir.convert %[[READ_WRITE_EMBOX]] : (!fir.ref<!fir.array<11xi32>>) -> !fir.ref<!fir.array<?xi32>>
110
+ ! HOST: fir.call @_QMassumed_array_routinesPassumed_size_array(%[[ARG1]]) fastmath<contract> : (!fir.ref<!fir.array<?xi32>>) -> ()
111
+ ! HOST: return
105
112
! HOST:}
106
113
107
114
subroutine call_assumed_shape_and_size_array
0 commit comments