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
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
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
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
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
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
32 addis 2, 12, .TOC.-.Lbytes_gep@ha
33 addi 2, 2, .TOC.-.Lbytes_gep@l
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)
45 # Dis-NEXT: lbz 3, -32752(2)
47 # Dis-NEXT: stb 3, -32751(2)
50 # NoOpt-LABEL: <bytes>:
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)
64 addis 2, 12, .TOC.-.Lhalfs_gep@ha
65 addi 2, 2, .TOC.-.Lhalfs_gep@l
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)
79 # Dis-NEXT: lhz 3, -32750(2)
81 # Dis-NEXT: lha 4, -32750(2)
83 # Dis-NEXT: sth 4, -32748(2)
86 # NoOpt-LABEL: <halfs>:
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)
100 .type words,@function
103 addis 2, 12, .TOC.-.Lwords_gep@ha
104 addi 2, 2, .TOC.-.Lwords_gep@l
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)
118 # Dis-NEXT: lwz 3, -32744(2)
120 # Dis-NEXT: lwa 4, -32744(2)
122 # Dis-NEXT: stw 4, -32740(2)
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)
138 .type doublewords,@function
141 addis 2, 12, .TOC.-.Ldoublewords_gep@ha
142 addi 2, 2, .TOC.-.Ldoublewords_gep@l
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)
151 # Dis-LABEL: doublewords
155 # Dis-NEXT: ld 3, -32736(2)
157 # Dis-NEXT: std 3, -32728(2)
160 # NoOpt-LABEL: doublewords
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)
171 .type vec_dq,@function
174 addis 2, 12, .TOC.-.Lvec_dq_gep@ha
175 addi 2, 2, .TOC.-.Lvec_dq_gep@l
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)
184 # Dis-LABEL: <vec_dq>:
188 # Dis-NEXT: lxv 3, -32720(2)
190 # Dis-NEXT: stxv 3, -32704(2)
193 # NoOpt-LABEL: <vec_dq>:
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)
204 .type vec_ds,@function
207 addis 2, 12, .TOC.-.Lvec_ds_gep@ha
208 addi 2, 2, .TOC.-.Lvec_ds_gep@l
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)
220 # Dis-LABEL: <vec_ds>:
224 # Dis-NEXT: lxsd 3, -32720(2)
226 # Dis-NEXT: stxsd 3, -32704(2)
228 # Dis-NEXT: lxssp 3, -32720(2)
230 # Dis-NEXT: stxssp 3, -32704(2)
233 # NoOpt-LABEL: <vec_ds>:
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)