Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / Intrinsics / achar.f90
blob31afaa90af67181a9f1835085cacacf07f5d7acb
1 ! RUN: bbc -emit-fir %s -o - | fir-opt --canonicalize | FileCheck %s
2 ! RUN: %flang_fc1 -emit-fir %s -o - | fir-opt --canonicalize | FileCheck %s
4 ! CHECK-LABEL: test1
5 ! CHECK-SAME: (%[[XREF:.*]]: !fir.ref<i32> {{.*}}, %[[CBOX:.*]]: !fir.boxchar<1> {{.*}})
6 ! CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index
7 ! CHECK-DAG: %[[FALSE:.*]] = arith.constant false
8 ! CHECK: %[[TEMP:.*]] = fir.alloca !fir.char<1> {adapt.valuebyref}
9 ! CHECK: %[[C:.*]]:2 = fir.unboxchar %[[CBOX]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
10 ! CHECK: %[[X:.*]] = fir.load %[[XREF]] : !fir.ref<i32>
11 ! CHECK: %[[X_I8:.*]] = fir.convert %[[X]] : (i32) -> i8
12 ! CHECK: %[[UNDEF:.*]] = fir.undefined !fir.char<1>
13 ! CHECK: %[[XCHAR:.*]] = fir.insert_value %[[UNDEF]], %[[X_I8]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
14 ! CHECK: fir.store %[[XCHAR]] to %[[TEMP]] : !fir.ref<!fir.char<1>>
15 ! CHECK: %[[C1_I64:.*]] = fir.convert %[[C1]] : (index) -> i64
16 ! CHECK: %[[C_CVT:.*]] = fir.convert %[[C]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
17 ! CHECK: %[[TEMP_WITH_XCHAR:.*]] = fir.convert %[[TEMP]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<i8>
18 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[C_CVT]], %[[TEMP_WITH_XCHAR]], %[[C1_I64]], %[[FALSE]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
19 subroutine test1(x, c)
20 integer :: x
21 character :: c
22 c = achar(x)
23 end subroutine