X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firmode_t.h;h=f2870836a0ecfac3e82c65e0172e531524672500;hb=e41f887b6ed60098916f3b66004c237de33d5241;hp=e1cd2f28d3df96e3746d3772456372f67e7eaf30;hpb=dddcc630819f338c3b45e2bc646233e6872d5bb6;p=libfirm diff --git a/ir/ir/irmode_t.h b/ir/ir/irmode_t.h index e1cd2f28d..f2870836a 100644 --- a/ir/ir/irmode_t.h +++ b/ir/ir/irmode_t.h @@ -1,120 +1,68 @@ /* - * Project: libFIRM - * File name: ir/ir/irmode_t.h - * Purpose: Data modes of operations -- private header. - * Author: Martin Trapp, Christian Schaefer - * Modified by: Goetz Lindenmaier, Mathias Heil - * Created: - * CVS-ID: $Id$ - * Copyright: (c) 1998-2003 Universität Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. */ - /** - * @file irmode_t.h + * @file + * @brief Data modes of operations -- private header. + * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Mathias Heil, + * Michael Beck */ +#ifndef FIRM_IR_IRMODE_T_H +#define FIRM_IR_IRMODE_T_H -# ifndef _IRMODE_T_H_ -# define _IRMODE_T_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. */ - int align; /**< mode alignment in Bits. */ - unsigned sign:1; /**< signedness of this mode */ - unsigned int modulo_shift; /**< number of bits a valus 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; - tarval *max; - tarval *null; - tarval *one; - void *link; /**< To store some intermediate information */ - const void *tv_priv; /**< tarval module will save private data here */ -}; - +#include +#include "irtypes.h" +#include "irmode.h" /* ------------------------------- * * inline functions * * ------------------------------- */ -extern ir_mode *mode_P_mach; - -static INLINE ir_mode * -__get_modeP_mach(void) { return mode_P_mach; } +static inline ir_mode *get_modeP_code_(void) { return mode_P_code; } -static INLINE void -__set_modeP_mach(ir_mode *p) { - assert(mode_is_reference(p)); - mode_P_mach = p; -} - -static INLINE modecode -__get_mode_modecode(const ir_mode *mode) { return mode->code; } +static inline ir_mode *get_modeP_data_(void) { return mode_P_data; } -static INLINE ident * -__get_mode_ident(const ir_mode *mode) { return mode->name; } +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 -__get_mode_size_bits(const ir_mode *mode) { return mode->size; } +static inline unsigned get_mode_size_bits_(const ir_mode *mode) { return mode->size; } -static INLINE int -__get_mode_size_bytes(const ir_mode *mode) { - int size = __get_mode_size_bits(mode); - if ((size & 7) != 0) return -1; - return size >> 3; +static inline unsigned get_mode_size_bytes_(const ir_mode *mode) +{ + unsigned size = get_mode_size_bits_(mode); + if ((size & 7) != 0) return (unsigned) -1; + return size >> 3; } -static INLINE int -__get_mode_align_bits(const ir_mode *mode) { return mode->align; } +static inline int get_mode_sign_(const ir_mode *mode) { return mode->sign; } -static INLINE int -__get_mode_align_bytes(const ir_mode *mode) { - int align = __get_mode_align_bits(mode); - if ((align & 7) != 0) return -1; - return align >> 3; -} +static inline ir_mode_arithmetic get_mode_arithmetic_(const ir_mode *mode) { return mode->arithmetic; } -static INLINE int -__get_mode_sign(const ir_mode *mode) { return mode->sign; } +static inline unsigned int get_mode_modulo_shift_(const ir_mode *mode) { return mode->modulo_shift; } -static INLINE int -__get_mode_arithmetic(const ir_mode *mode) { return mode->arithmetic; } +static inline void *get_mode_link_(const ir_mode *mode) { return mode->link; } -static INLINE unsigned int -__get_mode_modulo_shift(const ir_mode *mode) { return mode->modulo_shift; } +static inline void set_mode_link_(ir_mode *mode, void *l) { mode->link = l; } -static INLINE unsigned int -__get_mode_vector_elems(const ir_mode *mode) { return mode->vector_elem; } - -static INLINE void * -__get_mode_link(const ir_mode *mode) { return mode->link; } - -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 mode is signed, float, int, num, data, datab or dataM. For more exact definitions read the corresponding pages - in the firm documentation or the followingenumeration + in the firm documentation or the following enumeration The set of "float" is defined as: --------------------------------- @@ -149,76 +97,59 @@ __set_mode_link(ir_mode *mode, void *l) { mode->link = l; } = {data || irm_M} */ -static INLINE int -__mode_is_signed(const ir_mode *mode) { - assert(mode); - return mode->sign; -} - -static INLINE int -__mode_is_float(const ir_mode *mode) { - assert(mode); - return (__get_mode_sort(mode) == irms_float_number); +static inline int mode_is_signed_(const ir_mode *mode) +{ + return mode->sign; } -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_float_(const ir_mode *mode) +{ + return (get_mode_sort_(mode) == irms_float_number); } -static INLINE int -__mode_is_character(const ir_mode *mode) { - assert(mode); - return (__get_mode_sort(mode) == irms_character); +static inline int mode_is_int_(const ir_mode *mode) +{ + return (get_mode_sort_(mode) == irms_int_number); } -static INLINE int -__mode_is_reference(const ir_mode *mode) { - assert(mode); - return (__get_mode_sort(mode) == irms_reference); +static inline int mode_is_reference_(const ir_mode *mode) +{ + return (get_mode_sort_(mode) == irms_reference); } -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_num_(const ir_mode *mode) +{ + return (get_mode_sort_(mode) & irmsh_is_num); } -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)); +static inline int mode_is_data_(const ir_mode *mode) +{ + return (get_mode_sort_(mode) & irmsh_is_data); } -static INLINE int -__mode_is_data(const ir_mode *mode) { - assert(mode); - return (__mode_is_num(mode) || __get_mode_sort(mode) == irms_character || __get_mode_sort(mode) == irms_reference); +static inline int mode_is_datab_(const ir_mode *mode) +{ + return (get_mode_sort_(mode) & irmsh_is_datab); } -static INLINE int -__mode_is_datab(const ir_mode *mode) { - assert(mode); - return (__mode_is_data(mode) || __get_mode_sort(mode) == irms_internal_boolean); +static inline int mode_is_dataM_(const ir_mode *mode) +{ + return (get_mode_sort_(mode) & irmsh_is_dataM); } -static INLINE int -__mode_is_dataM(const ir_mode *mode) { - assert(mode); - return (__mode_is_data(mode) || __get_mode_modecode(mode) == irm_M); +static inline ir_type *get_type_for_mode_(const ir_mode *mode) +{ + return mode->type; } -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 unsigned get_mode_mantissa_size_(const ir_mode *mode) +{ + return mode->float_desc.mantissa_size; } -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); +static inline unsigned get_mode_exponent_size_(const ir_mode *mode) +{ + return mode->float_desc.exponent_size; } /** mode module initialization, call once before use of any other function **/ @@ -227,31 +158,27 @@ void init_mode(void); /** mode module finalization. frees all memory. */ void finish_mode(void); -#define get_modeP_mach() __get_modeP_mach() -#define set_modeP_mach(p) __set_modeP_mach(p) -#define get_mode_modecode(mode) __get_mode_modecode(mode) -#define get_mode_ident(mode) __get_mode_ident(mode) -#define get_mode_sort(mode) __get_mode_sort(mode) -#define get_mode_size_bits(mode) __get_mode_size_bits(mode) -#define get_mode_size_bytes(mode) __get_mode_size_bytes(mode) -#define get_mode_align(mode) __get_mode_align(mode) -#define get_mode_sign(mode) __get_mode_sign(mode) -#define get_mode_arithmetic(mode) __get_mode_arithmetic(mode) -#define get_mode_modulo_shift(mode) __get_mode_modulo_shift(mode) -#define get_mode_n_vector_elems(mode) __get_mode_vector_elems(mode) -#define get_mode_link(mode) __get_mode_link(mode) -#define set_mode_link(mode, l) __set_mode_link(mode, l) -#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) -#define mode_is_float_vector(mode) __mode_is_float_vector(mode) -#define mode_is_int_vector(mode) __mode_is_int_vector(mode) - -#endif /* _IRMODE_T_H_ */ +#define get_modeP_code() get_modeP_code_() +#define get_modeP_data() get_modeP_data_() +#define get_mode_ident(mode) get_mode_ident_(mode) +#define get_mode_sort(mode) get_mode_sort_(mode) +#define get_mode_size_bits(mode) get_mode_size_bits_(mode) +#define get_mode_size_bytes(mode) get_mode_size_bytes_(mode) +#define get_mode_sign(mode) get_mode_sign_(mode) +#define get_mode_arithmetic(mode) get_mode_arithmetic_(mode) +#define get_mode_modulo_shift(mode) get_mode_modulo_shift_(mode) +#define get_mode_link(mode) get_mode_link_(mode) +#define set_mode_link(mode, l) set_mode_link_(mode, l) +#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_reference(mode) mode_is_reference_(mode) +#define mode_is_num(mode) mode_is_num_(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) +#define get_type_for_mode(mode) get_type_for_mode_(mode) +#define get_mode_mantissa_size(mode) get_mode_mantissa_size_(mode) +#define get_mode_exponent_size(mode) get_mode_exponent_size_(mode) + +#endif