File: equivalence-1.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 (68 lines) | stat: -rw-r--r-- 2,812 bytes parent folder | download | duplicates (5)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
! RUN: bbc -o - %s | FileCheck %s

! CHECK-LABEL: func @_QPs1
SUBROUTINE s1
  INTEGER i
  REAL r
  ! CHECK: = fir.alloca !fir.array<4xi8> {uniq_name = "_QFs1Ei"}
  EQUIVALENCE (r,i)
  ! CHECK: %[[coor:.*]] = fir.coordinate_of %{{.*}}, %{{.*}} : (!fir.ref<!fir.array<4xi8>>, index) -> !fir.ref<i8>
  ! CHECK: %[[iloc:.*]] = fir.convert %[[coor]] : (!fir.ref<i8>) -> !fir.ptr<i32>
  ! CHECK-DAG: fir.store %{{.*}} to %[[iloc]] : !fir.ptr<i32>
  i = 4
  ! CHECK-DAG: %[[floc:.*]] = fir.convert %[[coor]] : (!fir.ref<i8>) -> !fir.ptr<f32>
  ! CHECK: %[[ld:.*]] = fir.load %[[floc]] : !fir.ptr<f32>
  PRINT *, r
END SUBROUTINE s1

! CHECK-LABEL: func @_QPs2
SUBROUTINE s2
  INTEGER i(10)
  REAL r(10)
  ! CHECK: %[[arr:.*]] = fir.alloca !fir.array<48xi8>
  EQUIVALENCE (r(3),i(5))
  ! CHECK: %[[iarr:.*]] = fir.convert %{{.*}} : (!fir.ref<i8>) -> !fir.ptr<!fir.array<10xi32>>
  ! CHECK: %[[foff:.*]] = fir.coordinate_of %[[arr]], %{{.*}} : (!fir.ref<!fir.array<48xi8>>, index) -> !fir.ref<i8>
  ! CHECK: %[[farr:.*]] = fir.convert %[[foff]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<10xf32>>
  ! CHECK: %[[ia:.*]] = fir.coordinate_of %[[iarr]], %{{.*}} : (!fir.ptr<!fir.array<10xi32>>, i64) -> !fir.ref<i32>
  ! CHECK: fir.store %{{.*}} to %[[ia]] : !fir.ref<i32>
  i(5) = 18
  ! CHECK: %[[fld:.*]] = fir.coordinate_of %[[farr]], %{{.*}} : (!fir.ptr<!fir.array<10xf32>>, i64) -> !fir.ref<f32>
  ! CHECK: = fir.load %[[fld]] : !fir.ref<f32>
  PRINT *, r(3)
END SUBROUTINE s2

! CHECK-LABEL: func @_QPs3
SUBROUTINE s3
  REAL r(10)
  TYPE t
    SEQUENCE
    REAL r(10)
  END TYPE t
  TYPE(t) x
  ! CHECK: %[[group:.*]] = fir.alloca !fir.array<40xi8>
  EQUIVALENCE (r,x)
  ! CHECK: %[[coor:.*]] = fir.coordinate_of %[[group]], %c0 : (!fir.ref<!fir.array<40xi8>>, index) -> !fir.ref<i8>
  ! CHECK: %[[rloc:.*]] = fir.convert %[[coor]] : (!fir.ref<i8>) -> !fir.ptr<!fir.array<10xf32>>
  ! CHECK: %[[xloc:.*]] = fir.convert %[[coor]] : (!fir.ref<i8>) -> !fir.ptr<!fir.type<_QFs3Tt{r:!fir.array<10xf32>}>>
  ! CHECK: %[[fidx:.*]] = fir.field_index r, !fir.type<_QFs3Tt{r:!fir.array<10xf32>}>
  ! CHECK: %[[xrloc:.*]] = fir.coordinate_of %[[xloc]], %[[fidx]] :
  ! CHECK: %[[v1loc:.*]] = fir.coordinate_of %[[xrloc]], %c8_i64 : (!fir.ref<!fir.array<10xf32>>, i64) -> !fir.ref<f32>
  ! CHECK: fir.store %{{.*}} to %[[v1loc]] : !fir.ref<f32>
  x%r(9) = 9.0
  ! CHECK: %[[v2loc:.*]] = fir.coordinate_of %[[rloc]], %c8_i64 : (!fir.ptr<!fir.array<10xf32>>, i64) -> !fir.ref<f32>
  ! CHECK: %{{.*}} = fir.load %[[v2loc]] : !fir.ref<f32>
  PRINT *, r(9)
END SUBROUTINE s3
  
! test that equivalence in main program containing arrays are placed in global memory.
! CHECK: fir.global internal @_QFEa : !fir.array<400000000xi8>
  integer :: a, b(100000000)
  equivalence (a, b)
  b(1) = 42
  print *, a

  CALL s1
  CALL s2
  CALL s3
END