| 1 |
/* This file contains the GPR save and restore routines for Darwin. |
| 2 |
* |
| 3 |
* Copyright (C) 2011-2025 Free Software Foundation, Inc. |
| 4 |
* |
| 5 |
* This file is free software; you can redistribute it and/or modify it |
| 6 |
* under the terms of the GNU General Public License as published by the |
| 7 |
* Free Software Foundation; either version 3, or (at your option) any |
| 8 |
* later version. |
| 9 |
* |
| 10 |
* This file is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* General Public License for more details. |
| 14 |
* |
| 15 |
* Under Section 7 of GPL version 3, you are granted additional |
| 16 |
* permissions described in the GCC Runtime Library Exception, version |
| 17 |
* 3.1, as published by the Free Software Foundation. |
| 18 |
* |
| 19 |
* You should have received a copy of the GNU General Public License and |
| 20 |
* a copy of the GCC Runtime Library Exception along with this program; |
| 21 |
* see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 22 |
* <http://www.gnu.org/licenses/>. |
| 23 |
*/ |
| 24 |
|
| 25 |
/* Contributed by Iain Sandoe <[email protected]> */ |
| 26 |
|
| 27 |
/* Like their FP and VEC counterparts, these routines have only one externally |
| 28 |
visible entry point. Calls have to be constructed as offsets from this. |
| 29 |
(I.E. callers have to jump to "saveGPR+((x-13)*4" to save registers x..31). |
| 30 |
|
| 31 |
Each save/load instruction is 4 bytes long (for both m32 and m64 builds). |
| 32 |
|
| 33 |
The save/restores here are done w.r.t r11. |
| 34 |
|
| 35 |
restGPRx restores the link reg from the stack and returns to the saved |
| 36 |
address. |
| 37 |
|
| 38 |
*/ |
| 39 |
|
| 40 |
#include "darwin-asm.h" |
| 41 |
|
| 42 |
.text |
| 43 |
.align 2 |
| 44 |
|
| 45 |
.private_extern saveGPR |
| 46 |
saveGPR: |
| 47 |
stg r13,(-19 * GPR_BYTES)(r11) |
| 48 |
stg r14,(-18 * GPR_BYTES)(r11) |
| 49 |
stg r15,(-17 * GPR_BYTES)(r11) |
| 50 |
stg r16,(-16 * GPR_BYTES)(r11) |
| 51 |
stg r17,(-15 * GPR_BYTES)(r11) |
| 52 |
stg r18,(-14 * GPR_BYTES)(r11) |
| 53 |
stg r19,(-13 * GPR_BYTES)(r11) |
| 54 |
stg r20,(-12 * GPR_BYTES)(r11) |
| 55 |
stg r21,(-11 * GPR_BYTES)(r11) |
| 56 |
stg r22,(-10 * GPR_BYTES)(r11) |
| 57 |
stg r23,( -9 * GPR_BYTES)(r11) |
| 58 |
stg r24,( -8 * GPR_BYTES)(r11) |
| 59 |
stg r25,( -7 * GPR_BYTES)(r11) |
| 60 |
stg r26,( -6 * GPR_BYTES)(r11) |
| 61 |
stg r27,( -5 * GPR_BYTES)(r11) |
| 62 |
stg r28,( -4 * GPR_BYTES)(r11) |
| 63 |
stg r29,( -3 * GPR_BYTES)(r11) |
| 64 |
stg r30,( -2 * GPR_BYTES)(r11) |
| 65 |
stg r31,( -1 * GPR_BYTES)(r11) |
| 66 |
blr |
| 67 |
|
| 68 |
/* */ |
| 69 |
|
| 70 |
.private_extern restGPR |
| 71 |
restGPR: |
| 72 |
lg r13,(-19 * GPR_BYTES)(r11) |
| 73 |
lg r14,(-18 * GPR_BYTES)(r11) |
| 74 |
lg r15,(-17 * GPR_BYTES)(r11) |
| 75 |
lg r16,(-16 * GPR_BYTES)(r11) |
| 76 |
lg r17,(-15 * GPR_BYTES)(r11) |
| 77 |
lg r18,(-14 * GPR_BYTES)(r11) |
| 78 |
lg r19,(-13 * GPR_BYTES)(r11) |
| 79 |
lg r20,(-12 * GPR_BYTES)(r11) |
| 80 |
lg r21,(-11 * GPR_BYTES)(r11) |
| 81 |
lg r22,(-10 * GPR_BYTES)(r11) |
| 82 |
lg r23,( -9 * GPR_BYTES)(r11) |
| 83 |
lg r24,( -8 * GPR_BYTES)(r11) |
| 84 |
lg r25,( -7 * GPR_BYTES)(r11) |
| 85 |
lg r26,( -6 * GPR_BYTES)(r11) |
| 86 |
lg r27,( -5 * GPR_BYTES)(r11) |
| 87 |
lg r28,( -4 * GPR_BYTES)(r11) |
| 88 |
lg r29,( -3 * GPR_BYTES)(r11) |
| 89 |
lg r30,( -2 * GPR_BYTES)(r11) |
| 90 |
lg r31,( -1 * GPR_BYTES)(r11) |
| 91 |
blr |
| 92 |
|
| 93 |
.private_extern restGPRx |
| 94 |
restGPRx: |
| 95 |
lg r13,(-19 * GPR_BYTES)(r11) |
| 96 |
lg r14,(-18 * GPR_BYTES)(r11) |
| 97 |
lg r15,(-17 * GPR_BYTES)(r11) |
| 98 |
lg r16,(-16 * GPR_BYTES)(r11) |
| 99 |
lg r17,(-15 * GPR_BYTES)(r11) |
| 100 |
lg r18,(-14 * GPR_BYTES)(r11) |
| 101 |
lg r19,(-13 * GPR_BYTES)(r11) |
| 102 |
lg r20,(-12 * GPR_BYTES)(r11) |
| 103 |
lg r21,(-11 * GPR_BYTES)(r11) |
| 104 |
lg r22,(-10 * GPR_BYTES)(r11) |
| 105 |
lg r23,( -9 * GPR_BYTES)(r11) |
| 106 |
lg r24,( -8 * GPR_BYTES)(r11) |
| 107 |
lg r25,( -7 * GPR_BYTES)(r11) |
| 108 |
lg r26,( -6 * GPR_BYTES)(r11) |
| 109 |
lg r27,( -5 * GPR_BYTES)(r11) |
| 110 |
lg r28,( -4 * GPR_BYTES)(r11) |
| 111 |
lg r29,( -3 * GPR_BYTES)(r11) |
| 112 |
/* Like the FP restore, we start from the offset for r30 |
| 113 |
thus a restore of only r31 is not going to work. */ |
| 114 |
lg r0,SAVED_LR_OFFSET(r1) |
| 115 |
lg r30,( -2 * GPR_BYTES)(r11) |
| 116 |
mtlr r0 |
| 117 |
lg r31,( -1 * GPR_BYTES)(r11) |
| 118 |
blr |