3 * File name: ir/ir/irmode_t.h
4 * Purpose: Data modes of operations -- private header.
5 * Author: Martin Trapp, Christian Schaefer
6 * Modified by: Goetz Lindenmaier, Mathias Heil
9 * Copyright: (c) 1998-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
24 /** This struct is supposed to completely define a mode. **/
26 firm_kind kind; /**< distinguishes this node from others */
27 modecode code; /**< unambiguous identifier of a mode */
28 ident *name; /**< Name ident of this mode */
30 /* ----------------------------------------------------------------------- */
31 /* On changing this struct you have to evaluate the mode_are_equal function!*/
32 mode_sort sort; /**< coarse classification of this mode:
33 int, float, reference ...
35 mode_arithmetic arithmetic; /**< different arithmetic operations possible with a mode */
36 int size; /**< size of the mode in Bits. */
37 int align; /**< byte alignment */
38 unsigned sign:1; /**< signedness of this mode */
39 unsigned int modulo_shift; /**< number of bits a valus of this mode will be shifted */
40 unsigned vector_elem; /**< if this is not equal 1, this is a vector mode with
41 vector_elem number of elements, size contains the size
42 of all bits and must be dividable by vector_elem */
44 /* ----------------------------------------------------------------------- */
49 void *link; /**< To store some intermediate information */
50 const void *tv_priv; /**< tarval module will save private data here */
53 /* ------------------------------- *
55 * ------------------------------- */
56 extern ir_mode *mode_P_mach;
58 static INLINE ir_mode *
59 __get_modeP_mach(void) { return mode_P_mach; }
62 __set_modeP_mach(ir_mode *p) {
63 assert(mode_is_reference(p));
67 static INLINE modecode
68 __get_mode_modecode(const ir_mode *mode) { return mode->code; }
71 __get_mode_ident(const ir_mode *mode) { return mode->name; }
73 static INLINE mode_sort
74 __get_mode_sort(const ir_mode* mode) { return mode->sort; }
77 __get_mode_size_bits(const ir_mode *mode) { return mode->size; }
80 __get_mode_size_bytes(const ir_mode *mode) {
81 int size = __get_mode_size_bits(mode);
82 if ((size & 7) != 0) return -1;
87 __get_mode_align(const ir_mode *mode) { return mode->align; }
90 __get_mode_sign(const ir_mode *mode) { return mode->sign; }
93 __get_mode_arithmetic(const ir_mode *mode) { return mode->arithmetic; }
95 static INLINE unsigned int
96 __get_mode_modulo_shift(const ir_mode *mode) { return mode->modulo_shift; }
98 static INLINE unsigned int
99 __get_mode_vector_elems(const ir_mode *mode) { return mode->vector_elem; }
102 __get_mode_link(const ir_mode *mode) { return mode->link; }
105 __set_mode_link(ir_mode *mode, void *l) { mode->link = l; }
107 /* Functions to check, whether a modecode is signed, float, int, num, data,
108 datab or dataM. For more exact definitions read the corresponding pages
109 in the firm documentation or the followingenumeration
111 The set of "float" is defined as:
112 ---------------------------------
113 float = {irm_F, irm_D, irm_E}
115 The set of "int" is defined as:
116 -------------------------------
117 int = {irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu}
119 The set of "num" is defined as:
120 -------------------------------
121 num = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
122 irm_Is, irm_Iu, irm_Ls, irm_Lu}
125 The set of "data" is defined as:
126 -------------------------------
127 data = {irm_F, irm_D, irm_E irm_Bs, irm_Bu, irm_Hs, irm_Hu,
128 irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P}
129 = {num || irm_C || irm_U || irm_P}
131 The set of "datab" is defined as:
132 ---------------------------------
133 datab = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
134 irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_b}
137 The set of "dataM" is defined as:
138 ---------------------------------
139 dataM = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu,
140 irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_M}
145 __mode_is_signed(const ir_mode *mode) {
151 __mode_is_float(const ir_mode *mode) {
153 return (__get_mode_sort(mode) == irms_float_number);
157 __mode_is_int(const ir_mode *mode) {
159 return (__get_mode_sort(mode) == irms_int_number);
163 __mode_is_character(const ir_mode *mode) {
165 return (__get_mode_sort(mode) == irms_character);
169 __mode_is_reference(const ir_mode *mode) {
171 return (__get_mode_sort(mode) == irms_reference);
175 __mode_is_num(const ir_mode *mode) {
177 return (__mode_is_int(mode) || __mode_is_float(mode));
181 __mode_is_numP(const ir_mode *mode) {
183 return (__mode_is_int(mode) || __mode_is_float(mode) || __mode_is_reference(mode));
187 __mode_is_data(const ir_mode *mode) {
189 return (__mode_is_num(mode) || __get_mode_sort(mode) == irms_character || __get_mode_sort(mode) == irms_reference);
193 __mode_is_datab(const ir_mode *mode) {
195 return (__mode_is_data(mode) || __get_mode_sort(mode) == irms_internal_boolean);
199 __mode_is_dataM(const ir_mode *mode) {
201 return (__mode_is_data(mode) || __get_mode_modecode(mode) == irm_M);
205 __mode_is_float_vector(const ir_mode *mode) {
207 return (__get_mode_sort(mode) == irms_float_number) && (__get_mode_vector_elems(mode) > 1);
211 __mode_is_int_vector(const ir_mode *mode) {
213 return (__get_mode_sort(mode) == irms_int_number) && (__get_mode_vector_elems(mode) > 1);
216 #define get_modeP_mach() __get_modeP_mach()
217 #define set_modeP_mach(p) __set_modeP_mach(p)
218 #define get_mode_modecode(mode) __get_mode_modecode(mode)
219 #define get_mode_ident(mode) __get_mode_ident(mode)
220 #define get_mode_sort(mode) __get_mode_sort(mode)
221 #define get_mode_size_bits(mode) __get_mode_size_bits(mode)
222 #define get_mode_size_bytes(mode) __get_mode_size_bytes(mode)
223 #define get_mode_align(mode) __get_mode_align(mode)
224 #define get_mode_sign(mode) __get_mode_sign(mode)
225 #define get_mode_arithmetic(mode) __get_mode_arithmetic(mode)
226 #define get_mode_modulo_shift(mode) __get_mode_modulo_shift(mode)
227 #define get_mode_vector_elems(mode) __get_mode_vector_elems(mode)
228 #define get_mode_link(mode) __get_mode_link(mode)
229 #define set_mode_link(mode, l) __set_mode_link(mode, l)
230 #define mode_is_signed(mode) __mode_is_signed(mode)
231 #define mode_is_float(mode) __mode_is_float(mode)
232 #define mode_is_int(mode) __mode_is_int(mode)
233 #define mode_is_character(mode) __mode_is_character(mode)
234 #define mode_is_reference(mode) __mode_is_reference(mode)
235 #define mode_is_num(mode) __mode_is_num(mode)
236 #define mode_is_numP(mode) __mode_is_numP(mode)
237 #define mode_is_data(mode) __mode_is_data(mode)
238 #define mode_is_datab(mode) __mode_is_datab(mode)
239 #define mode_is_dataM(mode) __mode_is_dataM(mode)
240 #define mode_is_float_vector(mode) __mode_is_float_vector(mode)
241 #define mode_is_int_vector(mode) __mode_is_int_vector(mode)
243 #endif /* _IRMODE_T_H_ */