File: designate.fir

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 (135 lines) | stat: -rw-r--r-- 7,924 bytes parent folder | download | duplicates (8)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// Test hlfir.designate operation parse, verify (no errors), and unparse.

// RUN: fir-opt %s | fir-opt | FileCheck %s

// array(1)
func.func @array_ref(%arg0 : !fir.ref<!fir.array<10xi32>>) {
  %c1 = arith.constant 1 : index
  %0 = hlfir.designate %arg0 (%c1) :  (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
  return
}
// CHECK-LABEL: func.func @array_ref(
// CHECK-SAME:    %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) {
// CHECK:  %[[VAL_1:.*]] = arith.constant 1 : index
// CHECK:  %[[VAL_2:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_1]]) :  (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>

// array(1, 2:3:4, 5)
func.func @array_section(%arg0 : !fir.box<!fir.array<10x?x30xi32>>) {
  %c1 = arith.constant 1 : index
  %c2 = arith.constant 2 : index
  %c3 = arith.constant 3 : index
  %c4 = arith.constant 4 : index
  %c5 = arith.constant 5 : index
  %shape = fir.undefined !fir.shape<1>
  %0 = hlfir.designate %arg0 (%c1, %c2:%c3:%c4, %c5) shape %shape:  (!fir.box<!fir.array<10x?x30xi32>>, index, index, index, index, index, !fir.shape<1>) -> !fir.box<!fir.array<?xi32>>
  return
}
// CHECK-LABEL: func.func @array_section(
// CHECK-SAME:    %[[VAL_0:.*]]: !fir.box<!fir.array<10x?x30xi32>>) {
// CHECK:  %[[VAL_1:.*]] = arith.constant 1 : index
// CHECK:  %[[VAL_2:.*]] = arith.constant 2 : index
// CHECK:  %[[VAL_3:.*]] = arith.constant 3 : index
// CHECK:  %[[VAL_4:.*]] = arith.constant 4 : index
// CHECK:  %[[VAL_5:.*]] = arith.constant 5 : index
// CHECK:  %[[VAL_6:.*]] = fir.undefined !fir.shape<1>
// CHECK:  %[[VAL_7:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_1]], %[[VAL_2]]:%[[VAL_3]]:%[[VAL_4]], %[[VAL_5]]) shape %[[VAL_6]] : (!fir.box<!fir.array<10x?x30xi32>>, index, index, index, index, index, !fir.shape<1>) -> !fir.box<!fir.array<?xi32>>

// array%comp
func.func @component_ref(%arg0 : !fir.box<!fir.array<10x!fir.type<t{i:i32}>>>) {
  %shape = fir.undefined !fir.shape<1>
  %0 = hlfir.designate %arg0 {"i"} shape %shape:  (!fir.box<!fir.array<10x!fir.type<t{i:i32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<10xi32>>
  return
}
// CHECK-LABEL: func.func @component_ref(
// CHECK-SAME:    %[[VAL_0:.*]]: !fir.box<!fir.array<10x!fir.type<t{i:i32}>>>) {
// CHECK:  %[[VAL_1:.*]] = fir.undefined !fir.shape<1>
// CHECK:  %[[VAL_2:.*]] = hlfir.designate %[[VAL_0]]{"i"} shape %[[VAL_1]] : (!fir.box<!fir.array<10x!fir.type<t{i:i32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<10xi32>>

// array%array_comp(1)
func.func @component_array_ref(%arg0 : !fir.box<!fir.array<10x!fir.type<t2{array_comp:!fir.array<100xi32>}>>>) {
  %c1 = arith.constant 1 : index
  %component_shape = fir.undefined !fir.shapeshift<1>
  %result_shape = fir.undefined !fir.shape<1>
  %0 = hlfir.designate %arg0 {"array_comp"}<%component_shape>(%c1) shape %result_shape : (!fir.box<!fir.array<10x!fir.type<t2{array_comp:!fir.array<100xi32>}>>>, !fir.shapeshift<1>, index, !fir.shape<1>) -> !fir.box<!fir.array<10xi32>>
  return
}
// CHECK-LABEL: func.func @component_array_ref(
// CHECK-SAME:    %[[VAL_0:.*]]: !fir.box<!fir.array<10x!fir.type<t2{array_comp:!fir.array<100xi32>}>>>) {
// CHECK:  %[[VAL_1:.*]] = arith.constant 1 : index
// CHECK:  %[[VAL_2:.*]] = fir.undefined !fir.shapeshift<1>
// CHECK:  %[[VAL_3:.*]] = fir.undefined !fir.shape<1>
// CHECK:  %[[VAL_4:.*]] = hlfir.designate %[[VAL_0]]{"array_comp"} <%[[VAL_2]]> (%[[VAL_1]]) shape %[[VAL_3]] : (!fir.box<!fir.array<10x!fir.type<t2{array_comp:!fir.array<100xi32>}>>>, !fir.shapeshift<1>, index, !fir.shape<1>) -> !fir.box<!fir.array<10xi32>>

// char(3:4)
func.func @substring(%arg0 : !fir.boxchar<1>) {
  %c2 = arith.constant 2 : index
  %c3 = arith.constant 3 : index
  %c4 = arith.constant 4 : index
  %0 = hlfir.designate %arg0 substr %c3, %c4 typeparams %c2:  (!fir.boxchar<1>, index, index, index) -> !fir.boxchar<1>
  return
}
// CHECK-LABEL: func.func @substring(
// CHECK-SAME:    %[[VAL_0:.*]]: !fir.boxchar<1>) {
// CHECK:  %[[VAL_1:.*]] = arith.constant 2 : index
// CHECK:  %[[VAL_2:.*]] = arith.constant 3 : index
// CHECK:  %[[VAL_3:.*]] = arith.constant 4 : index
// CHECK:  %[[VAL_4:.*]] = hlfir.designate %[[VAL_0]] substr %[[VAL_2]], %[[VAL_3]] typeparams %[[VAL_1]] : (!fir.boxchar<1>, index, index, index) -> !fir.boxchar<1>

// char_array(3:4)
func.func @array_substring(%arg0 : !fir.box<!fir.array<10x!fir.char<1,?>>>) {
  %c2 = arith.constant 2 : index
  %c3 = arith.constant 3 : index
  %c4 = arith.constant 4 : index
  %shape = fir.undefined !fir.shape<1>
  %0 = hlfir.designate %arg0 substr %c3, %c4 shape %shape typeparams %c2 : (!fir.box<!fir.array<10x!fir.char<1,?>>>, index, index, !fir.shape<1>, index) -> !fir.box<!fir.array<10x!fir.char<1,?>>>
  return
}
// CHECK-LABEL: func.func @array_substring(
// CHECK-SAME:    %[[VAL_0:.*]]: !fir.box<!fir.array<10x!fir.char<1,?>>>) {
// CHECK:  %[[VAL_1:.*]] = arith.constant 2 : index
// CHECK:  %[[VAL_2:.*]] = arith.constant 3 : index
// CHECK:  %[[VAL_3:.*]] = arith.constant 4 : index
// CHECK:  %[[VAL_4:.*]] = fir.undefined !fir.shape<1>
// CHECK:  %[[VAL_5:.*]] = hlfir.designate %[[VAL_0]] substr %[[VAL_2]], %[[VAL_3]] shape %[[VAL_4]] typeparams %[[VAL_1]] : (!fir.box<!fir.array<10x!fir.char<1,?>>>, index, index, !fir.shape<1>, index) -> !fir.box<!fir.array<10x!fir.char<1,?>>>

func.func @real_part(%arg0 : !fir.ref<!fir.complex<4>>) {
  %0 = hlfir.designate %arg0 real :  (!fir.ref<!fir.complex<4>>) -> !fir.ref<!fir.real<4>>
  return
}
// CHECK-LABEL: func.func @real_part(
// CHECK-SAME:    %[[VAL_0:.*]]: !fir.ref<!fir.complex<4>>) {
// CHECK:  %[[VAL_1:.*]] = hlfir.designate %[[VAL_0]] real :  (!fir.ref<!fir.complex<4>>) -> !fir.ref<!fir.real<4>>

func.func @imag_part_mlir_complex(%arg0 : !fir.ref<complex<f32>>) {
  %0 = hlfir.designate %arg0 imag :  (!fir.ref<complex<f32>>) -> !fir.ref<f32>
  return
}
// CHECK-LABEL: func.func @imag_part_mlir_complex(
// CHECK-SAME:    %[[VAL_0:.*]]: !fir.ref<complex<f32>>) {
// CHECK:  %[[VAL_1:.*]] = hlfir.designate %[[VAL_0]] imag :  (!fir.ref<complex<f32>>) -> !fir.ref<f32>

// array%array_complex_comp(1)%im
func.func @component_array_ref_cplx_part(%arg0 : !fir.box<!fir.array<10x!fir.type<t3{array_comp:!fir.array<100x!fir.complex<8>>}>>>) {
  %c1 = arith.constant 1 : index
  %component_shape = fir.undefined !fir.shapeshift<1>
  %result_shape = fir.undefined !fir.shape<1>
  %0 = hlfir.designate %arg0 {"array_comp"}<%component_shape>(%c1) imag shape %result_shape : (!fir.box<!fir.array<10x!fir.type<t3{array_comp:!fir.array<100x!fir.complex<8>>}>>>, !fir.shapeshift<1>, index, !fir.shape<1>) -> !fir.box<!fir.array<10x!fir.real<8>>>
  return
}
// CHECK-LABEL: func.func @component_array_ref_cplx_part(
// CHECK-SAME:    %[[VAL_0:.*]]: !fir.box<!fir.array<10x!fir.type<t3{array_comp:!fir.array<100x!fir.complex<8>>}>>>) {
// CHECK:  %[[VAL_1:.*]] = arith.constant 1 : index
// CHECK:  %[[VAL_2:.*]] = fir.undefined !fir.shapeshift<1>
// CHECK:  %[[VAL_3:.*]] = fir.undefined !fir.shape<1>
// CHECK:  %[[VAL_4:.*]] = hlfir.designate %[[VAL_0]]{"array_comp"} <%[[VAL_2]]> (%[[VAL_1]]) imag shape %[[VAL_3]] : (!fir.box<!fir.array<10x!fir.type<t3{array_comp:!fir.array<100x!fir.complex<8>>}>>>, !fir.shapeshift<1>, index, !fir.shape<1>) -> !fir.box<!fir.array<10x!fir.real<8>>>

// pdt_array(1)
func.func @pdt(%arg0 : !fir.box<!fir.array<?x!fir.type<pdt(param:i32){field:i32}>>>) {
  %c1 = arith.constant 1 : index
  %0 = hlfir.designate %arg0(%c1) typeparams %c1 :  (!fir.box<!fir.array<?x!fir.type<pdt(param:i32){field:i32}>>>, index, index) -> !fir.box<!fir.type<pdt(param:i32){field:i32}>>
  return
}
// CHECK-LABEL: func.func @pdt(
// CHECK-SAME:    %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.type<pdt(param:i32){field:i32}>>>) {
// CHECK:  %[[VAL_1:.*]] = arith.constant 1 : index
// CHECK:  %[[VAL_2:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_1]]) typeparams %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.type<pdt(param:i32){field:i32}>>>, index, index) -> !fir.box<!fir.type<pdt(param:i32){field:i32}>>