Path: blob/master/libs/unwind/src/UnwindRegistersSave.S
12346 views
//===------------------------ UnwindRegistersSave.S -----------------------===//1//2// The LLVM Compiler Infrastructure3//4// This file is dual licensed under the MIT and the University of Illinois Open5// Source Licenses. See LICENSE.TXT for details.6//7//===----------------------------------------------------------------------===//89#include "assembly.h"1011.text1213#if !defined(__USING_SJLJ_EXCEPTIONS__)1415#if defined(__i386__)1617#18# extern int unw_getcontext(unw_context_t* thread_state)19#20# On entry:21# + +22# +-----------------------+23# + thread_state pointer +24# +-----------------------+25# + return address +26# +-----------------------+ <-- SP27# + +28#29DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)30push %eax31movl 8(%esp), %eax32movl %ebx, 4(%eax)33movl %ecx, 8(%eax)34movl %edx, 12(%eax)35movl %edi, 16(%eax)36movl %esi, 20(%eax)37movl %ebp, 24(%eax)38movl %esp, %edx39addl $8, %edx40movl %edx, 28(%eax) # store what sp was at call site as esp41# skip ss42# skip eflags43movl 4(%esp), %edx44movl %edx, 40(%eax) # store return address as eip45# skip cs46# skip ds47# skip es48# skip fs49# skip gs50movl (%esp), %edx51movl %edx, (%eax) # store original eax52popl %eax53xorl %eax, %eax # return UNW_ESUCCESS54ret5556#elif defined(__arm64ec__)5758//59// extern int __unw_getcontext(unw_context_t* thread_state)60//61// On entry:62// thread_state pointer is in x063//64.section .text,"xr",discard,"#unw_getcontext"65.p2align 266DEFINE_LIBUNWIND_FUNCTION("#unw_getcontext")67stp x8, x27, [x0, #0x000] // rax, rbx68stp x0, x1, [x0, #0x010] // rcx, rdx69stp x26,x25, [x0, #0x020] // rdi, rsi70mov x1, sp71stp fp, x1, [x0, #0x030] // rbp, rsp72stp x2, x3, [x0, #0x040] // r8, r973stp x4, x5, [x0, #0x050] // r10, r1174stp x19,x20, [x0, #0x060] // r12, r1375stp x21,x22, [x0, #0x070] // r14, r1576str x30, [x0, #0x080] // store return address as pc77stp q0, q1, [x0, #0x0b0] // xmm0, xmm178stp q2, q3, [x0, #0x0d0] // xmm2, xmm379stp q4, q5, [x0, #0x0f0] // xmm4, xmm580stp q6, q7, [x0, #0x110] // xmm6, xmm781stp q8, q9, [x0, #0x130] // xmm8, xmm982stp q10,q11, [x0, #0x150] // xmm10,xmm1183stp q12,q13, [x0, #0x170] // xmm12,xmm1384stp q14,q15, [x0, #0x190] // xmm14,xmm1585mov x0, #0 // return UNW_ESUCCESS86ret8788.weak_anti_dep unw_getcontext89.set unw_getcontext, "#unw_getcontext"9091.section .hybmp$x,"yi"92.symidx "#unw_getcontext"93.symidx $ientry_thunk$cdecl$i8$i894.word 195.text9697#elif defined(__x86_64__)9899#100# extern int unw_getcontext(unw_context_t* thread_state)101#102# On entry:103# thread_state pointer is in rdi104#105DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)106#if defined(_WIN64)107#define PTR %rcx108#define TMP %rdx109#else110#define PTR %rdi111#define TMP %rsi112#endif113114movq %rax, (PTR)115movq %rbx, 8(PTR)116movq %rcx, 16(PTR)117movq %rdx, 24(PTR)118movq %rdi, 32(PTR)119movq %rsi, 40(PTR)120movq %rbp, 48(PTR)121movq %rsp, 56(PTR)122addq $8, 56(PTR)123movq %r8, 64(PTR)124movq %r9, 72(PTR)125movq %r10, 80(PTR)126movq %r11, 88(PTR)127movq %r12, 96(PTR)128movq %r13,104(PTR)129movq %r14,112(PTR)130movq %r15,120(PTR)131movq (%rsp),TMP132movq TMP,128(PTR) # store return address as rip133# skip rflags134# skip cs135# skip fs136# skip gs137138#if defined(_WIN64)139movdqu %xmm0,176(PTR)140movdqu %xmm1,192(PTR)141movdqu %xmm2,208(PTR)142movdqu %xmm3,224(PTR)143movdqu %xmm4,240(PTR)144movdqu %xmm5,256(PTR)145movdqu %xmm6,272(PTR)146movdqu %xmm7,288(PTR)147movdqu %xmm8,304(PTR)148movdqu %xmm9,320(PTR)149movdqu %xmm10,336(PTR)150movdqu %xmm11,352(PTR)151movdqu %xmm12,368(PTR)152movdqu %xmm13,384(PTR)153movdqu %xmm14,400(PTR)154movdqu %xmm15,416(PTR)155#endif156xorl %eax, %eax # return UNW_ESUCCESS157ret158159#elif defined(__mips__) && defined(_ABIO32) && _MIPS_SIM == _ABIO32160161#162# extern int unw_getcontext(unw_context_t* thread_state)163#164# On entry:165# thread_state pointer is in a0 ($4)166#167DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)168.set push169.set noat170.set noreorder171.set nomacro172sw $1, (4 * 1)($4)173sw $2, (4 * 2)($4)174sw $3, (4 * 3)($4)175sw $4, (4 * 4)($4)176sw $5, (4 * 5)($4)177sw $6, (4 * 6)($4)178sw $7, (4 * 7)($4)179sw $8, (4 * 8)($4)180sw $9, (4 * 9)($4)181sw $10, (4 * 10)($4)182sw $11, (4 * 11)($4)183sw $12, (4 * 12)($4)184sw $13, (4 * 13)($4)185sw $14, (4 * 14)($4)186sw $15, (4 * 15)($4)187sw $16, (4 * 16)($4)188sw $17, (4 * 17)($4)189sw $18, (4 * 18)($4)190sw $19, (4 * 19)($4)191sw $20, (4 * 20)($4)192sw $21, (4 * 21)($4)193sw $22, (4 * 22)($4)194sw $23, (4 * 23)($4)195sw $24, (4 * 24)($4)196sw $25, (4 * 25)($4)197sw $26, (4 * 26)($4)198sw $27, (4 * 27)($4)199sw $28, (4 * 28)($4)200sw $29, (4 * 29)($4)201sw $30, (4 * 30)($4)202sw $31, (4 * 31)($4)203# Store return address to pc204sw $31, (4 * 32)($4)205# hi and lo206mfhi $8207sw $8, (4 * 33)($4)208mflo $8209sw $8, (4 * 34)($4)210#ifdef __mips_hard_float211#if __mips_fpr != 64212sdc1 $f0, (4 * 36 + 8 * 0)($4)213sdc1 $f2, (4 * 36 + 8 * 2)($4)214sdc1 $f4, (4 * 36 + 8 * 4)($4)215sdc1 $f6, (4 * 36 + 8 * 6)($4)216sdc1 $f8, (4 * 36 + 8 * 8)($4)217sdc1 $f10, (4 * 36 + 8 * 10)($4)218sdc1 $f12, (4 * 36 + 8 * 12)($4)219sdc1 $f14, (4 * 36 + 8 * 14)($4)220sdc1 $f16, (4 * 36 + 8 * 16)($4)221sdc1 $f18, (4 * 36 + 8 * 18)($4)222sdc1 $f20, (4 * 36 + 8 * 20)($4)223sdc1 $f22, (4 * 36 + 8 * 22)($4)224sdc1 $f24, (4 * 36 + 8 * 24)($4)225sdc1 $f26, (4 * 36 + 8 * 26)($4)226sdc1 $f28, (4 * 36 + 8 * 28)($4)227sdc1 $f30, (4 * 36 + 8 * 30)($4)228#else229sdc1 $f0, (4 * 36 + 8 * 0)($4)230sdc1 $f1, (4 * 36 + 8 * 1)($4)231sdc1 $f2, (4 * 36 + 8 * 2)($4)232sdc1 $f3, (4 * 36 + 8 * 3)($4)233sdc1 $f4, (4 * 36 + 8 * 4)($4)234sdc1 $f5, (4 * 36 + 8 * 5)($4)235sdc1 $f6, (4 * 36 + 8 * 6)($4)236sdc1 $f7, (4 * 36 + 8 * 7)($4)237sdc1 $f8, (4 * 36 + 8 * 8)($4)238sdc1 $f9, (4 * 36 + 8 * 9)($4)239sdc1 $f10, (4 * 36 + 8 * 10)($4)240sdc1 $f11, (4 * 36 + 8 * 11)($4)241sdc1 $f12, (4 * 36 + 8 * 12)($4)242sdc1 $f13, (4 * 36 + 8 * 13)($4)243sdc1 $f14, (4 * 36 + 8 * 14)($4)244sdc1 $f15, (4 * 36 + 8 * 15)($4)245sdc1 $f16, (4 * 36 + 8 * 16)($4)246sdc1 $f17, (4 * 36 + 8 * 17)($4)247sdc1 $f18, (4 * 36 + 8 * 18)($4)248sdc1 $f19, (4 * 36 + 8 * 19)($4)249sdc1 $f20, (4 * 36 + 8 * 20)($4)250sdc1 $f21, (4 * 36 + 8 * 21)($4)251sdc1 $f22, (4 * 36 + 8 * 22)($4)252sdc1 $f23, (4 * 36 + 8 * 23)($4)253sdc1 $f24, (4 * 36 + 8 * 24)($4)254sdc1 $f25, (4 * 36 + 8 * 25)($4)255sdc1 $f26, (4 * 36 + 8 * 26)($4)256sdc1 $f27, (4 * 36 + 8 * 27)($4)257sdc1 $f28, (4 * 36 + 8 * 28)($4)258sdc1 $f29, (4 * 36 + 8 * 29)($4)259sdc1 $f30, (4 * 36 + 8 * 30)($4)260sdc1 $f31, (4 * 36 + 8 * 31)($4)261#endif262#endif263jr $31264# return UNW_ESUCCESS265or $2, $0, $0266.set pop267268#elif defined(__mips64)269270#271# extern int unw_getcontext(unw_context_t* thread_state)272#273# On entry:274# thread_state pointer is in a0 ($4)275#276DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)277.set push278.set noat279.set noreorder280.set nomacro281sd $1, (8 * 1)($4)282sd $2, (8 * 2)($4)283sd $3, (8 * 3)($4)284sd $4, (8 * 4)($4)285sd $5, (8 * 5)($4)286sd $6, (8 * 6)($4)287sd $7, (8 * 7)($4)288sd $8, (8 * 8)($4)289sd $9, (8 * 9)($4)290sd $10, (8 * 10)($4)291sd $11, (8 * 11)($4)292sd $12, (8 * 12)($4)293sd $13, (8 * 13)($4)294sd $14, (8 * 14)($4)295sd $15, (8 * 15)($4)296sd $16, (8 * 16)($4)297sd $17, (8 * 17)($4)298sd $18, (8 * 18)($4)299sd $19, (8 * 19)($4)300sd $20, (8 * 20)($4)301sd $21, (8 * 21)($4)302sd $22, (8 * 22)($4)303sd $23, (8 * 23)($4)304sd $24, (8 * 24)($4)305sd $25, (8 * 25)($4)306sd $26, (8 * 26)($4)307sd $27, (8 * 27)($4)308sd $28, (8 * 28)($4)309sd $29, (8 * 29)($4)310sd $30, (8 * 30)($4)311sd $31, (8 * 31)($4)312# Store return address to pc313sd $31, (8 * 32)($4)314# hi and lo315mfhi $8316sd $8, (8 * 33)($4)317mflo $8318sd $8, (8 * 34)($4)319#ifdef __mips_hard_float320sdc1 $f0, (8 * 35)($4)321sdc1 $f1, (8 * 36)($4)322sdc1 $f2, (8 * 37)($4)323sdc1 $f3, (8 * 38)($4)324sdc1 $f4, (8 * 39)($4)325sdc1 $f5, (8 * 40)($4)326sdc1 $f6, (8 * 41)($4)327sdc1 $f7, (8 * 42)($4)328sdc1 $f8, (8 * 43)($4)329sdc1 $f9, (8 * 44)($4)330sdc1 $f10, (8 * 45)($4)331sdc1 $f11, (8 * 46)($4)332sdc1 $f12, (8 * 47)($4)333sdc1 $f13, (8 * 48)($4)334sdc1 $f14, (8 * 49)($4)335sdc1 $f15, (8 * 50)($4)336sdc1 $f16, (8 * 51)($4)337sdc1 $f17, (8 * 52)($4)338sdc1 $f18, (8 * 53)($4)339sdc1 $f19, (8 * 54)($4)340sdc1 $f20, (8 * 55)($4)341sdc1 $f21, (8 * 56)($4)342sdc1 $f22, (8 * 57)($4)343sdc1 $f23, (8 * 58)($4)344sdc1 $f24, (8 * 59)($4)345sdc1 $f25, (8 * 60)($4)346sdc1 $f26, (8 * 61)($4)347sdc1 $f27, (8 * 62)($4)348sdc1 $f28, (8 * 63)($4)349sdc1 $f29, (8 * 64)($4)350sdc1 $f30, (8 * 65)($4)351sdc1 $f31, (8 * 66)($4)352#endif353jr $31354# return UNW_ESUCCESS355or $2, $0, $0356.set pop357358# elif defined(__mips__)359360#361# extern int unw_getcontext(unw_context_t* thread_state)362#363# Just trap for the time being.364DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)365teq $0, $0366367#elif defined(__powerpc64__)368369//370// extern int unw_getcontext(unw_context_t* thread_state)371//372// On entry:373// thread_state pointer is in r3374//375DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)376377// store register (GPR)378#define PPC64_STR(n) \379std %r##n, (8 * (n + 2))(%r3)380381// save GPRs382PPC64_STR(0)383mflr %r0384std %r0, PPC64_OFFS_SRR0(%r3) // store lr as ssr0385PPC64_STR(1)386PPC64_STR(2)387PPC64_STR(3)388PPC64_STR(4)389PPC64_STR(5)390PPC64_STR(6)391PPC64_STR(7)392PPC64_STR(8)393PPC64_STR(9)394PPC64_STR(10)395PPC64_STR(11)396PPC64_STR(12)397PPC64_STR(13)398PPC64_STR(14)399PPC64_STR(15)400PPC64_STR(16)401PPC64_STR(17)402PPC64_STR(18)403PPC64_STR(19)404PPC64_STR(20)405PPC64_STR(21)406PPC64_STR(22)407PPC64_STR(23)408PPC64_STR(24)409PPC64_STR(25)410PPC64_STR(26)411PPC64_STR(27)412PPC64_STR(28)413PPC64_STR(29)414PPC64_STR(30)415PPC64_STR(31)416417mfcr %r0418std %r0, PPC64_OFFS_CR(%r3)419mfxer %r0420std %r0, PPC64_OFFS_XER(%r3)421mflr %r0422std %r0, PPC64_OFFS_LR(%r3)423mfctr %r0424std %r0, PPC64_OFFS_CTR(%r3)425mfvrsave %r0426std %r0, PPC64_OFFS_VRSAVE(%r3)427428#ifdef PPC64_HAS_VMX429// save VS registers430// (note that this also saves floating point registers and V registers,431// because part of VS is mapped to these registers)432433addi %r4, %r3, PPC64_OFFS_FP434435// store VS register436#define PPC64_STVS(n) \437stxvd2x %vs##n, 0, %r4 ;\438addi %r4, %r4, 16439440PPC64_STVS(0)441PPC64_STVS(1)442PPC64_STVS(2)443PPC64_STVS(3)444PPC64_STVS(4)445PPC64_STVS(5)446PPC64_STVS(6)447PPC64_STVS(7)448PPC64_STVS(8)449PPC64_STVS(9)450PPC64_STVS(10)451PPC64_STVS(11)452PPC64_STVS(12)453PPC64_STVS(13)454PPC64_STVS(14)455PPC64_STVS(15)456PPC64_STVS(16)457PPC64_STVS(17)458PPC64_STVS(18)459PPC64_STVS(19)460PPC64_STVS(20)461PPC64_STVS(21)462PPC64_STVS(22)463PPC64_STVS(23)464PPC64_STVS(24)465PPC64_STVS(25)466PPC64_STVS(26)467PPC64_STVS(27)468PPC64_STVS(28)469PPC64_STVS(29)470PPC64_STVS(30)471PPC64_STVS(31)472PPC64_STVS(32)473PPC64_STVS(33)474PPC64_STVS(34)475PPC64_STVS(35)476PPC64_STVS(36)477PPC64_STVS(37)478PPC64_STVS(38)479PPC64_STVS(39)480PPC64_STVS(40)481PPC64_STVS(41)482PPC64_STVS(42)483PPC64_STVS(43)484PPC64_STVS(44)485PPC64_STVS(45)486PPC64_STVS(46)487PPC64_STVS(47)488PPC64_STVS(48)489PPC64_STVS(49)490PPC64_STVS(50)491PPC64_STVS(51)492PPC64_STVS(52)493PPC64_STVS(53)494PPC64_STVS(54)495PPC64_STVS(55)496PPC64_STVS(56)497PPC64_STVS(57)498PPC64_STVS(58)499PPC64_STVS(59)500PPC64_STVS(60)501PPC64_STVS(61)502PPC64_STVS(62)503PPC64_STVS(63)504505#else506507// store FP register508#define PPC64_STF(n) \509stfd %f##n, (PPC64_OFFS_FP + n * 16)(%r3)510511// save float registers512PPC64_STF(0)513PPC64_STF(1)514PPC64_STF(2)515PPC64_STF(3)516PPC64_STF(4)517PPC64_STF(5)518PPC64_STF(6)519PPC64_STF(7)520PPC64_STF(8)521PPC64_STF(9)522PPC64_STF(10)523PPC64_STF(11)524PPC64_STF(12)525PPC64_STF(13)526PPC64_STF(14)527PPC64_STF(15)528PPC64_STF(16)529PPC64_STF(17)530PPC64_STF(18)531PPC64_STF(19)532PPC64_STF(20)533PPC64_STF(21)534PPC64_STF(22)535PPC64_STF(23)536PPC64_STF(24)537PPC64_STF(25)538PPC64_STF(26)539PPC64_STF(27)540PPC64_STF(28)541PPC64_STF(29)542PPC64_STF(30)543PPC64_STF(31)544545// save vector registers546547// Use 16-bytes below the stack pointer as an548// aligned buffer to save each vector register.549// Note that the stack pointer is always 16-byte aligned.550subi %r4, %r1, 16551552#define PPC64_STV_UNALIGNED(n) \553stvx %v##n, 0, %r4 ;\554ld %r5, 0(%r4) ;\555std %r5, (PPC64_OFFS_V + n * 16)(%r3) ;\556ld %r5, 8(%r4) ;\557std %r5, (PPC64_OFFS_V + n * 16 + 8)(%r3)558559PPC64_STV_UNALIGNED(0)560PPC64_STV_UNALIGNED(1)561PPC64_STV_UNALIGNED(2)562PPC64_STV_UNALIGNED(3)563PPC64_STV_UNALIGNED(4)564PPC64_STV_UNALIGNED(5)565PPC64_STV_UNALIGNED(6)566PPC64_STV_UNALIGNED(7)567PPC64_STV_UNALIGNED(8)568PPC64_STV_UNALIGNED(9)569PPC64_STV_UNALIGNED(10)570PPC64_STV_UNALIGNED(11)571PPC64_STV_UNALIGNED(12)572PPC64_STV_UNALIGNED(13)573PPC64_STV_UNALIGNED(14)574PPC64_STV_UNALIGNED(15)575PPC64_STV_UNALIGNED(16)576PPC64_STV_UNALIGNED(17)577PPC64_STV_UNALIGNED(18)578PPC64_STV_UNALIGNED(19)579PPC64_STV_UNALIGNED(20)580PPC64_STV_UNALIGNED(21)581PPC64_STV_UNALIGNED(22)582PPC64_STV_UNALIGNED(23)583PPC64_STV_UNALIGNED(24)584PPC64_STV_UNALIGNED(25)585PPC64_STV_UNALIGNED(26)586PPC64_STV_UNALIGNED(27)587PPC64_STV_UNALIGNED(28)588PPC64_STV_UNALIGNED(29)589PPC64_STV_UNALIGNED(30)590PPC64_STV_UNALIGNED(31)591592#endif593594li %r3, 0 // return UNW_ESUCCESS595blr596597598#elif defined(__ppc__)599600//601// extern int unw_getcontext(unw_context_t* thread_state)602//603// On entry:604// thread_state pointer is in r3605//606DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)607stw %r0, 8(%r3)608mflr %r0609stw %r0, 0(%r3) // store lr as ssr0610stw %r1, 12(%r3)611stw %r2, 16(%r3)612stw %r3, 20(%r3)613stw %r4, 24(%r3)614stw %r5, 28(%r3)615stw %r6, 32(%r3)616stw %r7, 36(%r3)617stw %r8, 40(%r3)618stw %r9, 44(%r3)619stw %r10, 48(%r3)620stw %r11, 52(%r3)621stw %r12, 56(%r3)622stw %r13, 60(%r3)623stw %r14, 64(%r3)624stw %r15, 68(%r3)625stw %r16, 72(%r3)626stw %r17, 76(%r3)627stw %r18, 80(%r3)628stw %r19, 84(%r3)629stw %r20, 88(%r3)630stw %r21, 92(%r3)631stw %r22, 96(%r3)632stw %r23,100(%r3)633stw %r24,104(%r3)634stw %r25,108(%r3)635stw %r26,112(%r3)636stw %r27,116(%r3)637stw %r28,120(%r3)638stw %r29,124(%r3)639stw %r30,128(%r3)640stw %r31,132(%r3)641642// save VRSave register643mfspr %r0, 256644stw %r0, 156(%r3)645// save CR registers646mfcr %r0647stw %r0, 136(%r3)648// save CTR register649mfctr %r0650stw %r0, 148(%r3)651652// save float registers653stfd %f0, 160(%r3)654stfd %f1, 168(%r3)655stfd %f2, 176(%r3)656stfd %f3, 184(%r3)657stfd %f4, 192(%r3)658stfd %f5, 200(%r3)659stfd %f6, 208(%r3)660stfd %f7, 216(%r3)661stfd %f8, 224(%r3)662stfd %f9, 232(%r3)663stfd %f10,240(%r3)664stfd %f11,248(%r3)665stfd %f12,256(%r3)666stfd %f13,264(%r3)667stfd %f14,272(%r3)668stfd %f15,280(%r3)669stfd %f16,288(%r3)670stfd %f17,296(%r3)671stfd %f18,304(%r3)672stfd %f19,312(%r3)673stfd %f20,320(%r3)674stfd %f21,328(%r3)675stfd %f22,336(%r3)676stfd %f23,344(%r3)677stfd %f24,352(%r3)678stfd %f25,360(%r3)679stfd %f26,368(%r3)680stfd %f27,376(%r3)681stfd %f28,384(%r3)682stfd %f29,392(%r3)683stfd %f30,400(%r3)684stfd %f31,408(%r3)685686687// save vector registers688689subi %r4, %r1, 16690rlwinm %r4, %r4, 0, 0, 27 // mask low 4-bits691// r4 is now a 16-byte aligned pointer into the red zone692693#define SAVE_VECTOR_UNALIGNED(_vec, _offset) \694stvx _vec, 0, %r4 SEPARATOR \695lwz %r5, 0(%r4) SEPARATOR \696stw %r5, _offset(%r3) SEPARATOR \697lwz %r5, 4(%r4) SEPARATOR \698stw %r5, _offset+4(%r3) SEPARATOR \699lwz %r5, 8(%r4) SEPARATOR \700stw %r5, _offset+8(%r3) SEPARATOR \701lwz %r5, 12(%r4) SEPARATOR \702stw %r5, _offset+12(%r3)703704SAVE_VECTOR_UNALIGNED( %v0, 424+0x000)705SAVE_VECTOR_UNALIGNED( %v1, 424+0x010)706SAVE_VECTOR_UNALIGNED( %v2, 424+0x020)707SAVE_VECTOR_UNALIGNED( %v3, 424+0x030)708SAVE_VECTOR_UNALIGNED( %v4, 424+0x040)709SAVE_VECTOR_UNALIGNED( %v5, 424+0x050)710SAVE_VECTOR_UNALIGNED( %v6, 424+0x060)711SAVE_VECTOR_UNALIGNED( %v7, 424+0x070)712SAVE_VECTOR_UNALIGNED( %v8, 424+0x080)713SAVE_VECTOR_UNALIGNED( %v9, 424+0x090)714SAVE_VECTOR_UNALIGNED(%v10, 424+0x0A0)715SAVE_VECTOR_UNALIGNED(%v11, 424+0x0B0)716SAVE_VECTOR_UNALIGNED(%v12, 424+0x0C0)717SAVE_VECTOR_UNALIGNED(%v13, 424+0x0D0)718SAVE_VECTOR_UNALIGNED(%v14, 424+0x0E0)719SAVE_VECTOR_UNALIGNED(%v15, 424+0x0F0)720SAVE_VECTOR_UNALIGNED(%v16, 424+0x100)721SAVE_VECTOR_UNALIGNED(%v17, 424+0x110)722SAVE_VECTOR_UNALIGNED(%v18, 424+0x120)723SAVE_VECTOR_UNALIGNED(%v19, 424+0x130)724SAVE_VECTOR_UNALIGNED(%v20, 424+0x140)725SAVE_VECTOR_UNALIGNED(%v21, 424+0x150)726SAVE_VECTOR_UNALIGNED(%v22, 424+0x160)727SAVE_VECTOR_UNALIGNED(%v23, 424+0x170)728SAVE_VECTOR_UNALIGNED(%v24, 424+0x180)729SAVE_VECTOR_UNALIGNED(%v25, 424+0x190)730SAVE_VECTOR_UNALIGNED(%v26, 424+0x1A0)731SAVE_VECTOR_UNALIGNED(%v27, 424+0x1B0)732SAVE_VECTOR_UNALIGNED(%v28, 424+0x1C0)733SAVE_VECTOR_UNALIGNED(%v29, 424+0x1D0)734SAVE_VECTOR_UNALIGNED(%v30, 424+0x1E0)735SAVE_VECTOR_UNALIGNED(%v31, 424+0x1F0)736737li %r3, 0 // return UNW_ESUCCESS738blr739740741#elif defined(__arm64__) || defined(__aarch64__)742743//744// extern int unw_getcontext(unw_context_t* thread_state)745//746// On entry:747// thread_state pointer is in x0748//749.p2align 2750DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)751stp x0, x1, [x0, #0x000]752stp x2, x3, [x0, #0x010]753stp x4, x5, [x0, #0x020]754stp x6, x7, [x0, #0x030]755stp x8, x9, [x0, #0x040]756stp x10,x11, [x0, #0x050]757stp x12,x13, [x0, #0x060]758stp x14,x15, [x0, #0x070]759stp x16,x17, [x0, #0x080]760stp x18,x19, [x0, #0x090]761stp x20,x21, [x0, #0x0A0]762stp x22,x23, [x0, #0x0B0]763stp x24,x25, [x0, #0x0C0]764stp x26,x27, [x0, #0x0D0]765stp x28,x29, [x0, #0x0E0]766str x30, [x0, #0x0F0]767mov x1,sp768str x1, [x0, #0x0F8]769str x30, [x0, #0x100] // store return address as pc770// skip cpsr771stp d0, d1, [x0, #0x110]772stp d2, d3, [x0, #0x120]773stp d4, d5, [x0, #0x130]774stp d6, d7, [x0, #0x140]775stp d8, d9, [x0, #0x150]776stp d10,d11, [x0, #0x160]777stp d12,d13, [x0, #0x170]778stp d14,d15, [x0, #0x180]779stp d16,d17, [x0, #0x190]780stp d18,d19, [x0, #0x1A0]781stp d20,d21, [x0, #0x1B0]782stp d22,d23, [x0, #0x1C0]783stp d24,d25, [x0, #0x1D0]784stp d26,d27, [x0, #0x1E0]785stp d28,d29, [x0, #0x1F0]786str d30, [x0, #0x200]787str d31, [x0, #0x208]788mov x0, #0 // return UNW_ESUCCESS789ret790791#elif defined(__arm__) && !defined(__APPLE__)792793#if !defined(__ARM_ARCH_ISA_ARM)794.thumb795#endif796797@798@ extern int unw_getcontext(unw_context_t* thread_state)799@800@ On entry:801@ thread_state pointer is in r0802@803@ Per EHABI #4.7 this only saves the core integer registers.804@ EHABI #7.4.5 notes that in general all VRS registers should be restored805@ however this is very hard to do for VFP registers because it is unknown806@ to the library how many registers are implemented by the architecture.807@ Instead, VFP registers are demand saved by logic external to unw_getcontext.808@809.p2align 2810DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)811#if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1812stm r0!, {r0-r7}813mov r1, r8814mov r2, r9815mov r3, r10816stm r0!, {r1-r3}817mov r1, r11818mov r2, sp819mov r3, lr820str r1, [r0, #0] @ r11821@ r12 does not need storing, it it the intra-procedure-call scratch register822str r2, [r0, #8] @ sp823str r3, [r0, #12] @ lr824str r3, [r0, #16] @ store return address as pc825@ T1 does not have a non-cpsr-clobbering register-zeroing instruction.826@ It is safe to use here though because we are about to return, and cpsr is827@ not expected to be preserved.828movs r0, #0 @ return UNW_ESUCCESS829#else830@ 32bit thumb-2 restrictions for stm:831@ . the sp (r13) cannot be in the list832@ . the pc (r15) cannot be in the list in an STM instruction833stm r0, {r0-r12}834str sp, [r0, #52]835str lr, [r0, #56]836str lr, [r0, #60] @ store return address as pc837mov r0, #0 @ return UNW_ESUCCESS838#endif839JMP(lr)840841@842@ static void libunwind::Registers_arm::saveVFPWithFSTMD(unw_fpreg_t* values)843@844@ On entry:845@ values pointer is in r0846@847.p2align 2848#if defined(__ELF__)849.fpu vfpv3-d16850#endif851DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMDEPv)852vstmia r0, {d0-d15}853JMP(lr)854855@856@ static void libunwind::Registers_arm::saveVFPWithFSTMX(unw_fpreg_t* values)857@858@ On entry:859@ values pointer is in r0860@861.p2align 2862#if defined(__ELF__)863.fpu vfpv3-d16864#endif865DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMXEPv)866vstmia r0, {d0-d15} @ fstmiax is deprecated in ARMv7+ and now behaves like vstmia867JMP(lr)868869@870@ static void libunwind::Registers_arm::saveVFPv3(unw_fpreg_t* values)871@872@ On entry:873@ values pointer is in r0874@875.p2align 2876#if defined(__ELF__)877.fpu vfpv3878#endif879DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPv)880@ VFP and iwMMX instructions are only available when compiling with the flags881@ that enable them. We do not want to do that in the library (because we do not882@ want the compiler to generate instructions that access those) but this is883@ only accessed if the personality routine needs these registers. Use of884@ these registers implies they are, actually, available on the target, so885@ it's ok to execute.886@ So, generate the instructions using the corresponding coprocessor mnemonic.887vstmia r0, {d16-d31}888JMP(lr)889890#if defined(_LIBUNWIND_ARM_WMMX)891892@893@ static void libunwind::Registers_arm::saveiWMMX(unw_fpreg_t* values)894@895@ On entry:896@ values pointer is in r0897@898.p2align 2899#if defined(__ELF__)900.arch armv5te901#endif902DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPv)903stcl p1, cr0, [r0], #8 @ wstrd wR0, [r0], #8904stcl p1, cr1, [r0], #8 @ wstrd wR1, [r0], #8905stcl p1, cr2, [r0], #8 @ wstrd wR2, [r0], #8906stcl p1, cr3, [r0], #8 @ wstrd wR3, [r0], #8907stcl p1, cr4, [r0], #8 @ wstrd wR4, [r0], #8908stcl p1, cr5, [r0], #8 @ wstrd wR5, [r0], #8909stcl p1, cr6, [r0], #8 @ wstrd wR6, [r0], #8910stcl p1, cr7, [r0], #8 @ wstrd wR7, [r0], #8911stcl p1, cr8, [r0], #8 @ wstrd wR8, [r0], #8912stcl p1, cr9, [r0], #8 @ wstrd wR9, [r0], #8913stcl p1, cr10, [r0], #8 @ wstrd wR10, [r0], #8914stcl p1, cr11, [r0], #8 @ wstrd wR11, [r0], #8915stcl p1, cr12, [r0], #8 @ wstrd wR12, [r0], #8916stcl p1, cr13, [r0], #8 @ wstrd wR13, [r0], #8917stcl p1, cr14, [r0], #8 @ wstrd wR14, [r0], #8918stcl p1, cr15, [r0], #8 @ wstrd wR15, [r0], #8919JMP(lr)920921@922@ static void libunwind::Registers_arm::saveiWMMXControl(unw_uint32_t* values)923@924@ On entry:925@ values pointer is in r0926@927.p2align 2928#if defined(__ELF__)929.arch armv5te930#endif931DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControlEPj)932stc2 p1, cr8, [r0], #4 @ wstrw wCGR0, [r0], #4933stc2 p1, cr9, [r0], #4 @ wstrw wCGR1, [r0], #4934stc2 p1, cr10, [r0], #4 @ wstrw wCGR2, [r0], #4935stc2 p1, cr11, [r0], #4 @ wstrw wCGR3, [r0], #4936JMP(lr)937938#endif939940#elif defined(__or1k__)941942#943# extern int unw_getcontext(unw_context_t* thread_state)944#945# On entry:946# thread_state pointer is in r3947#948DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)949l.sw 0(r3), r0950l.sw 4(r3), r1951l.sw 8(r3), r2952l.sw 12(r3), r3953l.sw 16(r3), r4954l.sw 20(r3), r5955l.sw 24(r3), r6956l.sw 28(r3), r7957l.sw 32(r3), r8958l.sw 36(r3), r9959l.sw 40(r3), r10960l.sw 44(r3), r11961l.sw 48(r3), r12962l.sw 52(r3), r13963l.sw 56(r3), r14964l.sw 60(r3), r15965l.sw 64(r3), r16966l.sw 68(r3), r17967l.sw 72(r3), r18968l.sw 76(r3), r19969l.sw 80(r3), r20970l.sw 84(r3), r21971l.sw 88(r3), r22972l.sw 92(r3), r23973l.sw 96(r3), r24974l.sw 100(r3), r25975l.sw 104(r3), r26976l.sw 108(r3), r27977l.sw 112(r3), r28978l.sw 116(r3), r29979l.sw 120(r3), r30980l.sw 124(r3), r31981# store ra to pc982l.sw 128(r3), r9983# zero epcr984l.sw 132(r3), r0985986#elif defined(__sparc__)987988#989# extern int unw_getcontext(unw_context_t* thread_state)990#991# On entry:992# thread_state pointer is in o0993#994DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)995ta 3996add %o7, 8, %o7997std %g0, [%o0 + 0]998std %g2, [%o0 + 8]999std %g4, [%o0 + 16]1000std %g6, [%o0 + 24]1001std %o0, [%o0 + 32]1002std %o2, [%o0 + 40]1003std %o4, [%o0 + 48]1004std %o6, [%o0 + 56]1005std %l0, [%o0 + 64]1006std %l2, [%o0 + 72]1007std %l4, [%o0 + 80]1008std %l6, [%o0 + 88]1009std %i0, [%o0 + 96]1010std %i2, [%o0 + 104]1011std %i4, [%o0 + 112]1012std %i6, [%o0 + 120]1013jmp %o71014clr %o0 // return UNW_ESUCCESS1015#endif1016#endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */10171018NO_EXEC_STACK_DIRECTIVE101910201021