brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 2b02179 Raw
42 lines · plain
1! RUN: bbc -emit-hlfir %s -o - | FileCheck %s2! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s3!4! Test lowering of intrinsic subroutine FLUSH with and without optional UNIT argument.5!6! CHECK-LABEL: func.func @_QPflush_all()7! CHECK: %[[UNIT:.*]] = arith.constant -1 : i328! CHECK: fir.call @_FortranAFlush(%[[UNIT]]) fastmath<contract> : (i32) -> ()9! CHECK: return10subroutine flush_all()11  call flush() ! flush all units12end subroutine13 14! CHECK-LABEL: func.func @_QPflush_unit()15! CHECK: %[[ALLOCA:.*]] = fir.alloca i3216! CHECK: %[[UNITC:.*]] = arith.constant 10 : i3217! CHECK: fir.store %[[UNITC]] to %[[ALLOCA]] : !fir.ref<i32>18! CHECK: %[[LOADED:.*]] = fir.load %[[ALLOCA]] : !fir.ref<i32>19! CHECK: fir.call @_FortranAFlush(%[[LOADED]]) fastmath<contract> : (i32) -> ()20! CHECK: return21subroutine flush_unit()22  call flush(10) ! flush specific unit23end subroutine24 25! CHECK-LABEL: func.func @_QPflush_optional(26! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<i32> {fir.bindc_name = "unit", fir.optional}) {27! CHECK: %[[DECL:.*]]:2 = hlfir.declare %[[ARG0]] dummy_scope %{{.*}} {fortran_attrs = #fir.var_attrs<optional>, uniq_name = "_QFflush_optionalEunit"} : (!fir.ref<i32>, !fir.dscope) -> (!fir.ref<i32>, !fir.ref<i32>)28! CHECK: %[[IS_PRESENT:.*]] = fir.is_present %[[DECL]]#0 : (!fir.ref<i32>) -> i129! CHECK: %[[UNIT:.*]] = fir.if %[[IS_PRESENT]] -> (i32) {30! CHECK:   %[[LOADED:.*]] = fir.load %[[DECL]]#0 : !fir.ref<i32>31! CHECK:   fir.result %[[LOADED]] : i3232! CHECK: } else {33! CHECK:   %[[DEFAULT:.*]] = arith.constant -1 : i3234! CHECK:   fir.result %[[DEFAULT]] : i3235! CHECK: }36! CHECK: fir.call @_FortranAFlush(%[[UNIT]]) fastmath<contract> : (i32) -> ()37! CHECK: return38subroutine flush_optional(unit)39  integer, optional :: unit40  call flush(unit) ! flush with dynamically optional argument41end subroutine42