• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
6
7@RUN: llvm-mc -triple   armv7-apple-darwin %s | FileCheck %s
8@RUN: llvm-mc -triple thumbv5-apple-darwin %s | FileCheck %s
9@RUN: llvm-mc -triple thumbv7-apple-darwin %s | FileCheck %s
10
11@
12@ Check that large constants are converted to ldr from constant pool
13@
14@ simple test
15.section __TEXT,b,regular,pure_instructions
16@ CHECK-LABEL: f3:
17f3:
18  ldr r0, =0x10001
19@ CHECK: ldr r0, Ltmp0
20
21@ loading multiple constants
22.section __TEXT,c,regular,pure_instructions
23@ CHECK-LABEL: f4:
24f4:
25  ldr r0, =0x10002
26@ CHECK: ldr r0, Ltmp1
27  adds r0, r0, #1
28  adds r0, r0, #1
29  adds r0, r0, #1
30  adds r0, r0, #1
31  ldr r0, =0x10003
32@ CHECK: ldr r0, Ltmp2
33  adds r0, r0, #1
34  adds r0, r0, #1
35
36@ TODO: the same constants should have the same constant pool location
37.section __TEXT,d,regular,pure_instructions
38@ CHECK-LABEL: f5:
39f5:
40  ldr r0, =0x10004
41@ CHECK: ldr r0, Ltmp3
42  adds r0, r0, #1
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  ldr r0, =0x10004
50@ CHECK: ldr r0, Ltmp4
51  adds r0, r0, #1
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
58@ a section defined in multiple pieces should be merged and use a single constant pool
59.section __TEXT,e,regular,pure_instructions
60@ CHECK-LABEL: f6:
61f6:
62  ldr r0, =0x10006
63@ CHECK: ldr r0, Ltmp5
64  adds r0, r0, #1
65  adds r0, r0, #1
66  adds r0, r0, #1
67
68.section __TEXT,f,regular,pure_instructions
69@ CHECK-LABEL: f7:
70f7:
71  adds r0, r0, #1
72  adds r0, r0, #1
73  adds r0, r0, #1
74
75.section __TEXT,e,regular,pure_instructions
76@ CHECK-LABEL: f8:
77f8:
78  adds r0, r0, #1
79  ldr r0, =0x10007
80@ CHECK: ldr r0, Ltmp6
81  adds r0, r0, #1
82  adds r0, r0, #1
83
84@
85@ Check that symbols can be loaded using ldr pseudo
86@
87
88@ load an undefined symbol
89.section __TEXT,g,regular,pure_instructions
90@ CHECK-LABEL: f9:
91f9:
92  ldr r0, =foo
93@ CHECK: ldr r0, Ltmp7
94
95@ load a symbol from another section
96.section __TEXT,h,regular,pure_instructions
97@ CHECK-LABEL: f10:
98f10:
99  ldr r0, =f5
100@ CHECK: ldr r0, Ltmp8
101
102@ load a symbol from the same section
103.section __TEXT,i,regular,pure_instructions
104@ CHECK-LABEL: f11:
105f11:
106  ldr r0, =f12
107@ CHECK: ldr r0, Ltmp9
108
109@ CHECK-LABEL: f12:
110f12:
111  adds r0, r0, #1
112  adds r0, r0, #1
113
114.section __TEXT,j,regular,pure_instructions
115@ mix of symbols and constants
116@ CHECK-LABEL: f13:
117f13:
118  adds r0, r0, #1
119  adds r0, r0, #1
120  ldr r0, =0x101
121@ CHECK: ldr r0, Ltmp10
122  adds r0, r0, #1
123  adds r0, r0, #1
124  ldr r0, =bar
125@ CHECK: ldr r0, Ltmp11
126  adds r0, r0, #1
127  adds r0, r0, #1
128@
129@ Check for correct usage in other contexts
130@
131
132@ usage in macro
133.macro useit_in_a_macro
134  ldr r0, =0x10008
135  ldr r0, =baz
136.endm
137.section __TEXT,k,regular,pure_instructions
138@ CHECK-LABEL: f14:
139f14:
140  useit_in_a_macro
141@ CHECK: ldr r0, Ltmp12
142@ CHECK: ldr r0, Ltmp13
143
144@ usage with expressions
145.section __TEXT,l,regular,pure_instructions
146@ CHECK-LABEL: f15:
147f15:
148  ldr r0, =0x10001+8
149@ CHECK: ldr r0, Ltmp14
150  adds r0, r0, #1
151  ldr r0, =bar+4
152@ CHECK: ldr r0, Ltmp15
153  adds r0, r0, #1
154
155@
156@ Constant Pools
157@
158@ CHECK: .section __TEXT,b,regular,pure_instructions
159@ CHECK: .data_region
160@ CHECK: .align 2
161@ CHECK-LABEL: Ltmp0:
162@ CHECK: .long 65537
163@ CHECK: .end_data_region
164
165@ CHECK: .section __TEXT,c,regular,pure_instructions
166@ CHECK: .data_region
167@ CHECK: .align 2
168@ CHECK-LABEL: Ltmp1:
169@ CHECK: .long 65538
170@ CHECK: .align 2
171@ CHECK-LABEL: Ltmp2:
172@ CHECK: .long 65539
173@ CHECK: .end_data_region
174
175@ CHECK: .section __TEXT,d,regular,pure_instructions
176@ CHECK: .data_region
177@ CHECK: .align 2
178@ CHECK-LABEL: Ltmp3:
179@ CHECK: .long 65540
180@ CHECK: .align 2
181@ CHECK-LABEL: Ltmp4:
182@ CHECK: .long 65540
183@ CHECK: .end_data_region
184
185@ CHECK: .section __TEXT,e,regular,pure_instructions
186@ CHECK: .data_region
187@ CHECK: .align 2
188@ CHECK-LABEL: Ltmp5:
189@ CHECK: .long 65542
190@ CHECK: .align 2
191@ CHECK-LABEL: Ltmp6:
192@ CHECK: .long 65543
193@ CHECK: .end_data_region
194
195@ Should not switch to section because it has no constant pool
196@ CHECK-NOT: .section __TEXT,f,regular,pure_instructions
197
198@ CHECK: .section __TEXT,g,regular,pure_instructions
199@ CHECK: .data_region
200@ CHECK: .align 2
201@ CHECK-LABEL: Ltmp7:
202@ CHECK: .long foo
203@ CHECK: .end_data_region
204
205@ CHECK: .section __TEXT,h,regular,pure_instructions
206@ CHECK: .data_region
207@ CHECK: .align 2
208@ CHECK-LABEL: Ltmp8:
209@ CHECK: .long f5
210@ CHECK: .end_data_region
211
212@ CHECK: .section __TEXT,i,regular,pure_instructions
213@ CHECK: .data_region
214@ CHECK: .align 2
215@ CHECK-LABEL: Ltmp9:
216@ CHECK: .long f12
217@ CHECK: .end_data_region
218
219@ CHECK: .section __TEXT,j,regular,pure_instructions
220@ CHECK: .data_region
221@ CHECK: .align 2
222@ CHECK-LABEL: Ltmp10:
223@ CHECK: .long 257
224@ CHECK: .align 2
225@ CHECK-LABEL: Ltmp11:
226@ CHECK: .long bar
227@ CHECK: .end_data_region
228
229@ CHECK: .section __TEXT,k,regular,pure_instructions
230@ CHECK: .data_region
231@ CHECK: .align 2
232@ CHECK-LABEL: Ltmp12:
233@ CHECK: .long 65544
234@ CHECK: .align 2
235@ CHECK-LABEL: Ltmp13:
236@ CHECK: .long baz
237@ CHECK: .end_data_region
238
239@ CHECK: .section __TEXT,l,regular,pure_instructions
240@ CHECK: .data_region
241@ CHECK: .align 2
242@ CHECK-LABEL: Ltmp14:
243@ CHECK: .long 65545
244@ CHECK: .align 2
245@ CHECK-LABEL: Ltmp15:
246@ CHECK: .long bar+4
247@ CHECK: .end_data_region
248