1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 #define FROM_0_TO_15 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
12 #define FROM_16_TO_31 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
14 #define FROM_0_TO_31 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
15 #define FROM_32_TO_63 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
23 #if !defined(__USING_SJLJ_EXCEPTIONS__)
28 # extern int __unw_getcontext(unw_context_t* thread_state)
32 # +-----------------------+
33 # + thread_state pointer +
34 # +-----------------------+
36 # +-----------------------+ <-- SP
39 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
52 movl %edx, 28(%eax) # store what sp was at call site as esp
56 movl %edx, 40(%eax) # store return address as eip
63 movl %edx, (%eax) # store original eax
65 xorl %eax, %eax # return UNW_ESUCCESS
68 #elif defined(__x86_64__)
71 # extern int __unw_getcontext(unw_context_t* thread_state)
74 # thread_state pointer is in rdi
76 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
104 movq TMP,128(PTR) # store return address as rip
111 movdqu %xmm0,176(PTR)
112 movdqu %xmm1,192(PTR)
113 movdqu %xmm2,208(PTR)
114 movdqu %xmm3,224(PTR)
115 movdqu %xmm4,240(PTR)
116 movdqu %xmm5,256(PTR)
117 movdqu %xmm6,272(PTR)
118 movdqu %xmm7,288(PTR)
119 movdqu %xmm8,304(PTR)
120 movdqu %xmm9,320(PTR)
121 movdqu %xmm10,336(PTR)
122 movdqu %xmm11,352(PTR)
123 movdqu %xmm12,368(PTR)
124 movdqu %xmm13,384(PTR)
125 movdqu %xmm14,400(PTR)
126 movdqu %xmm15,416(PTR)
128 xorl %eax, %eax # return UNW_ESUCCESS
131 #elif defined(__mips__) && defined(_ABIO32) && _MIPS_SIM == _ABIO32
134 # extern int __unw_getcontext(unw_context_t* thread_state)
137 # thread_state pointer is in a0 ($4)
139 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
175 # Store return address to pc
182 #ifdef __mips_hard_float
184 sdc1 $f0, (4 * 36 + 8 * 0)($4)
185 sdc1 $f2, (4 * 36 + 8 * 2)($4)
186 sdc1 $f4, (4 * 36 + 8 * 4)($4)
187 sdc1 $f6, (4 * 36 + 8 * 6)($4)
188 sdc1 $f8, (4 * 36 + 8 * 8)($4)
189 sdc1 $f10, (4 * 36 + 8 * 10)($4)
190 sdc1 $f12, (4 * 36 + 8 * 12)($4)
191 sdc1 $f14, (4 * 36 + 8 * 14)($4)
192 sdc1 $f16, (4 * 36 + 8 * 16)($4)
193 sdc1 $f18, (4 * 36 + 8 * 18)($4)
194 sdc1 $f20, (4 * 36 + 8 * 20)($4)
195 sdc1 $f22, (4 * 36 + 8 * 22)($4)
196 sdc1 $f24, (4 * 36 + 8 * 24)($4)
197 sdc1 $f26, (4 * 36 + 8 * 26)($4)
198 sdc1 $f28, (4 * 36 + 8 * 28)($4)
199 sdc1 $f30, (4 * 36 + 8 * 30)($4)
201 sdc1 $f0, (4 * 36 + 8 * 0)($4)
202 sdc1 $f1, (4 * 36 + 8 * 1)($4)
203 sdc1 $f2, (4 * 36 + 8 * 2)($4)
204 sdc1 $f3, (4 * 36 + 8 * 3)($4)
205 sdc1 $f4, (4 * 36 + 8 * 4)($4)
206 sdc1 $f5, (4 * 36 + 8 * 5)($4)
207 sdc1 $f6, (4 * 36 + 8 * 6)($4)
208 sdc1 $f7, (4 * 36 + 8 * 7)($4)
209 sdc1 $f8, (4 * 36 + 8 * 8)($4)
210 sdc1 $f9, (4 * 36 + 8 * 9)($4)
211 sdc1 $f10, (4 * 36 + 8 * 10)($4)
212 sdc1 $f11, (4 * 36 + 8 * 11)($4)
213 sdc1 $f12, (4 * 36 + 8 * 12)($4)
214 sdc1 $f13, (4 * 36 + 8 * 13)($4)
215 sdc1 $f14, (4 * 36 + 8 * 14)($4)
216 sdc1 $f15, (4 * 36 + 8 * 15)($4)
217 sdc1 $f16, (4 * 36 + 8 * 16)($4)
218 sdc1 $f17, (4 * 36 + 8 * 17)($4)
219 sdc1 $f18, (4 * 36 + 8 * 18)($4)
220 sdc1 $f19, (4 * 36 + 8 * 19)($4)
221 sdc1 $f20, (4 * 36 + 8 * 20)($4)
222 sdc1 $f21, (4 * 36 + 8 * 21)($4)
223 sdc1 $f22, (4 * 36 + 8 * 22)($4)
224 sdc1 $f23, (4 * 36 + 8 * 23)($4)
225 sdc1 $f24, (4 * 36 + 8 * 24)($4)
226 sdc1 $f25, (4 * 36 + 8 * 25)($4)
227 sdc1 $f26, (4 * 36 + 8 * 26)($4)
228 sdc1 $f27, (4 * 36 + 8 * 27)($4)
229 sdc1 $f28, (4 * 36 + 8 * 28)($4)
230 sdc1 $f29, (4 * 36 + 8 * 29)($4)
231 sdc1 $f30, (4 * 36 + 8 * 30)($4)
232 sdc1 $f31, (4 * 36 + 8 * 31)($4)
236 # return UNW_ESUCCESS
240 #elif defined(__mips64)
243 # extern int __unw_getcontext(unw_context_t* thread_state)
246 # thread_state pointer is in a0 ($4)
248 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
253 .irp i,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
256 # Store return address to pc
263 #ifdef __mips_hard_float
265 sdc1 $f\i, (280+8*\i)($4)
269 # return UNW_ESUCCESS
273 # elif defined(__mips__)
276 # extern int __unw_getcontext(unw_context_t* thread_state)
278 # Just trap for the time being.
279 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
282 #elif defined(__powerpc64__)
285 // extern int __unw_getcontext(unw_context_t* thread_state)
288 // thread_state pointer is in r3
291 DEFINE_LIBUNWIND_FUNCTION_AND_WEAK_ALIAS(__unw_getcontext, unw_getcontext)
293 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
295 // store register (GPR)
296 #define PPC64_STR(n) \
297 std n, (8 * (n + 2))(3)
302 std 0, PPC64_OFFS_SRR0(3) // store lr as ssr0
336 std 0, PPC64_OFFS_CR(3)
338 std 0, PPC64_OFFS_XER(3)
340 std 0, PPC64_OFFS_LR(3)
342 std 0, PPC64_OFFS_CTR(3)
344 std 0, PPC64_OFFS_VRSAVE(3)
348 // (note that this also saves floating point registers and V registers,
349 // because part of VS is mapped to these registers)
351 addi 4, 3, PPC64_OFFS_FP
354 #ifdef __LITTLE_ENDIAN__
355 // For little-endian targets, we need a swap since stxvd2x will store the
356 // register in the incorrect doubleword order.
357 // FIXME: when supporting targets older than Power9 on LE is no longer required
358 // this can be changed to simply `stxv n, 16 * n(4)`.
359 #define PPC64_STVS(n) \
364 #define PPC64_STVS(n) \
437 #define PPC64_STF(n) \
438 stfd n, (PPC64_OFFS_FP + n * 16)(3)
440 // save float registers
474 #if defined(__ALTIVEC__)
475 // save vector registers
477 // Use 16-bytes below the stack pointer as an
478 // aligned buffer to save each vector register.
479 // Note that the stack pointer is always 16-byte aligned.
482 #define PPC64_STV_UNALIGNED(n) \
485 std 5, (PPC64_OFFS_V + n * 16)(3) ;\
487 std 5, (PPC64_OFFS_V + n * 16 + 8)(3)
489 PPC64_STV_UNALIGNED(0)
490 PPC64_STV_UNALIGNED(1)
491 PPC64_STV_UNALIGNED(2)
492 PPC64_STV_UNALIGNED(3)
493 PPC64_STV_UNALIGNED(4)
494 PPC64_STV_UNALIGNED(5)
495 PPC64_STV_UNALIGNED(6)
496 PPC64_STV_UNALIGNED(7)
497 PPC64_STV_UNALIGNED(8)
498 PPC64_STV_UNALIGNED(9)
499 PPC64_STV_UNALIGNED(10)
500 PPC64_STV_UNALIGNED(11)
501 PPC64_STV_UNALIGNED(12)
502 PPC64_STV_UNALIGNED(13)
503 PPC64_STV_UNALIGNED(14)
504 PPC64_STV_UNALIGNED(15)
505 PPC64_STV_UNALIGNED(16)
506 PPC64_STV_UNALIGNED(17)
507 PPC64_STV_UNALIGNED(18)
508 PPC64_STV_UNALIGNED(19)
509 PPC64_STV_UNALIGNED(20)
510 PPC64_STV_UNALIGNED(21)
511 PPC64_STV_UNALIGNED(22)
512 PPC64_STV_UNALIGNED(23)
513 PPC64_STV_UNALIGNED(24)
514 PPC64_STV_UNALIGNED(25)
515 PPC64_STV_UNALIGNED(26)
516 PPC64_STV_UNALIGNED(27)
517 PPC64_STV_UNALIGNED(28)
518 PPC64_STV_UNALIGNED(29)
519 PPC64_STV_UNALIGNED(30)
520 PPC64_STV_UNALIGNED(31)
525 li 3, 0 // return UNW_ESUCCESS
529 #elif defined(__powerpc__)
532 // extern int unw_getcontext(unw_context_t* thread_state)
535 // thread_state pointer is in r3
538 DEFINE_LIBUNWIND_FUNCTION_AND_WEAK_ALIAS(__unw_getcontext, unw_getcontext)
540 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
544 stw 0, 0(3) // store lr as ssr0
577 #if defined(__ALTIVEC__)
578 // save VRSave register
589 #if !defined(__NO_FPRS__)
590 // save float registers
625 #if defined(__ALTIVEC__)
626 // save vector registers
629 rlwinm 4, 4, 0, 0, 27 // mask low 4-bits
630 // r4 is now a 16-byte aligned pointer into the red zone
632 #define SAVE_VECTOR_UNALIGNED(_vec, _offset) \
633 stvx _vec, 0, 4 SEPARATOR \
634 lwz 5, 0(4) SEPARATOR \
635 stw 5, _offset(3) SEPARATOR \
636 lwz 5, 4(4) SEPARATOR \
637 stw 5, _offset+4(3) SEPARATOR \
638 lwz 5, 8(4) SEPARATOR \
639 stw 5, _offset+8(3) SEPARATOR \
640 lwz 5, 12(4) SEPARATOR \
643 SAVE_VECTOR_UNALIGNED( 0, 424+0x000)
644 SAVE_VECTOR_UNALIGNED( 1, 424+0x010)
645 SAVE_VECTOR_UNALIGNED( 2, 424+0x020)
646 SAVE_VECTOR_UNALIGNED( 3, 424+0x030)
647 SAVE_VECTOR_UNALIGNED( 4, 424+0x040)
648 SAVE_VECTOR_UNALIGNED( 5, 424+0x050)
649 SAVE_VECTOR_UNALIGNED( 6, 424+0x060)
650 SAVE_VECTOR_UNALIGNED( 7, 424+0x070)
651 SAVE_VECTOR_UNALIGNED( 8, 424+0x080)
652 SAVE_VECTOR_UNALIGNED( 9, 424+0x090)
653 SAVE_VECTOR_UNALIGNED(10, 424+0x0A0)
654 SAVE_VECTOR_UNALIGNED(11, 424+0x0B0)
655 SAVE_VECTOR_UNALIGNED(12, 424+0x0C0)
656 SAVE_VECTOR_UNALIGNED(13, 424+0x0D0)
657 SAVE_VECTOR_UNALIGNED(14, 424+0x0E0)
658 SAVE_VECTOR_UNALIGNED(15, 424+0x0F0)
659 SAVE_VECTOR_UNALIGNED(16, 424+0x100)
660 SAVE_VECTOR_UNALIGNED(17, 424+0x110)
661 SAVE_VECTOR_UNALIGNED(18, 424+0x120)
662 SAVE_VECTOR_UNALIGNED(19, 424+0x130)
663 SAVE_VECTOR_UNALIGNED(20, 424+0x140)
664 SAVE_VECTOR_UNALIGNED(21, 424+0x150)
665 SAVE_VECTOR_UNALIGNED(22, 424+0x160)
666 SAVE_VECTOR_UNALIGNED(23, 424+0x170)
667 SAVE_VECTOR_UNALIGNED(24, 424+0x180)
668 SAVE_VECTOR_UNALIGNED(25, 424+0x190)
669 SAVE_VECTOR_UNALIGNED(26, 424+0x1A0)
670 SAVE_VECTOR_UNALIGNED(27, 424+0x1B0)
671 SAVE_VECTOR_UNALIGNED(28, 424+0x1C0)
672 SAVE_VECTOR_UNALIGNED(29, 424+0x1D0)
673 SAVE_VECTOR_UNALIGNED(30, 424+0x1E0)
674 SAVE_VECTOR_UNALIGNED(31, 424+0x1F0)
677 li 3, 0 // return UNW_ESUCCESS
681 #elif defined(__aarch64__)
684 // extern int __unw_getcontext(unw_context_t* thread_state)
687 // thread_state pointer is in x0
690 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
691 stp x0, x1, [x0, #0x000]
692 stp x2, x3, [x0, #0x010]
693 stp x4, x5, [x0, #0x020]
694 stp x6, x7, [x0, #0x030]
695 stp x8, x9, [x0, #0x040]
696 stp x10,x11, [x0, #0x050]
697 stp x12,x13, [x0, #0x060]
698 stp x14,x15, [x0, #0x070]
699 stp x16,x17, [x0, #0x080]
700 stp x18,x19, [x0, #0x090]
701 stp x20,x21, [x0, #0x0A0]
702 stp x22,x23, [x0, #0x0B0]
703 stp x24,x25, [x0, #0x0C0]
704 stp x26,x27, [x0, #0x0D0]
705 stp x28,x29, [x0, #0x0E0]
706 str x30, [x0, #0x0F0]
709 str x30, [x0, #0x100] // store return address as pc
711 stp d0, d1, [x0, #0x110]
712 stp d2, d3, [x0, #0x120]
713 stp d4, d5, [x0, #0x130]
714 stp d6, d7, [x0, #0x140]
715 stp d8, d9, [x0, #0x150]
716 stp d10,d11, [x0, #0x160]
717 stp d12,d13, [x0, #0x170]
718 stp d14,d15, [x0, #0x180]
719 stp d16,d17, [x0, #0x190]
720 stp d18,d19, [x0, #0x1A0]
721 stp d20,d21, [x0, #0x1B0]
722 stp d22,d23, [x0, #0x1C0]
723 stp d24,d25, [x0, #0x1D0]
724 stp d26,d27, [x0, #0x1E0]
725 stp d28,d29, [x0, #0x1F0]
726 str d30, [x0, #0x200]
727 str d31, [x0, #0x208]
728 mov x0, #0 // return UNW_ESUCCESS
731 #elif defined(__arm__) && !defined(__APPLE__)
733 #if !defined(__ARM_ARCH_ISA_ARM)
734 #if (__ARM_ARCH_ISA_THUMB == 2)
741 @ extern int __unw_getcontext(unw_context_t* thread_state)
744 @ thread_state pointer is in r0
746 @ Per EHABI #4.7 this only saves the core integer registers.
747 @ EHABI #7.4.5 notes that in general all VRS registers should be restored
748 @ however this is very hard to do for VFP registers because it is unknown
749 @ to the library how many registers are implemented by the architecture.
750 @ Instead, VFP registers are demand saved by logic external to __unw_getcontext.
753 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
754 #if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1
763 str r1, [r0, #0] @ r11
764 @ r12 does not need storing, it it the intra-procedure-call scratch register
765 str r2, [r0, #8] @ sp
766 str r3, [r0, #12] @ lr
767 str r3, [r0, #16] @ store return address as pc
768 @ T1 does not have a non-cpsr-clobbering register-zeroing instruction.
769 @ It is safe to use here though because we are about to return, and cpsr is
770 @ not expected to be preserved.
771 movs r0, #0 @ return UNW_ESUCCESS
773 @ 32bit thumb-2 restrictions for stm:
774 @ . the sp (r13) cannot be in the list
775 @ . the pc (r15) cannot be in the list in an STM instruction
779 str lr, [r0, #60] @ store return address as pc
780 mov r0, #0 @ return UNW_ESUCCESS
785 @ static void libunwind::Registers_arm::saveVFPWithFSTMD(unw_fpreg_t* values)
788 @ values pointer is in r0
794 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMDEPv)
799 @ static void libunwind::Registers_arm::saveVFPWithFSTMX(unw_fpreg_t* values)
802 @ values pointer is in r0
808 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMXEPv)
809 vstmia r0, {d0-d15} @ fstmiax is deprecated in ARMv7+ and now behaves like vstmia
813 @ static void libunwind::Registers_arm::saveVFPv3(unw_fpreg_t* values)
816 @ values pointer is in r0
822 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPv)
823 @ VFP and iwMMX instructions are only available when compiling with the flags
824 @ that enable them. We do not want to do that in the library (because we do not
825 @ want the compiler to generate instructions that access those) but this is
826 @ only accessed if the personality routine needs these registers. Use of
827 @ these registers implies they are, actually, available on the target, so
828 @ it's ok to execute.
829 @ So, generate the instructions using the corresponding coprocessor mnemonic.
833 #if defined(_LIBUNWIND_ARM_WMMX)
836 @ static void libunwind::Registers_arm::saveiWMMX(unw_fpreg_t* values)
839 @ values pointer is in r0
845 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPv)
846 stcl p1, cr0, [r0], #8 @ wstrd wR0, [r0], #8
847 stcl p1, cr1, [r0], #8 @ wstrd wR1, [r0], #8
848 stcl p1, cr2, [r0], #8 @ wstrd wR2, [r0], #8
849 stcl p1, cr3, [r0], #8 @ wstrd wR3, [r0], #8
850 stcl p1, cr4, [r0], #8 @ wstrd wR4, [r0], #8
851 stcl p1, cr5, [r0], #8 @ wstrd wR5, [r0], #8
852 stcl p1, cr6, [r0], #8 @ wstrd wR6, [r0], #8
853 stcl p1, cr7, [r0], #8 @ wstrd wR7, [r0], #8
854 stcl p1, cr8, [r0], #8 @ wstrd wR8, [r0], #8
855 stcl p1, cr9, [r0], #8 @ wstrd wR9, [r0], #8
856 stcl p1, cr10, [r0], #8 @ wstrd wR10, [r0], #8
857 stcl p1, cr11, [r0], #8 @ wstrd wR11, [r0], #8
858 stcl p1, cr12, [r0], #8 @ wstrd wR12, [r0], #8
859 stcl p1, cr13, [r0], #8 @ wstrd wR13, [r0], #8
860 stcl p1, cr14, [r0], #8 @ wstrd wR14, [r0], #8
861 stcl p1, cr15, [r0], #8 @ wstrd wR15, [r0], #8
865 @ static void libunwind::Registers_arm::saveiWMMXControl(unw_uint32_t* values)
868 @ values pointer is in r0
874 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControlEPj)
875 stc2 p1, cr8, [r0], #4 @ wstrw wCGR0, [r0], #4
876 stc2 p1, cr9, [r0], #4 @ wstrw wCGR1, [r0], #4
877 stc2 p1, cr10, [r0], #4 @ wstrw wCGR2, [r0], #4
878 stc2 p1, cr11, [r0], #4 @ wstrw wCGR3, [r0], #4
883 #elif defined(__or1k__)
886 # extern int __unw_getcontext(unw_context_t* thread_state)
889 # thread_state pointer is in r3
891 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
929 #elif defined(__hexagon__)
931 # extern int unw_getcontext(unw_context_t* thread_state)
934 # thread_state pointer is in r0
936 #define OFFSET(offset) (offset/4)
937 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
967 r1 = c4 // Predicate register
969 r1 = memw(r30) // *FP == Saved FP
975 #elif defined(__sparc__) && defined(__arch64__)
978 # extern int __unw_getcontext(unw_context_t* thread_state)
981 # thread_state pointer is in %o0
983 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
984 .register %g2, #scratch
985 .register %g3, #scratch
986 .register %g6, #scratch
987 .register %g7, #scratch
988 stx %g1, [%o0 + 0x08]
989 stx %g2, [%o0 + 0x10]
990 stx %g3, [%o0 + 0x18]
991 stx %g4, [%o0 + 0x20]
992 stx %g5, [%o0 + 0x28]
993 stx %g6, [%o0 + 0x30]
994 stx %g7, [%o0 + 0x38]
995 stx %o0, [%o0 + 0x40]
996 stx %o1, [%o0 + 0x48]
997 stx %o2, [%o0 + 0x50]
998 stx %o3, [%o0 + 0x58]
999 stx %o4, [%o0 + 0x60]
1000 stx %o5, [%o0 + 0x68]
1001 stx %o6, [%o0 + 0x70]
1002 stx %o7, [%o0 + 0x78]
1003 stx %l0, [%o0 + 0x80]
1004 stx %l1, [%o0 + 0x88]
1005 stx %l2, [%o0 + 0x90]
1006 stx %l3, [%o0 + 0x98]
1007 stx %l4, [%o0 + 0xa0]
1008 stx %l5, [%o0 + 0xa8]
1009 stx %l6, [%o0 + 0xb0]
1010 stx %l7, [%o0 + 0xb8]
1011 stx %i0, [%o0 + 0xc0]
1012 stx %i1, [%o0 + 0xc8]
1013 stx %i2, [%o0 + 0xd0]
1014 stx %i3, [%o0 + 0xd8]
1015 stx %i4, [%o0 + 0xe0]
1016 stx %i5, [%o0 + 0xe8]
1017 stx %i6, [%o0 + 0xf0]
1018 stx %i7, [%o0 + 0xf8]
1020 # save StackGhost cookie
1023 # register window flush necessary even without StackGhost
1026 ldx [%sp + 2047 + 0x78], %g5
1028 stx %g4, [%o0 + 0x100]
1030 # return UNW_ESUCCESS
1033 #elif defined(__sparc__)
1036 # extern int __unw_getcontext(unw_context_t* thread_state)
1039 # thread_state pointer is in o0
1041 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1057 std %i2, [%o0 + 104]
1058 std %i4, [%o0 + 112]
1059 std %i6, [%o0 + 120]
1061 clr %o0 // return UNW_ESUCCESS
1063 #elif defined(__riscv)
1066 # extern int __unw_getcontext(unw_context_t* thread_state)
1069 # thread_state pointer is in a0
1071 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1072 ISTORE x1, (RISCV_ISIZE * 0)(a0) // store ra as pc
1073 .irp i,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
1074 ISTORE x\i, (RISCV_ISIZE * \i)(a0)
1077 # if defined(__riscv_flen)
1079 FSTORE f\i, (RISCV_FOFFSET + RISCV_FSIZE * \i)(a0)
1083 li a0, 0 // return UNW_ESUCCESS
1086 #elif defined(__s390x__)
1089 // extern int __unw_getcontext(unw_context_t* thread_state)
1092 // thread_state pointer is in r2
1094 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1097 stmg %r0, %r15, 16(%r2)
1101 stm %r0, %r1, 0(%r2)
1103 // Store return address as PSWA
1108 std %f\i, (144+8*\i)(%r2)
1111 // Return UNW_ESUCCESS
1115 #elif defined(__loongarch__) && __loongarch_grlen == 64
1118 # extern int __unw_getcontext(unw_context_t* thread_state)
1121 # thread_state pointer is in $a0($r4)
1123 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1124 .irp i,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
1125 st.d $r\i, $a0, (8*\i)
1127 st.d $r1, $a0, (8 * 32) // store $ra to pc
1129 # if __loongarch_frlen == 64
1131 fst.d $f\i, $a0, (8 * 33 + 8 * \i)
1135 move $a0, $zero // UNW_ESUCCESS
1140 WEAK_ALIAS(__unw_getcontext, unw_getcontext)
1142 #endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */
1144 NO_EXEC_STACK_DIRECTIVE