xref: /llvm-project/llvm/test/CodeGen/CSKY/inline-asm-abi-names.ll (revision 08db089124a49f0f97a1a6db9d1a85e5886d1eb7)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=csky -verify-machineinstrs -csky-no-aliases -no-integrated-as -mattr=+e2 < %s \
3; RUN:   | FileCheck -check-prefix=CSKY %s
4
5; These test that we can use both the architectural names (r*) and the ABI names
6; (a*, l* etc) to refer to registers in inline asm constraint lists. In each
7; case, the named register should be used for the source register of the `addi`.
8;
9; The inline assembly will, by default, contain the ABI names for the registers.
10;
11; Parenthesised registers in comments are the other aliases for this register.
12
13; NOTE: This test uses `r0` (`a0`) as an input, so it should be saved.
14define i32 @explicit_register_r0(i32 %a) nounwind {
15; CSKY-LABEL: explicit_register_r0:
16; CSKY:       # %bb.0:
17; CSKY-NEXT:    #APP
18; CSKY-NEXT:    addi a0, a0, 1
19; CSKY-NEXT:    #NO_APP
20; CSKY-NEXT:    rts16
21  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r0}"(i32 %a)
22  ret i32 %1
23}
24
25; NOTE: This test uses `r0` (`a0`) as an input, so it should be saved.
26define i32 @explicit_register_a0(i32 %a) nounwind {
27; CSKY-LABEL: explicit_register_a0:
28; CSKY:       # %bb.0:
29; CSKY-NEXT:    #APP
30; CSKY-NEXT:    addi a0, a0, 1
31; CSKY-NEXT:    #NO_APP
32; CSKY-NEXT:    rts16
33  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{a0}"(i32 %a)
34  ret i32 %1
35}
36
37; NOTE: This test uses `r1` (`a1`) as an input, so it should be saved.
38define i32 @explicit_register_r1(i32 %a) nounwind {
39; CSKY-LABEL: explicit_register_r1:
40; CSKY:       # %bb.0:
41; CSKY-NEXT:    mov16 a1, a0
42; CSKY-NEXT:    #APP
43; CSKY-NEXT:    addi a0, a1, 1
44; CSKY-NEXT:    #NO_APP
45; CSKY-NEXT:    rts16
46  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r1}"(i32 %a)
47  ret i32 %1
48}
49
50define i32 @explicit_register_a1(i32 %a) nounwind {
51; CSKY-LABEL: explicit_register_a1:
52; CSKY:       # %bb.0:
53; CSKY-NEXT:    mov16 a1, a0
54; CSKY-NEXT:    #APP
55; CSKY-NEXT:    addi a0, a1, 1
56; CSKY-NEXT:    #NO_APP
57; CSKY-NEXT:    rts16
58  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{a1}"(i32 %a)
59  ret i32 %1
60}
61
62; NOTE: This test uses `r2` (`a2`) as an input, so it should be saved.
63define i32 @explicit_register_r2(i32 %a) nounwind {
64; CSKY-LABEL: explicit_register_r2:
65; CSKY:       # %bb.0:
66; CSKY-NEXT:    mov16 a2, a0
67; CSKY-NEXT:    #APP
68; CSKY-NEXT:    addi a0, a2, 1
69; CSKY-NEXT:    #NO_APP
70; CSKY-NEXT:    rts16
71  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r2}"(i32 %a)
72  ret i32 %1
73}
74
75define i32 @explicit_register_a2(i32 %a) nounwind {
76; CSKY-LABEL: explicit_register_a2:
77; CSKY:       # %bb.0:
78; CSKY-NEXT:    mov16 a2, a0
79; CSKY-NEXT:    #APP
80; CSKY-NEXT:    addi a0, a2, 1
81; CSKY-NEXT:    #NO_APP
82; CSKY-NEXT:    rts16
83  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{a2}"(i32 %a)
84  ret i32 %1
85}
86
87; NOTE: This test uses `r3` (`a3`) as an input, so it should be saved.
88define i32 @explicit_register_r3(i32 %a) nounwind {
89; CSKY-LABEL: explicit_register_r3:
90; CSKY:       # %bb.0:
91; CSKY-NEXT:    mov16 a3, a0
92; CSKY-NEXT:    #APP
93; CSKY-NEXT:    addi a0, a3, 1
94; CSKY-NEXT:    #NO_APP
95; CSKY-NEXT:    rts16
96  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r3}"(i32 %a)
97  ret i32 %1
98}
99
100define i32 @explicit_register_a3(i32 %a) nounwind {
101; CSKY-LABEL: explicit_register_a3:
102; CSKY:       # %bb.0:
103; CSKY-NEXT:    mov16 a3, a0
104; CSKY-NEXT:    #APP
105; CSKY-NEXT:    addi a0, a3, 1
106; CSKY-NEXT:    #NO_APP
107; CSKY-NEXT:    rts16
108  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{a3}"(i32 %a)
109  ret i32 %1
110}
111
112; NOTE: This test uses `r4` (`l0`) as an input, so it should be saved.
113define i32 @explicit_register_r4(i32 %a) nounwind {
114; CSKY-LABEL: explicit_register_r4:
115; CSKY:       # %bb.0:
116; CSKY-NEXT:    subi16 sp, sp, 4
117; CSKY-NEXT:    st16.w l0, (sp, 0) # 4-byte Folded Spill
118; CSKY-NEXT:    mov16 l0, a0
119; CSKY-NEXT:    #APP
120; CSKY-NEXT:    addi a0, l0, 1
121; CSKY-NEXT:    #NO_APP
122; CSKY-NEXT:    ld16.w l0, (sp, 0) # 4-byte Folded Reload
123; CSKY-NEXT:    addi16 sp, sp, 4
124; CSKY-NEXT:    rts16
125  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r4}"(i32 %a)
126  ret i32 %1
127}
128
129define i32 @explicit_register_l0(i32 %a) nounwind {
130; CSKY-LABEL: explicit_register_l0:
131; CSKY:       # %bb.0:
132; CSKY-NEXT:    subi16 sp, sp, 4
133; CSKY-NEXT:    st16.w l0, (sp, 0) # 4-byte Folded Spill
134; CSKY-NEXT:    mov16 l0, a0
135; CSKY-NEXT:    #APP
136; CSKY-NEXT:    addi a0, l0, 1
137; CSKY-NEXT:    #NO_APP
138; CSKY-NEXT:    ld16.w l0, (sp, 0) # 4-byte Folded Reload
139; CSKY-NEXT:    addi16 sp, sp, 4
140; CSKY-NEXT:    rts16
141  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{l0}"(i32 %a)
142  ret i32 %1
143}
144
145; NOTE: This test uses `r5` (`l1`) as an input, so it should be saved.
146define i32 @explicit_register_r5(i32 %a) nounwind {
147; CSKY-LABEL: explicit_register_r5:
148; CSKY:       # %bb.0:
149; CSKY-NEXT:    subi16 sp, sp, 4
150; CSKY-NEXT:    st16.w l1, (sp, 0) # 4-byte Folded Spill
151; CSKY-NEXT:    mov16 l1, a0
152; CSKY-NEXT:    #APP
153; CSKY-NEXT:    addi a0, l1, 1
154; CSKY-NEXT:    #NO_APP
155; CSKY-NEXT:    ld16.w l1, (sp, 0) # 4-byte Folded Reload
156; CSKY-NEXT:    addi16 sp, sp, 4
157; CSKY-NEXT:    rts16
158  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r5}"(i32 %a)
159  ret i32 %1
160}
161
162define i32 @explicit_register_l1(i32 %a) nounwind {
163; CSKY-LABEL: explicit_register_l1:
164; CSKY:       # %bb.0:
165; CSKY-NEXT:    subi16 sp, sp, 4
166; CSKY-NEXT:    st16.w l1, (sp, 0) # 4-byte Folded Spill
167; CSKY-NEXT:    mov16 l1, a0
168; CSKY-NEXT:    #APP
169; CSKY-NEXT:    addi a0, l1, 1
170; CSKY-NEXT:    #NO_APP
171; CSKY-NEXT:    ld16.w l1, (sp, 0) # 4-byte Folded Reload
172; CSKY-NEXT:    addi16 sp, sp, 4
173; CSKY-NEXT:    rts16
174  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{l1}"(i32 %a)
175  ret i32 %1
176}
177
178; NOTE: This test uses `r6` (`l2`) as an input, so it should be saved.
179define i32 @explicit_register_r6(i32 %a) nounwind {
180; CSKY-LABEL: explicit_register_r6:
181; CSKY:       # %bb.0:
182; CSKY-NEXT:    subi16 sp, sp, 4
183; CSKY-NEXT:    st16.w l2, (sp, 0) # 4-byte Folded Spill
184; CSKY-NEXT:    mov16 l2, a0
185; CSKY-NEXT:    #APP
186; CSKY-NEXT:    addi a0, l2, 1
187; CSKY-NEXT:    #NO_APP
188; CSKY-NEXT:    ld16.w l2, (sp, 0) # 4-byte Folded Reload
189; CSKY-NEXT:    addi16 sp, sp, 4
190; CSKY-NEXT:    rts16
191  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r6}"(i32 %a)
192  ret i32 %1
193}
194
195define i32 @explicit_register_l2(i32 %a) nounwind {
196; CSKY-LABEL: explicit_register_l2:
197; CSKY:       # %bb.0:
198; CSKY-NEXT:    subi16 sp, sp, 4
199; CSKY-NEXT:    st16.w l2, (sp, 0) # 4-byte Folded Spill
200; CSKY-NEXT:    mov16 l2, a0
201; CSKY-NEXT:    #APP
202; CSKY-NEXT:    addi a0, l2, 1
203; CSKY-NEXT:    #NO_APP
204; CSKY-NEXT:    ld16.w l2, (sp, 0) # 4-byte Folded Reload
205; CSKY-NEXT:    addi16 sp, sp, 4
206; CSKY-NEXT:    rts16
207  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{l2}"(i32 %a)
208  ret i32 %1
209}
210
211; NOTE: This test uses `r7` (`l3`) as an input, so it should be saved.
212define i32 @explicit_register_r7(i32 %a) nounwind {
213; CSKY-LABEL: explicit_register_r7:
214; CSKY:       # %bb.0:
215; CSKY-NEXT:    subi16 sp, sp, 4
216; CSKY-NEXT:    st16.w l3, (sp, 0) # 4-byte Folded Spill
217; CSKY-NEXT:    mov16 l3, a0
218; CSKY-NEXT:    #APP
219; CSKY-NEXT:    addi a0, l3, 1
220; CSKY-NEXT:    #NO_APP
221; CSKY-NEXT:    ld16.w l3, (sp, 0) # 4-byte Folded Reload
222; CSKY-NEXT:    addi16 sp, sp, 4
223; CSKY-NEXT:    rts16
224  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r7}"(i32 %a)
225  ret i32 %1
226}
227
228define i32 @explicit_register_l3(i32 %a) nounwind {
229; CSKY-LABEL: explicit_register_l3:
230; CSKY:       # %bb.0:
231; CSKY-NEXT:    subi16 sp, sp, 4
232; CSKY-NEXT:    st16.w l3, (sp, 0) # 4-byte Folded Spill
233; CSKY-NEXT:    mov16 l3, a0
234; CSKY-NEXT:    #APP
235; CSKY-NEXT:    addi a0, l3, 1
236; CSKY-NEXT:    #NO_APP
237; CSKY-NEXT:    ld16.w l3, (sp, 0) # 4-byte Folded Reload
238; CSKY-NEXT:    addi16 sp, sp, 4
239; CSKY-NEXT:    rts16
240  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{l3}"(i32 %a)
241  ret i32 %1
242}
243
244; NOTE: This test uses `r8` (`l4`) as an input, so it should be saved.
245define i32 @explicit_register_r8(i32 %a) nounwind {
246; CSKY-LABEL: explicit_register_r8:
247; CSKY:       # %bb.0:
248; CSKY-NEXT:    subi16 sp, sp, 4
249; CSKY-NEXT:    st32.w l4, (sp, 0) # 4-byte Folded Spill
250; CSKY-NEXT:    mov16 l4, a0
251; CSKY-NEXT:    #APP
252; CSKY-NEXT:    addi a0, l4, 1
253; CSKY-NEXT:    #NO_APP
254; CSKY-NEXT:    ld32.w l4, (sp, 0) # 4-byte Folded Reload
255; CSKY-NEXT:    addi16 sp, sp, 4
256; CSKY-NEXT:    rts16
257  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r8}"(i32 %a)
258  ret i32 %1
259}
260
261define i32 @explicit_register_l4(i32 %a) nounwind {
262; CSKY-LABEL: explicit_register_l4:
263; CSKY:       # %bb.0:
264; CSKY-NEXT:    subi16 sp, sp, 4
265; CSKY-NEXT:    st32.w l4, (sp, 0) # 4-byte Folded Spill
266; CSKY-NEXT:    mov16 l4, a0
267; CSKY-NEXT:    #APP
268; CSKY-NEXT:    addi a0, l4, 1
269; CSKY-NEXT:    #NO_APP
270; CSKY-NEXT:    ld32.w l4, (sp, 0) # 4-byte Folded Reload
271; CSKY-NEXT:    addi16 sp, sp, 4
272; CSKY-NEXT:    rts16
273  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{l4}"(i32 %a)
274  ret i32 %1
275}
276
277; NOTE: This test uses `r9` (`l5`) as an input, so it should be saved.
278define i32 @explicit_register_r9(i32 %a) nounwind {
279; CSKY-LABEL: explicit_register_r9:
280; CSKY:       # %bb.0:
281; CSKY-NEXT:    subi16 sp, sp, 4
282; CSKY-NEXT:    st32.w l5, (sp, 0) # 4-byte Folded Spill
283; CSKY-NEXT:    mov16 l5, a0
284; CSKY-NEXT:    #APP
285; CSKY-NEXT:    addi a0, l5, 1
286; CSKY-NEXT:    #NO_APP
287; CSKY-NEXT:    ld32.w l5, (sp, 0) # 4-byte Folded Reload
288; CSKY-NEXT:    addi16 sp, sp, 4
289; CSKY-NEXT:    rts16
290  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r9}"(i32 %a)
291  ret i32 %1
292}
293
294define i32 @explicit_register_l5(i32 %a) nounwind {
295; CSKY-LABEL: explicit_register_l5:
296; CSKY:       # %bb.0:
297; CSKY-NEXT:    subi16 sp, sp, 4
298; CSKY-NEXT:    st32.w l5, (sp, 0) # 4-byte Folded Spill
299; CSKY-NEXT:    mov16 l5, a0
300; CSKY-NEXT:    #APP
301; CSKY-NEXT:    addi a0, l5, 1
302; CSKY-NEXT:    #NO_APP
303; CSKY-NEXT:    ld32.w l5, (sp, 0) # 4-byte Folded Reload
304; CSKY-NEXT:    addi16 sp, sp, 4
305; CSKY-NEXT:    rts16
306  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{l5}"(i32 %a)
307  ret i32 %1
308}
309
310; NOTE: This test uses `r10` (`l6`) as an input, so it should be saved.
311define i32 @explicit_register_r10(i32 %a) nounwind {
312; CSKY-LABEL: explicit_register_r10:
313; CSKY:       # %bb.0:
314; CSKY-NEXT:    subi16 sp, sp, 4
315; CSKY-NEXT:    st32.w l6, (sp, 0) # 4-byte Folded Spill
316; CSKY-NEXT:    mov16 l6, a0
317; CSKY-NEXT:    #APP
318; CSKY-NEXT:    addi a0, l6, 1
319; CSKY-NEXT:    #NO_APP
320; CSKY-NEXT:    ld32.w l6, (sp, 0) # 4-byte Folded Reload
321; CSKY-NEXT:    addi16 sp, sp, 4
322; CSKY-NEXT:    rts16
323  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r10}"(i32 %a)
324  ret i32 %1
325}
326
327define i32 @explicit_register_l6(i32 %a) nounwind {
328; CSKY-LABEL: explicit_register_l6:
329; CSKY:       # %bb.0:
330; CSKY-NEXT:    subi16 sp, sp, 4
331; CSKY-NEXT:    st32.w l6, (sp, 0) # 4-byte Folded Spill
332; CSKY-NEXT:    mov16 l6, a0
333; CSKY-NEXT:    #APP
334; CSKY-NEXT:    addi a0, l6, 1
335; CSKY-NEXT:    #NO_APP
336; CSKY-NEXT:    ld32.w l6, (sp, 0) # 4-byte Folded Reload
337; CSKY-NEXT:    addi16 sp, sp, 4
338; CSKY-NEXT:    rts16
339  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{l6}"(i32 %a)
340  ret i32 %1
341}
342
343; NOTE: This test uses `r11` (`l7`) as an input, so it should be saved.
344define i32 @explicit_register_r11(i32 %a) nounwind {
345; CSKY-LABEL: explicit_register_r11:
346; CSKY:       # %bb.0:
347; CSKY-NEXT:    subi16 sp, sp, 4
348; CSKY-NEXT:    st32.w l7, (sp, 0) # 4-byte Folded Spill
349; CSKY-NEXT:    mov16 l7, a0
350; CSKY-NEXT:    #APP
351; CSKY-NEXT:    addi a0, l7, 1
352; CSKY-NEXT:    #NO_APP
353; CSKY-NEXT:    ld32.w l7, (sp, 0) # 4-byte Folded Reload
354; CSKY-NEXT:    addi16 sp, sp, 4
355; CSKY-NEXT:    rts16
356  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r11}"(i32 %a)
357  ret i32 %1
358}
359
360define i32 @explicit_register_l7(i32 %a) nounwind {
361; CSKY-LABEL: explicit_register_l7:
362; CSKY:       # %bb.0:
363; CSKY-NEXT:    subi16 sp, sp, 4
364; CSKY-NEXT:    st32.w l7, (sp, 0) # 4-byte Folded Spill
365; CSKY-NEXT:    mov16 l7, a0
366; CSKY-NEXT:    #APP
367; CSKY-NEXT:    addi a0, l7, 1
368; CSKY-NEXT:    #NO_APP
369; CSKY-NEXT:    ld32.w l7, (sp, 0) # 4-byte Folded Reload
370; CSKY-NEXT:    addi16 sp, sp, 4
371; CSKY-NEXT:    rts16
372  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{l7}"(i32 %a)
373  ret i32 %1
374}
375
376; NOTE: This test uses `r12` (`t0`) as an input, so it should be saved.
377define i32 @explicit_register_r12(i32 %a) nounwind {
378; CSKY-LABEL: explicit_register_r12:
379; CSKY:       # %bb.0:
380; CSKY-NEXT:    mov16 t0, a0
381; CSKY-NEXT:    #APP
382; CSKY-NEXT:    addi a0, t0, 1
383; CSKY-NEXT:    #NO_APP
384; CSKY-NEXT:    rts16
385  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r12}"(i32 %a)
386  ret i32 %1
387}
388
389define i32 @explicit_register_t0(i32 %a) nounwind {
390; CSKY-LABEL: explicit_register_t0:
391; CSKY:       # %bb.0:
392; CSKY-NEXT:    mov16 t0, a0
393; CSKY-NEXT:    #APP
394; CSKY-NEXT:    addi a0, t0, 1
395; CSKY-NEXT:    #NO_APP
396; CSKY-NEXT:    rts16
397  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{t0}"(i32 %a)
398  ret i32 %1
399}
400
401; NOTE: This test uses `r13` (`t1`) as an input, so it should be saved.
402define i32 @explicit_register_r13(i32 %a) nounwind {
403; CSKY-LABEL: explicit_register_r13:
404; CSKY:       # %bb.0:
405; CSKY-NEXT:    mov16 t1, a0
406; CSKY-NEXT:    #APP
407; CSKY-NEXT:    addi a0, t1, 1
408; CSKY-NEXT:    #NO_APP
409; CSKY-NEXT:    rts16
410  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r13}"(i32 %a)
411  ret i32 %1
412}
413
414define i32 @explicit_register_t1(i32 %a) nounwind {
415; CSKY-LABEL: explicit_register_t1:
416; CSKY:       # %bb.0:
417; CSKY-NEXT:    mov16 t1, a0
418; CSKY-NEXT:    #APP
419; CSKY-NEXT:    addi a0, t1, 1
420; CSKY-NEXT:    #NO_APP
421; CSKY-NEXT:    rts16
422  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{t1}"(i32 %a)
423  ret i32 %1
424}
425
426; NOTE: This test uses `r14` (`sp`) as an input, so it should be saved.
427define i32 @explicit_register_r14(i32 %a) nounwind {
428; CSKY-LABEL: explicit_register_r14:
429; CSKY:       # %bb.0:
430; CSKY-NEXT:    mov16 sp, a0
431; CSKY-NEXT:    #APP
432; CSKY-NEXT:    addi a0, sp, 1
433; CSKY-NEXT:    #NO_APP
434; CSKY-NEXT:    rts16
435  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r14}"(i32 %a)
436  ret i32 %1
437}
438
439define i32 @explicit_register_sp(i32 %a) nounwind {
440; CSKY-LABEL: explicit_register_sp:
441; CSKY:       # %bb.0:
442; CSKY-NEXT:    mov16 sp, a0
443; CSKY-NEXT:    #APP
444; CSKY-NEXT:    addi a0, sp, 1
445; CSKY-NEXT:    #NO_APP
446; CSKY-NEXT:    rts16
447  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{sp}"(i32 %a)
448  ret i32 %1
449}
450
451; NOTE: This test uses `r15` (`lr`) as an input, so it should be saved.
452define i32 @explicit_register_r15(i32 %a) nounwind {
453; CSKY-LABEL: explicit_register_r15:
454; CSKY:       # %bb.0:
455; CSKY-NEXT:    subi16 sp, sp, 4
456; CSKY-NEXT:    st32.w lr, (sp, 0) # 4-byte Folded Spill
457; CSKY-NEXT:    mov16 lr, a0
458; CSKY-NEXT:    #APP
459; CSKY-NEXT:    addi a0, lr, 1
460; CSKY-NEXT:    #NO_APP
461; CSKY-NEXT:    ld32.w lr, (sp, 0) # 4-byte Folded Reload
462; CSKY-NEXT:    addi16 sp, sp, 4
463; CSKY-NEXT:    rts16
464  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r15}"(i32 %a)
465  ret i32 %1
466}
467
468define i32 @explicit_register_lr(i32 %a) nounwind {
469; CSKY-LABEL: explicit_register_lr:
470; CSKY:       # %bb.0:
471; CSKY-NEXT:    subi16 sp, sp, 4
472; CSKY-NEXT:    st32.w lr, (sp, 0) # 4-byte Folded Spill
473; CSKY-NEXT:    mov16 lr, a0
474; CSKY-NEXT:    #APP
475; CSKY-NEXT:    addi a0, lr, 1
476; CSKY-NEXT:    #NO_APP
477; CSKY-NEXT:    ld32.w lr, (sp, 0) # 4-byte Folded Reload
478; CSKY-NEXT:    addi16 sp, sp, 4
479; CSKY-NEXT:    rts16
480  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{lr}"(i32 %a)
481  ret i32 %1
482}
483
484; NOTE: This test uses `r16` (`l8`) as an input, so it should be saved.
485define i32 @explicit_register_r16(i32 %a) nounwind {
486; CSKY-LABEL: explicit_register_r16:
487; CSKY:       # %bb.0:
488; CSKY-NEXT:    subi16 sp, sp, 4
489; CSKY-NEXT:    st32.w l8, (sp, 0) # 4-byte Folded Spill
490; CSKY-NEXT:    mov32 l8, a0
491; CSKY-NEXT:    #APP
492; CSKY-NEXT:    addi a0, l8, 1
493; CSKY-NEXT:    #NO_APP
494; CSKY-NEXT:    ld32.w l8, (sp, 0) # 4-byte Folded Reload
495; CSKY-NEXT:    addi16 sp, sp, 4
496; CSKY-NEXT:    rts16
497  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r16}"(i32 %a)
498  ret i32 %1
499}
500
501define i32 @explicit_register_l8(i32 %a) nounwind {
502; CSKY-LABEL: explicit_register_l8:
503; CSKY:       # %bb.0:
504; CSKY-NEXT:    subi16 sp, sp, 4
505; CSKY-NEXT:    st32.w l8, (sp, 0) # 4-byte Folded Spill
506; CSKY-NEXT:    mov32 l8, a0
507; CSKY-NEXT:    #APP
508; CSKY-NEXT:    addi a0, l8, 1
509; CSKY-NEXT:    #NO_APP
510; CSKY-NEXT:    ld32.w l8, (sp, 0) # 4-byte Folded Reload
511; CSKY-NEXT:    addi16 sp, sp, 4
512; CSKY-NEXT:    rts16
513  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{l8}"(i32 %a)
514  ret i32 %1
515}
516
517; NOTE: This test uses `r17` (`l9`) as an input, so it should be saved.
518define i32 @explicit_register_r17(i32 %a) nounwind {
519; CSKY-LABEL: explicit_register_r17:
520; CSKY:       # %bb.0:
521; CSKY-NEXT:    subi16 sp, sp, 4
522; CSKY-NEXT:    st32.w l9, (sp, 0) # 4-byte Folded Spill
523; CSKY-NEXT:    mov32 l9, a0
524; CSKY-NEXT:    #APP
525; CSKY-NEXT:    addi a0, l9, 1
526; CSKY-NEXT:    #NO_APP
527; CSKY-NEXT:    ld32.w l9, (sp, 0) # 4-byte Folded Reload
528; CSKY-NEXT:    addi16 sp, sp, 4
529; CSKY-NEXT:    rts16
530  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r17}"(i32 %a)
531  ret i32 %1
532}
533
534define i32 @explicit_register_l9(i32 %a) nounwind {
535; CSKY-LABEL: explicit_register_l9:
536; CSKY:       # %bb.0:
537; CSKY-NEXT:    subi16 sp, sp, 4
538; CSKY-NEXT:    st32.w l9, (sp, 0) # 4-byte Folded Spill
539; CSKY-NEXT:    mov32 l9, a0
540; CSKY-NEXT:    #APP
541; CSKY-NEXT:    addi a0, l9, 1
542; CSKY-NEXT:    #NO_APP
543; CSKY-NEXT:    ld32.w l9, (sp, 0) # 4-byte Folded Reload
544; CSKY-NEXT:    addi16 sp, sp, 4
545; CSKY-NEXT:    rts16
546  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{l9}"(i32 %a)
547  ret i32 %1
548}
549
550; NOTE: This test uses `r18` (`t2`) as an input, so it should be saved.
551define i32 @explicit_register_r18(i32 %a) nounwind {
552; CSKY-LABEL: explicit_register_r18:
553; CSKY:       # %bb.0:
554; CSKY-NEXT:    mov32 t2, a0
555; CSKY-NEXT:    #APP
556; CSKY-NEXT:    addi a0, t2, 1
557; CSKY-NEXT:    #NO_APP
558; CSKY-NEXT:    rts16
559  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r18}"(i32 %a)
560  ret i32 %1
561}
562
563define i32 @explicit_register_t2(i32 %a) nounwind {
564; CSKY-LABEL: explicit_register_t2:
565; CSKY:       # %bb.0:
566; CSKY-NEXT:    mov32 t2, a0
567; CSKY-NEXT:    #APP
568; CSKY-NEXT:    addi a0, t2, 1
569; CSKY-NEXT:    #NO_APP
570; CSKY-NEXT:    rts16
571  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{t2}"(i32 %a)
572  ret i32 %1
573}
574
575; NOTE: This test uses `r19` (`t3`) as an input, so it should be saved.
576define i32 @explicit_register_r19(i32 %a) nounwind {
577; CSKY-LABEL: explicit_register_r19:
578; CSKY:       # %bb.0:
579; CSKY-NEXT:    mov32 t3, a0
580; CSKY-NEXT:    #APP
581; CSKY-NEXT:    addi a0, t3, 1
582; CSKY-NEXT:    #NO_APP
583; CSKY-NEXT:    rts16
584  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r19}"(i32 %a)
585  ret i32 %1
586}
587
588define i32 @explicit_register_t3(i32 %a) nounwind {
589; CSKY-LABEL: explicit_register_t3:
590; CSKY:       # %bb.0:
591; CSKY-NEXT:    mov32 t3, a0
592; CSKY-NEXT:    #APP
593; CSKY-NEXT:    addi a0, t3, 1
594; CSKY-NEXT:    #NO_APP
595; CSKY-NEXT:    rts16
596  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{t3}"(i32 %a)
597  ret i32 %1
598}
599
600; NOTE: This test uses `r20` (`t4`) as an input, so it should be saved.
601define i32 @explicit_register_r20(i32 %a) nounwind {
602; CSKY-LABEL: explicit_register_r20:
603; CSKY:       # %bb.0:
604; CSKY-NEXT:    mov32 t4, a0
605; CSKY-NEXT:    #APP
606; CSKY-NEXT:    addi a0, t4, 1
607; CSKY-NEXT:    #NO_APP
608; CSKY-NEXT:    rts16
609  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r20}"(i32 %a)
610  ret i32 %1
611}
612
613define i32 @explicit_register_t4(i32 %a) nounwind {
614; CSKY-LABEL: explicit_register_t4:
615; CSKY:       # %bb.0:
616; CSKY-NEXT:    mov32 t4, a0
617; CSKY-NEXT:    #APP
618; CSKY-NEXT:    addi a0, t4, 1
619; CSKY-NEXT:    #NO_APP
620; CSKY-NEXT:    rts16
621  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{t4}"(i32 %a)
622  ret i32 %1
623}
624
625; NOTE: This test uses `r21` (`t5`) as an input, so it should be saved.
626define i32 @explicit_register_r21(i32 %a) nounwind {
627; CSKY-LABEL: explicit_register_r21:
628; CSKY:       # %bb.0:
629; CSKY-NEXT:    mov32 t5, a0
630; CSKY-NEXT:    #APP
631; CSKY-NEXT:    addi a0, t5, 1
632; CSKY-NEXT:    #NO_APP
633; CSKY-NEXT:    rts16
634  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r21}"(i32 %a)
635  ret i32 %1
636}
637
638define i32 @explicit_register_t5(i32 %a) nounwind {
639; CSKY-LABEL: explicit_register_t5:
640; CSKY:       # %bb.0:
641; CSKY-NEXT:    mov32 t5, a0
642; CSKY-NEXT:    #APP
643; CSKY-NEXT:    addi a0, t5, 1
644; CSKY-NEXT:    #NO_APP
645; CSKY-NEXT:    rts16
646  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{t5}"(i32 %a)
647  ret i32 %1
648}
649
650; NOTE: This test uses `r22` (`t6`) as an input, so it should be saved.
651define i32 @explicit_register_r22(i32 %a) nounwind {
652; CSKY-LABEL: explicit_register_r22:
653; CSKY:       # %bb.0:
654; CSKY-NEXT:    mov32 t6, a0
655; CSKY-NEXT:    #APP
656; CSKY-NEXT:    addi a0, t6, 1
657; CSKY-NEXT:    #NO_APP
658; CSKY-NEXT:    rts16
659  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r22}"(i32 %a)
660  ret i32 %1
661}
662
663define i32 @explicit_register_t6(i32 %a) nounwind {
664; CSKY-LABEL: explicit_register_t6:
665; CSKY:       # %bb.0:
666; CSKY-NEXT:    mov32 t6, a0
667; CSKY-NEXT:    #APP
668; CSKY-NEXT:    addi a0, t6, 1
669; CSKY-NEXT:    #NO_APP
670; CSKY-NEXT:    rts16
671  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{t6}"(i32 %a)
672  ret i32 %1
673}
674
675; NOTE: This test uses `r23` (`t7`) as an input, so it should be saved.
676define i32 @explicit_register_r23(i32 %a) nounwind {
677; CSKY-LABEL: explicit_register_r23:
678; CSKY:       # %bb.0:
679; CSKY-NEXT:    mov32 t7, a0
680; CSKY-NEXT:    #APP
681; CSKY-NEXT:    addi a0, t7, 1
682; CSKY-NEXT:    #NO_APP
683; CSKY-NEXT:    rts16
684  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r23}"(i32 %a)
685  ret i32 %1
686}
687
688define i32 @explicit_register_t7(i32 %a) nounwind {
689; CSKY-LABEL: explicit_register_t7:
690; CSKY:       # %bb.0:
691; CSKY-NEXT:    mov32 t7, a0
692; CSKY-NEXT:    #APP
693; CSKY-NEXT:    addi a0, t7, 1
694; CSKY-NEXT:    #NO_APP
695; CSKY-NEXT:    rts16
696  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{t7}"(i32 %a)
697  ret i32 %1
698}
699
700; NOTE: This test uses `r24` (`t8`) as an input, so it should be saved.
701define i32 @explicit_register_r24(i32 %a) nounwind {
702; CSKY-LABEL: explicit_register_r24:
703; CSKY:       # %bb.0:
704; CSKY-NEXT:    mov32 t8, a0
705; CSKY-NEXT:    #APP
706; CSKY-NEXT:    addi a0, t8, 1
707; CSKY-NEXT:    #NO_APP
708; CSKY-NEXT:    rts16
709  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r24}"(i32 %a)
710  ret i32 %1
711}
712
713define i32 @explicit_register_t8(i32 %a) nounwind {
714; CSKY-LABEL: explicit_register_t8:
715; CSKY:       # %bb.0:
716; CSKY-NEXT:    mov32 t8, a0
717; CSKY-NEXT:    #APP
718; CSKY-NEXT:    addi a0, t8, 1
719; CSKY-NEXT:    #NO_APP
720; CSKY-NEXT:    rts16
721  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{t8}"(i32 %a)
722  ret i32 %1
723}
724
725; NOTE: This test uses `r25` (`t9`) as an input, so it should be saved.
726define i32 @explicit_register_r25(i32 %a) nounwind {
727; CSKY-LABEL: explicit_register_r25:
728; CSKY:       # %bb.0:
729; CSKY-NEXT:    mov32 t9, a0
730; CSKY-NEXT:    #APP
731; CSKY-NEXT:    addi a0, t9, 1
732; CSKY-NEXT:    #NO_APP
733; CSKY-NEXT:    rts16
734  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r25}"(i32 %a)
735  ret i32 %1
736}
737
738define i32 @explicit_register_t9(i32 %a) nounwind {
739; CSKY-LABEL: explicit_register_t9:
740; CSKY:       # %bb.0:
741; CSKY-NEXT:    mov32 t9, a0
742; CSKY-NEXT:    #APP
743; CSKY-NEXT:    addi a0, t9, 1
744; CSKY-NEXT:    #NO_APP
745; CSKY-NEXT:    rts16
746  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{t9}"(i32 %a)
747  ret i32 %1
748}
749
750; NOTE: This test uses `r26` (`r26`) as an input, so it should be saved.
751define i32 @explicit_register_r26(i32 %a) nounwind {
752; CSKY-LABEL: explicit_register_r26:
753; CSKY:       # %bb.0:
754; CSKY-NEXT:    mov32 r26, a0
755; CSKY-NEXT:    #APP
756; CSKY-NEXT:    addi a0, r26, 1
757; CSKY-NEXT:    #NO_APP
758; CSKY-NEXT:    rts16
759  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r26}"(i32 %a)
760  ret i32 %1
761}
762
763
764; NOTE: This test uses `r27` (`r27`) as an input, so it should be saved.
765define i32 @explicit_register_r27(i32 %a) nounwind {
766; CSKY-LABEL: explicit_register_r27:
767; CSKY:       # %bb.0:
768; CSKY-NEXT:    mov32 r27, a0
769; CSKY-NEXT:    #APP
770; CSKY-NEXT:    addi a0, r27, 1
771; CSKY-NEXT:    #NO_APP
772; CSKY-NEXT:    rts16
773  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r27}"(i32 %a)
774  ret i32 %1
775}
776
777; NOTE: This test uses `r28` (`rgb`) as an input, so it should be saved.
778define i32 @explicit_register_r28(i32 %a) nounwind {
779; CSKY-LABEL: explicit_register_r28:
780; CSKY:       # %bb.0:
781; CSKY-NEXT:    subi16 sp, sp, 4
782; CSKY-NEXT:    st32.w rgb, (sp, 0) # 4-byte Folded Spill
783; CSKY-NEXT:    mov32 rgb, a0
784; CSKY-NEXT:    #APP
785; CSKY-NEXT:    addi a0, rgb, 1
786; CSKY-NEXT:    #NO_APP
787; CSKY-NEXT:    ld32.w rgb, (sp, 0) # 4-byte Folded Reload
788; CSKY-NEXT:    addi16 sp, sp, 4
789; CSKY-NEXT:    rts16
790  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r28}"(i32 %a)
791  ret i32 %1
792}
793
794define i32 @explicit_register_rgb(i32 %a) nounwind {
795; CSKY-LABEL: explicit_register_rgb:
796; CSKY:       # %bb.0:
797; CSKY-NEXT:    subi16 sp, sp, 4
798; CSKY-NEXT:    st32.w rgb, (sp, 0) # 4-byte Folded Spill
799; CSKY-NEXT:    mov32 rgb, a0
800; CSKY-NEXT:    #APP
801; CSKY-NEXT:    addi a0, rgb, 1
802; CSKY-NEXT:    #NO_APP
803; CSKY-NEXT:    ld32.w rgb, (sp, 0) # 4-byte Folded Reload
804; CSKY-NEXT:    addi16 sp, sp, 4
805; CSKY-NEXT:    rts16
806  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{rgb}"(i32 %a)
807  ret i32 %1
808}
809
810; NOTE: This test uses `r29` (`rtb`) as an input, so it should be saved.
811define i32 @explicit_register_r29(i32 %a) nounwind {
812; CSKY-LABEL: explicit_register_r29:
813; CSKY:       # %bb.0:
814; CSKY-NEXT:    mov32 rtb, a0
815; CSKY-NEXT:    #APP
816; CSKY-NEXT:    addi a0, rtb, 1
817; CSKY-NEXT:    #NO_APP
818; CSKY-NEXT:    rts16
819  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r29}"(i32 %a)
820  ret i32 %1
821}
822
823define i32 @explicit_register_rtb(i32 %a) nounwind {
824; CSKY-LABEL: explicit_register_rtb:
825; CSKY:       # %bb.0:
826; CSKY-NEXT:    mov32 rtb, a0
827; CSKY-NEXT:    #APP
828; CSKY-NEXT:    addi a0, rtb, 1
829; CSKY-NEXT:    #NO_APP
830; CSKY-NEXT:    rts16
831  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{rtb}"(i32 %a)
832  ret i32 %1
833}
834
835; NOTE: This test uses `r30` (`svbr`) as an input, so it should be saved.
836define i32 @explicit_register_r30(i32 %a) nounwind {
837; CSKY-LABEL: explicit_register_r30:
838; CSKY:       # %bb.0:
839; CSKY-NEXT:    mov32 svbr, a0
840; CSKY-NEXT:    #APP
841; CSKY-NEXT:    addi a0, svbr, 1
842; CSKY-NEXT:    #NO_APP
843; CSKY-NEXT:    rts16
844  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r30}"(i32 %a)
845  ret i32 %1
846}
847
848define i32 @explicit_register_svbr(i32 %a) nounwind {
849; CSKY-LABEL: explicit_register_svbr:
850; CSKY:       # %bb.0:
851; CSKY-NEXT:    mov32 svbr, a0
852; CSKY-NEXT:    #APP
853; CSKY-NEXT:    addi a0, svbr, 1
854; CSKY-NEXT:    #NO_APP
855; CSKY-NEXT:    rts16
856  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{svbr}"(i32 %a)
857  ret i32 %1
858}
859
860; NOTE: This test uses `r31` (`tls`) as an input, so it should be saved.
861define i32 @explicit_register_r31(i32 %a) nounwind {
862; CSKY-LABEL: explicit_register_r31:
863; CSKY:       # %bb.0:
864; CSKY-NEXT:    mov32 tls, a0
865; CSKY-NEXT:    #APP
866; CSKY-NEXT:    addi a0, tls, 1
867; CSKY-NEXT:    #NO_APP
868; CSKY-NEXT:    rts16
869  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{r31}"(i32 %a)
870  ret i32 %1
871}
872
873define i32 @explicit_register_tls(i32 %a) nounwind {
874; CSKY-LABEL: explicit_register_tls:
875; CSKY:       # %bb.0:
876; CSKY-NEXT:    mov32 tls, a0
877; CSKY-NEXT:    #APP
878; CSKY-NEXT:    addi a0, tls, 1
879; CSKY-NEXT:    #NO_APP
880; CSKY-NEXT:    rts16
881  %1 = tail call i32 asm "addi $0, $1, 1", "=r,{tls}"(i32 %a)
882  ret i32 %1
883}
884