Debian Codegraph @

flang/test/Lower/Intrinsics/second.f90

raw
1 !RUN: bbc -emit-hlfir %s -o - | FileCheck %s
2 !RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
3
4 subroutine test_subroutine(time)
5 real :: time
6 call second(time)
7 end subroutine
8 ! CHECK-LABEL: func.func @_QPtest_subroutine(
9 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f32> {fir.bindc_name = "time"}) {
10 ! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
11 ! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {uniq_name = "_QFtest_subroutineEtime"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
12 ! CHECK: %[[VAL_3:.*]] = fir.call @_FortranACpuTime() fastmath<contract> : () -> f64
13 ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (f64) -> f32
14 ! CHECK: fir.store %[[VAL_4]] to %[[VAL_2]]#1 : !fir.ref<f32>
15 ! CHECK: return
16 ! CHECK: }
17
18
19 subroutine test_function(time)
20 real :: time
21 time = second()
22 end subroutine
23 ! CHECK-LABEL: func.func @_QPtest_function(
24 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f32> {fir.bindc_name = "time"}) {
25 ! CHECK: %[[VAL_1:.*]] = fir.alloca f32
26 ! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
27 ! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_functionEtime"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
28 ! CHECK: %[[VAL_4:.*]] = fir.call @_FortranACpuTime() fastmath<contract> : () -> f64
29 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (f64) -> f32
30 ! CHECK: fir.store %[[VAL_5]] to %[[VAL_1]] : !fir.ref<f32>
31 ! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_1]] : !fir.ref<f32>
32 ! CHECK: hlfir.assign %[[VAL_6]] to %[[VAL_3]]#0 : f32, !fir.ref<f32>
33 ! CHECK: return
34 ! CHECK: }
35
36 subroutine test_function_subexpr(t1, t2)
37 real :: t1, t2
38 t2 = second() - t1
39 end subroutine
40 ! CHECK-LABEL: func.func @_QPtest_function_subexpr(
41 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f32> {fir.bindc_name = "t1"},
42 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<f32> {fir.bindc_name = "t2"}) {
43 ! CHECK: %[[VAL_2:.*]] = fir.alloca f32
44 ! CHECK: %[[VAL_3:.*]] = fir.dummy_scope : !fir.dscope
45 ! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_3]] {uniq_name = "_QFtest_function_subexprEt1"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
46 ! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_3]] {uniq_name = "_QFtest_function_subexprEt2"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
47 ! CHECK: %[[VAL_6:.*]] = fir.call @_FortranACpuTime() fastmath<contract> : () -> f64
48 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (f64) -> f32
49 ! CHECK: fir.store %[[VAL_7]] to %[[VAL_2]] : !fir.ref<f32>
50 ! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_2]] : !fir.ref<f32>
51 ! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<f32>
52 ! CHECK: %[[VAL_10:.*]] = arith.subf %[[VAL_8]], %[[VAL_9]] fastmath<contract> : f32
53 ! CHECK: hlfir.assign %[[VAL_10]] to %[[VAL_5]]#0 : f32, !fir.ref<f32>
54 ! CHECK: return
55 ! CHECK: }