]>
git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/architecture/ppc/reg_help.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* Copyright (c) 1996 NeXT Software, Inc. All rights reserved.
30 * File: architecture/ppc/reg_help.h
31 * Author: Doug Mitchell, NeXT Computer, Inc.
33 * m98k-specific macros and inlines for defining machine registers.
36 * 05-Nov-92 Doug Mitchell at NeXT
39 * 29-Dec-96 Umesh Vaishampayan (umeshv@NeXT.com)
40 * Ported from m98k. Removed dependency on nrw directory.
41 * Merged code from architecture/nrw/reg_help.h.
42 * Moved Register Usage #defines from asm_help.h in here.
45 #ifndef _ARCH_PPC_REG_HELP_H_
46 #define _ARCH_PPC_REG_HELP_H_
48 #if defined(__ASSEMBLER__)
50 * GRF Register Usage Aliases
52 #define zt r0 // architecturally 0 for mem refs only!
53 // real reg other inst, caller-saved
54 #define sp r1 // stack pointer, callee-saved
55 #define toc r2 // tbl of contents, callee-saved
56 #define a0 r3 // arg 0, return value 0, caller saved
57 #define a1 r4 // arg 1, return value 1, caller saved
63 #define a7 r10 // arg 7, return value 7, caller saved
64 #define ep r11 // environment ptr, caller saved
65 #define at r12 // assembler temp, caller saved
66 #define s17 r13 // callee-saved 17
82 #define s1 r29 // ....
83 #define s0 r30 // callee-saved 0
84 #define fp r31 // frame-pointer, callee-saved
87 * Conversion of GRF aliases to register numbers
89 #define GRF_ZT 0 // architecturally 0 for mem refs only!
90 // real reg other inst, caller-saved
91 #define GRF_SP 1 // stack pointer, callee-saved
92 #define GRF_TOC 2 // tbl of contents, callee-saved
93 #define GRF_A0 3 // arg 0, return value 0, caller saved
94 #define GRF_A1 4 // arg 1, return value 1, caller saved
95 #define GRF_A2 5 // ....
100 #define GRF_A7 10 // arg 7, return value 7, caller saved
101 #define GRF_EP 11 // environment ptr, caller saved
102 #define GRF_AT 12 // assembler temp, caller saved
103 #define GRF_S17 13 // callee-saved 17
119 #define GRF_S1 29 // ....
120 #define GRF_S0 30 // callee-saved 0
121 #define GRF_FP 31 // frame pointer, callee-saved
126 #define ft0 f0 // scratch reg, caller-saved
127 #define fa0 f1 // fp arg 0, return 0, caller-saved
128 #define fa1 f2 // fp arg 1, caller-saved
129 #define fa2 f3 // fp arg 2, caller-saved
139 #define fa12 f13 // fp arg 12, caller-saved
140 #define fs17 f14 // callee-saved 17
157 #define fs0 f31 // callee-saved 0
160 * Conversion of FPF aliases to register numbers
162 #define FPF_FT0 0 // scratch reg, caller-saved
163 #define FPF_FA0 1 // fp arg 0, return 0, caller-saved
164 #define FPF_FA1 2 // fp arg 1, caller-saved
165 #define FPF_FA2 3 // fp arg 2, caller-saved
175 #define FPF_FA12 13 // fp arg 12, caller-saved
176 #define FPF_FS17 14 // callee-saved 17
193 #define FPF_FS0 31 // callee-saved 0
195 #endif /* __ASSEMBLER__ */
198 /* Bitfield definition aid */
199 #define BITS_WIDTH(msb, lsb) ((msb)-(lsb)+1)
200 #define BIT_WIDTH(pos) (1) /* mostly to record the position */
203 #define MKMASK(width, offset) (((unsigned)-1)>>(32-(width))<<(offset))
204 #define BITSMASK(msb, lsb) MKMASK(BITS_WIDTH(msb, lsb), lsb & 0x1f)
205 #define BITMASK(pos) MKMASK(BIT_WIDTH(pos), pos & 0x1f)
207 /* Register addresses */
209 # define REG_ADDR(type, addr) (addr)
210 #else /* ! __ASSEMBLER__ */
211 # define REG_ADDR(type, addr) (*(volatile type *)(addr))
212 #endif /* __ASSEMBLER__ */
214 /* Cast a register to be an unsigned */
215 /* CAUTION : non naturally aligned foo can result into alignment traps
218 #define CONTENTS(foo) (*(unsigned *) &(foo))
220 /* STRINGIFY -- perform all possible substitutions, then stringify */
221 #define __STR(x) #x /* just a helper macro */
222 #define STRINGIFY(x) __STR(x)
225 * Stack pointer must always be a multiple of 16
227 #define STACK_INCR 16
228 #define ROUND_FRAME(x) ((((unsigned)(x)) + STACK_INCR - 1) & ~(STACK_INCR-1))
230 #endif /* _ARCH_PPC_REG_HELP_H_ */