1/*  This file contains the vector save and restore routines.
2 *
3 *   Copyright (C) 2004 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 2, or (at your option) any
8 * later version.
9 *
10 * In addition to the permissions in the GNU General Public License, the
11 * Free Software Foundation gives you unlimited permission to link the
12 * compiled version of this file with other programs, and to distribute
13 * those programs without any restriction coming from the use of this
14 * file.  (The General Public License restrictions do apply in other
15 * respects; for example, they cover modification of the file, and
16 * distribution when not linked into another program.)
17 *
18 * This file is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 * General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; see the file COPYING.  If not, write to
25 * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
26 * Boston, MA 02110-1301, USA.
27 *
28 *  As a special exception, if you link this library with files
29 *  compiled with GCC to produce an executable, this does not cause the
30 *  resulting executable to be covered by the GNU General Public License.
31 *  This exception does not however invalidate any other reasons why the
32 *  executable file might be covered by the GNU General Public License.
33 */
34
35/* Vector save/restore routines for Darwin.  Note that each vector
36   save/restore requires 2 instructions (8 bytes.)
37
38   THE SAVE AND RESTORE ROUTINES CAN HAVE ONLY ONE GLOBALLY VISIBLE
39   ENTRY POINT - callers have to jump to "saveFP+60" to save f29..f31,
40   for example.  For FP reg saves/restores, it takes one instruction
41   (4 bytes) to do the operation; for Vector regs, 2 instructions are
42   required (8 bytes.).   */
43
44	.machine ppc7400
45.text
46	.align 2
47
48.private_extern saveVEC
49saveVEC:
50	li r11,-192
51	stvx v20,r11,r0
52	li r11,-176
53	stvx v21,r11,r0
54	li r11,-160
55	stvx v22,r11,r0
56	li r11,-144
57	stvx v23,r11,r0
58	li r11,-128
59	stvx v24,r11,r0
60	li r11,-112
61	stvx v25,r11,r0
62	li r11,-96
63	stvx v26,r11,r0
64	li r11,-80
65	stvx v27,r11,r0
66	li r11,-64
67	stvx v28,r11,r0
68	li r11,-48
69	stvx v29,r11,r0
70	li r11,-32
71	stvx v30,r11,r0
72	li r11,-16
73	stvx v31,r11,r0
74	blr
75
76.private_extern restVEC
77restVEC:
78	li r11,-192
79	lvx v20,r11,r0
80	li r11,-176
81	lvx v21,r11,r0
82	li r11,-160
83	lvx v22,r11,r0
84	li r11,-144
85	lvx v23,r11,r0
86	li r11,-128
87	lvx v24,r11,r0
88	li r11,-112
89	lvx v25,r11,r0
90	li r11,-96
91	lvx v26,r11,r0
92	li r11,-80
93	lvx v27,r11,r0
94	li r11,-64
95	lvx v28,r11,r0
96	li r11,-48
97	lvx v29,r11,r0
98	li r11,-32
99	lvx v30,r11,r0
100	li r11,-16
101	lvx v31,r11,r0
102	blr
103
104/* saveVEC_vr11 -- as saveVEC but VRsave is returned in R11.  */
105
106.private_extern saveVEC_vr11
107saveVEC_vr11:
108	li r11,-192
109	stvx v20,r11,r0
110	li r11,-176
111	stvx v21,r11,r0
112	li r11,-160
113	stvx v22,r11,r0
114	li r11,-144
115	stvx v23,r11,r0
116	li r11,-128
117	stvx v24,r11,r0
118	li r11,-112
119	stvx v25,r11,r0
120	li r11,-96
121	stvx v26,r11,r0
122	li r11,-80
123	stvx v27,r11,r0
124	li r11,-64
125	stvx v28,r11,r0
126	li r11,-48
127	stvx v29,r11,r0
128	li r11,-32
129	stvx v30,r11,r0
130	li r11,-16
131	stvx v31,r11,r0
132	mfspr r11,VRsave
133	blr
134
135/* As restVec, but the original VRsave value passed in R10.  */
136
137.private_extern restVEC_vr10
138restVEC_vr10:
139	li r11,-192
140	lvx v20,r11,r0
141	li r11,-176
142	lvx v21,r11,r0
143	li r11,-160
144	lvx v22,r11,r0
145	li r11,-144
146	lvx v23,r11,r0
147	li r11,-128
148	lvx v24,r11,r0
149	li r11,-112
150	lvx v25,r11,r0
151	li r11,-96
152	lvx v26,r11,r0
153	li r11,-80
154	lvx v27,r11,r0
155	li r11,-64
156	lvx v28,r11,r0
157	li r11,-48
158	lvx v29,r11,r0
159	li r11,-32
160	lvx v30,r11,r0
161	li r11,-16
162	lvx v31,r11,r0
163				/* restore VRsave from R10.  */
164	mtspr VRsave,r10
165	blr
166