1; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -mtriple=armv7-apple-ios | FileCheck %s --check-prefix=DARWIN-ARM
2; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -mtriple=armv7-linux-gnueabi | FileCheck %s --check-prefix=LINUX-ARM
3; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -mtriple=thumbv7-apple-ios | FileCheck %s --check-prefix=DARWIN-THUMB2
4; RUN: llc < %s -O0 -verify-machineinstrs -fast-isel-abort=1 -mtriple=thumbv7-linux-gnueabi | FileCheck %s --check-prefix=LINUX-THUMB2
5
6define i8* @frameaddr_index0() nounwind {
7entry:
8; DARWIN-ARM-LABEL: frameaddr_index0:
9; DARWIN-ARM: push {r7}
10; DARWIN-ARM: mov r7, sp
11; DARWIN-ARM: mov r0, r7
12
13; DARWIN-THUMB2-LABEL: frameaddr_index0:
14; DARWIN-THUMB2: str r7, [sp, #-4]!
15; DARWIN-THUMB2: mov r7, sp
16; DARWIN-THUMB2: mov r0, r7
17
18; LINUX-ARM-LABEL: frameaddr_index0:
19; LINUX-ARM: push {r11}
20; LINUX-ARM: mov r11, sp
21; LINUX-ARM: mov r0, r11
22
23; LINUX-THUMB2-LABEL: frameaddr_index0:
24; LINUX-THUMB2: str r7, [sp, #-4]!
25; LINUX-THUMB2: mov r7, sp
26; LINUX-THUMB2: mov r0, r7
27
28  %0 = call i8* @llvm.frameaddress(i32 0)
29  ret i8* %0
30}
31
32define i8* @frameaddr_index1() nounwind {
33entry:
34; DARWIN-ARM-LABEL: frameaddr_index1:
35; DARWIN-ARM: push {r7}
36; DARWIN-ARM: mov r7, sp
37; DARWIN-ARM: ldr r0, [r7]
38
39; DARWIN-THUMB2-LABEL: frameaddr_index1:
40; DARWIN-THUMB2: str r7, [sp, #-4]!
41; DARWIN-THUMB2: mov r7, sp
42; DARWIN-THUMB2: ldr r0, [r7]
43
44; LINUX-ARM-LABEL: frameaddr_index1:
45; LINUX-ARM: push {r11}
46; LINUX-ARM: mov r11, sp
47; LINUX-ARM: ldr r0, [r11]
48
49; LINUX-THUMB2-LABEL: frameaddr_index1:
50; LINUX-THUMB2: str r7, [sp, #-4]!
51; LINUX-THUMB2: mov r7, sp
52; LINUX-THUMB2: mov r0, r7
53; LINUX-THUMB2: ldr r0, [r0]
54
55  %0 = call i8* @llvm.frameaddress(i32 1)
56  ret i8* %0
57}
58
59define i8* @frameaddr_index3() nounwind {
60entry:
61; DARWIN-ARM-LABEL: frameaddr_index3:
62; DARWIN-ARM: push {r7}
63; DARWIN-ARM: mov r7, sp
64; DARWIN-ARM: ldr r0, [r7]
65; DARWIN-ARM: ldr r0, [r0]
66; DARWIN-ARM: ldr r0, [r0]
67
68; DARWIN-THUMB2-LABEL: frameaddr_index3:
69; DARWIN-THUMB2: str r7, [sp, #-4]!
70; DARWIN-THUMB2: mov r7, sp
71; DARWIN-THUMB2: ldr r0, [r7]
72; DARWIN-THUMB2: ldr r0, [r0]
73; DARWIN-THUMB2: ldr r0, [r0]
74
75; LINUX-ARM-LABEL: frameaddr_index3:
76; LINUX-ARM: push {r11}
77; LINUX-ARM: mov r11, sp
78; LINUX-ARM: ldr r0, [r11]
79; LINUX-ARM: ldr r0, [r0]
80; LINUX-ARM: ldr r0, [r0]
81
82; LINUX-THUMB2-LABEL: frameaddr_index3:
83; LINUX-THUMB2: str r7, [sp, #-4]!
84; LINUX-THUMB2: mov r7, sp
85; LINUX-THUMB2: mov r0, r7
86; LINUX-THUMB2: ldr r0, [r0]
87; LINUX-THUMB2: ldr r0, [r0]
88; LINUX-THUMB2: ldr r0, [r0]
89
90  %0 = call i8* @llvm.frameaddress(i32 3)
91  ret i8* %0
92}
93
94declare i8* @llvm.frameaddress(i32) nounwind readnone
95