1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -global-isel -stop-after=irtranslator -verify-machineinstrs < %s \
3 ; RUN: | FileCheck -check-prefix=RV32I %s
4 ; RUN: llc -mtriple=riscv64 -global-isel -stop-after=irtranslator -verify-machineinstrs < %s \
5 ; RUN: | FileCheck -check-prefix=RV64I %s
7 declare void @void_noargs()
9 define void @test_call_void_noargs() {
11 ; RV32I-LABEL: name: test_call_void_noargs
13 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
14 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @void_noargs, csr_ilp32_lp64, implicit-def $x1
15 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
16 ; RV32I-NEXT: PseudoRET
18 ; RV64I-LABEL: name: test_call_void_noargs
20 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
21 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @void_noargs, csr_ilp32_lp64, implicit-def $x1
22 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
23 ; RV64I-NEXT: PseudoRET
25 call void @void_noargs()
29 declare void @void_args_i8(i8, i8)
31 define void @test_call_void_args_i8() {
33 ; RV32I-LABEL: name: test_call_void_args_i8
35 ; RV32I-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 0
36 ; RV32I-NEXT: [[C1:%[0-9]+]]:_(s8) = G_CONSTANT i8 1
37 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
38 ; RV32I-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[C]](s8)
39 ; RV32I-NEXT: [[ANYEXT1:%[0-9]+]]:_(s32) = G_ANYEXT [[C1]](s8)
40 ; RV32I-NEXT: $x10 = COPY [[ANYEXT]](s32)
41 ; RV32I-NEXT: $x11 = COPY [[ANYEXT1]](s32)
42 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @void_args_i8, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11
43 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
44 ; RV32I-NEXT: PseudoRET
46 ; RV64I-LABEL: name: test_call_void_args_i8
48 ; RV64I-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 0
49 ; RV64I-NEXT: [[C1:%[0-9]+]]:_(s8) = G_CONSTANT i8 1
50 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
51 ; RV64I-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[C]](s8)
52 ; RV64I-NEXT: [[ANYEXT1:%[0-9]+]]:_(s64) = G_ANYEXT [[C1]](s8)
53 ; RV64I-NEXT: $x10 = COPY [[ANYEXT]](s64)
54 ; RV64I-NEXT: $x11 = COPY [[ANYEXT1]](s64)
55 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @void_args_i8, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11
56 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
57 ; RV64I-NEXT: PseudoRET
59 call void @void_args_i8(i8 0, i8 1)
63 declare void @void_args_i8_zext(i8 zeroext, i8 zeroext)
65 define void @test_call_void_args_i8_zext() {
67 ; RV32I-LABEL: name: test_call_void_args_i8_zext
69 ; RV32I-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 0
70 ; RV32I-NEXT: [[C1:%[0-9]+]]:_(s8) = G_CONSTANT i8 1
71 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
72 ; RV32I-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[C]](s8)
73 ; RV32I-NEXT: [[ZEXT1:%[0-9]+]]:_(s32) = G_ZEXT [[C1]](s8)
74 ; RV32I-NEXT: $x10 = COPY [[ZEXT]](s32)
75 ; RV32I-NEXT: $x11 = COPY [[ZEXT1]](s32)
76 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @void_args_i8_zext, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11
77 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
78 ; RV32I-NEXT: PseudoRET
80 ; RV64I-LABEL: name: test_call_void_args_i8_zext
82 ; RV64I-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 0
83 ; RV64I-NEXT: [[C1:%[0-9]+]]:_(s8) = G_CONSTANT i8 1
84 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
85 ; RV64I-NEXT: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[C]](s8)
86 ; RV64I-NEXT: [[ZEXT1:%[0-9]+]]:_(s64) = G_ZEXT [[C1]](s8)
87 ; RV64I-NEXT: $x10 = COPY [[ZEXT]](s64)
88 ; RV64I-NEXT: $x11 = COPY [[ZEXT1]](s64)
89 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @void_args_i8_zext, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11
90 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
91 ; RV64I-NEXT: PseudoRET
93 call void @void_args_i8_zext(i8 zeroext 0, i8 zeroext 1)
97 declare void @void_args_i16_sext(i16 signext, i16 signext)
99 define void @test_call_void_args_i16_sext() {
101 ; RV32I-LABEL: name: test_call_void_args_i16_sext
103 ; RV32I-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
104 ; RV32I-NEXT: [[C1:%[0-9]+]]:_(s16) = G_CONSTANT i16 1
105 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
106 ; RV32I-NEXT: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[C]](s16)
107 ; RV32I-NEXT: [[SEXT1:%[0-9]+]]:_(s32) = G_SEXT [[C1]](s16)
108 ; RV32I-NEXT: $x10 = COPY [[SEXT]](s32)
109 ; RV32I-NEXT: $x11 = COPY [[SEXT1]](s32)
110 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @void_args_i16_sext, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11
111 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
112 ; RV32I-NEXT: PseudoRET
114 ; RV64I-LABEL: name: test_call_void_args_i16_sext
116 ; RV64I-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
117 ; RV64I-NEXT: [[C1:%[0-9]+]]:_(s16) = G_CONSTANT i16 1
118 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
119 ; RV64I-NEXT: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[C]](s16)
120 ; RV64I-NEXT: [[SEXT1:%[0-9]+]]:_(s64) = G_SEXT [[C1]](s16)
121 ; RV64I-NEXT: $x10 = COPY [[SEXT]](s64)
122 ; RV64I-NEXT: $x11 = COPY [[SEXT1]](s64)
123 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @void_args_i16_sext, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11
124 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
125 ; RV64I-NEXT: PseudoRET
127 call void @void_args_i16_sext(i16 signext 0, i16 signext 1)
131 declare void @void_args_i32(i32, i32)
133 define void @test_call_void_args_i32() {
135 ; RV32I-LABEL: name: test_call_void_args_i32
137 ; RV32I-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
138 ; RV32I-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
139 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
140 ; RV32I-NEXT: $x10 = COPY [[C]](s32)
141 ; RV32I-NEXT: $x11 = COPY [[C1]](s32)
142 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @void_args_i32, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11
143 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
144 ; RV32I-NEXT: PseudoRET
146 ; RV64I-LABEL: name: test_call_void_args_i32
148 ; RV64I-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
149 ; RV64I-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
150 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
151 ; RV64I-NEXT: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[C]](s32)
152 ; RV64I-NEXT: [[ANYEXT1:%[0-9]+]]:_(s64) = G_ANYEXT [[C1]](s32)
153 ; RV64I-NEXT: $x10 = COPY [[ANYEXT]](s64)
154 ; RV64I-NEXT: $x11 = COPY [[ANYEXT1]](s64)
155 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @void_args_i32, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11
156 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
157 ; RV64I-NEXT: PseudoRET
159 call void @void_args_i32(i32 0, i32 1)
163 declare void @void_args_i64(i64, i64)
165 define void @test_call_void_args_i64() {
167 ; RV32I-LABEL: name: test_call_void_args_i64
169 ; RV32I-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
170 ; RV32I-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
171 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
172 ; RV32I-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C]](s64)
173 ; RV32I-NEXT: [[UV2:%[0-9]+]]:_(s32), [[UV3:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C1]](s64)
174 ; RV32I-NEXT: $x10 = COPY [[UV]](s32)
175 ; RV32I-NEXT: $x11 = COPY [[UV1]](s32)
176 ; RV32I-NEXT: $x12 = COPY [[UV2]](s32)
177 ; RV32I-NEXT: $x13 = COPY [[UV3]](s32)
178 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @void_args_i64, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11, implicit $x12, implicit $x13
179 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
180 ; RV32I-NEXT: PseudoRET
182 ; RV64I-LABEL: name: test_call_void_args_i64
184 ; RV64I-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
185 ; RV64I-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
186 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
187 ; RV64I-NEXT: $x10 = COPY [[C]](s64)
188 ; RV64I-NEXT: $x11 = COPY [[C1]](s64)
189 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @void_args_i64, csr_ilp32_lp64, implicit-def $x1, implicit $x10, implicit $x11
190 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
191 ; RV64I-NEXT: PseudoRET
193 call void @void_args_i64(i64 0, i64 1)
197 declare i8 @i8_noargs()
199 define void @test_call_i8_noargs() {
201 ; RV32I-LABEL: name: test_call_i8_noargs
203 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
204 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @i8_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10
205 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
206 ; RV32I-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
207 ; RV32I-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
208 ; RV32I-NEXT: PseudoRET
210 ; RV64I-LABEL: name: test_call_i8_noargs
212 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
213 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @i8_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10
214 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
215 ; RV64I-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
216 ; RV64I-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s64)
217 ; RV64I-NEXT: PseudoRET
219 %a = call i8 @i8_noargs()
223 declare i16 @i16_noargs()
225 define void @test_call_i16_noargs() {
227 ; RV32I-LABEL: name: test_call_i16_noargs
229 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
230 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @i16_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10
231 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
232 ; RV32I-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
233 ; RV32I-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
234 ; RV32I-NEXT: PseudoRET
236 ; RV64I-LABEL: name: test_call_i16_noargs
238 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
239 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @i16_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10
240 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
241 ; RV64I-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
242 ; RV64I-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s64)
243 ; RV64I-NEXT: PseudoRET
245 %a = call i16 @i16_noargs()
249 declare i32 @i32_noargs()
251 define void @test_call_i32_noargs() {
253 ; RV32I-LABEL: name: test_call_i32_noargs
255 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
256 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @i32_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10
257 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
258 ; RV32I-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
259 ; RV32I-NEXT: PseudoRET
261 ; RV64I-LABEL: name: test_call_i32_noargs
263 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
264 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @i32_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10
265 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
266 ; RV64I-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
267 ; RV64I-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
268 ; RV64I-NEXT: PseudoRET
270 %a = call i32 @i32_noargs()
274 declare i64 @i64_noargs()
276 define void @test_call_i64_noargs() {
278 ; RV32I-LABEL: name: test_call_i64_noargs
280 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
281 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @i64_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10, implicit-def $x11
282 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
283 ; RV32I-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
284 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
285 ; RV32I-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[COPY]](s32), [[COPY1]](s32)
286 ; RV32I-NEXT: PseudoRET
288 ; RV64I-LABEL: name: test_call_i64_noargs
290 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
291 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @i64_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10
292 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
293 ; RV64I-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
294 ; RV64I-NEXT: PseudoRET
296 %a = call i64 @i64_noargs()
300 declare ptr @ptr_noargs()
302 define void @test_call_ptr_noargs() {
303 ; RV32I-LABEL: name: test_call_ptr_noargs
305 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
306 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @ptr_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10
307 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
308 ; RV32I-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x10
309 ; RV32I-NEXT: PseudoRET
311 ; RV64I-LABEL: name: test_call_ptr_noargs
313 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
314 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @ptr_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10
315 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
316 ; RV64I-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x10
317 ; RV64I-NEXT: PseudoRET
319 %a = call ptr @ptr_noargs()
323 declare [2 x i32] @i32x2_noargs()
325 define void @test_call_i32x2_noargs() {
326 ; RV32I-LABEL: name: test_call_i32x2_noargs
328 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
329 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @i32x2_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10, implicit-def $x11
330 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
331 ; RV32I-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $x10
332 ; RV32I-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY $x11
333 ; RV32I-NEXT: PseudoRET
335 ; RV64I-LABEL: name: test_call_i32x2_noargs
337 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
338 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @i32x2_noargs, csr_ilp32_lp64, implicit-def $x1, implicit-def $x10, implicit-def $x11
339 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
340 ; RV64I-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x10
341 ; RV64I-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
342 ; RV64I-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x11
343 ; RV64I-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
344 ; RV64I-NEXT: PseudoRET
346 %a = call [2 x i32] @i32x2_noargs()
350 %struct.Foo = type { i32, i32, i32, i16, i8 }
351 @foo = global %struct.Foo { i32 1, i32 2, i32 3, i16 4, i8 5 }, align 4
353 declare void @void_byval_args(ptr byval(%struct.Foo) %f)
355 define void @test_void_byval_args() {
356 ; RV32I-LABEL: name: test_void_byval_args
358 ; RV32I-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @foo
359 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
360 ; RV32I-NEXT: $x10 = COPY [[GV]](p0)
361 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @void_byval_args, csr_ilp32_lp64, implicit-def $x1, implicit $x10
362 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
363 ; RV32I-NEXT: PseudoRET
365 ; RV64I-LABEL: name: test_void_byval_args
367 ; RV64I-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @foo
368 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
369 ; RV64I-NEXT: $x10 = COPY [[GV]](p0)
370 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @void_byval_args, csr_ilp32_lp64, implicit-def $x1, implicit $x10
371 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
372 ; RV64I-NEXT: PseudoRET
374 call void @void_byval_args(ptr byval(%struct.Foo) @foo)
378 declare void @void_sret_args(ptr sret(%struct.Foo) %f)
380 define void @test_void_sret_args() {
381 ; RV32I-LABEL: name: test_void_sret_args
383 ; RV32I-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @foo
384 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
385 ; RV32I-NEXT: $x10 = COPY [[GV]](p0)
386 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @void_sret_args, csr_ilp32_lp64, implicit-def $x1, implicit $x10
387 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
388 ; RV32I-NEXT: PseudoRET
390 ; RV64I-LABEL: name: test_void_sret_args
392 ; RV64I-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @foo
393 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
394 ; RV64I-NEXT: $x10 = COPY [[GV]](p0)
395 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @void_sret_args, csr_ilp32_lp64, implicit-def $x1, implicit $x10
396 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
397 ; RV64I-NEXT: PseudoRET
399 call void @void_sret_args(ptr sret(%struct.Foo) @foo)
403 declare external void @external_function()
405 define void @test_call_external() {
406 ; RV32I-LABEL: name: test_call_external
408 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
409 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @external_function, csr_ilp32_lp64, implicit-def $x1
410 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
411 ; RV32I-NEXT: PseudoRET
413 ; RV64I-LABEL: name: test_call_external
415 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
416 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @external_function, csr_ilp32_lp64, implicit-def $x1
417 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
418 ; RV64I-NEXT: PseudoRET
420 call void @external_function()
424 declare dso_local void @dso_local_function()
426 define void @test_call_local() {
427 ; RV32I-LABEL: name: test_call_local
429 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
430 ; RV32I-NEXT: PseudoCALL target-flags(riscv-call) @dso_local_function, csr_ilp32_lp64, implicit-def $x1
431 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
432 ; RV32I-NEXT: PseudoRET
434 ; RV64I-LABEL: name: test_call_local
436 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
437 ; RV64I-NEXT: PseudoCALL target-flags(riscv-call) @dso_local_function, csr_ilp32_lp64, implicit-def $x1
438 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
439 ; RV64I-NEXT: PseudoRET
441 call void @dso_local_function()
445 define void @test_indirect_call(ptr %func) {
446 ; RV32I-LABEL: name: test_indirect_call
447 ; RV32I: bb.1 (%ir-block.0):
448 ; RV32I-NEXT: liveins: $x10
450 ; RV32I-NEXT: [[COPY:%[0-9]+]]:gprjalr(p0) = COPY $x10
451 ; RV32I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
452 ; RV32I-NEXT: PseudoCALLIndirect [[COPY]](p0), csr_ilp32_lp64, implicit-def $x1
453 ; RV32I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
454 ; RV32I-NEXT: PseudoRET
456 ; RV64I-LABEL: name: test_indirect_call
457 ; RV64I: bb.1 (%ir-block.0):
458 ; RV64I-NEXT: liveins: $x10
460 ; RV64I-NEXT: [[COPY:%[0-9]+]]:gprjalr(p0) = COPY $x10
461 ; RV64I-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def $x2, implicit $x2
462 ; RV64I-NEXT: PseudoCALLIndirect [[COPY]](p0), csr_ilp32_lp64, implicit-def $x1
463 ; RV64I-NEXT: ADJCALLSTACKUP 0, 0, implicit-def $x2, implicit $x2
464 ; RV64I-NEXT: PseudoRET