1; Test the allocation of emergency spill slots.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; For frames of size less than 4096 - 2*160, no emercengy spill slot
6; is required.  Check the maximum such case.
7define void @f1(i64 %x) {
8; CHECK-LABEL: f1:
9; CHECK: stg %r2, 160(%r15)
10; CHECK: br %r14
11  %y = alloca [471 x i64], align 8
12  %ptr = getelementptr inbounds [471 x i64], [471 x i64]* %y, i64 0, i64 0
13  store volatile i64 %x, i64* %ptr
14  ret void
15}
16
17; If the frame size is at least 4096 - 2*160, we do need the emergency
18; spill slots.  Check the minimum such case.
19define void @f2(i64 %x) {
20; CHECK-LABEL: f2:
21; CHECK: stg %r2, 176(%r15)
22; CHECK: br %r14
23  %y = alloca [472 x i64], align 8
24  %ptr = getelementptr inbounds [472 x i64], [472 x i64]* %y, i64 0, i64 0
25  store volatile i64 %x, i64* %ptr
26  ret void
27}
28
29; However, if there are incoming stack arguments, those also need to be
30; in reach, so the maximum frame size without emergency spill slots is
31; 4096 - 2*160 - <size of incoming stack arguments>.  Check the maximum
32; case where we still need no emergency spill slots ...
33define void @f3(i64 %x, i64 %r3, i64 %r4, i64 %r5, i64 %r6, i64 %stack) {
34; CHECK-LABEL: f3:
35; CHECK: stg %r2, 160(%r15)
36; CHECK: br %r14
37  %y = alloca [470 x i64], align 8
38  %ptr = getelementptr inbounds [470 x i64], [470 x i64]* %y, i64 0, i64 0
39  store volatile i64 %x, i64* %ptr
40  ret void
41}
42
43; ... and the minimum case where we do.
44define void @f4(i64 %x, i64 %r3, i64 %r4, i64 %r5, i64 %r6, i64 %stack) {
45; CHECK-LABEL: f4:
46; CHECK: stg %r2, 176(%r15)
47; CHECK: br %r14
48  %y = alloca [471 x i64], align 8
49  %ptr = getelementptr inbounds [471 x i64], [471 x i64]* %y, i64 0, i64 0
50  store volatile i64 %x, i64* %ptr
51  ret void
52}
53
54; Try again for the case of two stack arguments.
55; Check the maximum case where we still need no emergency spill slots ...
56define void @f5(i64 %x, i64 %r3, i64 %r4, i64 %r5, i64 %r6, i64 %stack1, i64 %stack2) {
57; CHECK-LABEL: f5:
58; CHECK: stg %r2, 160(%r15)
59; CHECK: br %r14
60  %y = alloca [469 x i64], align 8
61  %ptr = getelementptr inbounds [469 x i64], [469 x i64]* %y, i64 0, i64 0
62  store volatile i64 %x, i64* %ptr
63  ret void
64}
65
66; ... and the minimum case where we do.
67define void @f6(i64 %x, i64 %r3, i64 %r4, i64 %r5, i64 %r6, i64 %stack1, i64 %stack2) {
68; CHECK-LABEL: f6:
69; CHECK: stg %r2, 176(%r15)
70; CHECK: br %r14
71  %y = alloca [470 x i64], align 8
72  %ptr = getelementptr inbounds [470 x i64], [470 x i64]* %y, i64 0, i64 0
73  store volatile i64 %x, i64* %ptr
74  ret void
75}
76
77