1 //===------------------------- unwind_registers.S -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
9 // Abstracts accessing local vs remote address spaces.
11 //===----------------------------------------------------------------------===//
12 #include <machine/asm.h>
15 .hidden _ZN7_Unwind13Registers_x86C1Ev
16 ENTRY(_ZN7_Unwind13Registers_x86C1Ev)
18 movl 8(%esp), %eax /* Load this */
19 /* Save all registers except EAX, EIP and ESP */
27 leal 8(%esp), %edx /* Compute ESP from the call site */
28 movl %edx, 16(%eax) /* ...and store it as ESP */
29 movl 4(%esp), %edx /* Load return address */
30 movl %edx, 32(%eax) /* ...and store it as EIP */
31 popl %edx /* Take old EAX from stack */
32 movl %edx, 0(%eax) /* ...and store it */ // XXX skip
35 .hidden _ZNK7_Unwind13Registers_x866jumptoEv
36 ENTRY(_ZNK7_Unwind13Registers_x866jumptoEv)
37 movl 4(%esp), %eax /* Load this */
38 movl 16(%eax), %edx /* Load new stack pointer */
39 subl $4, %edx /* Reserve space on new stack for EIP */
40 movl 32(%eax), %ebx /* Load new EIP */
41 movl %ebx, 0(%edx) /* ...and save it on the new stack */
42 pushl %edx /* Save new stack pointer on old stack */
43 /* New stack is prepared, now restore all registers except ESP */
44 /* EAX is the index register and must be restored last */
53 /* Now load new stack pointer pushed on the old stack earlier */
55 /* Return address is already on the new stack. */
60 .hidden _ZN7_Unwind16Registers_x86_64C1Ev
61 ENTRY(_ZN7_Unwind16Registers_x86_64C1Ev)
84 .hidden _ZNK7_Unwind16Registers_x86_646jumptoEv
85 ENTRY(_ZNK7_Unwind16Registers_x86_646jumptoEv)
88 subq $8, %rax /* Reserve space on new stack for RIP */
89 movq 128(%rdi), %rbx /* Load new RIP */
90 movq %rbx, 0(%rax) /* ...and save it on the new stack */
91 pushq %rax /* Save new stack pointer on old stack */
92 /* New stack is prepared, now restore all registers */
98 /* RDI restored later as it is still used as index register */
100 /* RSP is restored later */
110 /* Now load new stack pointer pushed on the old stack earlier */
112 /* Return address is already on the new stack. */
117 .hidden _ZN7_Unwind15Registers_ppc32C1Ev
118 ENTRY(_ZN7_Unwind15Registers_ppc32C1Ev)
119 /* TODO: skip non-callee-safe registers */
153 stw %r0, 136(%r3) /* SRR0 */
155 stw %r0, 132(%r3) /* CR */
190 /* LR is undefined */
193 .hidden _ZNK7_Unwind15Registers_ppc326jumptoEv
194 ENTRY(_ZNK7_Unwind15Registers_ppc326jumptoEv)
229 /* skip r3 for now */
259 lwz %r0, 128(%r3) /* LR */
261 lwz %r0, 132(%r3) /* CR */
263 lwz %r0, 136(%r3) /* SRR0 */
266 lwz %r0, 0(%r3) /* do r0 now */
267 lwz %r1, 4(%r3) /* do sp now */
268 lwz %r3, 12(%r3) /* do r3 last */
273 .hidden _ZN7_Unwind17Registers_aarch64C1Ev
274 ENTRY(_ZN7_Unwind17Registers_aarch64C1Ev)
277 stp x2, x3, [x0], #16
278 stp x4, x5, [x0], #16
279 stp x6, x7, [x0], #16
280 stp x8, x9, [x0], #16
281 stp x10, x11, [x0], #16
282 stp x12, x13, [x0], #16
283 stp x14, x15, [x0], #16
284 stp x16, x17, [x0], #16
285 stp x18, x19, [x0], #16
286 stp x20, x22, [x0], #16
287 stp x22, x24, [x0], #16
288 stp x24, x26, [x0], #16
289 stp x26, x27, [x0], #16
290 stp x28, x29, [x0], #16
292 stp x30, x1, [x0], #16
297 stp q0, q1, [x0], #64
298 stp q2, q3, [x0], #64
299 stp q4, q5, [x0], #64
300 stp q6, q7, [x0], #64
301 stp q8, q9, [x0], #64
302 stp q10, q11, [x0], #64
303 stp q12, q13, [x0], #64
304 stp q14, q15, [x0], #64
305 stp q16, q17, [x0], #64
306 stp q18, q19, [x0], #64
307 stp q20, q21, [x0], #64
308 stp q22, q23, [x0], #64
309 stp q24, q25, [x0], #64
310 stp q26, q27, [x0], #64
311 stp q28, q29, [x0], #64
312 stp q30, q31, [x0], #64
315 END(_ZN7_Unwind17Registers_aarch64C1Ev)
317 .hidden _ZNK7_Unwind17Registers_aarch646jumptoEv
318 ENTRY(_ZNK7_Unwind17Registers_aarch646jumptoEv)
319 ldp x2, x3, [x0, #16]
320 ldp x4, x6, [x0, #32]
321 ldp x6, x7, [x0, #48]
322 ldp x8, x9, [x0, #64]
323 ldp x10, x11, [x0, #80]
324 ldp x12, x13, [x0, #96]
325 ldp x14, x16, [x0, #112]
326 ldp x16, x17, [x0, #128]
327 ldp x18, x19, [x0, #144]
328 ldp x20, x21, [x0, #160]
329 ldp x22, x23, [x0, #176]
330 ldp x24, x26, [x0, #192]
331 ldp x26, x27, [x0, #208]
332 ldp x28, x29, [x0, #224]
333 ldp x30, x1, [x0, #240]
338 END(_ZNK7_Unwind17Registers_aarch646jumptoEv)
339 #endif /* __aarch64__ */
343 .hidden _ZN7_Unwind15Registers_arm32C1Ev
344 ARM_ENTRY(_ZN7_Unwind15Registers_arm32C1Ev)
346 str lr, [r0, #60] /* PC */
348 str r1, [r0, #64] /* CPSR */
352 END(_ZN7_Unwind15Registers_arm32C1Ev)
354 .hidden _ZN7_Unwind15Registers_arm328lazyVFP1Ev
355 ARM_ENTRY(_ZN7_Unwind15Registers_arm328lazyVFP1Ev)
359 END(_ZN7_Unwind15Registers_arm328lazyVFP1Ev)
361 .hidden _ZN7_Unwind15Registers_arm328lazyVFP3Ev
362 ARM_ENTRY(_ZN7_Unwind15Registers_arm328lazyVFP3Ev)
366 END(_ZN7_Unwind15Registers_arm328lazyVFP3Ev)
368 .hidden _ZNK7_Unwind15Registers_arm326jumptoEv
369 ARM_ENTRY(_ZNK7_Unwind15Registers_arm326jumptoEv)
384 END(_ZNK7_Unwind15Registers_arm326jumptoEv)
388 .hidden _ZN7_Unwind13Registers_vaxC1Ev
389 ENTRY(_ZN7_Unwind13Registers_vaxC1Ev, R0)
404 movl 12(%fp), 52(%r0)
405 addl3 $36, %sp, 56(%r0)
407 movl 16(%fp), 60(%r0)
408 /* Load saved value of r0 as r1 */
413 END(_ZN7_Unwind13Registers_vaxC1Ev)
415 .hidden _ZNK7_Unwind13Registers_vax6jumptoEv
416 ENTRY(_ZNK7_Unwind13Registers_vax6jumptoEv, 0)
435 /* XXX restore PSW */
437 END(_ZNK7_Unwind13Registers_vax6jumptoEv)
440 #if defined(__m68k__)
441 ENTRY(_ZN7_Unwind14Registers_M68KC1Ev)
443 movem.l %d0-%d7/%a0-%a7, (%a0)
444 fmovem %fp0-%fp7, 72(%a0)
449 END(_ZN7_Unwind14Registers_M68KC1Ev)
451 ENTRY(_ZNK7_Unwind14Registers_M68K6jumptoEv)
457 fmovem 72(%a0), %fp0-%fp7
458 movem.l (%a0), %d0-%d7/%a0-%a7
460 END(_ZNK7_Unwind14Registers_M68K6jumptoEv)
464 .hidden _ZN7_Unwind13Registers_SH3C1Ev
465 ENTRY(_ZN7_Unwind13Registers_SH3C1Ev)
491 SET_ENTRY_SIZE(_ZN7_Unwind13Registers_SH3C1Ev)
493 .hidden _ZNK7_Unwind13Registers_SH36jumptoEv
494 ENTRY(_ZNK7_Unwind13Registers_SH36jumptoEv)
517 SET_ENTRY_SIZE(_ZNK7_Unwind13Registers_SH36jumptoEv)
520 #if defined(__sparc64__)
521 #include <machine/trap.h>
522 .register %g2, #ignore
523 .register %g3, #ignore
524 .register %g6, #ignore
525 .register %g7, #ignore
526 .hidden _ZN7_Unwind17Registers_SPARC64C1Ev
527 ENTRY(_ZN7_Unwind17Registers_SPARC64C1Ev)
564 END(_ZN7_Unwind17Registers_SPARC64C1Ev)
566 .hidden _ZNK7_Unwind17Registers_SPARC646jumptoEv
567 ENTRY(_ZNK7_Unwind17Registers_SPARC646jumptoEv)
604 END(_ZNK7_Unwind17Registers_SPARC646jumptoEv)
605 #elif defined(__sparc__)
606 #include <machine/trap.h>
608 .hidden _ZN7_Unwind15Registers_SPARCC1Ev
609 ENTRY(_ZN7_Unwind15Registers_SPARCC1Ev)
646 END(_ZN7_Unwind15Registers_SPARCC1Ev)
648 .hidden _ZNK7_Unwind15Registers_SPARC6jumptoEv
649 ENTRY(_ZNK7_Unwind15Registers_SPARC6jumptoEv)
685 END(_ZNK7_Unwind15Registers_SPARC6jumptoEv)
688 #if defined(__alpha__)
691 .hidden _ZN7_Unwind15Registers_AlphaC1Ev
692 LEAF_NOPROFILE(_ZN7_Unwind15Registers_AlphaC1Ev, 1)
758 END(_ZN7_Unwind15Registers_AlphaC1Ev)
762 .hidden _ZNK7_Unwind15Registers_Alpha6jumptoEv
763 LEAF_NOPROFILE(_ZNK7_Unwind15Registers_Alpha6jumptoEv, 1)
828 END(_ZNK7_Unwind15Registers_Alpha6jumptoEv)
831 #if defined(__mips_n64) || defined(__mips_n32)
833 LEAF(_ZN7_Unwind16Registers_MIPS64C1Ev)
902 END(_ZN7_Unwind16Registers_MIPS64C1Ev)
904 LEAF(_ZNK7_Unwind16Registers_MIPS646jumptoEv)
973 END(_ZNK7_Unwind16Registers_MIPS646jumptoEv)
974 #elif defined(__mips__)
976 LEAF(_ZN7_Unwind14Registers_MIPSC1Ev)
1047 END(_ZN7_Unwind14Registers_MIPSC1Ev)
1049 LEAF(_ZNK7_Unwind14Registers_MIPS6jumptoEv)
1120 END(_ZNK7_Unwind14Registers_MIPS6jumptoEv)
1123 #if defined(__hppa__)
1124 LEAF_ENTRY_NOPROFILE(_ZN7_Unwind14Registers_HPPAC1Ev)
1158 addl %r19, %r26, %r19
1159 fstds,ma %fr4, 8(%r19)
1160 fstds,ma %fr5, 8(%r19)
1161 fstds,ma %fr6, 8(%r19)
1162 fstds,ma %fr7, 8(%r19)
1163 fstds,ma %fr8, 8(%r19)
1164 fstds,ma %fr9, 8(%r19)
1165 fstds,ma %fr10, 8(%r19)
1166 fstds,ma %fr11, 8(%r19)
1167 fstds,ma %fr12, 8(%r19)
1168 fstds,ma %fr13, 8(%r19)
1169 fstds,ma %fr14, 8(%r19)
1170 fstds,ma %fr15, 8(%r19)
1171 fstds,ma %fr16, 8(%r19)
1172 fstds,ma %fr17, 8(%r19)
1173 fstds,ma %fr18, 8(%r19)
1174 fstds,ma %fr19, 8(%r19)
1175 fstds,ma %fr20, 8(%r19)
1176 fstds,ma %fr21, 8(%r19)
1177 fstds,ma %fr22, 8(%r19)
1178 fstds,ma %fr23, 8(%r19)
1179 fstds,ma %fr24, 8(%r19)
1180 fstds,ma %fr25, 8(%r19)
1181 fstds,ma %fr19, 8(%r19)
1182 fstds,ma %fr27, 8(%r19)
1183 fstds,ma %fr28, 8(%r19)
1184 fstds,ma %fr29, 8(%r19)
1185 fstds,ma %fr30, 8(%r19)
1186 fstds,ma %fr31, 8(%r19)
1189 EXIT(_ZN7_Unwind14Registers_HPPAC1Ev)
1191 LEAF_ENTRY_NOPROFILE(_ZNK7_Unwind14Registers_HPPA6jumptoEv)
1193 addl %r19, %r26, %r19
1194 fldds,ma 8(%r19), %fr4
1195 fldds,ma 8(%r19), %fr5
1196 fldds,ma 8(%r19), %fr6
1197 fldds,ma 8(%r19), %fr7
1198 fldds,ma 8(%r19), %fr8
1199 fldds,ma 8(%r19), %fr9
1200 fldds,ma 8(%r19), %fr10
1201 fldds,ma 8(%r19), %fr11
1202 fldds,ma 8(%r19), %fr12
1203 fldds,ma 8(%r19), %fr13
1204 fldds,ma 8(%r19), %fr14
1205 fldds,ma 8(%r19), %fr15
1206 fldds,ma 8(%r19), %fr16
1207 fldds,ma 8(%r19), %fr17
1208 fldds,ma 8(%r19), %fr18
1209 fldds,ma 8(%r19), %fr19
1210 fldds,ma 8(%r19), %fr20
1211 fldds,ma 8(%r19), %fr21
1212 fldds,ma 8(%r19), %fr22
1213 fldds,ma 8(%r19), %fr23
1214 fldds,ma 8(%r19), %fr24
1215 fldds,ma 8(%r19), %fr25
1216 fldds,ma 8(%r19), %fr26
1217 fldds,ma 8(%r19), %fr27
1218 fldds,ma 8(%r19), %fr28
1219 fldds,ma 8(%r19), %fr29
1220 fldds,ma 8(%r19), %fr30
1221 fldds,ma 8(%r19), %fr31
1254 EXIT(_ZNK7_Unwind14Registers_HPPA6jumptoEv)
1258 ENTRY_NP(_ZN7_Unwind14Registers_or1kC1Ev)
1269 l.sw (10*3)(r3), r10
1270 l.sw (11*3)(r3), r11
1271 l.sw (12*3)(r3), r12
1272 l.sw (13*3)(r3), r13
1273 l.sw (14*3)(r3), r14
1274 l.sw (15*3)(r3), r15
1275 l.sw (16*3)(r3), r16
1276 l.sw (17*3)(r3), r17
1277 l.sw (18*3)(r3), r18
1278 l.sw (19*3)(r3), r19
1279 l.sw (20*3)(r3), r20
1280 l.sw (21*3)(r3), r21
1281 l.sw (22*3)(r3), r22
1282 l.sw (23*3)(r3), r23
1283 l.sw (24*3)(r3), r24
1284 l.sw (25*3)(r3), r25
1285 l.sw (26*3)(r3), r26
1286 l.sw (27*3)(r3), r27
1287 l.sw (28*3)(r3), r28
1288 l.sw (29*3)(r3), r29
1289 l.sw (30*3)(r3), r30
1290 l.sw (31*3)(r3), r31
1295 END(_ZN7_Unwind14Registers_or1kC1Ev)
1297 ENTRY_NP(_ZNK7_Unwind14Registers_or1k6jumptoEv)
1298 l.lwz r6, (32*4)(r3)
1309 l.lwz r10, (10*4)(r3)
1310 l.lwz r11, (11*4)(r3)
1311 l.lwz r12, (12*4)(r3)
1312 l.lwz r13, (13*4)(r3)
1313 l.lwz r14, (14*4)(r3)
1314 l.lwz r15, (15*4)(r3)
1315 l.lwz r16, (16*4)(r3)
1316 l.lwz r17, (17*4)(r3)
1317 l.lwz r18, (18*4)(r3)
1318 l.lwz r19, (19*4)(r3)
1319 l.lwz r20, (20*4)(r3)
1320 l.lwz r21, (21*4)(r3)
1321 l.lwz r22, (22*4)(r3)
1322 l.lwz r23, (23*4)(r3)
1323 l.lwz r24, (24*4)(r3)
1324 l.lwz r25, (25*4)(r3)
1325 l.lwz r26, (26*4)(r3)
1326 l.lwz r27, (27*4)(r3)
1327 l.lwz r28, (28*4)(r3)
1328 l.lwz r29, (29*4)(r3)
1329 l.lwz r30, (30*4)(r3)
1330 l.lwz r31, (31*4)(r3)
1332 l.lwz r3, (3*4)(r3) /* return r3 */
1334 END(_ZNK7_Unwind14Registers_or1k6jumptoEv)