]> git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/architecture/ppc/reg_help.h
xnu-344.21.74.tar.gz
[apple/xnu.git] / EXTERNAL_HEADERS / architecture / ppc / reg_help.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /* Copyright (c) 1996 NeXT Software, Inc. All rights reserved.
26 *
27 * File: architecture/ppc/reg_help.h
28 * Author: Doug Mitchell, NeXT Computer, Inc.
29 *
30 * m98k-specific macros and inlines for defining machine registers.
31 *
32 * HISTORY
33 * 05-Nov-92 Doug Mitchell at NeXT
34 * Created.
35 *
36 * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)
37 * Ported from m98k. Removed dependency on nrw directory.
38 * Merged code from architecture/nrw/reg_help.h.
39 * Moved Register Usage #defines from asm_help.h in here.
40 */
41
42 #ifndef _ARCH_PPC_REG_HELP_H_
43 #define _ARCH_PPC_REG_HELP_H_
44
45 #if defined(__ASSEMBLER__)
46 /*
47 * GRF Register Usage Aliases
48 */
49 #define zt r0 // architecturally 0 for mem refs only!
50 // real reg other inst, caller-saved
51 #define sp r1 // stack pointer, callee-saved
52 #define toc r2 // tbl of contents, callee-saved
53 #define a0 r3 // arg 0, return value 0, caller saved
54 #define a1 r4 // arg 1, return value 1, caller saved
55 #define a2 r5 // ....
56 #define a3 r6
57 #define a4 r7
58 #define a5 r8
59 #define a6 r9
60 #define a7 r10 // arg 7, return value 7, caller saved
61 #define ep r11 // environment ptr, caller saved
62 #define at r12 // assembler temp, caller saved
63 #define s17 r13 // callee-saved 17
64 #define s16 r14
65 #define s15 r15
66 #define s14 r16
67 #define s13 r17
68 #define s12 r18
69 #define s11 r19
70 #define s10 r20
71 #define s9 r21
72 #define s8 r22
73 #define s7 r23
74 #define s6 r24
75 #define s5 r25
76 #define s4 r26
77 #define s3 r27
78 #define s2 r28
79 #define s1 r29 // ....
80 #define s0 r30 // callee-saved 0
81 #define fp r31 // frame-pointer, callee-saved
82
83 /*
84 * Conversion of GRF aliases to register numbers
85 */
86 #define GRF_ZT 0 // architecturally 0 for mem refs only!
87 // real reg other inst, caller-saved
88 #define GRF_SP 1 // stack pointer, callee-saved
89 #define GRF_TOC 2 // tbl of contents, callee-saved
90 #define GRF_A0 3 // arg 0, return value 0, caller saved
91 #define GRF_A1 4 // arg 1, return value 1, caller saved
92 #define GRF_A2 5 // ....
93 #define GRF_A3 6
94 #define GRF_A4 7
95 #define GRF_A5 8
96 #define GRF_A6 9
97 #define GRF_A7 10 // arg 7, return value 7, caller saved
98 #define GRF_EP 11 // environment ptr, caller saved
99 #define GRF_AT 12 // assembler temp, caller saved
100 #define GRF_S17 13 // callee-saved 17
101 #define GRF_S16 14
102 #define GRF_S15 15
103 #define GRF_S14 16
104 #define GRF_S13 17
105 #define GRF_S12 18
106 #define GRF_S11 19
107 #define GRF_S10 20
108 #define GRF_S9 21
109 #define GRF_S8 22
110 #define GRF_S7 23
111 #define GRF_S6 24
112 #define GRF_S5 25
113 #define GRF_S4 26
114 #define GRF_S3 27
115 #define GRF_S2 28
116 #define GRF_S1 29 // ....
117 #define GRF_S0 30 // callee-saved 0
118 #define GRF_FP 31 // frame pointer, callee-saved
119
120 /*
121 * FPF Register names
122 */
123 #define ft0 f0 // scratch reg, caller-saved
124 #define fa0 f1 // fp arg 0, return 0, caller-saved
125 #define fa1 f2 // fp arg 1, caller-saved
126 #define fa2 f3 // fp arg 2, caller-saved
127 #define fa3 f4
128 #define fa4 f5
129 #define fa5 f6
130 #define fa6 f7
131 #define fa7 f8
132 #define fa8 f9
133 #define fa9 f10
134 #define fa10 f11
135 #define fa11 f12
136 #define fa12 f13 // fp arg 12, caller-saved
137 #define fs17 f14 // callee-saved 17
138 #define fs16 f15
139 #define fs15 f16
140 #define fs14 f17
141 #define fs13 f18
142 #define fs12 f19
143 #define fs11 f20
144 #define fs10 f21
145 #define fs9 f22
146 #define fs8 f23
147 #define fs7 f24
148 #define fs6 f25
149 #define fs5 f26
150 #define fs4 f27
151 #define fs3 f28
152 #define fs2 f29
153 #define fs1 f30
154 #define fs0 f31 // callee-saved 0
155
156 /*
157 * Conversion of FPF aliases to register numbers
158 */
159 #define FPF_FT0 0 // scratch reg, caller-saved
160 #define FPF_FA0 1 // fp arg 0, return 0, caller-saved
161 #define FPF_FA1 2 // fp arg 1, caller-saved
162 #define FPF_FA2 3 // fp arg 2, caller-saved
163 #define FPF_FA3 4
164 #define FPF_FA4 5
165 #define FPF_FA5 6
166 #define FPF_FA6 7
167 #define FPF_FA7 8
168 #define FPF_FA8 9
169 #define FPF_FA9 10
170 #define FPF_FA10 11
171 #define FPF_FA11 12
172 #define FPF_FA12 13 // fp arg 12, caller-saved
173 #define FPF_FS17 14 // callee-saved 17
174 #define FPF_FS16 15
175 #define FPF_FS15 16
176 #define FPF_FS14 17
177 #define FPF_FS13 18
178 #define FPF_FS12 19
179 #define FPF_FS11 20
180 #define FPF_FS10 21
181 #define FPF_FS9 22
182 #define FPF_FS8 23
183 #define FPF_FS7 24
184 #define FPF_FS6 25
185 #define FPF_FS5 26
186 #define FPF_FS4 27
187 #define FPF_FS3 28
188 #define FPF_FS2 29
189 #define FPF_FS1 30
190 #define FPF_FS0 31 // callee-saved 0
191
192 #endif /* __ASSEMBLER__ */
193
194
195 /* Bitfield definition aid */
196 #define BITS_WIDTH(msb, lsb) ((msb)-(lsb)+1)
197 #define BIT_WIDTH(pos) (1) /* mostly to record the position */
198
199 /* Mask creation */
200 #define MKMASK(width, offset) (((unsigned)-1)>>(32-(width))<<(offset))
201 #define BITSMASK(msb, lsb) MKMASK(BITS_WIDTH(msb, lsb), lsb & 0x1f)
202 #define BITMASK(pos) MKMASK(BIT_WIDTH(pos), pos & 0x1f)
203
204 /* Register addresses */
205 #if __ASSEMBLER__
206 # define REG_ADDR(type, addr) (addr)
207 #else /* ! __ASSEMBLER__ */
208 # define REG_ADDR(type, addr) (*(volatile type *)(addr))
209 #endif /* __ASSEMBLER__ */
210
211 /* Cast a register to be an unsigned */
212 /* CAUTION : non naturally aligned foo can result into alignment traps
213 * use at own risk.
214 */
215 #define CONTENTS(foo) (*(unsigned *) &(foo))
216
217 /* STRINGIFY -- perform all possible substitutions, then stringify */
218 #define __STR(x) #x /* just a helper macro */
219 #define STRINGIFY(x) __STR(x)
220
221 /*
222 * Stack pointer must always be a multiple of 16
223 */
224 #define STACK_INCR 16
225 #define ROUND_FRAME(x) ((((unsigned)(x)) + STACK_INCR - 1) & ~(STACK_INCR-1))
226
227 #endif /* _ARCH_PPC_REG_HELP_H_ */