Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / format-statement.f90
blob8f8d86e9dd7592a375d74265d7f3a5bad2c3c77d
1 ! RUN: bbc %s -o - | FileCheck %s
3 ! CHECK-LABEL: func @_QPformatassign
4 subroutine formatAssign(flag1, flag2, flag3)
5 real :: pi
6 integer :: label
7 logical :: flag1, flag2, flag3
9 ! CHECK-DAG: %[[ONE:.*]] = arith.constant 100 : i32
10 ! CHECK-DAG: %[[TWO:.*]] = arith.constant 200 : i32
11 if (flag1) then
12 assign 100 to label
13 else
14 assign 200 to label
15 end if
17 ! CHECK: cond_br %{{.*}}, ^bb[[BLK1:.*]], ^bb[[BLK2:.*]]
18 ! CHECK: ^bb[[BLK1]]:
19 ! CHECK: fir.store %[[ONE]]
20 ! CHECK: br ^bb[[END_BLOCK:.*]]
21 ! CHECK: ^bb[[BLK2]]:
22 ! CHECK: fir.store %[[TWO]]
23 ! CHECK: br ^bb[[END_BLOCK]]
24 ! CHECK: ^bb[[END_BLOCK]]
25 ! CHECK: fir.call @{{.*}}BeginExternalFormattedOutput
26 ! CHECK: fir.call @{{.*}}OutputAscii
27 ! CHECK: fir.call @{{.*}}OutputReal32
28 ! CHECK: fir.call @{{.*}}EndIoStatement
29 pi = 3.141592653589
30 write(*, label) " PI=", pi
31 ! CHECK: fir.call @{{.*}}BeginExternalFormattedOutput
32 ! CHECK: fir.call @{{.*}}OutputAscii
33 ! CHECK: fir.call @{{.*}}OutputReal32
34 ! CHECK: fir.call @{{.*}}EndIoStatement
35 if (flag2) write(*, label) "2PI=", 2*pi
36 if (flag1 .and. flag2 .and. flag3) then
37 assign 100 to label
38 else
39 assign 200 to label
40 end if
41 if (flag3) then
42 ! CHECK: fir.call @{{.*}}BeginExternalFormattedOutput
43 ! CHECK: fir.call @{{.*}}OutputAscii
44 ! CHECK: fir.call @{{.*}}OutputReal32
45 ! CHECK: fir.call @{{.*}}EndIoStatement
46 write(*, label) "3PI=", 3*pi
47 endif
49 100 format (A, F10.3)
50 200 format (A,E8.1)
51 300 format (A, E4.2)
53 end subroutine
55 ! CHECK-LABEL: func @_QQmain
56 call formatAssign(.true., .true., .true.)
57 print*
58 call formatAssign(.true., .false., .true.)
59 end