]> git.saurik.com Git - apple/libc.git/blame - ppc/gen/genassym.h
Libc-391.tar.gz
[apple/libc.git] / ppc / gen / genassym.h
CommitLineData
e9ce8d39
A
1/*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
734aad71
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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
e9ce8d39
A
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
734aad71
A
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
e9ce8d39
A
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*
24 * genassym.h -- macros of use with genassym.c and assymdefs.c
25 */
26
27#import <architecture/ppc/reg_help.h>
28#import <architecture/ppc/macro_help.h>
29
30#define PRINT_OFFSET(ptr_type, field) \
31MACRO_BEGIN \
32 print_define("", #ptr_type, #field); \
33 print_hex((unsigned) &(((ptr_type)0)->field)); \
34MACRO_END
35
36#define PRINT_BIT_FIELD(reg_type, field) \
37MACRO_BEGIN \
38 reg_type __reg; \
39 CONTENTS(__reg) = 0; \
40 __reg.field = (typeof (__reg.field)) -1; \
41 print_define("", #reg_type, #field); \
42 print_hex(CONTENTS(__reg)); \
43MACRO_END
44
45#define PRINT_ENUM(item) \
46MACRO_BEGIN \
47 print_define("", "", #item); \
48 print_hex((unsigned)item); \
49MACRO_END
50
51#define PRINT_DEFINE(macro) \
52MACRO_BEGIN \
53 print_define("", "", #macro); \
54 print_str(STRINGIFY(macro)); \
55MACRO_END
56
57#define PRINT_CONSTANT(macro) \
58MACRO_BEGIN \
59 print_define("", "", #macro); \
60 print_hex((unsigned)macro); \
61MACRO_END
62
63#define PRINT_REGADDR(macro) \
64MACRO_BEGIN \
65 print_define("", "", #macro); \
66 print_hex((unsigned) &macro); \
67MACRO_END
68
69#define PRINT_REG_PAIR(struct_ptr, name0, name1) \
70MACRO_BEGIN \
71 print_define("", #struct_ptr, #name0 "_" #name1); \
72 print_hex((unsigned) &(((struct_ptr)0)->U_##name0##_##name1)); \
73MACRO_END
74
75#define PRINT_BIT_POS(reg_type, field) \
76MACRO_BEGIN \
77 reg_type __reg; \
78 CONTENTS(__reg) = 0; \
79 __reg.field = 1; \
80 print_define("", #reg_type, #field "_BIT"); \
81 print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
82MACRO_END
83
84#define PRINT_FIELD_INFO(reg_type, field) \
85MACRO_BEGIN \
86 reg_type __reg; \
87 CONTENTS(__reg) = 0; \
88 __reg.field = -1; \
89 print_define("", #reg_type, #field "_OFF"); \
90 print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
91 print_define("", #reg_type, #field "_WIDTH"); \
92 print_dec((int) field_width(#reg_type, #field, CONTENTS(__reg)));\
93MACRO_END
94
95#define PRINT_L2_SIZE(type) \
96MACRO_BEGIN \
97 print_define("L2_SIZEOF", #type, ""); \
98 print_dec((int) log2(sizeof(type), #type)); \
99MACRO_END
100
101#define PRINT_SIZEOF(type) \
102MACRO_BEGIN \
103 print_define("SIZEOF", #type, ""); \
104 print_dec((int) sizeof(type)); \
105MACRO_END
106
107#define PRINT_L2_CONSTANT(macro) \
108MACRO_BEGIN \
109 print_define("L2", "", #macro); \
110 print_dec((int) log2(macro, #macro)); \
111MACRO_END
112
113typedef enum {
114 MAJOR, MINOR
115} cmt_level_t;
116
117extern void comment(cmt_level_t level, const char *cmt);
118extern void print_define(const char *prefix, const char *type_name,
119 const char *field);
120extern void print_dec(int val);
121extern void print_hex(unsigned val);
122extern void print_str(const char *str);
123extern unsigned bit_num(char *reg_type, char *field, unsigned bits);
124extern unsigned field_width(char *reg_type, char *field, unsigned bits);
125extern unsigned log2(unsigned val, char *type);
126extern void assymdefs(void);
127