40 lines · plain
1! RUN: bbc -emit-fir %s -o - | FileCheck %s2 3! CHECK-LABEL: len_trim_test4integer function len_trim_test(c)5character(*) :: c6ltrim = len_trim(c)7! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index8! CHECK-DAG: %[[c1:.*]] = arith.constant 1 : index9! CHECK-DAG: %[[cm1:.*]] = arith.constant -1 : index10! CHECK-DAG: %[[lastChar:.*]] = arith.subi {{.*}}, %[[c1]]11! CHECK: %[[iterateResult:.*]]:2 = fir.iterate_while (%[[index:.*]] = %[[lastChar]] to %[[c0]] step %[[cm1]]) and ({{.*}}) iter_args({{.*}}) {12 ! CHECK: %[[addr:.*]] = fir.coordinate_of {{.*}}, %[[index]]13 ! CHECK: %[[codeAddr:.*]] = fir.convert %[[addr]]14 ! CHECK: %[[code:.*]] = fir.load %[[codeAddr]]15 ! CHECK: %[[bool:.*]] = arith.cmpi eq16 ! CHECK: fir.result %[[bool]], %[[index]]17! CHECK: }18! CHECK: %[[len:.*]] = arith.addi %[[iterateResult]]#1, %[[c1]]19! CHECK: select %[[iterateResult]]#0, %[[c0]], %[[len]]20end function21 22! CHECK-LABEL: lnblnk_test23integer function lnblnk_test(c)24character(*) :: c25ltrim = lnblnk(c)26! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index27! CHECK-DAG: %[[c1:.*]] = arith.constant 1 : index28! CHECK-DAG: %[[cm1:.*]] = arith.constant -1 : index29! CHECK-DAG: %[[lastChar:.*]] = arith.subi {{.*}}, %[[c1]]30! CHECK: %[[iterateResult:.*]]:2 = fir.iterate_while (%[[index:.*]] = %[[lastChar]] to %[[c0]] step %[[cm1]]) and ({{.*}}) iter_args({{.*}}) {31 ! CHECK: %[[addr:.*]] = fir.coordinate_of {{.*}}, %[[index]]32 ! CHECK: %[[codeAddr:.*]] = fir.convert %[[addr]]33 ! CHECK: %[[code:.*]] = fir.load %[[codeAddr]]34 ! CHECK: %[[bool:.*]] = arith.cmpi eq35 ! CHECK: fir.result %[[bool]], %[[index]]36! CHECK: }37! CHECK: %[[len:.*]] = arith.addi %[[iterateResult]]#1, %[[c1]]38! CHECK: select %[[iterateResult]]#0, %[[c0]], %[[len]]39end function40