]> git.saurik.com Git - apple/libc.git/blame - gen.subproj/ppc.subproj/genassym.h
Libc-167.tar.gz
[apple/libc.git] / gen.subproj / ppc.subproj / genassym.h
CommitLineData
e9ce8d39
A
1/*
2 * Copyright (c) 1999 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/*
23 * genassym.h -- macros of use with genassym.c and assymdefs.c
24 */
25
26#import <architecture/ppc/reg_help.h>
27#import <architecture/ppc/macro_help.h>
28
29#define PRINT_OFFSET(ptr_type, field) \
30MACRO_BEGIN \
31 print_define("", #ptr_type, #field); \
32 print_hex((unsigned) &(((ptr_type)0)->field)); \
33MACRO_END
34
35#define PRINT_BIT_FIELD(reg_type, field) \
36MACRO_BEGIN \
37 reg_type __reg; \
38 CONTENTS(__reg) = 0; \
39 __reg.field = (typeof (__reg.field)) -1; \
40 print_define("", #reg_type, #field); \
41 print_hex(CONTENTS(__reg)); \
42MACRO_END
43
44#define PRINT_ENUM(item) \
45MACRO_BEGIN \
46 print_define("", "", #item); \
47 print_hex((unsigned)item); \
48MACRO_END
49
50#define PRINT_DEFINE(macro) \
51MACRO_BEGIN \
52 print_define("", "", #macro); \
53 print_str(STRINGIFY(macro)); \
54MACRO_END
55
56#define PRINT_CONSTANT(macro) \
57MACRO_BEGIN \
58 print_define("", "", #macro); \
59 print_hex((unsigned)macro); \
60MACRO_END
61
62#define PRINT_REGADDR(macro) \
63MACRO_BEGIN \
64 print_define("", "", #macro); \
65 print_hex((unsigned) &macro); \
66MACRO_END
67
68#define PRINT_REG_PAIR(struct_ptr, name0, name1) \
69MACRO_BEGIN \
70 print_define("", #struct_ptr, #name0 "_" #name1); \
71 print_hex((unsigned) &(((struct_ptr)0)->U_##name0##_##name1)); \
72MACRO_END
73
74#define PRINT_BIT_POS(reg_type, field) \
75MACRO_BEGIN \
76 reg_type __reg; \
77 CONTENTS(__reg) = 0; \
78 __reg.field = 1; \
79 print_define("", #reg_type, #field "_BIT"); \
80 print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
81MACRO_END
82
83#define PRINT_FIELD_INFO(reg_type, field) \
84MACRO_BEGIN \
85 reg_type __reg; \
86 CONTENTS(__reg) = 0; \
87 __reg.field = -1; \
88 print_define("", #reg_type, #field "_OFF"); \
89 print_dec((int) bit_num(#reg_type, #field, CONTENTS(__reg))); \
90 print_define("", #reg_type, #field "_WIDTH"); \
91 print_dec((int) field_width(#reg_type, #field, CONTENTS(__reg)));\
92MACRO_END
93
94#define PRINT_L2_SIZE(type) \
95MACRO_BEGIN \
96 print_define("L2_SIZEOF", #type, ""); \
97 print_dec((int) log2(sizeof(type), #type)); \
98MACRO_END
99
100#define PRINT_SIZEOF(type) \
101MACRO_BEGIN \
102 print_define("SIZEOF", #type, ""); \
103 print_dec((int) sizeof(type)); \
104MACRO_END
105
106#define PRINT_L2_CONSTANT(macro) \
107MACRO_BEGIN \
108 print_define("L2", "", #macro); \
109 print_dec((int) log2(macro, #macro)); \
110MACRO_END
111
112typedef enum {
113 MAJOR, MINOR
114} cmt_level_t;
115
116extern void comment(cmt_level_t level, const char *cmt);
117extern void print_define(const char *prefix, const char *type_name,
118 const char *field);
119extern void print_dec(int val);
120extern void print_hex(unsigned val);
121extern void print_str(const char *str);
122extern unsigned bit_num(char *reg_type, char *field, unsigned bits);
123extern unsigned field_width(char *reg_type, char *field, unsigned bits);
124extern unsigned log2(unsigned val, char *type);
125extern void assymdefs(void);
126