OLD | NEW |
(Empty) | |
| 1 //===------------------------ UnwindRegistersSave.s -----------------------===// |
| 2 // |
| 3 // The LLVM Compiler Infrastructure |
| 4 // |
| 5 // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 // Source Licenses. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 |
| 10 |
| 11 .text |
| 12 |
| 13 #if __i386__ |
| 14 |
| 15 # |
| 16 # extern int unw_getcontext(unw_context_t* thread_state) |
| 17 # |
| 18 # On entry: |
| 19 # + + |
| 20 # +-----------------------+ |
| 21 # + thread_state pointer + |
| 22 # +-----------------------+ |
| 23 # + return address + |
| 24 # +-----------------------+ <-- SP |
| 25 # + + |
| 26 # |
| 27 .globl _unw_getcontext |
| 28 _unw_getcontext: |
| 29 push %eax |
| 30 movl 8(%esp), %eax |
| 31 movl %ebx, 4(%eax) |
| 32 movl %ecx, 8(%eax) |
| 33 movl %edx, 12(%eax) |
| 34 movl %edi, 16(%eax) |
| 35 movl %esi, 20(%eax) |
| 36 movl %ebp, 24(%eax) |
| 37 movl %esp, %edx |
| 38 addl $8, %edx |
| 39 movl %edx, 28(%eax) # store what sp was at call site as esp |
| 40 # skip ss |
| 41 # skip eflags |
| 42 movl 4(%esp), %edx |
| 43 movl %edx, 40(%eax) # store return address as eip |
| 44 # skip cs |
| 45 # skip ds |
| 46 # skip es |
| 47 # skip fs |
| 48 # skip gs |
| 49 movl (%esp), %edx |
| 50 movl %edx, (%eax) # store original eax |
| 51 popl %eax |
| 52 xorl %eax, %eax # return UNW_ESUCCESS |
| 53 ret |
| 54 |
| 55 #elif __x86_64__ |
| 56 |
| 57 # |
| 58 # extern int unw_getcontext(unw_context_t* thread_state) |
| 59 # |
| 60 # On entry: |
| 61 # thread_state pointer is in rdi |
| 62 # |
| 63 .globl _unw_getcontext |
| 64 _unw_getcontext: |
| 65 movq %rax, (%rdi) |
| 66 movq %rbx, 8(%rdi) |
| 67 movq %rcx, 16(%rdi) |
| 68 movq %rdx, 24(%rdi) |
| 69 movq %rdi, 32(%rdi) |
| 70 movq %rsi, 40(%rdi) |
| 71 movq %rbp, 48(%rdi) |
| 72 movq %rsp, 56(%rdi) |
| 73 addq $8, 56(%rdi) |
| 74 movq %r8, 64(%rdi) |
| 75 movq %r9, 72(%rdi) |
| 76 movq %r10, 80(%rdi) |
| 77 movq %r11, 88(%rdi) |
| 78 movq %r12, 96(%rdi) |
| 79 movq %r13,104(%rdi) |
| 80 movq %r14,112(%rdi) |
| 81 movq %r15,120(%rdi) |
| 82 movq (%rsp),%rsi |
| 83 movq %rsi,128(%rdi) # store return address as rip |
| 84 # skip rflags |
| 85 # skip cs |
| 86 # skip fs |
| 87 # skip gs |
| 88 xorl %eax, %eax # return UNW_ESUCCESS |
| 89 ret |
| 90 |
| 91 #elif __ppc__ |
| 92 |
| 93 ; |
| 94 ; extern int unw_getcontext(unw_context_t* thread_state) |
| 95 ; |
| 96 ; On entry: |
| 97 ; thread_state pointer is in r3 |
| 98 ; |
| 99 .globl _unw_getcontext |
| 100 _unw_getcontext: |
| 101 stw r0, 8(r3) |
| 102 mflr r0 |
| 103 stw r0, 0(r3) ; store lr as ssr0 |
| 104 stw r1, 12(r3) |
| 105 stw r2, 16(r3) |
| 106 stw r3, 20(r3) |
| 107 stw r4, 24(r3) |
| 108 stw r5, 28(r3) |
| 109 stw r6, 32(r3) |
| 110 stw r7, 36(r3) |
| 111 stw r8, 40(r3) |
| 112 stw r9, 44(r3) |
| 113 stw r10, 48(r3) |
| 114 stw r11, 52(r3) |
| 115 stw r12, 56(r3) |
| 116 stw r13, 60(r3) |
| 117 stw r14, 64(r3) |
| 118 stw r15, 68(r3) |
| 119 stw r16, 72(r3) |
| 120 stw r17, 76(r3) |
| 121 stw r18, 80(r3) |
| 122 stw r19, 84(r3) |
| 123 stw r20, 88(r3) |
| 124 stw r21, 92(r3) |
| 125 stw r22, 96(r3) |
| 126 stw r23,100(r3) |
| 127 stw r24,104(r3) |
| 128 stw r25,108(r3) |
| 129 stw r26,112(r3) |
| 130 stw r27,116(r3) |
| 131 stw r28,120(r3) |
| 132 stw r29,124(r3) |
| 133 stw r30,128(r3) |
| 134 stw r31,132(r3) |
| 135 |
| 136 ; save VRSave register |
| 137 mfspr r0,256 |
| 138 stw r0,156(r3) |
| 139 ; save CR registers |
| 140 mfcr r0 |
| 141 stw r0,136(r3) |
| 142 ; save CTR register |
| 143 mfctr r0 |
| 144 stw r0,148(r3) |
| 145 |
| 146 ; save float registers |
| 147 stfd f0, 160(r3) |
| 148 stfd f1, 168(r3) |
| 149 stfd f2, 176(r3) |
| 150 stfd f3, 184(r3) |
| 151 stfd f4, 192(r3) |
| 152 stfd f5, 200(r3) |
| 153 stfd f6, 208(r3) |
| 154 stfd f7, 216(r3) |
| 155 stfd f8, 224(r3) |
| 156 stfd f9, 232(r3) |
| 157 stfd f10,240(r3) |
| 158 stfd f11,248(r3) |
| 159 stfd f12,256(r3) |
| 160 stfd f13,264(r3) |
| 161 stfd f14,272(r3) |
| 162 stfd f15,280(r3) |
| 163 stfd f16,288(r3) |
| 164 stfd f17,296(r3) |
| 165 stfd f18,304(r3) |
| 166 stfd f19,312(r3) |
| 167 stfd f20,320(r3) |
| 168 stfd f21,328(r3) |
| 169 stfd f22,336(r3) |
| 170 stfd f23,344(r3) |
| 171 stfd f24,352(r3) |
| 172 stfd f25,360(r3) |
| 173 stfd f26,368(r3) |
| 174 stfd f27,376(r3) |
| 175 stfd f28,384(r3) |
| 176 stfd f29,392(r3) |
| 177 stfd f30,400(r3) |
| 178 stfd f31,408(r3) |
| 179 |
| 180 |
| 181 ; save vector registers |
| 182 |
| 183 subi r4,r1,16 |
| 184 rlwinm r4,r4,0,0,27 ; mask low 4-bits |
| 185 ; r4 is now a 16-byte aligned pointer into the red zone |
| 186 |
| 187 #define SAVE_VECTOR_UNALIGNED(_vec, _offset) \ |
| 188 stvx _vec,0,r4 @\ |
| 189 lwz r5, 0(r4) @\ |
| 190 stw r5, _offset(r3) @\ |
| 191 lwz r5, 4(r4) @\ |
| 192 stw r5, _offset+4(r3) @\ |
| 193 lwz r5, 8(r4) @\ |
| 194 stw r5, _offset+8(r3) @\ |
| 195 lwz r5, 12(r4) @\ |
| 196 stw r5, _offset+12(r3) |
| 197 |
| 198 SAVE_VECTOR_UNALIGNED( v0, 424+0x000) |
| 199 SAVE_VECTOR_UNALIGNED( v1, 424+0x010) |
| 200 SAVE_VECTOR_UNALIGNED( v2, 424+0x020) |
| 201 SAVE_VECTOR_UNALIGNED( v3, 424+0x030) |
| 202 SAVE_VECTOR_UNALIGNED( v4, 424+0x040) |
| 203 SAVE_VECTOR_UNALIGNED( v5, 424+0x050) |
| 204 SAVE_VECTOR_UNALIGNED( v6, 424+0x060) |
| 205 SAVE_VECTOR_UNALIGNED( v7, 424+0x070) |
| 206 SAVE_VECTOR_UNALIGNED( v8, 424+0x080) |
| 207 SAVE_VECTOR_UNALIGNED( v9, 424+0x090) |
| 208 SAVE_VECTOR_UNALIGNED(v10, 424+0x0A0) |
| 209 SAVE_VECTOR_UNALIGNED(v11, 424+0x0B0) |
| 210 SAVE_VECTOR_UNALIGNED(v12, 424+0x0C0) |
| 211 SAVE_VECTOR_UNALIGNED(v13, 424+0x0D0) |
| 212 SAVE_VECTOR_UNALIGNED(v14, 424+0x0E0) |
| 213 SAVE_VECTOR_UNALIGNED(v15, 424+0x0F0) |
| 214 SAVE_VECTOR_UNALIGNED(v16, 424+0x100) |
| 215 SAVE_VECTOR_UNALIGNED(v17, 424+0x110) |
| 216 SAVE_VECTOR_UNALIGNED(v18, 424+0x120) |
| 217 SAVE_VECTOR_UNALIGNED(v19, 424+0x130) |
| 218 SAVE_VECTOR_UNALIGNED(v20, 424+0x140) |
| 219 SAVE_VECTOR_UNALIGNED(v21, 424+0x150) |
| 220 SAVE_VECTOR_UNALIGNED(v22, 424+0x160) |
| 221 SAVE_VECTOR_UNALIGNED(v23, 424+0x170) |
| 222 SAVE_VECTOR_UNALIGNED(v24, 424+0x180) |
| 223 SAVE_VECTOR_UNALIGNED(v25, 424+0x190) |
| 224 SAVE_VECTOR_UNALIGNED(v26, 424+0x1A0) |
| 225 SAVE_VECTOR_UNALIGNED(v27, 424+0x1B0) |
| 226 SAVE_VECTOR_UNALIGNED(v28, 424+0x1C0) |
| 227 SAVE_VECTOR_UNALIGNED(v29, 424+0x1D0) |
| 228 SAVE_VECTOR_UNALIGNED(v30, 424+0x1E0) |
| 229 SAVE_VECTOR_UNALIGNED(v31, 424+0x1F0) |
| 230 |
| 231 li r3, 0 ; return UNW_ESUCCESS |
| 232 blr |
| 233 |
| 234 |
| 235 #elif __arm64__ |
| 236 |
| 237 ; |
| 238 ; extern int unw_getcontext(unw_context_t* thread_state) |
| 239 ; |
| 240 ; On entry: |
| 241 ; thread_state pointer is in x0 |
| 242 ; |
| 243 .globl _unw_getcontext |
| 244 _unw_getcontext: |
| 245 stp x0, x1, [x0, #0x000] |
| 246 stp x2, x3, [x0, #0x010] |
| 247 stp x4, x5, [x0, #0x020] |
| 248 stp x6, x7, [x0, #0x030] |
| 249 stp x8, x9, [x0, #0x040] |
| 250 stp x10,x11, [x0, #0x050] |
| 251 stp x12,x13, [x0, #0x060] |
| 252 stp x14,x15, [x0, #0x070] |
| 253 stp x16,x17, [x0, #0x080] |
| 254 stp x18,x19, [x0, #0x090] |
| 255 stp x20,x21, [x0, #0x0A0] |
| 256 stp x22,x23, [x0, #0x0B0] |
| 257 stp x24,x25, [x0, #0x0C0] |
| 258 stp x26,x27, [x0, #0x0D0] |
| 259 stp x28,fp, [x0, #0x0E0] |
| 260 str lr, [x0, #0x0F0] |
| 261 mov x1,sp |
| 262 str x1, [x0, #0x0F8] |
| 263 str lr, [x0, #0x100] ; store return address as pc |
| 264 ; skip cpsr |
| 265 stp d0, d1, [x0, #0x110] |
| 266 stp d2, d3, [x0, #0x120] |
| 267 stp d4, d5, [x0, #0x130] |
| 268 stp d6, d7, [x0, #0x140] |
| 269 stp d8, d9, [x0, #0x150] |
| 270 stp d10,d11, [x0, #0x160] |
| 271 stp d12,d13, [x0, #0x170] |
| 272 stp d14,d15, [x0, #0x180] |
| 273 stp d16,d17, [x0, #0x190] |
| 274 stp d18,d19, [x0, #0x1A0] |
| 275 stp d20,d21, [x0, #0x1B0] |
| 276 stp d22,d23, [x0, #0x1C0] |
| 277 stp d24,d25, [x0, #0x1D0] |
| 278 stp d26,d27, [x0, #0x1E0] |
| 279 stp d28,d29, [x0, #0x1F0] |
| 280 str d30, [x0, #0x200] |
| 281 str d31, [x0, #0x208] |
| 282 ldr x0, #0 ; return UNW_ESUCCESS |
| 283 ret |
| 284 |
| 285 #endif |
| 286 |
OLD | NEW |