[llvm-readobj] - Simplify stack-sizes.test test case.
[llvm-complete.git] / test / MC / ARM / eh-directive-setfp.s
blob0d9d9e600760d92eb3a13da19da4e51da036411d
1 @ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \
2 @ RUN: | llvm-readobj -S --sd | FileCheck %s
4 @ Check for .setfp directive.
6 @ The .setfp directive will track the offset between the frame pointer and
7 @ the stack pointer. This is required for the function that will change
8 @ the stack pointer out of the function prologue. If the exception is thrown,
9 @ then libunwind will reconstruct the stack pointer from the frame pointer.
10 @ The reconstruction code is implemented by two different unwind opcode:
11 @ (i) the unwind opcode to copy stack offset from the other register, and
12 @ (ii) the unwind opcode to add or subtract the stack offset.
14 @ This file includes several cases separated by different range of -offset
16 @ (-offset) < 0x00
17 @ (-offset) == 0x00
18 @ 0x04 <= (-offset) <= 0x100
19 @ 0x104 <= (-offset) <= 0x200
20 @ 0x204 <= (-offset)
23 .syntax unified
25 @-------------------------------------------------------------------------------
26 @ TEST1
27 @-------------------------------------------------------------------------------
28 .section .TEST1
29 .globl func1
30 .align 2
31 .type func1,%function
32 .fnstart
33 func1:
34 .setfp fp, sp, #0
35 add fp, sp, #0
36 sub sp, fp, #0
37 bx lr
38 .personality __gxx_personality_v0
39 .handlerdata
40 .fnend
42 @-------------------------------------------------------------------------------
43 @ The assembler should emit 0x9B to copy stack pointer from r11.
44 @-------------------------------------------------------------------------------
45 @ CHECK: Section {
46 @ CHECK: Name: .ARM.extab.TEST1
47 @ CHECK: SectionData (
48 @ CHECK: 0000: 00000000 B0B09B00 |........|
49 @ CHECK: )
50 @ CHECK: }
54 @-------------------------------------------------------------------------------
55 @ TEST2
56 @-------------------------------------------------------------------------------
57 .section .TEST2
58 .globl func2a
59 .align 2
60 .type func2a,%function
61 .fnstart
62 func2a:
63 .setfp fp, sp, #-4
64 add fp, sp, #4
65 sub sp, fp, #4
66 bx lr
67 .personality __gxx_personality_v0
68 .handlerdata
69 .fnend
71 .globl func2b
72 .align 2
73 .type func2b,%function
74 .fnstart
75 func2b:
76 .setfp fp, sp, #-0x100
77 add fp, sp, #0x100
78 sub sp, fp, #0x100
79 bx lr
80 .personality __gxx_personality_v0
81 .handlerdata
82 .fnend
84 @-------------------------------------------------------------------------------
85 @ The assembler should emit 0x9B to copy stack pointer from r11.
86 @ The assembler should emit ((-offset - 4) >> 2) for offset.
87 @-------------------------------------------------------------------------------
88 @ CHECK: Section {
89 @ CHECK: Name: .ARM.extab.TEST2
90 @ CHECK: SectionData (
91 @ CHECK: 0000: 00000000 B0009B00 00000000 B03F9B00 |.............?..|
92 @ CHECK: )
93 @ CHECK: }
97 @-------------------------------------------------------------------------------
98 @ TEST3
99 @-------------------------------------------------------------------------------
100 .section .TEST3
101 .globl func3a
102 .align 2
103 .type func3a,%function
104 .fnstart
105 func3a:
106 .setfp fp, sp, #-0x104
107 sub fp, sp, #0x104
108 add sp, fp, #0x104
109 bx lr
110 .personality __gxx_personality_v0
111 .handlerdata
112 .fnend
114 .globl func3b
115 .align 2
116 .type func3b,%function
117 .fnstart
118 func3b:
119 .setfp fp, sp, #-0x200
120 sub fp, sp, #0x200
121 add sp, fp, #0x200
122 bx lr
123 .personality __gxx_personality_v0
124 .handlerdata
125 .fnend
127 @-------------------------------------------------------------------------------
128 @ The assembler should emit 0x9B to copy stack pointer from r11.
129 @ The assembler should emit 0x3F and ((-offset - 0x104) >> 2) for offset.
130 @-------------------------------------------------------------------------------
131 @ CHECK: Section {
132 @ CHECK: Name: .ARM.extab.TEST3
133 @ CHECK: SectionData (
134 @ CHECK: 0000: 00000000 3F009B00 00000000 3F3F9B00 |....?.......??..|
135 @ CHECK: )
136 @ CHECK: }
140 @-------------------------------------------------------------------------------
141 @ TEST4
142 @-------------------------------------------------------------------------------
143 .section .TEST4
144 .globl func4a
145 .align 2
146 .type func4a,%function
147 .fnstart
148 func4a:
149 .setfp fp, sp, #-0x204
150 sub fp, sp, #0x204
151 add sp, fp, #0x204
152 bx lr
153 .personality __gxx_personality_v0
154 .handlerdata
155 .fnend
157 .globl func4b
158 .align 2
159 .type func4b,%function
160 .fnstart
161 func4b:
162 .setfp fp, sp, #-0x580
163 sub fp, sp, #0x580
164 add sp, fp, #0x580
165 bx lr
166 .personality __gxx_personality_v0
167 .handlerdata
168 .fnend
170 @-------------------------------------------------------------------------------
171 @ The assembler should emit 0x9B to copy stack pointer from r11.
172 @ The assembler should emit 0xB2 and the ULEB128 encoding of
173 @ ((-offset - 0x204) >> 2) for offset.
174 @-------------------------------------------------------------------------------
175 @ CHECK: Section {
176 @ CHECK: Name: .ARM.extab.TEST4
177 @ CHECK: SectionData (
178 @ CHECK: 0000: 00000000 00B29B00 00000000 DFB29B01 |................|
179 @ CHECK: 0010: B0B0B001 |....|
180 @ CHECK: )
181 @ CHECK: }
185 @-------------------------------------------------------------------------------
186 @ TEST5
187 @-------------------------------------------------------------------------------
188 .section .TEST5
189 .globl func5a
190 .align 2
191 .type func5a,%function
192 .fnstart
193 func5a:
194 .setfp fp, sp, #0x4
195 add fp, sp, #0x4
196 sub sp, fp, #0x4
197 bx lr
198 .personality __gxx_personality_v0
199 .handlerdata
200 .fnend
202 .globl func5b
203 .align 2
204 .type func5b,%function
205 .fnstart
206 func5b:
207 .setfp fp, sp, #0x104
208 add fp, sp, #0x104
209 sub sp, fp, #0x104
210 bx lr
211 .personality __gxx_personality_v0
212 .handlerdata
213 .fnend
215 .globl func5c
216 .align 2
217 .type func5c,%function
218 .fnstart
219 func5c:
220 .setfp fp, sp, #0x204
221 add fp, sp, #0x204
222 sub sp, fp, #0x204
223 bx lr
224 .personality __gxx_personality_v0
225 .handlerdata
226 .fnend
228 @-------------------------------------------------------------------------------
229 @ The assembler should emit 0x9B to copy stack pointer from r11.
230 @ The assembler should emit (0x40 | (offset - 4)) >> 2 for offset.
231 @ If (offset - 4) is greater than 0x3f, then multiple 0x7f should be emitted.
232 @-------------------------------------------------------------------------------
233 @ CHECK: Section {
234 @ CHECK: Name: .ARM.extab.TEST5
235 @ CHECK: SectionData (
236 @ CHECK: 0000: 00000000 B0409B00 00000000 7F409B00 |.....@.......@..|
237 @ CHECK: 0010: 00000000 7F409B01 B0B0B07F |.....@......|
238 @ CHECK: )
239 @ CHECK: }