@@ -198,16 +198,61 @@ func.func @_QPpointer_source() {
198
198
%c0_i32 = arith.constant 0 : i32
199
199
%c1 = arith.constant 1 : index
200
200
%c0 = arith.constant 0 : index
201
- %0 = fir.alloca !fir.box<!fir.heap <!fir.array<?x?xf32>>> {bindc_name = "a", uniq_name = "_QFpointer_sourceEa"}
202
- %4 = fir.declare %0 {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFpointer_sourceEa"} : (!fir.ref<!fir.box<!fir.heap <!fir.array<?x?xf32>>>>) -> !fir.ref<!fir.box<!fir.heap <!fir.array<?x?xf32>>>>
203
- %5 = cuf.alloc !fir.box<!fir.heap <!fir.array<?x?xf32>>> {bindc_name = "a_d", data_attr = #cuf.cuda<device>, uniq_name = "_QFpointer_sourceEa_d"} -> !fir.ref<!fir.box<!fir.heap <!fir.array<?x?xf32>>>>
204
- %7 = fir.declare %5 {data_attr = #cuf.cuda<device>, fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFpointer_sourceEa_d"} : (!fir.ref<!fir.box<!fir.heap <!fir.array<?x?xf32>>>>) -> !fir.ref<!fir.box<!fir.heap <!fir.array<?x?xf32>>>>
205
- %8 = fir.load %4 : !fir.ref<!fir.box<!fir.heap <!fir.array<?x?xf32>>>>
206
- %22 = cuf.allocate %7 : !fir.ref<!fir.box<!fir.heap <!fir.array<?x?xf32>>>> source(%8 : !fir.box<!fir.heap <!fir.array<?x?xf32>>>) {data_attr = #cuf.cuda<device>} -> i32
201
+ %0 = fir.alloca !fir.box<!fir.ptr <!fir.array<?x?xf32>>> {bindc_name = "a", uniq_name = "_QFpointer_sourceEa"}
202
+ %4 = fir.declare %0 {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFpointer_sourceEa"} : (!fir.ref<!fir.box<!fir.ptr <!fir.array<?x?xf32>>>>) -> !fir.ref<!fir.box<!fir.ptr <!fir.array<?x?xf32>>>>
203
+ %5 = cuf.alloc !fir.box<!fir.ptr <!fir.array<?x?xf32>>> {bindc_name = "a_d", data_attr = #cuf.cuda<device>, uniq_name = "_QFpointer_sourceEa_d"} -> !fir.ref<!fir.box<!fir.ptr <!fir.array<?x?xf32>>>>
204
+ %7 = fir.declare %5 {data_attr = #cuf.cuda<device>, fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFpointer_sourceEa_d"} : (!fir.ref<!fir.box<!fir.ptr <!fir.array<?x?xf32>>>>) -> !fir.ref<!fir.box<!fir.ptr <!fir.array<?x?xf32>>>>
205
+ %8 = fir.load %4 : !fir.ref<!fir.box<!fir.ptr <!fir.array<?x?xf32>>>>
206
+ %22 = cuf.allocate %7 : !fir.ref<!fir.box<!fir.ptr <!fir.array<?x?xf32>>>> source(%8 : !fir.box<!fir.ptr <!fir.array<?x?xf32>>>) {data_attr = #cuf.cuda<device>} -> i32
207
207
return
208
208
}
209
209
210
210
// CHECK-LABEL: func.func @_QPpointer_source()
211
211
// CHECK: _FortranACUFPointerAllocateSource
212
212
213
+ fir.global @_QMdataEb2 {data_attr = #cuf.cuda<device>} : !fir.box<!fir.ptr<!fir.array<?xi32>>> {
214
+ %c0 = arith.constant 0 : index
215
+ %0 = fir.zero_bits !fir.ptr<!fir.array<?xi32>>
216
+ %1 = fir.shape %c0 : (index) -> !fir.shape<1>
217
+ %2 = fir.embox %0(%1) {allocator_idx = 2 : i32} : (!fir.ptr<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
218
+ fir.has_value %2 : !fir.box<!fir.ptr<!fir.array<?xi32>>>
219
+ }
220
+
221
+ func.func @_QQpointer_sync() attributes {fir.bindc_name = "test"} {
222
+ %c0_i32 = arith.constant 0 : i32
223
+ %c10_i32 = arith.constant 10 : i32
224
+ %c1 = arith.constant 1 : index
225
+ %0 = fir.address_of(@_QMdataEb2) : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
226
+ %1 = fir.declare %0 {data_attr = #cuf.cuda<device>, fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QMdataEb"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>)
227
+ %2 = fir.convert %1 : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
228
+ %3 = fir.convert %c1 : (index) -> i64
229
+ %4 = fir.convert %c10_i32 : (i32) -> i64
230
+ fir.call @_FortranAAllocatableSetBounds(%2, %c0_i32, %3, %4) fastmath<contract> : (!fir.ref<!fir.box<none>>, i32, i64, i64) -> ()
231
+ %6 = cuf.allocate %1 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> {data_attr = #cuf.cuda<device>} -> i32
232
+ return
233
+ }
234
+
235
+ // CHECK-LABEL: func.func @_QQpointer_sync()
236
+ // CHECK: _FortranACUFPointerAllocateSync
237
+
238
+ fir.global @_QMmod1Ea_d2 {data_attr = #cuf.cuda<device>} : !fir.box<!fir.ptr<!fir.array<?x?xf32>>> {
239
+ %c0 = arith.constant 0 : index
240
+ %0 = fir.zero_bits !fir.ptr<!fir.array<?x?xf32>>
241
+ %1 = fir.shape %c0, %c0 : (index, index) -> !fir.shape<2>
242
+ %2 = fir.embox %0(%1) {allocator_idx = 2 : i32} : (!fir.ptr<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.box<!fir.ptr<!fir.array<?x?xf32>>>
243
+ fir.has_value %2 : !fir.box<!fir.ptr<!fir.array<?x?xf32>>>
244
+ }
245
+ func.func @_QMmod1Ppointer_source_global() {
246
+ %0 = fir.address_of(@_QMmod1Ea_d2) : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
247
+ %1 = fir.declare %0 {data_attr = #cuf.cuda<device>, fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QMmod1Ea_d"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
248
+ %2 = fir.alloca !fir.box<!fir.ptr<!fir.array<?x?xf32>>> {bindc_name = "a", uniq_name = "_QMmod1Fallocate_source_globalEa"}
249
+ %6 = fir.declare %2 {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QMmod1Fallocate_source_globalEa"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
250
+ %7 = fir.load %6 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
251
+ %21 = cuf.allocate %1 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>> source(%7 : !fir.box<!fir.ptr<!fir.array<?x?xf32>>>) {data_attr = #cuf.cuda<device>} -> i32
252
+ return
253
+ }
254
+
255
+ // CHECK-LABEL: func.func @_QMmod1Ppointer_source_global()
256
+ // CHECK: fir.call @_FortranACUFPointerAllocateSourceSync
257
+
213
258
} // end of module
0 commit comments