• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: ppc
2
3# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
4# RUN: llvm-readelf -r %t.o | FileCheck --check-prefix=InputRelocs %s
5
6# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/shared-ppc64.s -o %t2.o
7# RUN: ld.lld -shared -soname=t2.so %t2.o -o %t2.so
8
9## Place all sections in the same segment so that .text and .TOC. are on the same page.
10# RUN: echo 'PHDRS { all PT_LOAD; }' > %t.script
11#
12# RUN: ld.lld %t2.so %t.o -T %t.script -o %t
13# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=Dis %s
14#
15# RUN: ld.lld %t2.so %t.o -T %t.script --no-toc-optimize -o %t
16# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=NoOpt %s
17
18# InputRelocs:  Relocation section '.rela.text'
19# InputRelocs:   R_PPC64_TOC16_HA
20# InputRelocs:   R_PPC64_TOC16_LO
21# InputRelocs:   R_PPC64_TOC16_LO_DS
22
23
24        .text
25	.abiversion 2
26
27        .global bytes
28        .p2align        4
29        .type   bytes,@function
30bytes:
31.Lbytes_gep:
32        addis 2, 12, .TOC.-.Lbytes_gep@ha
33        addi  2, 2,  .TOC.-.Lbytes_gep@l
34.Lbytes_lep:
35        .localentry     bytes, .Lbytes_lep-.Lbytes_gep
36        addis 3, 2, byteLd@toc@ha
37        lbz   3,    byteLd@toc@l(3)
38        addis 4, 2, byteSt@toc@ha
39        stb   3,    byteSt@toc@l(4)
40        blr
41# Dis-LABEL: <bytes>:
42# Dis-NEXT:   addis
43# Dis-NEXT:   addi
44# Dis-NEXT:   nop
45# Dis-NEXT:   lbz   3, -32752(2)
46# Dis-NEXT:   nop
47# Dis-NEXT:   stb   3, -32751(2)
48# Dis-NEXT:   blr
49
50# NoOpt-LABEL: <bytes>:
51# NoOpt-NEXT:     addis
52# NoOpt-NEXT:     addi
53# NoOpt-NEXT:     addis 3, 2, 0
54# NoOpt-NEXT:     lbz 3, -32752(3)
55# NoOpt-NEXT:     addis 4, 2, 0
56# NoOpt-NEXT:     stb 3, -32751(4)
57# NoOpt-NEXT:     blr
58
59        .global  halfs
60        .p2align        4
61        .type   halfs,@function
62halfs:
63.Lhalfs_gep:
64        addis 2, 12, .TOC.-.Lhalfs_gep@ha
65        addi  2, 2,  .TOC.-.Lhalfs_gep@l
66.Lhalfs_lep:
67        .localentry  halfs, .Lhalfs_lep-.Lhalfs_gep
68        addis 3, 2, halfLd@toc@ha
69        lhz   3,    halfLd@toc@l(3)
70        addis 4, 2, halfLd@toc@ha
71        lha   4,    halfLd@toc@l(4)
72        addis 5, 2, halfSt@toc@ha
73        sth   4,    halfSt@toc@l(5)
74        blr
75# Dis-LABEL: <halfs>:
76# Dis-NEXT:   addis
77# Dis-NEXT:   addi
78# Dis-NEXT:   nop
79# Dis-NEXT:   lhz 3, -32750(2)
80# Dis-NEXT:   nop
81# Dis-NEXT:   lha 4, -32750(2)
82# Dis-NEXT:   nop
83# Dis-NEXT:   sth 4, -32748(2)
84# Dis-NEXT:   blr
85
86# NoOpt-LABEL: <halfs>:
87# NoOpt-NEXT:   addis
88# NoOpt-NEXT:   addi
89# NoOpt-NEXT:   addis 3, 2, 0
90# NoOpt-NEXT:   lhz   3, -32750(3)
91# NoOpt-NEXT:   addis 4, 2, 0
92# NoOpt-NEXT:   lha 4, -32750(4)
93# NoOpt-NEXT:   addis 5, 2, 0
94# NoOpt-NEXT:   sth 4, -32748(5)
95# NoOpt-NEXT:   blr
96
97
98        .global words
99        .p2align        4
100        .type   words,@function
101words:
102.Lwords_gep:
103       addis 2, 12, .TOC.-.Lwords_gep@ha
104       addi  2, 2,  .TOC.-.Lwords_gep@l
105.Lwords_lep:
106       .localentry words, .Lwords_lep-.Lwords_gep
107       addis 3, 2, wordLd@toc@ha
108       lwz   3,    wordLd@toc@l(3)
109       addis 4, 2, wordLd@toc@ha
110       lwa   4,    wordLd@toc@l(4)
111       addis 5, 2, wordSt@toc@ha
112       stw   4,    wordSt@toc@l(5)
113       blr
114# Dis-LABEL: words
115# Dis-NEXT:    addis
116# Dis-NEXT:    addi
117# Dis-NEXT:    nop
118# Dis-NEXT:    lwz 3, -32744(2)
119# Dis-NEXT:    nop
120# Dis-NEXT:    lwa 4, -32744(2)
121# Dis-NEXT:    nop
122# Dis-NEXT:    stw 4, -32740(2)
123# Dis-NEXT:    blr
124
125# NoOpt-LABEL: words
126# NoOpt-NEXT:    addis
127# NoOpt-NEXT:    addi
128# NoOpt-NEXT:    addis 3, 2, 0
129# NoOpt-NEXT:    lwz 3, -32744(3)
130# NoOpt-NEXT:    addis 4, 2, 0
131# NoOpt-NEXT:    lwa 4, -32744(4)
132# NoOpt-NEXT:    addis 5, 2, 0
133# NoOpt-NEXT:    stw 4, -32740(5)
134# NoOpt-NEXT:    blr
135
136        .global doublewords
137        .p2align        4
138        .type   doublewords,@function
139doublewords:
140.Ldoublewords_gep:
141       addis 2, 12, .TOC.-.Ldoublewords_gep@ha
142       addi  2, 2,  .TOC.-.Ldoublewords_gep@l
143.Ldoublewords_lep:
144       .localentry doublewords, .Ldoublewords_lep-.Ldoublewords_gep
145        addis 3, 2, dwordLd@toc@ha
146        ld    3,    dwordLd@toc@l(3)
147        addis 4, 2, dwordSt@toc@ha
148        std   3,    dwordSt@toc@l(4)
149        blr
150
151# Dis-LABEL: doublewords
152# Dis-NEXT:    addis
153# Dis-NEXT:    addi
154# Dis-NEXT:    nop
155# Dis-NEXT:    ld 3, -32736(2)
156# Dis-NEXT:    nop
157# Dis-NEXT:    std 3, -32728(2)
158# Dis-NEXT:    blr
159
160# NoOpt-LABEL: doublewords
161# NoOpt-NEXT:    addis
162# NoOpt-NEXT:    addi
163# NoOpt-NEXT:    addis 3, 2, 0
164# NoOpt-NEXT:    ld 3, -32736(3)
165# NoOpt-NEXT:    addis 4, 2, 0
166# NoOpt-NEXT:    std 3, -32728(4)
167# NoOpt-NEXT:    blr
168
169       .global vec_dq
170       .p2align 4
171        .type vec_dq,@function
172vec_dq:
173.Lvec_dq_gep:
174        addis 2, 12, .TOC.-.Lvec_dq_gep@ha
175        addi  2,  2, .TOC.-.Lvec_dq_gep@l
176.Lvec_dq_lep:
177        .localentry  vec_dq, .Lvec_dq_lep-.Lvec_dq_gep
178        addis 3, 2, vecLd@toc@ha
179        lxv   3,    vecLd@toc@l(3)
180        addis 3, 2, vecSt@toc@ha
181        stxv  3,    vecSt@toc@l(3)
182        blr
183
184# Dis-LABEL: <vec_dq>:
185# Dis-NEXT:    addis
186# Dis-NEXT:    addi
187# Dis-NEXT:    nop
188# Dis-NEXT:    lxv 3, -32720(2)
189# Dis-NEXT:    nop
190# Dis-NEXT:    stxv 3, -32704(2)
191# Dis-NEXT:    blr
192
193# NoOpt-LABEL: <vec_dq>:
194# NoOpt-NEXT:    addis
195# NoOpt-NEXT:    addi
196# NoOpt-NEXT:    addis 3, 2, 0
197# NoOpt-NEXT:    lxv 3, -32720(3)
198# NoOpt-NEXT:    addis 3, 2, 0
199# NoOpt-NEXT:    stxv 3, -32704(3)
200# NoOpt-NEXT:    blr
201
202       .global vec_ds
203       .p2align 4
204        .type vec_ds,@function
205vec_ds:
206.Lvec_ds_gep:
207        addis 2, 12, .TOC.-.Lvec_ds_gep@ha
208        addi  2,  2, .TOC.-.Lvec_ds_gep@l
209.Lvec_ds_lep:
210        .localentry  vec_ds, .Lvec_dq_lep-.Lvec_dq_gep
211        addis  3, 2, vecLd@toc@ha
212        lxsd   3,    vecLd@toc@l(3)
213        addis  3, 2, vecSt@toc@ha
214        stxsd  3,    vecSt@toc@l(3)
215        addis  3, 2, vecLd@toc@ha
216        lxssp  3,    vecLd@toc@l(3)
217        addis  3, 2, vecSt@toc@ha
218        stxssp 3,    vecSt@toc@l(3)
219        blr
220# Dis-LABEL: <vec_ds>:
221# Dis-NEXT:   addis
222# Dis-NEXT:   addi
223# Dis-NEXT:   nop
224# Dis-NEXT:   lxsd 3, -32720(2)
225# Dis-NEXT:   nop
226# Dis-NEXT:   stxsd 3, -32704(2)
227# Dis-NEXT:   nop
228# Dis-NEXT:   lxssp 3, -32720(2)
229# Dis-NEXT:   nop
230# Dis-NEXT:   stxssp 3, -32704(2)
231# Dis-NEXT:   blr
232
233# NoOpt-LABEL: <vec_ds>:
234# NoOpt-NEXT:   addis
235# NoOpt-NEXT:   addi
236# NoOpt-NEXT:   addis 3, 2, 0
237# NoOpt-NEXT:   lxsd 3, -32720(3)
238# NoOpt-NEXT:   addis 3, 2, 0
239# NoOpt-NEXT:   stxsd 3, -32704(3)
240# NoOpt-NEXT:   addis 3, 2, 0
241# NoOpt-NEXT:   lxssp 3, -32720(3)
242# NoOpt-NEXT:   addis 3, 2, 0
243# NoOpt-NEXT:   stxssp 3, -32704(3)
244# NoOpt-NEXT:   blr
245
246
247       .global byteLd
248       .lcomm  byteLd, 1, 1
249
250       .global byteSt
251       .lcomm  byteSt, 1, 1
252
253       .global halfLd
254       .lcomm  halfLd, 2, 2
255
256       .global halfSt
257       .lcomm  halfSt, 2, 2
258
259       .global wordLd
260       .lcomm  wordLd, 4, 4
261
262       .global wordSt
263       .lcomm  wordSt, 4, 4
264
265       .global dwordLd
266       .lcomm  dwordLd, 8, 8
267
268       .global dwordSt
269       .lcomm  dwordSt, 8, 8
270
271       .global vecLd
272       .lcomm  vecLd, 16, 16
273
274       .global vecSt
275       .lcomm  vecSt, 16, 16
276