IR: de-duplicate two CmpInst routines (NFC) (#116866)
[llvm-project.git] / flang / test / Lower / io-char-array.f90
blobb3b9d240f583d74507635b0ab43c3223ee8d33bd
1 ! Check that a box is created instead of a temp to write to a char array.
2 ! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
4 subroutine io_char_array
5 character(12) :: r(2) = 'badbadbadbad'
6 write(r(1:2),8)
7 print *, r
8 1 format((1X,A))
9 8 format("new"/"data")
10 end subroutine
12 ! CHECK-LABEL: func.func @_QPio_char_array()
13 ! CHECK: %[[R:.*]] = fir.address_of(@_QFio_char_arrayEr) : !fir.ref<!fir.array<2x!fir.char<1,12>>>
14 ! CHECK: %[[C2_SHAPE:.*]] = arith.constant 2 : index
15 ! CHECK: %[[C1_I64_0:.*]] = arith.constant 1 : i64
16 ! CHECK: %[[C1_IDX_0:.*]] = fir.convert %[[C1_I64_0]] : (i64) -> index
17 ! CHECK: %[[C1_I64_1:.*]] = arith.constant 1 : i64
18 ! CHECK: %[[C1_IDX_1:.*]] = fir.convert %[[C1_I64_1]] : (i64) -> index
19 ! CHECK: %[[C2_I64:.*]] = arith.constant 2 : i64
20 ! CHECK: %[[C2_IDX:.*]] = fir.convert %[[C2_I64]] : (i64) -> index
21 ! CHECK: %[[SHAPE:.*]] = fir.shape %[[C2_SHAPE]] : (index) -> !fir.shape<1>
22 ! CHECK: %[[SLICE:.*]] = fir.slice %[[C1_IDX_0]], %[[C2_IDX]], %[[C1_IDX_1]] : (index, index, index) -> !fir.slice<1>
23 ! CHECK: %[[BOX_R:.*]] = fir.embox %[[R]](%[[SHAPE]]) [%[[SLICE]]] : (!fir.ref<!fir.array<2x!fir.char<1,12>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<2x!fir.char<1,12>>>
24 ! CHECK: %[[BOX_R_NONE:.*]] = fir.convert %[[BOX_R]] : (!fir.box<!fir.array<2x!fir.char<1,12>>>) -> !fir.box<none>
25 ! CHECK: %[[DATA:.*]] = fir.address_of(@_QQclX{{.*}}) : !fir.ref<!fir.char<1,14>>
26 ! CHECK: %[[DATA_PTR:.*]] = fir.convert %8 : (!fir.ref<!fir.char<1,14>>) -> !fir.ref<i8>
27 ! CHECK: %{{.*}} = fir.call @_FortranAioBeginInternalArrayFormattedOutput(%[[BOX_R_NONE]], %[[DATA_PTR]], %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i64, !fir.box<none>, !fir.ref<!fir.llvm_ptr<i8>>, i64, !fir.ref<i8>, i32) -> !fir.ref<i8>