File: alternate-return.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 (49 lines) | stat: -rw-r--r-- 1,183 bytes parent folder | download | duplicates (15)
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
40
41
42
43
44
45
46
47
48
49
! RUN: bbc -emit-fir -o - %s | FileCheck %s

! CHECK-LABEL: func @_QPss
subroutine ss(n)
  print*, n
  ! CHECK: return{{$}}
  return
! CHECK-LABEL: func @_QPee
entry ee(n,*)
  print*, n
  ! CHECK: return %{{.}} : index
  return 1
end

! CHECK-LABEL: func @_QQmain
  call ss(7)
  call ee(2, *3)
  print*, 'default'
3 print*, 3

  print*, k(10,20)
  print*, k(15,15)
  print*, k(20,10)
end

! CHECK-LABEL: func @_QPk
function k(n1, n2)
  ! CHECK-NOT: ^bb
  ! CHECK: [[selector:%[0-9]+]] = fir.call @_QPs
  ! CHECK-NEXT: fir.select [[selector]] : index [1, ^[[block1:bb[0-9]+]], 2, ^[[block2:bb[0-9]+]], unit, ^[[blockunit:bb[0-9]+]]
  call s(n1, *5, n2, *7)
  ! CHECK: ^[[blockunit]]: // pred: ^bb0
  k =  0; return;
  ! CHECK: ^[[block1]]: // pred: ^bb0
5 k = -1; return;
  ! CHECK: ^[[block2]]: // pred: ^bb0
7 k =  1; return
end

! CHECK-LABEL: func @_QPs
subroutine s(n1, *, n2, *)
  ! CHECK: [[retval:%[0-9]+]] = fir.alloca index {{{.*}}bindc_name = "s"}
  ! CHECK-COUNT-3: fir.store {{.*}} to [[retval]] : !fir.ref<index>
  if (n1 < n2) return 1
  if (n1 > n2) return 2
  ! CHECK: {{.*}} = fir.load [[retval]] : !fir.ref<index>
  ! CHECK-NEXT: return {{.*}} : index
  return
end