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