1 /* This file contains the GPR save and restore routines for Darwin.
3 * Copyright (C) 2011-2016 Free Software Foundation, Inc.
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
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.
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.
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/>.
25 /* Contributed by Iain Sandoe <iains@gcc.gnu.org> */
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).
31 Each save/load instruction is 4 bytes long (for both m32 and m64 builds).
33 The save/restores here are done w.r.t r11.
35 restGPRx restores the link reg from the stack and returns to the saved
40 #include "darwin-asm.h"
45 .private_extern 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)
70 .private_extern 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)
93 .private_extern 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)
117 lg r31,( -1 * GPR_BYTES)(r11)