1 ; Test the handling of the frame pointer (%r11).
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -frame-pointer=all | FileCheck %s
5 ; We should always initialise %r11 when FP elimination is disabled.
6 ; We don't need to allocate any more than the caller-provided 160-byte
8 define i32 @f1(i32 %x) {
10 ; CHECK: stmg %r11, %r15, 88(%r15)
11 ; CHECK: .cfi_offset %r11, -72
12 ; CHECK: .cfi_offset %r15, -40
14 ; CHECK: lgr %r11, %r15
15 ; CHECK: .cfi_def_cfa_register %r11
16 ; CHECK: lmg %r11, %r15, 88(%r11)
22 ; Make sure that frame accesses after the initial allocation are relative
23 ; to %r11 rather than %r15.
24 define void @f2(i64 %x) {
26 ; CHECK: stmg %r11, %r15, 88(%r15)
27 ; CHECK: .cfi_offset %r11, -72
28 ; CHECK: .cfi_offset %r15, -40
29 ; CHECK: aghi %r15, -168
30 ; CHECK: .cfi_def_cfa_offset 328
31 ; CHECK: lgr %r11, %r15
32 ; CHECK: .cfi_def_cfa_register %r11
33 ; CHECK: stg %r2, 160(%r11)
34 ; CHECK: lmg %r11, %r15, 256(%r11)
36 %y = alloca i64, align 8
37 store volatile i64 %x, ptr %y
41 ; This function should require all GPRs but no other spill slots.
42 ; It shouldn't need to allocate its own frame.
43 define void @f3(ptr %ptr) {
45 ; CHECK: stmg %r6, %r15, 48(%r15)
48 ; CHECK: .cfi_offset %r6, -112
49 ; CHECK: .cfi_offset %r7, -104
50 ; CHECK: .cfi_offset %r8, -96
51 ; CHECK: .cfi_offset %r9, -88
52 ; CHECK: .cfi_offset %r10, -80
53 ; CHECK: .cfi_offset %r11, -72
54 ; CHECK: .cfi_offset %r12, -64
55 ; CHECK: .cfi_offset %r13, -56
56 ; CHECK: .cfi_offset %r14, -48
57 ; CHECK: .cfi_offset %r15, -40
59 ; CHECK: lgr %r11, %r15
60 ; CHECK: .cfi_def_cfa_register %r11
61 ; ...main function body...
64 ; CHECK: st {{.*}}, 4(%r2)
65 ; CHECK: lmg %r6, %r15, 48(%r11)
67 %l0 = load volatile i32, ptr %ptr
68 %l1 = load volatile i32, ptr %ptr
69 %l3 = load volatile i32, ptr %ptr
70 %l4 = load volatile i32, ptr %ptr
71 %l5 = load volatile i32, ptr %ptr
72 %l6 = load volatile i32, ptr %ptr
73 %l7 = load volatile i32, ptr %ptr
74 %l8 = load volatile i32, ptr %ptr
75 %l9 = load volatile i32, ptr %ptr
76 %l10 = load volatile i32, ptr %ptr
77 %l12 = load volatile i32, ptr %ptr
78 %l13 = load volatile i32, ptr %ptr
79 %l14 = load volatile i32, ptr %ptr
80 %add0 = add i32 %l0, %l0
81 %add1 = add i32 %l1, %add0
82 %add3 = add i32 %l3, %add1
83 %add4 = add i32 %l4, %add3
84 %add5 = add i32 %l5, %add4
85 %add6 = add i32 %l6, %add5
86 %add7 = add i32 %l7, %add6
87 %add8 = add i32 %l8, %add7
88 %add9 = add i32 %l9, %add8
89 %add10 = add i32 %l10, %add9
90 %add12 = add i32 %l12, %add10
91 %add13 = add i32 %l13, %add12
92 %add14 = add i32 %l14, %add13
93 store volatile i32 %add0, ptr %ptr
94 store volatile i32 %add1, ptr %ptr
95 store volatile i32 %add3, ptr %ptr
96 store volatile i32 %add4, ptr %ptr
97 store volatile i32 %add5, ptr %ptr
98 store volatile i32 %add6, ptr %ptr
99 store volatile i32 %add7, ptr %ptr
100 store volatile i32 %add8, ptr %ptr
101 store volatile i32 %add9, ptr %ptr
102 store volatile i32 %add10, ptr %ptr
103 store volatile i32 %add12, ptr %ptr
104 store volatile i32 %add13, ptr %ptr
105 %final = getelementptr i32, ptr %ptr, i32 1
106 store volatile i32 %add14, ptr %final
110 ; The largest frame for which the LMG is in range. This frame has two
111 ; emergency spill slots at 160(%r11), so create a frame of size 524192
112 ; by allocating (524192 - 176) / 8 = 65502 doublewords.
113 define void @f4(i64 %x) {
115 ; CHECK: stmg %r11, %r15, 88(%r15)
116 ; CHECK: .cfi_offset %r11, -72
117 ; CHECK: .cfi_offset %r15, -40
118 ; CHECK: agfi %r15, -524192
119 ; CHECK: .cfi_def_cfa_offset 524352
120 ; CHECK: lgr %r11, %r15
121 ; CHECK: .cfi_def_cfa_register %r11
122 ; CHECK: stg %r2, 176(%r11)
124 ; CHECK: lmg %r11, %r15, 524280(%r11)
126 %y = alloca [65502 x i64], align 8
127 store volatile i64 %x, ptr %y
131 ; The next frame size larger than f4.
132 define void @f5(i64 %x) {
134 ; CHECK: stmg %r11, %r15, 88(%r15)
135 ; CHECK: .cfi_offset %r11, -72
136 ; CHECK: .cfi_offset %r15, -40
137 ; CHECK: agfi %r15, -524200
138 ; CHECK: .cfi_def_cfa_offset 524360
139 ; CHECK: lgr %r11, %r15
140 ; CHECK: .cfi_def_cfa_register %r11
141 ; CHECK: stg %r2, 176(%r11)
142 ; CHECK: aghi %r11, 8
143 ; CHECK: lmg %r11, %r15, 524280(%r11)
145 %y = alloca [65503 x i64], align 8
146 store volatile i64 %x, ptr %y
150 ; The tests above establish that %r11 is handled like %r15 for LMG.
151 ; Rely on the %r15-based tests in frame-08.ll for other cases.