Debian Codegraph @

gcc/testsuite/gfortran.dg/gomp/append_args-4.f90

raw
1 ! { dg-do compile }
2 ! { dg-additional-options "-fdump-tree-gimple -cpp" }
3
4 module my_omp_lib
5 use iso_c_binding
6 implicit none
7
8 ! The following definitions are in omp_lib, which cannot be included
9 ! in gcc/testsuite/
10 integer, parameter :: omp_interop_kind = c_intptr_t
11 integer, parameter :: omp_interop_fr_kind = c_int
12
13 integer (omp_interop_kind), parameter :: omp_interop_none = 0_omp_interop_kind
14 integer (omp_interop_fr_kind), parameter :: omp_ifr_cuda = 1
15 integer (omp_interop_fr_kind), parameter :: omp_ifr_cuda_driver = 2
16 integer (omp_interop_fr_kind), parameter :: omp_ifr_opencl = 3
17 integer (omp_interop_fr_kind), parameter :: omp_ifr_sycl = 4
18 integer (omp_interop_fr_kind), parameter :: omp_ifr_hip = 5
19 integer (omp_interop_fr_kind), parameter :: omp_ifr_level_zero = 6
20 integer (omp_interop_fr_kind), parameter :: omp_ifr_hsa = 7
21 end module my_omp_lib
22
23 module m
24 use my_omp_lib
25 implicit none (type, external)
26
27 integer(omp_interop_kind) :: myobj_mod, myobj2_mod
28 integer(omp_interop_kind), allocatable :: myobj_mod_alloc, myobj2_mod_alloc
29 contains
30
31 integer function vifun (str, int_opt, alloc_str, o_dummy, o_value)
32 character(len=*) :: str
33 integer, optional, value :: int_opt
34 character(len=:), allocatable :: alloc_str
35 integer(omp_interop_kind) :: o_dummy
36 integer(omp_interop_kind), value :: o_value
37 vifun = 0
38 end
39 integer function ifun (str, int_opt, alloc_str)
40 character(len=*) :: str
41 integer, optional, value :: int_opt
42 character(len=:), allocatable :: alloc_str
43 !$omp declare variant (vifun ) match(construct={dispatch}) append_args (interop(targetsync), interop( target, prefer_type ( {fr("cuda"), attr("ompx_xx")}, {attr("ompx_yy")} )))
44 ifun = 0
45 end
46
47 character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
48 character(len=*) :: str
49 integer, value :: int_var
50 integer, optional, value :: int_opt
51 character(len=:), allocatable :: alloc_str
52 integer(omp_interop_kind) :: o2_dummy
53 integer(omp_interop_kind), value :: o2_value
54 vfun = ""
55 end
56 character(len=len(str)) function fun (str, int_var, int_opt, alloc_str)
57 !$omp declare variant(vfun), match(construct={dispatch}),append_args (interop(target), interop(target))
58 character(len=*) :: str
59 integer, value :: int_var
60 integer, optional, value :: int_opt
61 character(len=:), allocatable :: alloc_str
62 fun = ""
63 end
64 end
65
66 integer function test_ifun(obj_dummy_val, obj_dummy, obj_dummy_opt, obj_dummy_alloc, obj_dummy_alloc_opt, obj_dummy_ptr, obj_dummy_ptr_opt)
67 use m
68 implicit none (type, external)
69
70 integer(omp_interop_kind), value :: obj_dummy_val
71 integer(omp_interop_kind) :: obj_dummy
72 integer(omp_interop_kind), optional :: obj_dummy_opt
73
74 integer(omp_interop_kind), allocatable :: obj_dummy_alloc
75 integer(omp_interop_kind), allocatable, optional :: obj_dummy_alloc_opt
76
77 integer(omp_interop_kind), pointer :: obj_dummy_ptr
78 integer(omp_interop_kind), pointer, optional :: obj_dummy_ptr_opt
79
80 integer(omp_interop_kind), target :: obj_loc
81 integer(omp_interop_kind), pointer :: obj_loc_ptr
82 integer(omp_interop_kind), allocatable :: obj_loc_alloc
83
84 character(len=:), allocatable :: str_alloc
85 integer :: i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21
86
87 obj_loc = omp_interop_none
88 obj_loc_ptr => obj_loc
89
90 !$omp dispatch device(10) interop(obj_dummy_val, obj_dummy)
91 i10 = ifun ("abc10", i10, str_alloc)
92 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
93 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
94 ! { dg-final { scan-tree-dump-times "i10 = vifun \\(&\"abc10\"\\\[1\\\]\{lb: 1 sz: 1\}, i10, &str_alloc, &obj_dummy_val\\.\[0-9\]+, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
95
96 !$omp dispatch device(11) interop(obj_dummy, obj_dummy_val)
97 i11 = ifun ("abc11", i11, str_alloc)
98 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
99 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
100 ! { dg-final { scan-tree-dump-times "i11 = vifun \\(&\"abc11\"\\\[1\\\]\{lb: 1 sz: 1\}, i11, &str_alloc, obj_dummy, obj_dummy_val, 1, 5, &.str_alloc\\);" 1 "gimple" } }
101
102 !$omp dispatch device(12) interop(obj_dummy_opt, obj_dummy_alloc)
103 i12 = ifun ("abc12", i12, str_alloc)
104 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
105 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
106 ! { dg-final { scan-tree-dump-times "i12 = vifun \\(&\"abc12\"\\\[1\\\]\{lb: 1 sz: 1\}, i12, &str_alloc, obj_dummy_opt, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
107
108 !$omp dispatch device(13) interop(obj_dummy_alloc, obj_dummy_opt)
109 i13 = ifun ("abc13", i13, str_alloc)
110 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
111 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
112 ! { dg-final { scan-tree-dump-times "i13 = vifun \\(&\"abc13\"\\\[1\\\]\{lb: 1 sz: 1\}, i13, &str_alloc, D\.\[0-9\]+, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
113
114 !$omp dispatch device(14) interop(obj_dummy_alloc_opt, obj_dummy_ptr)
115 i14 = ifun ("abc14", i14, str_alloc)
116 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
117 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
118 ! { dg-final { scan-tree-dump-times "i14 = vifun \\(&\"abc14\"\\\[1\\\]\{lb: 1 sz: 1\}, i14, &str_alloc, D\.\[0-9\]+, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
119
120 !$omp dispatch device(15) interop(obj_dummy_ptr, obj_dummy_alloc_opt)
121 i15 = ifun ("abc15", i15, str_alloc)
122 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
123 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
124 ! { dg-final { scan-tree-dump-times "i15 = vifun \\(&\"abc15\"\\\[1\\\]\{lb: 1 sz: 1\}, i15, &str_alloc, D\.\[0-9\]+, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
125
126 !$omp dispatch device(16) interop(obj_dummy_ptr_opt, myobj_mod)
127 i16 = ifun ("abc16", i16, str_alloc)
128 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
129 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
130 ! { dg-final { scan-tree-dump-times "i16 = vifun \\(&\"abc16\"\\\[1\\\]\{lb: 1 sz: 1\}, i16, &str_alloc, D\.\[0-9\]+, myobj_mod\\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
131
132 !$omp dispatch device(17) interop(myobj_mod, obj_dummy_ptr_opt)
133 i17 = ifun ("abc17", i17, str_alloc)
134 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
135 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
136 ! { dg-final { scan-tree-dump-times "i17 = vifun \\(&\"abc17\"\\\[1\\\]\{lb: 1 sz: 1\}, i17, &str_alloc, &myobj_mod, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
137
138 !$omp dispatch device(18) interop(obj_loc, obj_loc_ptr)
139 i18 = ifun ("abc18", i18, str_alloc)
140 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
141 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
142 ! { dg-final { scan-tree-dump-times "i18 = vifun \\(&\"abc18\"\\\[1\\\]\{lb: 1 sz: 1\}, i18, &str_alloc, &obj_loc, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
143
144 !$omp dispatch device(19) interop(obj_loc_ptr, obj_loc)
145 i19 = ifun ("abc19", i19, str_alloc)
146 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
147 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
148 ! { dg-final { scan-tree-dump-times "i19 = vifun \\(&\"abc19\"\\\[1\\\]\{lb: 1 sz: 1\}, i19, &str_alloc, obj_loc_ptr, obj_loc\\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
149
150 !$omp dispatch device(20) interop(obj_loc_alloc, myobj_mod_alloc)
151 i20 = ifun ("abc20", i20, str_alloc)
152 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
153 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
154 ! { dg-final { scan-tree-dump-times "i20 = vifun \\(&\"abc20\"\\\[1\\\]\{lb: 1 sz: 1\}, i20, &str_alloc, obj_loc_alloc, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
155
156 !$omp dispatch device(21) interop(myobj_mod_alloc, obj_loc_alloc)
157 i21 = ifun ("abc21", i21, str_alloc)
158 ! integer function ifun (str, int_opt, alloc_str, o_dummy, o_value)
159 ! -> int vifun (str, int_opt, alloc_str, o_dummy, o_value, .int_opt, _str, _alloc_str)
160 ! { dg-final { scan-tree-dump-times "i21 = vifun \\(&\"abc21\"\\\[1\\\]\{lb: 1 sz: 1\}, i21, &str_alloc, myobj_mod_alloc\\.\[0-9\]+, D\.\[0-9\]+, 1, 5, &.str_alloc\\);" 1 "gimple" } }
161
162 test_ifun = i10 + i11 + i12 + i13 + i14 + i15 + i16 + i17 + i18 + i19 + i20 + i21
163 end
164
165
166 integer(c_int) function test_fun (obj2_dummy_val, obj2_dummy, obj2_dummy_opt, obj2_dummy_alloc, obj2_dummy_alloc_opt, obj2_dummy_ptr, obj2_dummy_ptr_opt)
167 use m
168 implicit none (type, external)
169
170 integer(omp_interop_kind), value :: obj2_dummy_val
171 integer(omp_interop_kind) :: obj2_dummy
172 integer(omp_interop_kind), optional :: obj2_dummy_opt
173
174 integer(omp_interop_kind), allocatable :: obj2_dummy_alloc
175 integer(omp_interop_kind), allocatable, optional :: obj2_dummy_alloc_opt
176
177 integer(omp_interop_kind), pointer :: obj2_dummy_ptr
178 integer(omp_interop_kind), pointer, optional :: obj2_dummy_ptr_opt
179
180 integer(omp_interop_kind), target :: obj2_loc
181 integer(omp_interop_kind), pointer :: obj2_loc_ptr
182 integer(omp_interop_kind), allocatable :: obj2_loc_alloc
183
184 character(len=:), allocatable :: str_alloc
185 character(1) :: res_str
186 integer :: i30, i31, i32, i33, i34, i35, i36, i37, i38, i39, i40, i41
187 i30 = 0; i31 = 0; i32 = 0; i33 = 0; i34 = 0; i35 = 0; i36 = 0; i37 = 0; i38 = 0; i39 = 0; i40 = 0; i41 = 0
188
189 obj2_loc = omp_interop_none
190 obj2_loc_ptr => obj2_loc
191
192 !$omp dispatch device(30) interop(obj2_dummy, obj2_dummy_val)
193 res_str = fun ("klm30", 300, i30, str_alloc)
194 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
195 ! -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
196
197 !$omp dispatch device(31) interop(obj2_dummy_val, obj2_dummy)
198 res_str = fun ("klm31", 301, i31, str_alloc)
199 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
200 ! -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
201
202 !$omp dispatch device(32) interop(obj2_dummy_opt, obj2_dummy_alloc)
203 res_str = fun ("klm32", 302, i32, str_alloc)
204 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
205 ! -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
206
207 !$omp dispatch device(33) interop(obj2_dummy_alloc, obj2_dummy_opt)
208 res_str = fun ("klm33", 303, i33, str_alloc)
209 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
210 ! -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
211
212 !$omp dispatch device(34) interop(obj2_dummy_alloc_opt, obj2_dummy_ptr)
213 res_str = fun ("klm34", 304, i34, str_alloc)
214 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
215 ! -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
216
217 !$omp dispatch device(35) interop(obj2_dummy_ptr, obj2_dummy_alloc_opt)
218 res_str = fun ("klm35", 305, i35, str_alloc)
219 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
220 ! -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
221
222 !$omp dispatch device(36) interop(obj2_dummy_ptr_opt, myobj2_mod)
223 res_str = fun ("klm36", 306, i36, str_alloc)
224 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
225 ! -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
226
227 !$omp dispatch device(37) interop(myobj2_mod, obj2_dummy_ptr_opt)
228 res_str = fun ("klm37", 307, i37, str_alloc)
229 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
230 ! -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
231
232 !$omp dispatch device(38) interop(obj2_loc, obj2_loc_ptr)
233 res_str = fun ("klm30", 308, i38, str_alloc)
234 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
235 ! -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
236
237 !$omp dispatch device(39) interop(obj2_loc_ptr, obj2_loc)
238 res_str = fun ("klm39", 309, i39, str_alloc)
239 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
240 ! -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
241
242 !$omp dispatch device(40) interop(obj2_loc_alloc, myobj2_mod_alloc)
243 res_str = fun ("klm40", 400, i40, str_alloc)
244 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
245
246 !$omp dispatch device(41) interop(myobj2_mod_alloc, obj2_loc_alloc)
247 res_str = fun ("klm41", 401, i41, str_alloc)
248 ! character(len=len(str)) function vfun (str, int_var, int_opt, alloc_str, o2_dummy, o2_value)
249 ! -> void vfun (__result, .__result, str, int_var, int_opt, alloc_str, o2_dummy, o2_value, .int_opt, _str, _alloc_str)
250
251 test_fun = i30 + i31 + i32 + i33 + i34 + i35 + i36 + i37 + i38 + i39 + i40 + i41
252 end
253 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 300, D\\.\[0-9\]+, D\\.\[0-9\]+, obj2_dummy, obj2_dummy_val, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
254 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 301, D\\.\[0-9\]+, D\\.\[0-9\]+, &obj2_dummy_val\\.\[0-9\]+, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
255 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 302, D\\.\[0-9\]+, D\\.\[0-9\]+, obj2_dummy_opt, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
256 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 303, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
257 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 304, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
258 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 305, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
259 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 306, D\\.\[0-9\]+, D\\.\[0-9\]+, D\\.\[0-9\]+, myobj2_mod\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
260 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 307, D\\.\[0-9\]+, D\\.\[0-9\]+, &myobj2_mod, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
261 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 308, D\\.\[0-9\]+, D\\.\[0-9\]+, &obj2_loc, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
262 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 309, D\\.\[0-9\]+, D\\.\[0-9\]+, obj2_loc_ptr, obj2_loc\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
263 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 400, D\\.\[0-9\]+, D\\.\[0-9\]+, obj2_loc_alloc, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }
264 ! { dg-final { scan-tree-dump-times "vfun \\(&str\\.\[0-9\]+, 5, D\\.\[0-9\]+, 401, D\\.\[0-9\]+, D\\.\[0-9\]+, myobj2_mod_alloc\\.\[0-9\]+, D\\.\[0-9\]+, 1, 5, &.str_alloc\\.\[0-9\]+\\);" 1 "gimple" } }