|
| 1 | +/* This file is derived from the state-threads md.S file, which has no |
| 2 | + * specific license. It does claim the following, but does not indicate |
| 3 | + * which portions were contributed by SGI. |
| 4 | + * |
| 5 | + * Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc. |
| 6 | + * All Rights Reserved. |
| 7 | + */ |
| 8 | + |
| 9 | +/* |
| 10 | + * Internal __jmp_buf layout for AArch64 |
| 11 | + * |
| 12 | + * Callee-saved general-purpose registers: x19-x28, x29 (FP), x30 (LR) |
| 13 | + * Stack pointer: SP |
| 14 | + * Callee-saved SIMD/FP registers: d8-d15 |
| 15 | + */ |
| 16 | +#define JB_X19 0 |
| 17 | +#define JB_X20 1 |
| 18 | +#define JB_X21 2 |
| 19 | +#define JB_X22 3 |
| 20 | +#define JB_X23 4 |
| 21 | +#define JB_X24 5 |
| 22 | +#define JB_X25 6 |
| 23 | +#define JB_X26 7 |
| 24 | +#define JB_X27 8 |
| 25 | +#define JB_X28 9 |
| 26 | +#define JB_X29 10 |
| 27 | +#define JB_LR 11 |
| 28 | +#define JB_SP 12 |
| 29 | +#define JB_D8 13 |
| 30 | +#define JB_D9 14 |
| 31 | +#define JB_D10 15 |
| 32 | +#define JB_D11 16 |
| 33 | +#define JB_D12 17 |
| 34 | +#define JB_D13 18 |
| 35 | +#define JB_D14 19 |
| 36 | +#define JB_D15 20 |
| 37 | + |
| 38 | + .text |
| 39 | + |
| 40 | + /* _lua_setjmp_aarch64(__jmp_buf env) */ |
| 41 | +.globl _lua_setjmp_aarch64 |
| 42 | + .align 4 |
| 43 | +_lua_setjmp_aarch64: |
| 44 | + /* |
| 45 | + * Save callee-saved general-purpose registers. |
| 46 | + */ |
| 47 | + stp x19, x20, [x0, #(JB_X19*8)] |
| 48 | + stp x21, x22, [x0, #(JB_X21*8)] |
| 49 | + stp x23, x24, [x0, #(JB_X23*8)] |
| 50 | + stp x25, x26, [x0, #(JB_X25*8)] |
| 51 | + stp x27, x28, [x0, #(JB_X27*8)] |
| 52 | + stp x29, x30, [x0, #(JB_X29*8)] |
| 53 | + /* Save SP */ |
| 54 | + mov x2, sp |
| 55 | + str x2, [x0, #(JB_SP*8)] |
| 56 | + /* |
| 57 | + * Save callee-saved SIMD/FP registers. |
| 58 | + */ |
| 59 | + stp d8, d9, [x0, #(JB_D8*8)] |
| 60 | + stp d10, d11, [x0, #(JB_D10*8)] |
| 61 | + stp d12, d13, [x0, #(JB_D12*8)] |
| 62 | + stp d14, d15, [x0, #(JB_D14*8)] |
| 63 | + /* Return 0 */ |
| 64 | + mov w0, #0 |
| 65 | + ret |
| 66 | + |
| 67 | +/****************************************************************/ |
| 68 | + |
| 69 | + /* _lua_longjmp_aarch64(__jmp_buf env, int val) */ |
| 70 | +.globl _lua_longjmp_aarch64 |
| 71 | + .align 4 |
| 72 | +_lua_longjmp_aarch64: |
| 73 | + /* |
| 74 | + * Restore callee-saved general-purpose registers. |
| 75 | + */ |
| 76 | + ldp x19, x20, [x0, #(JB_X19*8)] |
| 77 | + ldp x21, x22, [x0, #(JB_X21*8)] |
| 78 | + ldp x23, x24, [x0, #(JB_X23*8)] |
| 79 | + ldp x25, x26, [x0, #(JB_X25*8)] |
| 80 | + ldp x27, x28, [x0, #(JB_X27*8)] |
| 81 | + ldp x29, x30, [x0, #(JB_X29*8)] |
| 82 | + /* Restore SP */ |
| 83 | + ldr x2, [x0, #(JB_SP*8)] |
| 84 | + mov sp, x2 |
| 85 | + /* |
| 86 | + * Restore callee-saved SIMD/FP registers. |
| 87 | + */ |
| 88 | + ldp d8, d9, [x0, #(JB_D8*8)] |
| 89 | + ldp d10, d11, [x0, #(JB_D10*8)] |
| 90 | + ldp d12, d13, [x0, #(JB_D12*8)] |
| 91 | + ldp d14, d15, [x0, #(JB_D14*8)] |
| 92 | + /* Set return value: if val == 0, return 1 instead */ |
| 93 | + cmp w1, #0 |
| 94 | + csinc w0, w1, wzr, ne |
| 95 | + /* Jump to saved PC (LR was restored into x30 above) */ |
| 96 | + ret |
| 97 | + |
| 98 | +/****************************************************************/ |
0 commit comments