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