xref: /aosp_15_r20/external/llvm/test/CodeGen/SPARC/leafproc.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=sparc -disable-sparc-leaf-proc=0 < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:      func_nobody:
4*9880d681SAndroid Build Coastguard Worker; CHECK:      retl
5*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: nop
6*9880d681SAndroid Build Coastguard Workerdefine void @func_nobody() {
7*9880d681SAndroid Build Coastguard Workerentry:
8*9880d681SAndroid Build Coastguard Worker  ret void
9*9880d681SAndroid Build Coastguard Worker}
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:      return_int_const:
13*9880d681SAndroid Build Coastguard Worker; CHECK:      retl
14*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: mov 1729, %o0
15*9880d681SAndroid Build Coastguard Workerdefine i32 @return_int_const() {
16*9880d681SAndroid Build Coastguard Workerentry:
17*9880d681SAndroid Build Coastguard Worker  ret i32 1729
18*9880d681SAndroid Build Coastguard Worker}
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:      return_double_const:
21*9880d681SAndroid Build Coastguard Worker; CHECK:      sethi
22*9880d681SAndroid Build Coastguard Worker; CHECK:      retl
23*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ldd {{.*}}, %f0
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Workerdefine double @return_double_const() {
26*9880d681SAndroid Build Coastguard Workerentry:
27*9880d681SAndroid Build Coastguard Worker  ret double 0.000000e+00
28*9880d681SAndroid Build Coastguard Worker}
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:      leaf_proc_with_args:
31*9880d681SAndroid Build Coastguard Worker; CHECK:      add {{%o[0-1]}}, {{%o[0-1]}}, [[R:%[go][0-7]]]
32*9880d681SAndroid Build Coastguard Worker; CHECK:      retl
33*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: add [[R]], %o2, %o0
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Workerdefine i32 @leaf_proc_with_args(i32 %a, i32 %b, i32 %c) {
36*9880d681SAndroid Build Coastguard Workerentry:
37*9880d681SAndroid Build Coastguard Worker  %0 = add nsw i32 %b, %a
38*9880d681SAndroid Build Coastguard Worker  %1 = add nsw i32 %0, %c
39*9880d681SAndroid Build Coastguard Worker  ret i32 %1
40*9880d681SAndroid Build Coastguard Worker}
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:     leaf_proc_with_args_in_stack:
43*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ld [%sp+92], {{%[go][0-7]}}
44*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: ld [%sp+96], {{%[go][0-7]}}
45*9880d681SAndroid Build Coastguard Worker; CHECK:     retl
46*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: add {{.*}}, %o0
47*9880d681SAndroid Build Coastguard Workerdefine i32 @leaf_proc_with_args_in_stack(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, i32 %h) {
48*9880d681SAndroid Build Coastguard Workerentry:
49*9880d681SAndroid Build Coastguard Worker  %0 = add nsw i32 %b, %a
50*9880d681SAndroid Build Coastguard Worker  %1 = add nsw i32 %0, %c
51*9880d681SAndroid Build Coastguard Worker  %2 = add nsw i32 %1, %d
52*9880d681SAndroid Build Coastguard Worker  %3 = add nsw i32 %2, %e
53*9880d681SAndroid Build Coastguard Worker  %4 = add nsw i32 %3, %f
54*9880d681SAndroid Build Coastguard Worker  %5 = add nsw i32 %4, %g
55*9880d681SAndroid Build Coastguard Worker  %6 = add nsw i32 %5, %h
56*9880d681SAndroid Build Coastguard Worker  ret i32 %6
57*9880d681SAndroid Build Coastguard Worker}
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL:      leaf_proc_with_local_array:
60*9880d681SAndroid Build Coastguard Worker; CHECK:      add %sp, -104, %sp
61*9880d681SAndroid Build Coastguard Worker; CHECK:      mov 1, [[R1:%[go][0-7]]]
62*9880d681SAndroid Build Coastguard Worker; CHECK:      st [[R1]], [%sp+96]
63*9880d681SAndroid Build Coastguard Worker; CHECK:      mov 2, [[R2:%[go][0-7]]]
64*9880d681SAndroid Build Coastguard Worker; CHECK:      st [[R2]], [%sp+100]
65*9880d681SAndroid Build Coastguard Worker; CHECK:      ld {{.+}}, %o0
66*9880d681SAndroid Build Coastguard Worker; CHECK:      retl
67*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: add %sp, 104, %sp
68*9880d681SAndroid Build Coastguard Worker
69*9880d681SAndroid Build Coastguard Workerdefine i32 @leaf_proc_with_local_array(i32 %a, i32 %b, i32 %c) {
70*9880d681SAndroid Build Coastguard Workerentry:
71*9880d681SAndroid Build Coastguard Worker  %array = alloca [2 x i32], align 4
72*9880d681SAndroid Build Coastguard Worker  %0 = sub nsw i32 %b, %c
73*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds [2 x i32], [2 x i32]* %array, i32 0, i32 0
74*9880d681SAndroid Build Coastguard Worker  store i32 1, i32* %1, align 4
75*9880d681SAndroid Build Coastguard Worker  %2 = getelementptr inbounds [2 x i32], [2 x i32]* %array, i32 0, i32 1
76*9880d681SAndroid Build Coastguard Worker  store i32 2, i32* %2, align 4
77*9880d681SAndroid Build Coastguard Worker  %3 = getelementptr inbounds [2 x i32], [2 x i32]* %array, i32 0, i32 %a
78*9880d681SAndroid Build Coastguard Worker  %4 = load i32, i32* %3, align 4
79*9880d681SAndroid Build Coastguard Worker  ret i32 %4
80*9880d681SAndroid Build Coastguard Worker}
81