[llvm-readobj] - Simplify stack-sizes.test test case.
[llvm-complete.git] / test / MC / ARM / ldr-pseudo-darwin.s
blob941310a592efda24ed504edf629a22f18115e3c3
1 @ This test has a partner (ldr-pseudo.s) that contains matching
2 @ tests for the ldr-pseudo on linux targets. We need separate files
3 @ because the syntax for switching sections and temporary labels differs
4 @ between darwin and linux. Any tests added here should have a matching
5 @ test added there.
7 @RUN: llvm-mc -triple armv7-base-apple-darwin %s | FileCheck --check-prefix=CHECK-ARM --check-prefix=CHECK %s
8 @RUN: llvm-mc -triple armv5-base-apple-darwin %s | FileCheck --check-prefix=CHECK-ARMV5 --check-prefix=CHECK %s
9 @RUN: llvm-mc -triple thumbv5-base-apple-darwin %s | FileCheck --check-prefix=CHECK-THUMB --check-prefix=CHECK %s
10 @RUN: llvm-mc -triple thumbv7-base-apple-darwin %s | FileCheck --check-prefix=CHECK-THUMB2 --check-prefix=CHECK %s
11 @RUN: llvm-mc -triple thumbv8m.base-base-apple-darwin %s | FileCheck --check-prefix=CHECK-BASELINE --check-prefix=CHECK %s
13 @ Check that large constants are converted to ldr from constant pool
15 @ simple test
16 .section __TEXT,b,regular,pure_instructions
17 @ CHECK-LABEL: f3:
18 f3:
19 ldr r0, =0x10002
20 @ CHECK: ldr r0, Ltmp0
22 @ loading multiple constants
23 .section __TEXT,c,regular,pure_instructions
24 @ CHECK-LABEL: f4:
25 f4:
26 ldr r0, =0x10003
27 @ CHECK: ldr r0, Ltmp1
28 adds r0, r0, #1
29 adds r0, r0, #1
30 adds r0, r0, #1
31 adds r0, r0, #1
32 ldr r0, =0x10004
33 @ CHECK: ldr r0, Ltmp2
34 adds r0, r0, #1
35 adds r0, r0, #1
37 @ TODO: the same constants should have the same constant pool location
38 .section __TEXT,d,regular,pure_instructions
39 @ CHECK-LABEL: f5:
40 f5:
41 ldr r0, =0x10005
42 @ CHECK: ldr r0, Ltmp3
43 adds r0, r0, #1
44 adds r0, r0, #1
45 adds r0, r0, #1
46 adds r0, r0, #1
47 adds r0, r0, #1
48 adds r0, r0, #1
49 adds r0, r0, #1
50 ldr r0, =0x10005
51 @ CHECK: ldr r0, Ltmp3
52 adds r0, r0, #1
53 adds r0, r0, #1
54 adds r0, r0, #1
55 adds r0, r0, #1
56 adds r0, r0, #1
57 adds r0, r0, #1
59 @ a section defined in multiple pieces should be merged and use a single constant pool
60 .section __TEXT,e,regular,pure_instructions
61 @ CHECK-LABEL: f6:
62 f6:
63 ldr r0, =0x10006
64 @ CHECK: ldr r0, Ltmp4
65 adds r0, r0, #1
66 adds r0, r0, #1
67 adds r0, r0, #1
69 .section __TEXT,f,regular,pure_instructions
70 @ CHECK-LABEL: f7:
71 f7:
72 adds r0, r0, #1
73 adds r0, r0, #1
74 adds r0, r0, #1
76 .section __TEXT,e,regular,pure_instructions
77 @ CHECK-LABEL: f8:
78 f8:
79 adds r0, r0, #1
80 ldr r0, =0x10007
81 @ CHECK: ldr r0, Ltmp5
82 adds r0, r0, #1
83 adds r0, r0, #1
86 @ Check that symbols can be loaded using ldr pseudo
89 @ load an undefined symbol
90 .section __TEXT,g,regular,pure_instructions
91 @ CHECK-LABEL: f9:
92 f9:
93 ldr r0, =foo
94 @ CHECK: ldr r0, Ltmp6
96 @ load a symbol from another section
97 .section __TEXT,h,regular,pure_instructions
98 @ CHECK-LABEL: f10:
99 f10:
100 ldr r0, =f5
101 @ CHECK: ldr r0, Ltmp7
103 @ load a symbol from the same section
104 .section __TEXT,i,regular,pure_instructions
105 @ CHECK-LABEL: f11:
106 f11:
107 ldr r0, =f12
108 @ CHECK: ldr r0, Ltmp8
110 @ CHECK-LABEL: f12:
111 f12:
112 adds r0, r0, #1
113 adds r0, r0, #1
115 .section __TEXT,j,regular,pure_instructions
116 @ mix of symbols and constants
117 @ CHECK-LABEL: f13:
118 f13:
119 adds r0, r0, #1
120 adds r0, r0, #1
121 ldr r0, =0x10008
122 @ CHECK: ldr r0, Ltmp9
123 adds r0, r0, #1
124 adds r0, r0, #1
125 ldr r0, =bar
126 @ CHECK: ldr r0, Ltmp10
127 adds r0, r0, #1
128 adds r0, r0, #1
130 @ Check for correct usage in other contexts
133 @ usage in macro
134 .macro useit_in_a_macro
135 ldr r0, =0x10009
136 ldr r0, =baz
137 .endm
138 .section __TEXT,k,regular,pure_instructions
139 @ CHECK-LABEL: f14:
140 f14:
141 useit_in_a_macro
142 @ CHECK: ldr r0, Ltmp11
143 @ CHECK: ldr r0, Ltmp12
145 @ usage with expressions
146 .section __TEXT,l,regular,pure_instructions
147 @ CHECK-LABEL: f15:
148 f15:
149 ldr r0, =0x10001+9
150 @ CHECK: ldr r0, Ltmp13
151 adds r0, r0, #1
152 ldr r0, =bar+4
153 @ CHECK: ldr r0, Ltmp14
154 adds r0, r0, #1
156 @ transformation to mov
157 .section __TEXT,m,regular,pure_instructions
158 @ CHECK-LABEL: f16:
159 f16:
161 @ Representable in ARM, and Thumb with support mov.w or movw
162 ldr r1, =0x1
163 @ CHECK-ARM: mov r1, #1
164 @ CHECK-ARMV5: mov r1, #1
165 @ CHECK-THUMB: ldr r1, Ltmp15
166 @ CHECK-THUMB2: mov.w r1, #1
167 @ CHECK-BASELINE: movw r1, #1
169 @ Immediate is representable in A1 and T2 modified immediate only not movw
170 ldr r2, =0x120000
171 @ CHECK-ARM: mov r2, #1179648
172 @ CHECK-ARMV5: mov r2, #1179648
173 @ CHECK-THUMB: ldr r2, Ltmp16
174 @ CHECK-THUMB2: mov.w r2, #1179648
175 @ CHECK-BASELINE: ldr r2, Ltmp15
177 @ Immediate can be represented only with movw instruction
178 ldr r3, =0x1234
179 @ CHECK-ARM: movw r3, #4660
180 @ CHECK-ARMV5: ldr r3, Ltmp15
181 @ CHECK-THUMB: ldr r3, Ltmp17
182 @ CHECK-THUMB2: movw r3, #4660
183 @ CHECK-BASELINE: movw r3, #4660
185 @ Immediate can be represented only with T2 modified immediate
186 ldr r4, =0xabababab
187 @ CHECK-ARM: ldr r4, Ltmp15
188 @ CHECK-ARMV5: ldr r4, Ltmp16
189 @ CHECK-THUMB: ldr r4, Ltmp18
190 @ CHECK-THUMB2: mov.w r4, #2880154539
191 @ CHECK-BASELINE: ldr r4, Ltmp16
193 @ Immediate can be represented only with A1 modified immediate
194 ldr r5, =0x1000000b
195 @ CHECK-ARM: mov r5, #268435467
196 @ CHECK-ARMV5: mov r5, #268435467
197 @ CHECK-THUMB: ldr r5, Ltmp19
198 @ CHECK-THUMB2: ldr r5, Ltmp15
199 @ CHECK-BASELINE: ldr r5, Ltmp17
201 @ Negative numbers can be used with MVN or in Thumb2 with modified immediate
202 ldr r6, =-1
203 @ CHECK-ARM: mvn r6, #0
204 @ CHECK-ARMV5: mvn r6, #0
205 @ CHECK-THUMB: ldr r6, Ltmp20
206 @ CHECK-THUMB2: mov.w r6, #-1
207 @ CHECK-BASELINE: ldr r6, Ltmp18
208 ldr r7, =-0x100
209 @ CHECK-ARM: mvn r7, #255
210 @ CHECK-ARMV5: mvn r7, #255
211 @ CHECK-THUMB: ldr r7, Ltmp21
212 @ CHECK-THUMB2: mvn r7, #255
213 @ CHECK-BASELINE: ldr r7, Ltmp19
215 @ Constant expressions can be used
216 .equ expr, 0x10 + 0x10
217 ldr r0, = expr
218 @ CHECK-ARM: mov r0, #32
219 @ CHECK-ARMV5: mov r0, #32
220 @ CHECK-THUMB: ldr r0, Ltmp22
221 @ CHECK-THUMB2: mov.w r0, #32
222 @ CHECK-BASELINE: movw r0, #32
223 ldr r1, = expr - 0x10
224 @ CHECK-ARM: mov r1, #16
225 @ CHECK-ARMV5: mov r1, #16
226 @ CHECK-THUMB: ldr r1, Ltmp23
227 @ CHECK-THUMB2: mov.w r1, #16
228 @ CHECK-BASELINE: movw r1, #16
230 @ usage of translation in macro
231 .macro usemov_in_a_macro
232 ldr r2, =0x3
233 ldr r3, =expr
234 .endm
235 @ CHECK-LABEL: f17:
236 f17:
237 usemov_in_a_macro
238 @ CHECK-ARM: mov r2, #3
239 @ CHECK-ARM: mov r3, #32
240 @ CHECK-ARMV5: mov r2, #3
241 @ CHECK-ARMV5: mov r3, #32
242 @ CHECK-THUMB: ldr r2, Ltmp24
243 @ CHECK-THUMB: ldr r3, Ltmp22
244 @ CHECK-THUMB2: mov.w r2, #3
245 @ CHECK-THUMB2: mov.w r3, #32
246 @ CHECK-BASELINE: movw r2, #3
247 @ CHECK-BASELINE: movw r3, #32
249 @ Constant Pools
251 @ CHECK: .section __TEXT,b,regular,pure_instructions
252 @ CHECK: .data_region
253 @ CHECK: .p2align 2
254 @ CHECK-LABEL: Ltmp0:
255 @ CHECK: .long 65538
256 @ CHECK: .end_data_region
258 @ CHECK: .section __TEXT,c,regular,pure_instructions
259 @ CHECK: .data_region
260 @ CHECK: .p2align 2
261 @ CHECK-LABEL: Ltmp1:
262 @ CHECK: .long 65539
263 @ CHECK: .p2align 2
264 @ CHECK-LABEL: Ltmp2:
265 @ CHECK: .long 65540
266 @ CHECK: .end_data_region
268 @ CHECK: .section __TEXT,d,regular,pure_instructions
269 @ CHECK: .data_region
270 @ CHECK: .p2align 2
271 @ CHECK-LABEL: Ltmp3:
272 @ CHECK: .long 65541
273 @ CHECK: .end_data_region
275 @ CHECK: .section __TEXT,e,regular,pure_instructions
276 @ CHECK: .data_region
277 @ CHECK: .p2align 2
278 @ CHECK-LABEL: Ltmp4:
279 @ CHECK: .long 65542
280 @ CHECK: .p2align 2
281 @ CHECK-LABEL: Ltmp5:
282 @ CHECK: .long 65543
283 @ CHECK: .end_data_region
285 @ Should not switch to section because it has no constant pool
286 @ CHECK-NOT: .section __TEXT,f,regular,pure_instructions
288 @ CHECK: .section __TEXT,g,regular,pure_instructions
289 @ CHECK: .data_region
290 @ CHECK: .p2align 2
291 @ CHECK-LABEL: Ltmp6:
292 @ CHECK: .long foo
293 @ CHECK: .end_data_region
295 @ CHECK: .section __TEXT,h,regular,pure_instructions
296 @ CHECK: .data_region
297 @ CHECK: .p2align 2
298 @ CHECK-LABEL: Ltmp7:
299 @ CHECK: .long f5
300 @ CHECK: .end_data_region
302 @ CHECK: .section __TEXT,i,regular,pure_instructions
303 @ CHECK: .data_region
304 @ CHECK: .p2align 2
305 @ CHECK-LABEL: Ltmp8:
306 @ CHECK: .long f12
307 @ CHECK: .end_data_region
309 @ CHECK: .section __TEXT,j,regular,pure_instructions
310 @ CHECK: .data_region
311 @ CHECK: .p2align 2
312 @ CHECK-LABEL: Ltmp9:
313 @ CHECK: .long 65544
314 @ CHECK: .p2align 2
315 @ CHECK-LABEL: Ltmp10:
316 @ CHECK: .long bar
317 @ CHECK: .end_data_region
319 @ CHECK: .section __TEXT,k,regular,pure_instructions
320 @ CHECK: .data_region
321 @ CHECK: .p2align 2
322 @ CHECK-LABEL: Ltmp11:
323 @ CHECK: .long 65545
324 @ CHECK: .p2align 2
325 @ CHECK-LABEL: Ltmp12:
326 @ CHECK: .long baz
327 @ CHECK: .end_data_region
329 @ CHECK: .section __TEXT,l,regular,pure_instructions
330 @ CHECK: .data_region
331 @ CHECK: .p2align 2
332 @ CHECK-LABEL: Ltmp13:
333 @ CHECK: .long 65546
334 @ CHECK: .p2align 2
335 @ CHECK-LABEL: Ltmp14:
336 @ CHECK: .long bar+4
337 @ CHECK: .end_data_region