[MIParser] Set RegClassOrRegBank during instruction parsing
[llvm-complete.git] / test / CodeGen / Thumb / segmented-stacks.ll
blob7340842a42f4166627e2b8c18eff4acba56bf74b
1 ; RUN: llc < %s -mtriple=thumb-linux-androideabi -verify-machineinstrs | FileCheck %s -check-prefix=Thumb-android
2 ; RUN: llc < %s -mtriple=thumb-linux-unknown-gnueabi -verify-machineinstrs | FileCheck %s -check-prefix=Thumb-linux
3 ; RUN: llc < %s -mtriple=thumb-linux-androideabi -filetype=obj
4 ; RUN: llc < %s -mtriple=thumb-linux-unknown-gnueabi -filetype=obj
7 ; Just to prevent the alloca from being optimized away
8 declare void @dummy_use(i32*, i32)
10 define void @test_basic() #0 {
11         %mem = alloca i32, i32 10
12         call void @dummy_use (i32* %mem, i32 10)
13         ret void
15 ; Thumb-android-LABEL:      test_basic:
17 ; Thumb-android:      push    {r4, r5}
18 ; Thumb-android-NEXT: mov     r5, sp
19 ; Thumb-android-NEXT: ldr     r4, .LCPI0_0
20 ; Thumb-android-NEXT: ldr     r4, [r4]
21 ; Thumb-android-NEXT: cmp     r4, r5
22 ; Thumb-android-NEXT: blo     .LBB0_2
24 ; Thumb-android:      mov     r4, #48
25 ; Thumb-android-NEXT: mov     r5, #0
26 ; Thumb-android-NEXT: push    {lr}
27 ; Thumb-android-NEXT: bl      __morestack
28 ; Thumb-android-NEXT: pop     {r4}
29 ; Thumb-android-NEXT: mov     lr, r4
30 ; Thumb-android-NEXT: pop     {r4, r5}
31 ; Thumb-android-NEXT: bx      lr
33 ; Thumb-android:      pop     {r4, r5}
35 ; Thumb-android: .p2align 2
36 ; Thumb-android: .LCPI0_0:
37 ; Thumb-android-NEXT: .long __STACK_LIMIT
39 ; Thumb-linux-LABEL:      test_basic:
41 ; Thumb-linux:      push    {r4, r5}
42 ; Thumb-linux-NEXT: mov     r5, sp
43 ; Thumb-linux-NEXT: ldr     r4, .LCPI0_0
44 ; Thumb-linux-NEXT: ldr     r4, [r4]
45 ; Thumb-linux-NEXT: cmp     r4, r5
46 ; Thumb-linux-NEXT: blo     .LBB0_2
48 ; Thumb-linux:      mov     r4, #48
49 ; Thumb-linux-NEXT: mov     r5, #0
50 ; Thumb-linux-NEXT: push    {lr}
51 ; Thumb-linux-NEXT: bl      __morestack
52 ; Thumb-linux-NEXT: pop     {r4}
53 ; Thumb-linux-NEXT: mov     lr, r4
54 ; Thumb-linux-NEXT: pop     {r4, r5}
55 ; Thumb-linux-NEXT: bx      lr
57 ; Thumb-linux:      pop     {r4, r5}
61 define i32 @test_nested(i32 * nest %closure, i32 %other) #0 {
62        %addend = load i32 , i32 * %closure
63        %result = add i32 %other, %addend
64        %mem = alloca i32, i32 10
65        call void @dummy_use (i32* %mem, i32 10)
66        ret i32 %result
68 ; Thumb-android-LABEL:      test_nested:
70 ; Thumb-android:      push  {r4, r5}
71 ; Thumb-android-NEXT: mov     r5, sp
72 ; Thumb-android-NEXT: ldr     r4, .LCPI1_0
73 ; Thumb-android-NEXT: ldr     r4, [r4]
74 ; Thumb-android-NEXT: cmp     r4, r5
75 ; Thumb-android-NEXT: blo     .LBB1_2
77 ; Thumb-android:      mov     r4, #56
78 ; Thumb-android-NEXT: mov     r5, #0
79 ; Thumb-android-NEXT: push    {lr}
80 ; Thumb-android-NEXT: bl      __morestack
81 ; Thumb-android-NEXT: pop     {r4}
82 ; Thumb-android-NEXT: mov     lr, r4
83 ; Thumb-android-NEXT: pop     {r4, r5}
84 ; Thumb-android-NEXT: bx      lr
86 ; Thumb-android:      pop     {r4, r5}
88 ; Thumb-linux-LABEL:      test_nested:
90 ; Thumb-linux:      push    {r4, r5}
91 ; Thumb-linux-NEXT: mov     r5, sp
92 ; Thumb-linux-NEXT: ldr     r4, .LCPI1_0
93 ; Thumb-linux-NEXT: ldr     r4, [r4]
94 ; Thumb-linux-NEXT: cmp     r4, r5
95 ; Thumb-linux-NEXT: blo     .LBB1_2
97 ; Thumb-linux:      mov     r4, #56
98 ; Thumb-linux-NEXT: mov     r5, #0
99 ; Thumb-linux-NEXT: push    {lr}
100 ; Thumb-linux-NEXT: bl      __morestack
101 ; Thumb-linux-NEXT: pop     {r4}
102 ; Thumb-linux-NEXT: mov     lr, r4
103 ; Thumb-linux-NEXT: pop     {r4, r5}
104 ; Thumb-linux-NEXT: bx      lr
106 ; Thumb-linux:      pop     {r4, r5}
110 define void @test_large() #0 {
111         %mem = alloca i32, i32 10000
112         call void @dummy_use (i32* %mem, i32 0)
113         ret void
115 ; Thumb-android-LABEL:      test_large:
117 ; Thumb-android:      push    {r4, r5}
118 ; Thumb-android-NEXT: mov     r5, sp
119 ; Thumb-android-NEXT: sub     r5, #40192
120 ; Thumb-android-NEXT: ldr     r4, .LCPI2_2
121 ; Thumb-android-NEXT: ldr     r4, [r4]
122 ; Thumb-android-NEXT: cmp     r4, r5
123 ; Thumb-android-NEXT: blo     .LBB2_2
125 ; Thumb-android:      mov     r4, #40192
126 ; Thumb-android-NEXT: mov     r5, #0
127 ; Thumb-android-NEXT: push    {lr}
128 ; Thumb-android-NEXT: bl      __morestack
129 ; Thumb-android-NEXT: pop     {r4}
130 ; Thumb-android-NEXT: mov     lr, r4
131 ; Thumb-android-NEXT: pop     {r4, r5}
132 ; Thumb-android-NEXT: bx      lr
134 ; Thumb-android:      pop     {r4, r5}
136 ; Thumb-linux-LABEL:      test_large:
138 ; Thumb-linux:      push    {r4, r5}
139 ; Thumb-linux-NEXT: mov     r5, sp
140 ; Thumb-linux-NEXT: sub     r5, #40192
141 ; Thumb-linux-NEXT: ldr     r4, .LCPI2_2
142 ; Thumb-linux-NEXT: ldr     r4, [r4]
143 ; Thumb-linux-NEXT: cmp     r4, r5
144 ; Thumb-linux-NEXT: blo     .LBB2_2
146 ; Thumb-linux:      mov     r4, #40192
147 ; Thumb-linux-NEXT: mov     r5, #0
148 ; Thumb-linux-NEXT: push    {lr}
149 ; Thumb-linux-NEXT: bl      __morestack
150 ; Thumb-linux-NEXT: pop     {r4}
151 ; Thumb-linux-NEXT: mov     lr, r4
152 ; Thumb-linux-NEXT: pop     {r4, r5}
153 ; Thumb-linux-NEXT: bx      lr
155 ; Thumb-linux:      pop     {r4, r5}
159 define fastcc void @test_fastcc() #0 {
160         %mem = alloca i32, i32 10
161         call void @dummy_use (i32* %mem, i32 10)
162         ret void
164 ; Thumb-android-LABEL:      test_fastcc:
166 ; Thumb-android:      push    {r4, r5}
167 ; Thumb-android-NEXT: mov     r5, sp
168 ; Thumb-android-NEXT: ldr     r4, .LCPI3_0
169 ; Thumb-android-NEXT: ldr     r4, [r4]
170 ; Thumb-android-NEXT: cmp     r4, r5
171 ; Thumb-android-NEXT: blo     .LBB3_2
173 ; Thumb-android:      mov     r4, #48
174 ; Thumb-android-NEXT: mov     r5, #0
175 ; Thumb-android-NEXT: push    {lr}
176 ; Thumb-android-NEXT: bl      __morestack
177 ; Thumb-android-NEXT: pop     {r4}
178 ; Thumb-android-NEXT: mov     lr, r4
179 ; Thumb-android-NEXT: pop     {r4, r5}
180 ; Thumb-android-NEXT: bx      lr
182 ; Thumb-android:      pop     {r4, r5}
184 ; Thumb-linux-LABEL:      test_fastcc:
186 ; Thumb-linux:      push    {r4, r5}
187 ; Thumb-linux-NEXT: mov     r5, sp
188 ; Thumb-linux-NEXT: ldr     r4, .LCPI3_0
189 ; Thumb-linux-NEXT: ldr     r4, [r4]
190 ; Thumb-linux-NEXT: cmp     r4, r5
191 ; Thumb-linux-NEXT: blo     .LBB3_2
193 ; Thumb-linux:      mov     r4, #48
194 ; Thumb-linux-NEXT: mov     r5, #0
195 ; Thumb-linux-NEXT: push    {lr}
196 ; Thumb-linux-NEXT: bl      __morestack
197 ; Thumb-linux-NEXT: pop     {r4}
198 ; Thumb-linux-NEXT: mov     lr, r4
199 ; Thumb-linux-NEXT: pop     {r4, r5}
200 ; Thumb-linux-NEXT: bx      lr
202 ; Thumb-linux:      pop     {r4, r5}
206 define fastcc void @test_fastcc_large() #0 {
207         %mem = alloca i32, i32 10000
208         call void @dummy_use (i32* %mem, i32 0)
209         ret void
211 ; Thumb-android-LABEL:      test_fastcc_large:
213 ; Thumb-android:      push    {r4, r5}
214 ; Thumb-android-NEXT: mov     r5, sp
215 ; Thumb-android-NEXT: sub     r5, #40192
216 ; Thumb-android-NEXT: ldr     r4, .LCPI4_2
217 ; Thumb-android-NEXT: ldr     r4, [r4]
218 ; Thumb-android-NEXT: cmp     r4, r5
219 ; Thumb-android-NEXT: blo     .LBB4_2
221 ; Thumb-android:      mov     r4, #40192
222 ; Thumb-android-NEXT: mov     r5, #0
223 ; Thumb-android-NEXT: push    {lr}
224 ; Thumb-android-NEXT: bl      __morestack
225 ; Thumb-android-NEXT: pop     {r4}
226 ; Thumb-android-NEXT: mov     lr, r4
227 ; Thumb-android-NEXT: pop     {r4, r5}
228 ; Thumb-android-NEXT: bx      lr
230 ; Thumb-android:      pop     {r4, r5}
232 ; Thumb-linux-LABEL:      test_fastcc_large:
234 ; Thumb-linux:      push    {r4, r5}
235 ; Thumb-linux-NEXT: mov     r5, sp
236 ; Thumb-linux-NEXT: sub     r5, #40192
237 ; Thumb-linux-NEXT: ldr     r4, .LCPI4_2
238 ; Thumb-linux-NEXT: ldr     r4, [r4]
239 ; Thumb-linux-NEXT: cmp     r4, r5
240 ; Thumb-linux-NEXT: blo     .LBB4_2
242 ; Thumb-linux:      mov     r4, #40192
243 ; Thumb-linux-NEXT: mov     r5, #0
244 ; Thumb-linux-NEXT: push    {lr}
245 ; Thumb-linux-NEXT: bl      __morestack
246 ; Thumb-linux-NEXT: pop     {r4}
247 ; Thumb-linux-NEXT: mov     lr, r4
248 ; Thumb-linux-NEXT: pop     {r4, r5}
249 ; Thumb-linux-NEXT: bx      lr
251 ; Thumb-linux:      pop     {r4, r5}
255 define void @test_nostack() #0 {
256         ret void
258 ; Thumb-android-LABEL: test_nostack:
259 ; Thumb-android-NOT:   bl __morestack
261 ; Thumb-linux-LABEL: test_nostack:
262 ; Thumb-linux-NOT:   bl __morestack
265 attributes #0 = { "split-stack" }