1; RUN: llc < %s -mtriple=thumbv7m -mattr=+execute-only -O0 %s -o - \
2; RUN:  | FileCheck --check-prefix=CHECK-SUBW-ADDW %s
3; RUN: llc < %s -mtriple=thumbv8m.base -mattr=+execute-only -O0 %s -o - \
4; RUN:  | FileCheck --check-prefix=CHECK-MOVW-MOVT-ADD %s
5; RUN: llc < %s -mtriple=thumbv8m.main -mattr=+execute-only -O0 %s -o - \
6; RUN:  | FileCheck --check-prefix=CHECK-SUBW-ADDW %s
7
8define i8 @test_big_stack_frame() {
9; CHECK-SUBW-ADDW-LABEL: test_big_stack_frame:
10; CHECK-SUBW-ADDW-NOT:   ldr {{r[0-9]+}}, .{{.*}}
11; CHECK-SUBW-ADDW:       sub.w sp, sp, #65536
12; CHECK-SUBW-ADDW-NOT:   ldr {{r[0-9]+}}, .{{.*}}
13; CHECK-SUBW-ADDW:       add.w [[REG1:r[0-9]+|lr]], sp, #255
14; CHECK-SUBW-ADDW:       add.w {{r[0-9]+}}, [[REG1]], #65280
15; CHECK-SUBW-ADDW-NOT:   ldr {{r[0-9]+}}, .{{.*}}
16; CHECK-SUBW-ADDW:       add.w [[REGX:r[0-9]+|lr]], sp, #61440
17; CHECK-SUBW-ADDW-NOT:   ldr {{r[0-9]+}}, .{{.*}}
18; CHECK-SUBW-ADDW:       add.w sp, sp, #65536
19
20; CHECK-MOVW-MOVT-ADD-LABEL: test_big_stack_frame:
21; CHECK-MOVW-MOVT-ADD-NOT:   ldr {{r[0-9]+}}, .{{.*}}
22; CHECK-MOVW-MOVT-ADD:       movw [[REG1:r[0-9]+]], #0
23; CHECK-MOVW-MOVT-ADD:       movt [[REG1]], #65535
24; CHECK-MOVW-MOVT-ADD:       add sp, [[REG1]]
25; CHECK-MOVW-MOVT-ADD-NOT:   ldr {{r[0-9]+}}, .{{.*}}
26; CHECK-MOVW-MOVT-ADD:       movw [[REG2:r[0-9]+]], #65532
27; CHECK-MOVW-MOVT-ADD:       movt [[REG2]], #0
28; CHECK-MOVW-MOVT-ADD:       add [[REG2]], sp
29; CHECK-MOVW-MOVT-ADD-NOT:   ldr {{r[0-9]+}}, .{{.*}}
30; CHECK-MOVW-MOVT-ADD:       movw [[REG3:r[0-9]+]], #65532
31; CHECK-MOVW-MOVT-ADD:       movt [[REG3]], #0
32; CHECK-MOVW-MOVT-ADD:       add [[REG3]], sp
33; CHECK-MOVW-MOVT-ADD-NOT:   ldr {{r[0-9]+}}, .{{.*}}
34; CHECK-MOVW-MOVT-ADD:       movw [[REG4:r[0-9]+]], #0
35; CHECK-MOVW-MOVT-ADD:       movt [[REG4]], #1
36; CHECK-MOVW-MOVT-ADD:       add sp, [[REG4]]
37
38entry:
39  %s1 = alloca i8
40  %buffer = alloca [65528 x i8], align 1
41  call void @foo(i8* %s1)
42  %load = load i8, i8* %s1
43  ret i8 %load
44}
45
46declare void @foo(i8*)
47