2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Data modes of operations -- private header.
23 * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Mathias Heil,
26 #ifndef FIRM_IR_IRMODE_T_H
27 #define FIRM_IR_IRMODE_T_H
33 /* ------------------------------- *
35 * ------------------------------- */
36 static inline ir_mode *get_modeP_code_(void) { return mode_P_code; }
38 static inline ir_mode *get_modeP_data_(void) { return mode_P_data; }
40 static inline ident *get_mode_ident_(const ir_mode *mode) { return mode->name; }
42 static inline ir_mode_sort get_mode_sort_(const ir_mode *mode) { return mode->sort; }
44 static inline unsigned get_mode_size_bits_(const ir_mode *mode) { return mode->size; }
46 static inline unsigned get_mode_size_bytes_(const ir_mode *mode)
48 unsigned size = get_mode_size_bits_(mode);
49 if ((size & 7) != 0) return (unsigned) -1;
53 static inline int get_mode_sign_(const ir_mode *mode) { return mode->sign; }
55 static inline ir_mode_arithmetic get_mode_arithmetic_(const ir_mode *mode) { return mode->arithmetic; }
57 static inline unsigned int get_mode_modulo_shift_(const ir_mode *mode) { return mode->modulo_shift; }
59 static inline void *get_mode_link_(const ir_mode *mode) { return mode->link; }
61 static inline void set_mode_link_(ir_mode *mode, void *l) { mode->link = l; }
63 /* Functions to check, whether a mode is signed, float, int, num, data,
64 datab or dataM. For more exact definitions read the corresponding pages
65 in the firm documentation or the following enumeration
67 The set of "float" is defined as:
68 ---------------------------------
69 float = {irm_F, irm_D, irm_E}
71 The set of "int" is defined as:
72 -------------------------------
73 int = {irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu}
75 The set of "num" is defined as:
76 -------------------------------
77 num = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
78 irm_Is, irm_Iu, irm_Ls, irm_Lu}
81 The set of "data" is defined as:
82 -------------------------------
83 data = {irm_F, irm_D, irm_E irm_Bs, irm_Bu, irm_Hs, irm_Hu,
84 irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P}
85 = {num || irm_C || irm_U || irm_P}
87 The set of "datab" is defined as:
88 ---------------------------------
89 datab = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
90 irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_b}
93 The set of "dataM" is defined as:
94 ---------------------------------
95 dataM = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
96 irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_M}
100 static inline int mode_is_signed_(const ir_mode *mode)
105 static inline int mode_is_float_(const ir_mode *mode)
107 return (get_mode_sort_(mode) == irms_float_number);
110 static inline int mode_is_int_(const ir_mode *mode)
112 return (get_mode_sort_(mode) == irms_int_number);
115 static inline int mode_is_reference_(const ir_mode *mode)
117 return (get_mode_sort_(mode) == irms_reference);
120 static inline int mode_is_num_(const ir_mode *mode)
122 return (get_mode_sort_(mode) & irmsh_is_num);
125 static inline int mode_is_data_(const ir_mode *mode)
127 return (get_mode_sort_(mode) & irmsh_is_data);
130 static inline int mode_is_datab_(const ir_mode *mode)
132 return (get_mode_sort_(mode) & irmsh_is_datab);
135 static inline int mode_is_dataM_(const ir_mode *mode)
137 return (get_mode_sort_(mode) & irmsh_is_dataM);
140 static inline ir_type *get_type_for_mode_(const ir_mode *mode)
145 static inline unsigned get_mode_mantissa_size_(const ir_mode *mode)
147 return mode->float_desc.mantissa_size;
150 static inline unsigned get_mode_exponent_size_(const ir_mode *mode)
152 return mode->float_desc.exponent_size;
155 /** mode module initialization, call once before use of any other function **/
156 void init_mode(void);
158 /** mode module finalization. frees all memory. */
159 void finish_mode(void);
161 #define get_modeP_code() get_modeP_code_()
162 #define get_modeP_data() get_modeP_data_()
163 #define get_mode_ident(mode) get_mode_ident_(mode)
164 #define get_mode_sort(mode) get_mode_sort_(mode)
165 #define get_mode_size_bits(mode) get_mode_size_bits_(mode)
166 #define get_mode_size_bytes(mode) get_mode_size_bytes_(mode)
167 #define get_mode_sign(mode) get_mode_sign_(mode)
168 #define get_mode_arithmetic(mode) get_mode_arithmetic_(mode)
169 #define get_mode_modulo_shift(mode) get_mode_modulo_shift_(mode)
170 #define get_mode_link(mode) get_mode_link_(mode)
171 #define set_mode_link(mode, l) set_mode_link_(mode, l)
172 #define mode_is_signed(mode) mode_is_signed_(mode)
173 #define mode_is_float(mode) mode_is_float_(mode)
174 #define mode_is_int(mode) mode_is_int_(mode)
175 #define mode_is_reference(mode) mode_is_reference_(mode)
176 #define mode_is_num(mode) mode_is_num_(mode)
177 #define mode_is_data(mode) mode_is_data_(mode)
178 #define mode_is_datab(mode) mode_is_datab_(mode)
179 #define mode_is_dataM(mode) mode_is_dataM_(mode)
180 #define get_type_for_mode(mode) get_type_for_mode_(mode)
181 #define get_mode_mantissa_size(mode) get_mode_mantissa_size_(mode)
182 #define get_mode_exponent_size(mode) get_mode_exponent_size_(mode)