Ticket #9743: jump_ppc64_linux_elf_gas.S

File jump_ppc64_linux_elf_gas.S, 9.5 KB (added by Tony Reix <tony.reix@…>, 9 years ago)

Assembler code for Linux on Power BE/LE PPC64

Line 
1/*
2 Copyright Oliver Kowalke 2009.
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
6*/
7
8/*******************************************************
9 * *
10 * ------------------------------------------------- *
11 * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
12 * ------------------------------------------------- *
13 * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
14 * ------------------------------------------------- *
15 * | F14 | F15 | F16 | F17 | *
16 * ------------------------------------------------- *
17 * ------------------------------------------------- *
18 * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
19 * ------------------------------------------------- *
20 * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
21 * ------------------------------------------------- *
22 * | F18 | F19 | F20 | F21 | *
23 * ------------------------------------------------- *
24 * ------------------------------------------------- *
25 * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
26 * ------------------------------------------------- *
27 * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
28 * ------------------------------------------------- *
29 * | F22 | F23 | F24 | F25 | *
30 * ------------------------------------------------- *
31 * ------------------------------------------------- *
32 * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
33 * ------------------------------------------------- *
34 * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
35 * ------------------------------------------------- *
36 * | F26 | F27 | F28 | F29 | *
37 * ------------------------------------------------- *
38 * ------------------------------------------------- *
39 * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
40 * ------------------------------------------------- *
41 * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
42 * ------------------------------------------------- *
43 * | F30 | F31 | fpscr | TOC | *
44 * ------------------------------------------------- *
45 * ------------------------------------------------- *
46 * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
47 * ------------------------------------------------- *
48 * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
49 * ------------------------------------------------- *
50 * | R14 | R15 | R16 | R17 | *
51 * ------------------------------------------------- *
52 * ------------------------------------------------- *
53 * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
54 * ------------------------------------------------- *
55 * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
56 * ------------------------------------------------- *
57 * | R18 | R19 | R20 | R21 | *
58 * ------------------------------------------------- *
59 * ------------------------------------------------- *
60 * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | *
61 * ------------------------------------------------- *
62 * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | *
63 * ------------------------------------------------- *
64 * | R22 | R23 | R24 | R25 | *
65 * ------------------------------------------------- *
66 * ------------------------------------------------- *
67 * | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | *
68 * ------------------------------------------------- *
69 * | 256 | 260 | 264 | 268 | 272 | 276 | 280 | 284 | *
70 * ------------------------------------------------- *
71 * | R26 | R27 | R28 | R29 | *
72 * ------------------------------------------------- *
73 * ------------------------------------------------- *
74 * | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | *
75 * ------------------------------------------------- *
76 * | 288 | 292 | 296 | 300 | 304 | 308 | 312 | 316 | *
77 * ------------------------------------------------- *
78 * ------------------------------------------------- *
79 * | R30 | R31 | CR | LR | *
80 * ------------------------------------------------- *
81 * ------------------------------------------------- *
82 * | 80 | 81 | | *
83 * ------------------------------------------------- *
84 * | 320 | 324 | | *
85 * ------------------------------------------------- *
86 * | PC | | *
87 * ------------------------------------------------- *
88 * *
89 *******************************************************/
90
91.globl jump_fcontext
92#if _CALL_ELF == 2
93 .text
94 .align 2
95jump_fcontext:
96 addis %r2, %r12, .TOC.-jump_fcontext@ha
97 addi %r2, %r2, .TOC.-jump_fcontext@l
98 .localentry jump_fcontext, . - jump_fcontext
99#else
100 .section ".opd","aw"
101 .align 3
102jump_fcontext:
103# ifdef _CALL_LINUX
104 .quad .L.jump_fcontext,.TOC.@tocbase,0
105 .type jump_fcontext,@function
106 .text
107 .align 2
108.L.jump_fcontext:
109# else
110 .hidden .jump_fcontext
111 .globl .jump_fcontext
112 .quad .jump_fcontext,.TOC.@tocbase,0
113 .size jump_fcontext,24
114 .type .jump_fcontext,@function
115 .text
116 .align 2
117.jump_fcontext:
118# endif
119#endif
120 # reserve space on stack
121 subi %r1, %r1, 328
122
123#if _CALL_ELF != 2
124 std %r2, 152(%r1) # save TOC
125#endif
126 std %r14, 160(%r1) # save R14
127 std %r15, 168(%r1) # save R15
128 std %r16, 176(%r1) # save R16
129 std %r17, 184(%r1) # save R17
130 std %r18, 192(%r1) # save R18
131 std %r19, 200(%r1) # save R19
132 std %r20, 208(%r1) # save R20
133 std %r21, 216(%r1) # save R21
134 std %r22, 224(%r1) # save R22
135 std %r23, 232(%r1) # save R23
136 std %r24, 240(%r1) # save R24
137 std %r25, 248(%r1) # save R25
138 std %r26, 256(%r1) # save R26
139 std %r27, 264(%r1) # save R27
140 std %r28, 272(%r1) # save R28
141 std %r29, 280(%r1) # save R29
142 std %r30, 288(%r1) # save R30
143 std %r31, 296(%r1) # save R31
144
145 # save CR
146 mfcr %r0
147 std %r0, 304(%r1)
148 # save LR
149 mflr %r0
150 std %r0, 312(%r1)
151 # save LR as PC
152 std %r0, 320(%r1)
153
154 # test if fpu env should be preserved
155 cmpwi cr7, %r6, 0
156 beq cr7, 1f
157
158 stfd %f14, 0(%r1) # save F14
159 stfd %f15, 8(%r1) # save F15
160 stfd %f16, 16(%r1) # save F16
161 stfd %f17, 24(%r1) # save F17
162 stfd %f18, 32(%r1) # save F18
163 stfd %f19, 40(%r1) # save F19
164 stfd %f20, 48(%r1) # save F20
165 stfd %f21, 56(%r1) # save F21
166 stfd %f22, 64(%r1) # save F22
167 stfd %f23, 72(%r1) # save F23
168 stfd %f24, 80(%r1) # save F24
169 stfd %f25, 88(%r1) # save F25
170 stfd %f26, 96(%r1) # save F26
171 stfd %f27, 104(%r1) # save F27
172 stfd %f28, 112(%r1) # save F28
173 stfd %f29, 120(%r1) # save F29
174 stfd %f30, 128(%r1) # save F30
175 stfd %f31, 136(%r1) # save F31
176 mffs %f0 # load FPSCR
177 stfd %f0, 144(%r1) # save FPSCR
178
1791:
180 # store RSP (pointing to context-data) in R3
181 std %r1, 0(%r3)
182
183 # restore RSP (pointing to context-data) from R4
184 mr %r1, %r4
185
186 # test if fpu env should be preserved
187 cmpwi cr7, %r6, 0
188 beq cr7, 2f
189
190 lfd %f14, 0(%r1) # restore F14
191 lfd %f15, 8(%r1) # restore F15
192 lfd %f16, 16(%r1) # restore F16
193 lfd %f17, 24(%r1) # restore F17
194 lfd %f18, 32(%r1) # restore F18
195 lfd %f19, 40(%r1) # restore F19
196 lfd %f20, 48(%r1) # restore F20
197 lfd %f21, 56(%r1) # restore F21
198 lfd %f22, 64(%r1) # restore F22
199 lfd %f23, 72(%r1) # restore F23
200 lfd %f24, 80(%r1) # restore F24
201 lfd %f25, 88(%r1) # restore F25
202 lfd %f26, 96(%r1) # restore F26
203 lfd %f27, 104(%r1) # restore F27
204 lfd %f28, 112(%r1) # restore F28
205 lfd %f29, 120(%r1) # restore F29
206 lfd %f30, 128(%r1) # restore F30
207 lfd %f31, 136(%r1) # restore F31
208 lfd %f0, 144(%r1) # load FPSCR
209 mtfsf 0xff, %f0 # restore FPSCR
210
2112:
212#if _CALL_ELF != 2
213 ld %r2, 152(%r1) # restore TOC
214#endif
215 ld %r14, 160(%r1) # restore R14
216 ld %r15, 168(%r1) # restore R15
217 ld %r16, 176(%r1) # restore R16
218 ld %r17, 184(%r1) # restore R17
219 ld %r18, 192(%r1) # restore R18
220 ld %r19, 200(%r1) # restore R19
221 ld %r20, 208(%r1) # restore R20
222 ld %r21, 216(%r1) # restore R21
223 ld %r22, 224(%r1) # restore R22
224 ld %r23, 232(%r1) # restore R23
225 ld %r24, 240(%r1) # restore R24
226 ld %r25, 248(%r1) # restore R25
227 ld %r26, 256(%r1) # restore R26
228 ld %r27, 264(%r1) # restore R27
229 ld %r28, 272(%r1) # restore R28
230 ld %r29, 280(%r1) # restore R29
231 ld %r30, 288(%r1) # restore R30
232 ld %r31, 296(%r1) # restore R31
233
234 # restore CR
235 ld %r0, 304(%r1)
236 mtcr %r0
237 # restore LR
238 ld %r0, 312(%r1)
239 mtlr %r0
240
241 # load PC
242 ld %r12, 320(%r1)
243 # restore CTR
244 mtctr %r12
245
246 # adjust stack
247 addi %r1, %r1, 328
248
249 # use third arg as return value after jump
250 # use third arg as first arg in context function
251 mr %r3, %r5
252
253 # jump to context
254 bctr
255#if _CALL_ELF == 2
256 .size jump_fcontext, .-jump_fcontext
257#else
258# ifdef _CALL_LINUX
259 .size .jump_fcontext, .-.L.jump_fcontext
260# else
261 .size .jump_fcontext, .-.jump_fcontext
262# endif
263#endif
264
265
266/* Mark that we don't need executable stack. */
267.section .note.GNU-stack,"",%progbits