File: character-elemental.f90

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (39 lines) | stat: -rw-r--r-- 2,108 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
! RUN: bbc %s -o - | FileCheck %s

! CHECK-LABEL: substring_main
subroutine substring_main
  character*7 :: string(2) = ['12     ', '12     ']
  integer :: result(2)
  integer :: ival

  ival = 1
  ! CHECK: %[[a0:.*]] = fir.alloca i32 {bindc_name = "ival", uniq_name = "_QFsubstring_mainEival"}
  ! CHECK: %[[a2:.*]] = fir.address_of(@_QFsubstring_mainEstring) : !fir.ref<!fir.array<2x!fir.char<1,7>>>
  ! CHECK: fir.store {{.*}} to %[[a0]] : !fir.ref<i32>
  ! CHECK: %[[a3:.*]] = fir.shape {{.*}} : (index) -> !fir.shape<1>
  ! CHECK: %[[a4:.*]] = fir.slice {{.*}}, {{.*}}, {{.*}} : (index, index, index) -> !fir.slice<1>
  ! CHECK: br ^bb1({{.*}}, {{.*}} : index, index)
  ! CHECK: ^bb1(%[[a5:.*]]: index, %[[a6:.*]]: index):  // 2 preds: ^bb0, ^bb2
  ! CHECK: %[[a7:.*]] = arith.cmpi sgt, %[[a6]], {{.*}} : index
  ! CHECK: cond_br %[[a7]], ^bb2, ^bb3
  ! CHECK: ^bb2:  // pred: ^bb1
  ! CHECK: %[[a8:.*]] = arith.addi %[[a5]], {{.*}} : index
  ! CHECK: %[[a9:.*]] = fir.array_coor %[[a2]](%[[a3]]) [%[[a4]]] %[[a8]] : (!fir.ref<!fir.array<2x!fir.char<1,7>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.ref<!fir.char<1,7>>
  ! CHECK: %[[a10:.*]] = fir.load %[[a0]] : !fir.ref<i32>
  ! CHECK: %[[a11:.*]] = fir.convert %[[a10]] : (i32) -> index
  ! CHECK: %[[a12:.*]] = arith.subi %[[a11]], {{.*}} : index
  ! CHECK: %[[a13:.*]] = fir.convert %[[a9]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<!fir.array<7x!fir.char<1>>>
  ! CHECK: %[[a14:.*]] = fir.coordinate_of %[[a13]], %[[a12]] : (!fir.ref<!fir.array<7x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
  ! CHECK: %[[a15:.*]] = fir.convert %[[a14]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
  ! CHECK: %[[a16:.*]] = fir.emboxchar %[[a15]], {{.*}} : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
  ! CHECK: %[[a17:.*]] = fir.call @_QFsubstring_mainPinner(%[[a16]]) {{.*}}: (!fir.boxchar<1>) -> i32
  result = inner(string(1:2)(ival:ival))
  print *, result
contains
  elemental function inner(arg)
    character(len=*), intent(in) :: arg
    integer :: inner

    inner = len(arg)
  end function inner
end subroutine substring_main