1;RUN: llc -march=sparc < %s | FileCheck %s -check-prefix=V8
2;RUN: llc -march=sparc -mattr=v9 < %s | FileCheck %s -check-prefix=V9
3;RUN: llc -march=sparc -regalloc=basic < %s | FileCheck %s -check-prefix=V8
4;RUN: llc -march=sparc -regalloc=basic -mattr=v9 < %s | FileCheck %s -check-prefix=V9
5;RUN: llc -march=sparcv9  < %s | FileCheck %s -check-prefix=SPARC64
6
7
8define i8* @frameaddr() nounwind readnone {
9entry:
10;V8-LABEL: frameaddr:
11;V8: save %sp, -96, %sp
12;V8: ret
13;V8: restore %g0, %fp, %o0
14
15;V9-LABEL: frameaddr:
16;V9: save %sp, -96, %sp
17;V9: ret
18;V9: restore %g0, %fp, %o0
19
20;SPARC64-LABEL: frameaddr
21;SPARC64:       save %sp, -128, %sp
22;SPARC64:       add  %fp, 2047, %i0
23;SPARC64:       ret
24;SPARC64-NOT:   restore %g0, %g0, %g0
25;SPARC64:       restore
26
27  %0 = tail call i8* @llvm.frameaddress(i32 0)
28  ret i8* %0
29}
30
31define i8* @frameaddr2() nounwind readnone {
32entry:
33;V8-LABEL: frameaddr2:
34;V8: ta 3
35;V8: ld [%fp+56], {{.+}}
36;V8: ld [{{.+}}+56], {{.+}}
37;V8: ld [{{.+}}+56], {{.+}}
38
39;V9-LABEL: frameaddr2:
40;V9: flushw
41;V9: ld [%fp+56], {{.+}}
42;V9: ld [{{.+}}+56], {{.+}}
43;V9: ld [{{.+}}+56], {{.+}}
44
45;SPARC64-LABEL: frameaddr2
46;SPARC64: flushw
47;SPARC64: ldx [%fp+2159],     %[[R0:[goli][0-7]]]
48;SPARC64: ldx [%[[R0]]+2159], %[[R1:[goli][0-7]]]
49;SPARC64: ldx [%[[R1]]+2159], %[[R2:[goli][0-7]]]
50;SPARC64: add %[[R2]], 2047, {{.+}}
51
52  %0 = tail call i8* @llvm.frameaddress(i32 3)
53  ret i8* %0
54}
55
56declare i8* @llvm.frameaddress(i32) nounwind readnone
57
58
59
60define i8* @retaddr() nounwind readnone {
61entry:
62;V8-LABEL: retaddr:
63;V8: mov %o7, {{.+}}
64
65;V9-LABEL: retaddr:
66;V9: mov %o7, {{.+}}
67
68;SPARC64-LABEL: retaddr
69;SPARC64:       mov %o7, {{.+}}
70
71  %0 = tail call i8* @llvm.returnaddress(i32 0)
72  ret i8* %0
73}
74
75define i8* @retaddr2() nounwind readnone {
76entry:
77;V8-LABEL: retaddr2:
78;V8: ta 3
79;V8: ld [%fp+56], {{.+}}
80;V8: ld [{{.+}}+56], {{.+}}
81;V8: ld [{{.+}}+60], {{.+}}
82
83;V9-LABEL: retaddr2:
84;V9: flushw
85;V9: ld [%fp+56], {{.+}}
86;V9: ld [{{.+}}+56], {{.+}}
87;V9: ld [{{.+}}+60], {{.+}}
88
89;SPARC64-LABEL: retaddr2
90;SPARC64:       flushw
91;SPARC64: ldx [%fp+2159],     %[[R0:[goli][0-7]]]
92;SPARC64: ldx [%[[R0]]+2159], %[[R1:[goli][0-7]]]
93;SPARC64: ldx [%[[R1]]+2167], {{.+}}
94
95  %0 = tail call i8* @llvm.returnaddress(i32 3)
96  ret i8* %0
97}
98
99declare i8* @llvm.returnaddress(i32) nounwind readnone
100