libFirm
irmode.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5 
12 #ifndef FIRM_IR_IRMODE_H
13 #define FIRM_IR_IRMODE_H
14 
15 #include "firm_types.h"
16 #include "begin.h"
17 
18 #include <stddef.h>
19 
36 typedef enum ir_mode_arithmetic {
37  irma_none = 1,
42  irma_ieee754 = 256,
48 
60 
77 FIRM_API ir_mode *new_int_mode(const char *name,
78  unsigned bit_size, int sign,
79  unsigned modulo_shift);
80 
86 FIRM_API ir_mode *new_reference_mode(const char *name,
87  unsigned bit_size,
88  unsigned modulo_shift);
89 
101 FIRM_API ir_mode *new_float_mode(const char *name,
102  ir_mode_arithmetic arithmetic,
103  unsigned exponent_size,
104  unsigned mantissa_size,
106  int_conv_overflow);
107 
112 FIRM_API ir_mode *new_non_arithmetic_mode(const char *name, unsigned bit_size);
113 
115 FIRM_API ident *get_mode_ident(const ir_mode *mode);
116 
118 FIRM_API const char *get_mode_name(const ir_mode *mode);
119 
121 FIRM_API unsigned get_mode_size_bits(const ir_mode *mode);
122 
125 FIRM_API unsigned get_mode_size_bytes(const ir_mode *mode);
126 
128 FIRM_API ir_mode_arithmetic get_mode_arithmetic(const ir_mode *mode);
129 
136 FIRM_API unsigned int get_mode_modulo_shift(const ir_mode *mode);
137 
144 FIRM_API ir_tarval *get_mode_min(const ir_mode *mode);
145 
152 FIRM_API ir_tarval *get_mode_max(const ir_mode *mode);
153 
162 FIRM_API ir_tarval *get_mode_null(const ir_mode *mode);
163 
171 FIRM_API ir_tarval *get_mode_one(const ir_mode *mode);
172 
179 FIRM_API ir_tarval *get_mode_all_one(const ir_mode *mode);
180 
188 FIRM_API ir_tarval *get_mode_infinite(const ir_mode *mode);
189 
190 FIRM_API ir_mode *mode_M;
192 FIRM_API ir_mode *mode_F;
193 FIRM_API ir_mode *mode_D;
194 FIRM_API ir_mode *mode_Bs;
195 FIRM_API ir_mode *mode_Bu;
196 FIRM_API ir_mode *mode_Hs;
197 FIRM_API ir_mode *mode_Hu;
198 FIRM_API ir_mode *mode_Is;
199 FIRM_API ir_mode *mode_Iu;
200 FIRM_API ir_mode *mode_Ls;
201 FIRM_API ir_mode *mode_Lu;
202 FIRM_API ir_mode *mode_P;
215 FIRM_API ir_mode *mode_b;
216 
217 FIRM_API ir_mode *mode_X;
218 FIRM_API ir_mode *mode_BB;
220 FIRM_API ir_mode *mode_T;
221 FIRM_API ir_mode *mode_ANY;
222 FIRM_API ir_mode *mode_BAD;
225 FIRM_API ir_mode *get_modeF(void);
227 FIRM_API ir_mode *get_modeD(void);
229 FIRM_API ir_mode *get_modeBs(void);
231 FIRM_API ir_mode *get_modeBu(void);
233 FIRM_API ir_mode *get_modeHs(void);
235 FIRM_API ir_mode *get_modeHu(void);
237 FIRM_API ir_mode *get_modeIs(void);
239 FIRM_API ir_mode *get_modeIu(void);
241 FIRM_API ir_mode *get_modeLs(void);
243 FIRM_API ir_mode *get_modeLu(void);
245 FIRM_API ir_mode *get_modeP(void);
247 FIRM_API ir_mode *get_modeb(void);
249 FIRM_API ir_mode *get_modeX(void);
251 FIRM_API ir_mode *get_modeBB(void);
253 FIRM_API ir_mode *get_modeM(void);
255 FIRM_API ir_mode *get_modeT(void);
257 FIRM_API ir_mode *get_modeANY(void);
259 FIRM_API ir_mode *get_modeBAD(void);
260 
262 FIRM_API void set_modeP(ir_mode *p);
263 
265 FIRM_API int mode_is_signed(const ir_mode *mode);
266 
268 FIRM_API int mode_is_float(const ir_mode *mode);
269 
271 FIRM_API int mode_is_int(const ir_mode *mode);
272 
274 FIRM_API int mode_is_reference(const ir_mode *mode);
275 
281 FIRM_API int mode_is_num(const ir_mode *mode);
282 
289 FIRM_API int mode_is_data(const ir_mode *mode);
290 
302 FIRM_API int smaller_mode(const ir_mode *sm, const ir_mode *lm);
303 
314 FIRM_API int values_in_mode(const ir_mode *sm, const ir_mode *lm);
315 
320 FIRM_API ir_mode *find_unsigned_mode(const ir_mode *mode);
321 
326 FIRM_API ir_mode *find_signed_mode(const ir_mode *mode);
327 
332 FIRM_API ir_mode *find_double_bits_int_mode(const ir_mode *mode);
333 
339 FIRM_API int mode_has_signed_zero(const ir_mode *mode);
340 
344 FIRM_API int mode_overflow_on_unary_Minus(const ir_mode *mode);
345 
352 FIRM_API int mode_wrap_around(const ir_mode *mode);
353 
358 FIRM_API ir_mode *get_reference_offset_mode(const ir_mode *mode);
359 
363 FIRM_API void set_reference_offset_mode(ir_mode *ref_mode, ir_mode *int_mode);
364 
369 FIRM_API unsigned get_mode_mantissa_size(const ir_mode *mode);
370 
374 FIRM_API unsigned get_mode_exponent_size(const ir_mode *mode);
375 
380  const ir_mode *mode);
381 
387 FIRM_API int is_reinterpret_cast(const ir_mode *src, const ir_mode *dst);
388 
392 FIRM_API ir_type *get_type_for_mode(const ir_mode *mode);
393 
395 FIRM_API size_t ir_get_n_modes(void);
396 
398 FIRM_API ir_mode *ir_get_mode(size_t num);
399 
402 #include "end.h"
403 
404 #endif
int mode_is_num(const ir_mode *mode)
Returns 1 if mode is for numeric values, 0 otherwise.
ir_mode * mode_Bu
uint8
Definition: irmode.h:195
ir_mode * mode_P
pointer
Definition: irmode.h:202
unsigned get_mode_size_bytes(const ir_mode *mode)
Returns the size of values of the mode in bytes.
int values_in_mode(const ir_mode *sm, const ir_mode *lm)
Returns true if no information is lost when converting a value of mode sm into mode lm (and back to m...
const char ident
Identifier.
Definition: firm_types.h:50
ir_mode * get_modeD(void)
Returns double mode.
ir_mode * get_modeBAD(void)
Returns BAD mode.
ir_mode * get_modeIu(void)
Returns integer unsigned mode.
ir_mode * mode_Is
int32
Definition: irmode.h:198
For modes for which no representation is specified.
Definition: irmode.h:37
ir_mode_arithmetic get_mode_arithmetic(const ir_mode *mode)
Returns the arithmetic of a mode.
unsigned get_mode_exponent_size(const ir_mode *mode)
Returns size of exponent in bits (for float modes)
ir_mode * mode_BB
block
Definition: irmode.h:218
ir_mode * mode_Bs
int8
Definition: irmode.h:194
ir_mode * mode_BAD
bad mode
Definition: irmode.h:222
ident * get_mode_ident(const ir_mode *mode)
Returns the ident* of the mode.
ir_mode * get_modeANY(void)
Returns ANY mode.
ir_mode * find_signed_mode(const ir_mode *mode)
Returns a matching signed mode for a given integer unsigned mode.
ir_mode * mode_Hs
int16
Definition: irmode.h:196
ir_mode * get_modeF(void)
Returns float mode.
ir_mode * get_modeT(void)
Returns tuple mode.
ir_tarval * get_mode_all_one(const ir_mode *mode)
Returns the value where all bits are One, represented in this mode.
x86 extended floating point values
Definition: irmode.h:45
const char * get_mode_name(const ir_mode *mode)
Returns the null-terminated name of this mode.
ir_mode * mode_D
ieee754 binary64 float (double precision)
Definition: irmode.h:193
ir_mode * find_unsigned_mode(const ir_mode *mode)
Returns a matching unsigned mode for a given integer signed mode.
int mode_is_int(const ir_mode *mode)
Returns 1 if mode is for integer numbers, 0 otherwise.
ir_mode * mode_ANY
undefined mode
Definition: irmode.h:221
void set_reference_offset_mode(ir_mode *ref_mode, ir_mode *int_mode)
Sets the (signed) integer equivalent mode for an reference mode.
struct ir_type ir_type
Type.
Definition: firm_types.h:71
ir_mode * mode_M
memory
Definition: irmode.h:190
struct ir_tarval ir_tarval
Target Machine Value.
Definition: firm_types.h:68
ir_mode * get_modeHs(void)
Returns halfword signed mode.
ir_mode * mode_Ls
int64
Definition: irmode.h:200
ir_tarval * get_mode_min(const ir_mode *mode)
Returns the smallest representable value of a given mode.
ir_tarval * get_mode_infinite(const ir_mode *mode)
Returns a positive infinite value of a mode.
int mode_overflow_on_unary_Minus(const ir_mode *mode)
Returns non-zero if the given mode might overflow on unary Minus.
ir_mode * new_float_mode(const char *name, ir_mode_arithmetic arithmetic, unsigned exponent_size, unsigned mantissa_size, float_int_conversion_overflow_style_t int_conv_overflow)
Create a new ieee754 float mode.
ir_mode * get_reference_offset_mode(const ir_mode *mode)
Returns the integer equivalent mode for an reference mode.
ir_mode * get_modeBs(void)
Returns byte signed mode.
ir_mode * mode_T
tuple (none)
Definition: irmode.h:220
ir_mode * get_modeM(void)
Returns memory mode.
float_int_conversion_overflow_style_t
Specifies what happens when a float value is converted to an integer and overflow happens...
Definition: irmode.h:53
ir_mode * ir_get_mode(size_t num)
Returns known mode number num.
int smaller_mode(const ir_mode *sm, const ir_mode *lm)
Returns true if a value of mode sm can be converted to mode lm without loss.
ir_mode * find_double_bits_int_mode(const ir_mode *mode)
Returns an integer mode with 2*n bits for a given integer mode with n bits.
Values of the mode are represented as two&#39;s complement.
Definition: irmode.h:39
ir_mode * mode_Lu
uint64
Definition: irmode.h:201
unsigned get_mode_size_bits(const ir_mode *mode)
Returns the size of values of the mode in bits.
size_t ir_get_n_modes(void)
Returns number of known modes.
unsigned get_mode_mantissa_size(const ir_mode *mode)
Returns size of bits used for to encode the mantissa (for float modes).
ir_mode * get_modeLs(void)
Returns long signed mode.
int mode_is_signed(const ir_mode *mode)
Returns 1 if mode is signed, 0 otherwise.
float_int_conversion_overflow_style_t get_mode_float_int_overflow(const ir_mode *mode)
Returns semantic on float to integer conversion overflow.
ir_mode * get_modeHu(void)
Returns halfword unsigned mode.
int mode_has_signed_zero(const ir_mode *mode)
Returns non-zero if the given mode has negative zeros, i.e.
ir_mode * get_modeIs(void)
Returns integer signed mode.
ir_mode * new_non_arithmetic_mode(const char *name, unsigned bit_size)
Creates a new mode for data values which are not used to perform arithmetic.
INT_MIN/INT_MAX is returned depending on the sign of the floatingpoint number.
Definition: irmode.h:56
ir_mode * get_modeLu(void)
Returns long unsigned mode.
ir_mode * new_reference_mode(const char *name, unsigned bit_size, unsigned modulo_shift)
Create a new reference mode.
ir_tarval * get_mode_one(const ir_mode *mode)
Returns the value One, represented in this mode.
int mode_is_float(const ir_mode *mode)
Returns 1 if mode is for floating point numbers, 0 otherwise.
ir_mode * get_modeP(void)
Returns pointer mode.
int is_reinterpret_cast(const ir_mode *src, const ir_mode *dst)
Returns non-zero if the cast from mode src to mode dst is a reinterpret cast (i.e.
struct ir_mode ir_mode
SSA Value mode.
Definition: firm_types.h:59
int mode_is_data(const ir_mode *mode)
Returns 1 if mode is for data values, 0 otherwise.
Values of the mode are represented according to ieee754 floating point standard.
Definition: irmode.h:42
ir_mode * get_modeb(void)
Returns internal boolean mode.
ir_mode * mode_b
This mode represents (parts of) the processor status flag queried in conditional jumps or predicated ...
Definition: irmode.h:215
ir_mode_arithmetic
These values represent the different arithmetic operations possible with a mode.
Definition: irmode.h:36
int mode_wrap_around(const ir_mode *mode)
Returns non-zero if the mode has a reversed wrap-around logic, especially (a + x) - x == a...
ir_tarval * get_mode_max(const ir_mode *mode)
Returns the biggest representable value of a given mode.
ir_mode * get_modeBu(void)
Returns byte unsigned mode.
the integer indefinite value (=INT_MIN) is returned.
Definition: irmode.h:54
int mode_is_reference(const ir_mode *mode)
Returns 1 if mode is for references/pointers, 0 otherwise.
ir_mode * mode_Hu
uint16
Definition: irmode.h:197
ir_mode * mode_Iu
uint32
Definition: irmode.h:199
ir_mode * new_int_mode(const char *name, unsigned bit_size, int sign, unsigned modulo_shift)
Creates a new mode.
ir_mode * mode_F
ieee754 binary32 float (single precision)
Definition: irmode.h:192
ir_mode * mode_X
execution
Definition: irmode.h:217
ir_mode * get_modeX(void)
Returns control-flow mode.
unsigned int get_mode_modulo_shift(const ir_mode *mode)
Returns the modulo shift attribute.
void set_modeP(ir_mode *p)
Sets the machine specific pointer mode.
ir_mode * get_modeBB(void)
Returns Basic-Block mode.
ir_tarval * get_mode_null(const ir_mode *mode)
Returns the value Zero represented in this mode.
ir_type * get_type_for_mode(const ir_mode *mode)
Returns the primitive type matching the given mode.