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
177 #if __mips_isa_rev < 6
184 #ifdef __mips_hard_float
186 sdc1 $f0, (4 * 36 + 8 * 0)($4)
187 sdc1 $f2, (4 * 36 + 8 * 2)($4)
188 sdc1 $f4, (4 * 36 + 8 * 4)($4)
189 sdc1 $f6, (4 * 36 + 8 * 6)($4)
190 sdc1 $f8, (4 * 36 + 8 * 8)($4)
191 sdc1 $f10, (4 * 36 + 8 * 10)($4)
192 sdc1 $f12, (4 * 36 + 8 * 12)($4)
193 sdc1 $f14, (4 * 36 + 8 * 14)($4)
194 sdc1 $f16, (4 * 36 + 8 * 16)($4)
195 sdc1 $f18, (4 * 36 + 8 * 18)($4)
196 sdc1 $f20, (4 * 36 + 8 * 20)($4)
197 sdc1 $f22, (4 * 36 + 8 * 22)($4)
198 sdc1 $f24, (4 * 36 + 8 * 24)($4)
199 sdc1 $f26, (4 * 36 + 8 * 26)($4)
200 sdc1 $f28, (4 * 36 + 8 * 28)($4)
201 sdc1 $f30, (4 * 36 + 8 * 30)($4)
203 sdc1 $f0, (4 * 36 + 8 * 0)($4)
204 sdc1 $f1, (4 * 36 + 8 * 1)($4)
205 sdc1 $f2, (4 * 36 + 8 * 2)($4)
206 sdc1 $f3, (4 * 36 + 8 * 3)($4)
207 sdc1 $f4, (4 * 36 + 8 * 4)($4)
208 sdc1 $f5, (4 * 36 + 8 * 5)($4)
209 sdc1 $f6, (4 * 36 + 8 * 6)($4)
210 sdc1 $f7, (4 * 36 + 8 * 7)($4)
211 sdc1 $f8, (4 * 36 + 8 * 8)($4)
212 sdc1 $f9, (4 * 36 + 8 * 9)($4)
213 sdc1 $f10, (4 * 36 + 8 * 10)($4)
214 sdc1 $f11, (4 * 36 + 8 * 11)($4)
215 sdc1 $f12, (4 * 36 + 8 * 12)($4)
216 sdc1 $f13, (4 * 36 + 8 * 13)($4)
217 sdc1 $f14, (4 * 36 + 8 * 14)($4)
218 sdc1 $f15, (4 * 36 + 8 * 15)($4)
219 sdc1 $f16, (4 * 36 + 8 * 16)($4)
220 sdc1 $f17, (4 * 36 + 8 * 17)($4)
221 sdc1 $f18, (4 * 36 + 8 * 18)($4)
222 sdc1 $f19, (4 * 36 + 8 * 19)($4)
223 sdc1 $f20, (4 * 36 + 8 * 20)($4)
224 sdc1 $f21, (4 * 36 + 8 * 21)($4)
225 sdc1 $f22, (4 * 36 + 8 * 22)($4)
226 sdc1 $f23, (4 * 36 + 8 * 23)($4)
227 sdc1 $f24, (4 * 36 + 8 * 24)($4)
228 sdc1 $f25, (4 * 36 + 8 * 25)($4)
229 sdc1 $f26, (4 * 36 + 8 * 26)($4)
230 sdc1 $f27, (4 * 36 + 8 * 27)($4)
231 sdc1 $f28, (4 * 36 + 8 * 28)($4)
232 sdc1 $f29, (4 * 36 + 8 * 29)($4)
233 sdc1 $f30, (4 * 36 + 8 * 30)($4)
234 sdc1 $f31, (4 * 36 + 8 * 31)($4)
238 # return UNW_ESUCCESS
242 #elif defined(__mips64)
245 # extern int __unw_getcontext(unw_context_t* thread_state)
248 # thread_state pointer is in a0 ($4)
250 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
255 .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
258 # Store return address to pc
260 #if __mips_isa_rev < 6
267 #ifdef __mips_hard_float
269 sdc1 $f\i, (280+8*\i)($4)
273 # return UNW_ESUCCESS
277 # elif defined(__mips__)
280 # extern int __unw_getcontext(unw_context_t* thread_state)
282 # Just trap for the time being.
283 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
286 #elif defined(__powerpc64__)
289 // extern int __unw_getcontext(unw_context_t* thread_state)
292 // thread_state pointer is in r3
295 DEFINE_LIBUNWIND_FUNCTION_AND_WEAK_ALIAS(__unw_getcontext, unw_getcontext)
297 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
299 // store register (GPR)
300 #define PPC64_STR(n) \
301 std n, (8 * (n + 2))(3)
306 std 0, PPC64_OFFS_SRR0(3) // store lr as ssr0
340 std 0, PPC64_OFFS_CR(3)
342 std 0, PPC64_OFFS_XER(3)
344 std 0, PPC64_OFFS_LR(3)
346 std 0, PPC64_OFFS_CTR(3)
348 std 0, PPC64_OFFS_VRSAVE(3)
352 // (note that this also saves floating point registers and V registers,
353 // because part of VS is mapped to these registers)
355 addi 4, 3, PPC64_OFFS_FP
358 #ifdef __LITTLE_ENDIAN__
359 // For little-endian targets, we need a swap since stxvd2x will store the
360 // register in the incorrect doubleword order.
361 // FIXME: when supporting targets older than Power9 on LE is no longer required
362 // this can be changed to simply `stxv n, 16 * n(4)`.
363 #define PPC64_STVS(n) \
368 #define PPC64_STVS(n) \
441 #define PPC64_STF(n) \
442 stfd n, (PPC64_OFFS_FP + n * 16)(3)
444 // save float registers
478 #if defined(__ALTIVEC__)
479 // save vector registers
481 // Use 16-bytes below the stack pointer as an
482 // aligned buffer to save each vector register.
483 // Note that the stack pointer is always 16-byte aligned.
486 #define PPC64_STV_UNALIGNED(n) \
489 std 5, (PPC64_OFFS_V + n * 16)(3) ;\
491 std 5, (PPC64_OFFS_V + n * 16 + 8)(3)
493 PPC64_STV_UNALIGNED(0)
494 PPC64_STV_UNALIGNED(1)
495 PPC64_STV_UNALIGNED(2)
496 PPC64_STV_UNALIGNED(3)
497 PPC64_STV_UNALIGNED(4)
498 PPC64_STV_UNALIGNED(5)
499 PPC64_STV_UNALIGNED(6)
500 PPC64_STV_UNALIGNED(7)
501 PPC64_STV_UNALIGNED(8)
502 PPC64_STV_UNALIGNED(9)
503 PPC64_STV_UNALIGNED(10)
504 PPC64_STV_UNALIGNED(11)
505 PPC64_STV_UNALIGNED(12)
506 PPC64_STV_UNALIGNED(13)
507 PPC64_STV_UNALIGNED(14)
508 PPC64_STV_UNALIGNED(15)
509 PPC64_STV_UNALIGNED(16)
510 PPC64_STV_UNALIGNED(17)
511 PPC64_STV_UNALIGNED(18)
512 PPC64_STV_UNALIGNED(19)
513 PPC64_STV_UNALIGNED(20)
514 PPC64_STV_UNALIGNED(21)
515 PPC64_STV_UNALIGNED(22)
516 PPC64_STV_UNALIGNED(23)
517 PPC64_STV_UNALIGNED(24)
518 PPC64_STV_UNALIGNED(25)
519 PPC64_STV_UNALIGNED(26)
520 PPC64_STV_UNALIGNED(27)
521 PPC64_STV_UNALIGNED(28)
522 PPC64_STV_UNALIGNED(29)
523 PPC64_STV_UNALIGNED(30)
524 PPC64_STV_UNALIGNED(31)
529 li 3, 0 // return UNW_ESUCCESS
533 #elif defined(__powerpc__)
536 // extern int unw_getcontext(unw_context_t* thread_state)
539 // thread_state pointer is in r3
542 DEFINE_LIBUNWIND_FUNCTION_AND_WEAK_ALIAS(__unw_getcontext, unw_getcontext)
544 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
548 stw 0, 0(3) // store lr as ssr0
581 #if defined(__ALTIVEC__)
582 // save VRSave register
593 #if !defined(__NO_FPRS__)
594 // save float registers
629 #if defined(__ALTIVEC__)
630 // save vector registers
633 rlwinm 4, 4, 0, 0, 27 // mask low 4-bits
634 // r4 is now a 16-byte aligned pointer into the red zone
636 #define SAVE_VECTOR_UNALIGNED(_vec, _offset) \
637 stvx _vec, 0, 4 SEPARATOR \
638 lwz 5, 0(4) SEPARATOR \
639 stw 5, _offset(3) SEPARATOR \
640 lwz 5, 4(4) SEPARATOR \
641 stw 5, _offset+4(3) SEPARATOR \
642 lwz 5, 8(4) SEPARATOR \
643 stw 5, _offset+8(3) SEPARATOR \
644 lwz 5, 12(4) SEPARATOR \
647 SAVE_VECTOR_UNALIGNED( 0, 424+0x000)
648 SAVE_VECTOR_UNALIGNED( 1, 424+0x010)
649 SAVE_VECTOR_UNALIGNED( 2, 424+0x020)
650 SAVE_VECTOR_UNALIGNED( 3, 424+0x030)
651 SAVE_VECTOR_UNALIGNED( 4, 424+0x040)
652 SAVE_VECTOR_UNALIGNED( 5, 424+0x050)
653 SAVE_VECTOR_UNALIGNED( 6, 424+0x060)
654 SAVE_VECTOR_UNALIGNED( 7, 424+0x070)
655 SAVE_VECTOR_UNALIGNED( 8, 424+0x080)
656 SAVE_VECTOR_UNALIGNED( 9, 424+0x090)
657 SAVE_VECTOR_UNALIGNED(10, 424+0x0A0)
658 SAVE_VECTOR_UNALIGNED(11, 424+0x0B0)
659 SAVE_VECTOR_UNALIGNED(12, 424+0x0C0)
660 SAVE_VECTOR_UNALIGNED(13, 424+0x0D0)
661 SAVE_VECTOR_UNALIGNED(14, 424+0x0E0)
662 SAVE_VECTOR_UNALIGNED(15, 424+0x0F0)
663 SAVE_VECTOR_UNALIGNED(16, 424+0x100)
664 SAVE_VECTOR_UNALIGNED(17, 424+0x110)
665 SAVE_VECTOR_UNALIGNED(18, 424+0x120)
666 SAVE_VECTOR_UNALIGNED(19, 424+0x130)
667 SAVE_VECTOR_UNALIGNED(20, 424+0x140)
668 SAVE_VECTOR_UNALIGNED(21, 424+0x150)
669 SAVE_VECTOR_UNALIGNED(22, 424+0x160)
670 SAVE_VECTOR_UNALIGNED(23, 424+0x170)
671 SAVE_VECTOR_UNALIGNED(24, 424+0x180)
672 SAVE_VECTOR_UNALIGNED(25, 424+0x190)
673 SAVE_VECTOR_UNALIGNED(26, 424+0x1A0)
674 SAVE_VECTOR_UNALIGNED(27, 424+0x1B0)
675 SAVE_VECTOR_UNALIGNED(28, 424+0x1C0)
676 SAVE_VECTOR_UNALIGNED(29, 424+0x1D0)
677 SAVE_VECTOR_UNALIGNED(30, 424+0x1E0)
678 SAVE_VECTOR_UNALIGNED(31, 424+0x1F0)
681 li 3, 0 // return UNW_ESUCCESS
685 #elif defined(__aarch64__)
688 // extern int __unw_getcontext(unw_context_t* thread_state)
691 // thread_state pointer is in x0
694 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
695 stp x0, x1, [x0, #0x000]
696 stp x2, x3, [x0, #0x010]
697 stp x4, x5, [x0, #0x020]
698 stp x6, x7, [x0, #0x030]
699 stp x8, x9, [x0, #0x040]
700 stp x10,x11, [x0, #0x050]
701 stp x12,x13, [x0, #0x060]
702 stp x14,x15, [x0, #0x070]
703 stp x16,x17, [x0, #0x080]
704 stp x18,x19, [x0, #0x090]
705 stp x20,x21, [x0, #0x0A0]
706 stp x22,x23, [x0, #0x0B0]
707 stp x24,x25, [x0, #0x0C0]
708 stp x26,x27, [x0, #0x0D0]
709 stp x28,x29, [x0, #0x0E0]
710 str x30, [x0, #0x0F0]
713 str x30, [x0, #0x100] // store return address as pc
715 stp d0, d1, [x0, #0x110]
716 stp d2, d3, [x0, #0x120]
717 stp d4, d5, [x0, #0x130]
718 stp d6, d7, [x0, #0x140]
719 stp d8, d9, [x0, #0x150]
720 stp d10,d11, [x0, #0x160]
721 stp d12,d13, [x0, #0x170]
722 stp d14,d15, [x0, #0x180]
723 stp d16,d17, [x0, #0x190]
724 stp d18,d19, [x0, #0x1A0]
725 stp d20,d21, [x0, #0x1B0]
726 stp d22,d23, [x0, #0x1C0]
727 stp d24,d25, [x0, #0x1D0]
728 stp d26,d27, [x0, #0x1E0]
729 stp d28,d29, [x0, #0x1F0]
730 str d30, [x0, #0x200]
731 str d31, [x0, #0x208]
732 mov x0, #0 // return UNW_ESUCCESS
735 #elif defined(__arm__) && !defined(__APPLE__)
737 #if !defined(__ARM_ARCH_ISA_ARM)
738 #if (__ARM_ARCH_ISA_THUMB == 2)
745 @ extern int __unw_getcontext(unw_context_t* thread_state)
748 @ thread_state pointer is in r0
750 @ Per EHABI #4.7 this only saves the core integer registers.
751 @ EHABI #7.4.5 notes that in general all VRS registers should be restored
752 @ however this is very hard to do for VFP registers because it is unknown
753 @ to the library how many registers are implemented by the architecture.
754 @ Instead, VFP registers are demand saved by logic external to __unw_getcontext.
757 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
758 #if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1
767 str r1, [r0, #0] @ r11
768 @ r12 does not need storing, it it the intra-procedure-call scratch register
769 str r2, [r0, #8] @ sp
770 str r3, [r0, #12] @ lr
771 str r3, [r0, #16] @ store return address as pc
772 @ T1 does not have a non-cpsr-clobbering register-zeroing instruction.
773 @ It is safe to use here though because we are about to return, and cpsr is
774 @ not expected to be preserved.
775 movs r0, #0 @ return UNW_ESUCCESS
777 @ 32bit thumb-2 restrictions for stm:
778 @ . the sp (r13) cannot be in the list
779 @ . the pc (r15) cannot be in the list in an STM instruction
783 str lr, [r0, #60] @ store return address as pc
784 mov r0, #0 @ return UNW_ESUCCESS
789 @ static void libunwind::Registers_arm::saveVFPWithFSTMD(unw_fpreg_t* values)
792 @ values pointer is in r0
798 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMDEPv)
803 @ static void libunwind::Registers_arm::saveVFPWithFSTMX(unw_fpreg_t* values)
806 @ values pointer is in r0
812 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMXEPv)
813 vstmia r0, {d0-d15} @ fstmiax is deprecated in ARMv7+ and now behaves like vstmia
817 @ static void libunwind::Registers_arm::saveVFPv3(unw_fpreg_t* values)
820 @ values pointer is in r0
826 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPv)
827 @ VFP and iwMMX instructions are only available when compiling with the flags
828 @ that enable them. We do not want to do that in the library (because we do not
829 @ want the compiler to generate instructions that access those) but this is
830 @ only accessed if the personality routine needs these registers. Use of
831 @ these registers implies they are, actually, available on the target, so
832 @ it's ok to execute.
833 @ So, generate the instructions using the corresponding coprocessor mnemonic.
837 #if defined(_LIBUNWIND_ARM_WMMX)
840 @ static void libunwind::Registers_arm::saveiWMMX(unw_fpreg_t* values)
843 @ values pointer is in r0
849 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPv)
850 stcl p1, cr0, [r0], #8 @ wstrd wR0, [r0], #8
851 stcl p1, cr1, [r0], #8 @ wstrd wR1, [r0], #8
852 stcl p1, cr2, [r0], #8 @ wstrd wR2, [r0], #8
853 stcl p1, cr3, [r0], #8 @ wstrd wR3, [r0], #8
854 stcl p1, cr4, [r0], #8 @ wstrd wR4, [r0], #8
855 stcl p1, cr5, [r0], #8 @ wstrd wR5, [r0], #8
856 stcl p1, cr6, [r0], #8 @ wstrd wR6, [r0], #8
857 stcl p1, cr7, [r0], #8 @ wstrd wR7, [r0], #8
858 stcl p1, cr8, [r0], #8 @ wstrd wR8, [r0], #8
859 stcl p1, cr9, [r0], #8 @ wstrd wR9, [r0], #8
860 stcl p1, cr10, [r0], #8 @ wstrd wR10, [r0], #8
861 stcl p1, cr11, [r0], #8 @ wstrd wR11, [r0], #8
862 stcl p1, cr12, [r0], #8 @ wstrd wR12, [r0], #8
863 stcl p1, cr13, [r0], #8 @ wstrd wR13, [r0], #8
864 stcl p1, cr14, [r0], #8 @ wstrd wR14, [r0], #8
865 stcl p1, cr15, [r0], #8 @ wstrd wR15, [r0], #8
869 @ static void libunwind::Registers_arm::saveiWMMXControl(unw_uint32_t* values)
872 @ values pointer is in r0
878 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControlEPj)
879 stc2 p1, cr8, [r0], #4 @ wstrw wCGR0, [r0], #4
880 stc2 p1, cr9, [r0], #4 @ wstrw wCGR1, [r0], #4
881 stc2 p1, cr10, [r0], #4 @ wstrw wCGR2, [r0], #4
882 stc2 p1, cr11, [r0], #4 @ wstrw wCGR3, [r0], #4
887 #elif defined(__or1k__)
890 # extern int __unw_getcontext(unw_context_t* thread_state)
893 # thread_state pointer is in r3
895 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
933 #elif defined(__hexagon__)
935 # extern int unw_getcontext(unw_context_t* thread_state)
938 # thread_state pointer is in r0
940 #define OFFSET(offset) (offset/4)
941 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
971 r1 = c4 // Predicate register
973 r1 = memw(r30) // *FP == Saved FP
979 #elif defined(__sparc__) && defined(__arch64__)
982 # extern int __unw_getcontext(unw_context_t* thread_state)
985 # thread_state pointer is in %o0
987 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
988 .register %g2, #scratch
989 .register %g3, #scratch
990 .register %g6, #scratch
991 .register %g7, #scratch
992 stx %g1, [%o0 + 0x08]
993 stx %g2, [%o0 + 0x10]
994 stx %g3, [%o0 + 0x18]
995 stx %g4, [%o0 + 0x20]
996 stx %g5, [%o0 + 0x28]
997 stx %g6, [%o0 + 0x30]
998 stx %g7, [%o0 + 0x38]
999 stx %o0, [%o0 + 0x40]
1000 stx %o1, [%o0 + 0x48]
1001 stx %o2, [%o0 + 0x50]
1002 stx %o3, [%o0 + 0x58]
1003 stx %o4, [%o0 + 0x60]
1004 stx %o5, [%o0 + 0x68]
1005 stx %o6, [%o0 + 0x70]
1006 stx %o7, [%o0 + 0x78]
1007 stx %l0, [%o0 + 0x80]
1008 stx %l1, [%o0 + 0x88]
1009 stx %l2, [%o0 + 0x90]
1010 stx %l3, [%o0 + 0x98]
1011 stx %l4, [%o0 + 0xa0]
1012 stx %l5, [%o0 + 0xa8]
1013 stx %l6, [%o0 + 0xb0]
1014 stx %l7, [%o0 + 0xb8]
1015 stx %i0, [%o0 + 0xc0]
1016 stx %i1, [%o0 + 0xc8]
1017 stx %i2, [%o0 + 0xd0]
1018 stx %i3, [%o0 + 0xd8]
1019 stx %i4, [%o0 + 0xe0]
1020 stx %i5, [%o0 + 0xe8]
1021 stx %i6, [%o0 + 0xf0]
1022 stx %i7, [%o0 + 0xf8]
1024 # save StackGhost cookie
1027 # register window flush necessary even without StackGhost
1030 ldx [%sp + 2047 + 0x78], %g5
1032 stx %g4, [%o0 + 0x100]
1034 # return UNW_ESUCCESS
1037 #elif defined(__sparc__)
1040 # extern int __unw_getcontext(unw_context_t* thread_state)
1043 # thread_state pointer is in o0
1045 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1061 std %i2, [%o0 + 104]
1062 std %i4, [%o0 + 112]
1063 std %i6, [%o0 + 120]
1065 clr %o0 // return UNW_ESUCCESS
1067 #elif defined(__riscv)
1070 # extern int __unw_getcontext(unw_context_t* thread_state)
1073 # thread_state pointer is in a0
1075 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1076 ISTORE x1, (RISCV_ISIZE * 0)(a0) // store ra as pc
1077 .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
1078 ISTORE x\i, (RISCV_ISIZE * \i)(a0)
1081 # if defined(__riscv_flen)
1083 FSTORE f\i, (RISCV_FOFFSET + RISCV_FSIZE * \i)(a0)
1087 li a0, 0 // return UNW_ESUCCESS
1090 #elif defined(__s390x__)
1093 // extern int __unw_getcontext(unw_context_t* thread_state)
1096 // thread_state pointer is in r2
1098 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1101 stmg %r0, %r15, 16(%r2)
1105 stm %r0, %r1, 0(%r2)
1107 // Store return address as PSWA
1112 std %f\i, (144+8*\i)(%r2)
1115 // Return UNW_ESUCCESS
1119 #elif defined(__loongarch__) && __loongarch_grlen == 64
1122 # extern int __unw_getcontext(unw_context_t* thread_state)
1125 # thread_state pointer is in $a0($r4)
1127 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1128 .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
1129 st.d $r\i, $a0, (8*\i)
1131 st.d $r1, $a0, (8 * 32) // store $ra to pc
1133 # if __loongarch_frlen == 64
1135 fst.d $f\i, $a0, (8 * 33 + 8 * \i)
1139 move $a0, $zero // UNW_ESUCCESS
1144 WEAK_ALIAS(__unw_getcontext, unw_getcontext)
1146 #endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */
1148 NO_EXEC_STACK_DIRECTIVE