bearch: Use arch_register_req_is(req, ignore) instead of arch_irn_is_ignore(...)...
[libfirm] / ir / ir / irmode_t.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Data modes of operations -- private header.
23  * @author  Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Mathias Heil,
24  *          Michael Beck
25  */
26 #ifndef FIRM_IR_IRMODE_T_H
27 #define FIRM_IR_IRMODE_T_H
28
29 #include <assert.h>
30 #include "irtypes.h"
31 #include "irmode.h"
32
33 #define get_modeP_code()               get_modeP_code_()
34 #define get_modeP_data()               get_modeP_data_()
35 #define get_mode_ident(mode)           get_mode_ident_(mode)
36 #define get_mode_sort(mode)            get_mode_sort_(mode)
37 #define get_mode_size_bits(mode)       get_mode_size_bits_(mode)
38 #define get_mode_size_bytes(mode)      get_mode_size_bytes_(mode)
39 #define get_mode_sign(mode)            get_mode_sign_(mode)
40 #define get_mode_arithmetic(mode)      get_mode_arithmetic_(mode)
41 #define get_mode_modulo_shift(mode)    get_mode_modulo_shift_(mode)
42 #define get_mode_link(mode)            get_mode_link_(mode)
43 #define set_mode_link(mode, l)         set_mode_link_(mode, l)
44 #define mode_is_signed(mode)           mode_is_signed_(mode)
45 #define mode_is_float(mode)            mode_is_float_(mode)
46 #define mode_is_int(mode)              mode_is_int_(mode)
47 #define mode_is_reference(mode)        mode_is_reference_(mode)
48 #define mode_is_num(mode)              mode_is_num_(mode)
49 #define mode_is_data(mode)             mode_is_data_(mode)
50 #define mode_is_datab(mode)            mode_is_datab_(mode)
51 #define mode_is_dataM(mode)            mode_is_dataM_(mode)
52 #define get_type_for_mode(mode)        get_type_for_mode_(mode)
53 #define get_mode_mantissa_size(mode)   get_mode_mantissa_size_(mode)
54 #define get_mode_exponent_size(mode)   get_mode_exponent_size_(mode)
55
56 static inline ir_mode *get_modeP_code_(void) { return mode_P_code; }
57
58 static inline ir_mode *get_modeP_data_(void) { return mode_P_data; }
59
60 static inline ident *get_mode_ident_(const ir_mode *mode) { return mode->name; }
61
62 static inline ir_mode_sort get_mode_sort_(const ir_mode *mode) { return mode->sort; }
63
64 static inline unsigned get_mode_size_bits_(const ir_mode *mode) { return mode->size; }
65
66 static inline unsigned get_mode_size_bytes_(const ir_mode *mode)
67 {
68         unsigned size = get_mode_size_bits_(mode);
69         if ((size & 7) != 0) return (unsigned) -1;
70         return size >> 3;
71 }
72
73 static inline int get_mode_sign_(const ir_mode *mode) { return mode->sign; }
74
75 static inline ir_mode_arithmetic get_mode_arithmetic_(const ir_mode *mode) { return mode->arithmetic; }
76
77 static inline unsigned int get_mode_modulo_shift_(const ir_mode *mode) { return mode->modulo_shift; }
78
79 static inline void *get_mode_link_(const ir_mode *mode) { return mode->link; }
80
81 static inline void set_mode_link_(ir_mode *mode, void *l) { mode->link = l; }
82
83 /* Functions to check, whether a mode is signed, float, int, num, data,
84    datab or dataM. For more exact definitions read the corresponding pages
85    in the firm documentation or the following enumeration
86
87    The set of "float" is defined as:
88    ---------------------------------
89    float = {irm_F, irm_D, irm_E}
90
91    The set of "int" is defined as:
92    -------------------------------
93    int   = {irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu}
94
95    The set of "num" is defined as:
96    -------------------------------
97    num   = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
98             irm_Is, irm_Iu, irm_Ls, irm_Lu}
99             = {float || int}
100
101    The set of "data" is defined as:
102    -------------------------------
103    data  = {irm_F, irm_D, irm_E irm_Bs, irm_Bu, irm_Hs, irm_Hu,
104             irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P}
105             = {num || irm_C || irm_U || irm_P}
106
107    The set of "datab" is defined as:
108    ---------------------------------
109    datab = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
110             irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_b}
111             = {data || irm_b }
112
113    The set of "dataM" is defined as:
114    ---------------------------------
115    dataM = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
116             irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_M}
117             = {data || irm_M}
118 */
119
120 static inline int mode_is_signed_(const ir_mode *mode)
121 {
122         return mode->sign;
123 }
124
125 static inline int mode_is_float_(const ir_mode *mode)
126 {
127         return (get_mode_sort(mode) == irms_float_number);
128 }
129
130 static inline int mode_is_int_(const ir_mode *mode)
131 {
132         return (get_mode_sort(mode) == irms_int_number);
133 }
134
135 static inline int mode_is_reference_(const ir_mode *mode)
136 {
137         return (get_mode_sort(mode) == irms_reference);
138 }
139
140 static inline int mode_is_num_(const ir_mode *mode)
141 {
142         return (get_mode_sort(mode) & irmsh_is_num);
143 }
144
145 static inline int mode_is_data_(const ir_mode *mode)
146 {
147         return (get_mode_sort(mode) & irmsh_is_data);
148 }
149
150 static inline int mode_is_datab_(const ir_mode *mode)
151 {
152         return (get_mode_sort(mode) & irmsh_is_datab);
153 }
154
155 static inline int mode_is_dataM_(const ir_mode *mode)
156 {
157         return (get_mode_sort(mode) & irmsh_is_dataM);
158 }
159
160 static inline ir_type *get_type_for_mode_(const ir_mode *mode)
161 {
162         return mode->type;
163 }
164
165 static inline unsigned get_mode_mantissa_size_(const ir_mode *mode)
166 {
167         return mode->float_desc.mantissa_size;
168 }
169
170 static inline unsigned get_mode_exponent_size_(const ir_mode *mode)
171 {
172         return mode->float_desc.exponent_size;
173 }
174
175 /** mode module initialization, call once before use of any other function **/
176 void init_mode(void);
177
178 /** mode module finalization. frees all memory.  */
179 void finish_mode(void);
180
181 #endif