]>
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_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
22 /* Copyright (c) 1996 NeXT Software, Inc. All rights reserved.
24 * File: architecture/ppc/reg_help.h
25 * Author: Doug Mitchell, NeXT Computer, Inc.
27 * m98k-specific macros and inlines for defining machine registers.
30 * 05-Nov-92 Doug Mitchell at NeXT
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.
39 #ifndef _ARCH_PPC_REG_HELP_H_
40 #define _ARCH_PPC_REG_HELP_H_
42 #if defined(__ASSEMBLER__)
44 * GRF Register Usage Aliases
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
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
76 #define s1 r29 // ....
77 #define s0 r30 // callee-saved 0
78 #define fp r31 // frame-pointer, callee-saved
81 * Conversion of GRF aliases to register numbers
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 // ....
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
113 #define GRF_S1 29 // ....
114 #define GRF_S0 30 // callee-saved 0
115 #define GRF_FP 31 // frame pointer, callee-saved
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
133 #define fa12 f13 // fp arg 12, caller-saved
134 #define fs17 f14 // callee-saved 17
151 #define fs0 f31 // callee-saved 0
154 * Conversion of FPF aliases to register numbers
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
169 #define FPF_FA12 13 // fp arg 12, caller-saved
170 #define FPF_FS17 14 // callee-saved 17
187 #define FPF_FS0 31 // callee-saved 0
189 #endif /* __ASSEMBLER__ */
192 /* Bitfield definition aid */
193 #define BITS_WIDTH(msb, lsb) ((msb)-(lsb)+1)
194 #define BIT_WIDTH(pos) (1) /* mostly to record the position */
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)
201 /* Register addresses */
203 # define REG_ADDR(type, addr) (addr)
204 #else /* ! __ASSEMBLER__ */
205 # define REG_ADDR(type, addr) (*(volatile type *)(addr))
206 #endif /* __ASSEMBLER__ */
208 /* Cast a register to be an unsigned */
209 /* CAUTION : non naturally aligned foo can result into alignment traps
212 #define CONTENTS(foo) (*(unsigned *) &(foo))
214 /* STRINGIFY -- perform all possible substitutions, then stringify */
215 #define __STR(x) #x /* just a helper macro */
216 #define STRINGIFY(x) __STR(x)
219 * Stack pointer must always be a multiple of 16
221 #define STACK_INCR 16
222 #define ROUND_FRAME(x) ((((unsigned)(x)) + STACK_INCR - 1) & ~(STACK_INCR-1))
224 #endif /* _ARCH_PPC_REG_HELP_H_ */