X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firmode_t.h;h=e6844281b5680bb88b0ff411712d484a22359ad4;hb=296dfbcbe4da36ca193f81c60443dda80890fab4;hp=609aec1602c144a4158a6f7296e614d2ae43220d;hpb=a142727aca4ef56cf754045fc0129b6d1b840a63;p=libfirm diff --git a/ir/ir/irmode_t.h b/ir/ir/irmode_t.h index 609aec160..e6844281b 100644 --- a/ir/ir/irmode_t.h +++ b/ir/ir/irmode_t.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -28,90 +28,58 @@ #define FIRM_IR_IRMODE_T_H #include +#include "irtypes.h" #include "irmode.h" -#include "tv.h" - -/** This struct is supposed to completely define a mode. **/ -struct ir_mode { - firm_kind kind; /**< distinguishes this node from others */ - modecode code; /**< unambiguous identifier of a mode */ - ident *name; /**< Name ident of this mode */ - - /* ----------------------------------------------------------------------- */ - /* On changing this struct you have to evaluate the mode_are_equal function!*/ - mode_sort sort; /**< coarse classification of this mode: - int, float, reference ... - (see irmode.h) */ - mode_arithmetic arithmetic; /**< different arithmetic operations possible with a mode */ - int size; /**< size of the mode in Bits. */ - unsigned sign:1; /**< signedness of this mode */ - unsigned int modulo_shift; /**< number of bits a values of this mode will be shifted */ - unsigned vector_elem; /**< if this is not equal 1, this is a vector mode with - vector_elem number of elements, size contains the size - of all bits and must be dividable by vector_elem */ - - /* ----------------------------------------------------------------------- */ - tarval *min; /**< the minimum value that can be expressed */ - tarval *max; /**< the maximum value that can be expressed */ - tarval *null; /**< the value 0 */ - tarval *one; /**< the value 1 */ - tarval *minus_one; /**< the value -1 */ - ir_mode *eq_signed; /**< For pointer modes, the equivalent signed integer one. */ - ir_mode *eq_unsigned; /**< For pointer modes, the equivalent unsigned integer one. */ - void *link; /**< To store some intermediate information */ - const void *tv_priv; /**< tarval module will save private data here */ -}; - /* ------------------------------- * * inline functions * * ------------------------------- */ extern ir_mode *mode_P_code, *mode_P_data; -static INLINE ir_mode * +static inline ir_mode * _get_modeP_code(void) { return mode_P_code; } -static INLINE ir_mode * +static inline ir_mode * _get_modeP_data(void) { return mode_P_data; } -static INLINE modecode +static inline ir_modecode _get_mode_modecode(const ir_mode *mode) { return mode->code; } -static INLINE ident * +static inline ident * _get_mode_ident(const ir_mode *mode) { return mode->name; } -static INLINE mode_sort -_get_mode_sort(const ir_mode* mode) { return mode->sort; } +static inline ir_mode_sort +_get_mode_sort(const ir_mode *mode) { return mode->sort; } -static INLINE int +static inline unsigned _get_mode_size_bits(const ir_mode *mode) { return mode->size; } -static INLINE int +static inline unsigned _get_mode_size_bytes(const ir_mode *mode) { - int size = _get_mode_size_bits(mode); - if ((size & 7) != 0) return -1; + unsigned size = _get_mode_size_bits(mode); + if ((size & 7) != 0) return (unsigned) -1; return size >> 3; } -static INLINE int +static inline int _get_mode_sign(const ir_mode *mode) { return mode->sign; } -static INLINE int +static inline ir_mode_arithmetic _get_mode_arithmetic(const ir_mode *mode) { return mode->arithmetic; } -static INLINE unsigned int +static inline unsigned int _get_mode_modulo_shift(const ir_mode *mode) { return mode->modulo_shift; } -static INLINE unsigned int +static inline unsigned int _get_mode_vector_elems(const ir_mode *mode) { return mode->vector_elem; } -static INLINE void * +static inline void * _get_mode_link(const ir_mode *mode) { return mode->link; } -static INLINE void +static inline void _set_mode_link(ir_mode *mode, void *l) { mode->link = l; } -/* Functions to check, whether a modecode is signed, float, int, num, data, +/* Functions to check, whether a ir_modecode is signed, float, int, num, data, datab or dataM. For more exact definitions read the corresponding pages in the firm documentation or the following enumeration @@ -148,75 +116,53 @@ _set_mode_link(ir_mode *mode, void *l) { mode->link = l; } = {data || irm_M} */ -static INLINE int +static inline int _mode_is_signed(const ir_mode *mode) { - assert(mode); return mode->sign; } -static INLINE int +static inline int _mode_is_float(const ir_mode *mode) { - assert(mode); return (_get_mode_sort(mode) == irms_float_number); } -static INLINE int +static inline int _mode_is_int(const ir_mode *mode) { - assert(mode); return (_get_mode_sort(mode) == irms_int_number); } -static INLINE int -_mode_is_character(const ir_mode *mode) { - assert(mode); - return (_get_mode_sort(mode) == irms_character); -} - -static INLINE int +static inline int _mode_is_reference(const ir_mode *mode) { - assert(mode); return (_get_mode_sort(mode) == irms_reference); } -static INLINE int +static inline int _mode_is_num(const ir_mode *mode) { - assert(mode); - return (_mode_is_int(mode) || _mode_is_float(mode)); -} - -static INLINE int -_mode_is_numP(const ir_mode *mode) { - assert(mode); - return (_mode_is_int(mode) || _mode_is_float(mode) || _mode_is_reference(mode)); + return (_get_mode_sort(mode) & irmsh_is_num); } -static INLINE int +static inline int _mode_is_data(const ir_mode *mode) { - assert(mode); - return (_mode_is_numP(mode) || _get_mode_sort(mode) == irms_character); + return (_get_mode_sort(mode) & irmsh_is_data); } -static INLINE int +static inline int _mode_is_datab(const ir_mode *mode) { - assert(mode); - return (_mode_is_data(mode) || _get_mode_sort(mode) == irms_internal_boolean); + return (_get_mode_sort(mode) & irmsh_is_datab); } -static INLINE int +static inline int _mode_is_dataM(const ir_mode *mode) { - assert(mode); - return (_mode_is_data(mode) || _get_mode_modecode(mode) == irm_M); + return (_get_mode_sort(mode) & irmsh_is_dataM); } -static INLINE int +static inline int _mode_is_float_vector(const ir_mode *mode) { - assert(mode); return (_get_mode_sort(mode) == irms_float_number) && (_get_mode_vector_elems(mode) > 1); } -static INLINE int +static inline int _mode_is_int_vector(const ir_mode *mode) { - assert(mode); return (_get_mode_sort(mode) == irms_int_number) && (_get_mode_vector_elems(mode) > 1); } @@ -242,10 +188,8 @@ void finish_mode(void); #define mode_is_signed(mode) _mode_is_signed(mode) #define mode_is_float(mode) _mode_is_float(mode) #define mode_is_int(mode) _mode_is_int(mode) -#define mode_is_character(mode) _mode_is_character(mode) #define mode_is_reference(mode) _mode_is_reference(mode) #define mode_is_num(mode) _mode_is_num(mode) -#define mode_is_numP(mode) _mode_is_numP(mode) #define mode_is_data(mode) _mode_is_data(mode) #define mode_is_datab(mode) _mode_is_datab(mode) #define mode_is_dataM(mode) _mode_is_dataM(mode)