From 6ab5eb8f50f7423c4ec475a22f67264b39777611 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Tue, 19 Oct 2004 10:47:34 +0000 Subject: [PATCH] removed the align attribute find_double_bits_int_mode() added [r4147] --- ir/ir/irmode.c | 55 ++++++++++++++---------------------------------- ir/ir/irmode.h | 24 ++++++++++----------- ir/ir/irmode_t.h | 20 ++++-------------- 3 files changed, 31 insertions(+), 68 deletions(-) diff --git a/ir/ir/irmode.c b/ir/ir/irmode.c index f1c37aa02..de7ed6340 100644 --- a/ir/ir/irmode.c +++ b/ir/ir/irmode.c @@ -59,7 +59,6 @@ INLINE static int modes_are_equal(const ir_mode *m, const ir_mode *n) if (m->sort == n->sort && m->arithmetic == n->arithmetic && m->size == n->size && - m->align == n->align && m->sign == n->sign && m->modulo_shift == n->modulo_shift && m->vector_elem == n->vector_elem) @@ -261,7 +260,7 @@ static ir_mode *register_mode(const ir_mode* new_mode) /* * Creates a new mode. */ -ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int bit_align, int sign, +ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int sign, mode_arithmetic arithmetic, unsigned int modulo_shift ) { ir_mode mode_tmpl; @@ -270,7 +269,6 @@ ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int bit_ali mode_tmpl.name = new_id_from_str(name); mode_tmpl.sort = sort; mode_tmpl.size = bit_size; - mode_tmpl.align = bit_align; mode_tmpl.sign = sign ? 1 : 0; mode_tmpl.modulo_shift = (mode_tmpl.sort == irms_int_number) ? modulo_shift : 0; mode_tmpl.vector_elem = 1; @@ -306,7 +304,7 @@ ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int bit_ali /* * Creates a new vector mode. */ -ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsigned num_of_elem, int bit_align, int sign, +ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsigned num_of_elem, int sign, mode_arithmetic arithmetic, unsigned int modulo_shift ) { ir_mode mode_tmpl; @@ -315,7 +313,6 @@ ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsi mode_tmpl.name = new_id_from_str(name); mode_tmpl.sort = sort; mode_tmpl.size = bit_size * num_of_elem; - mode_tmpl.align = bit_align; mode_tmpl.sign = sign ? 1 : 0; mode_tmpl.modulo_shift = (mode_tmpl.sort == irms_int_number) ? modulo_shift : 0; mode_tmpl.vector_elem = num_of_elem; @@ -399,20 +396,6 @@ int return __get_mode_size_bytes(mode); } -int -(get_mode_align_bits)(const ir_mode *mode) -{ - ANNOUNCE(); - return __get_mode_align_bits(mode); -} - -int -(get_mode_align_bytes)(const ir_mode *mode) -{ - ANNOUNCE(); - return __get_mode_align_bytes(mode); -} - int (get_mode_sign)(const ir_mode *mode) { @@ -693,7 +676,6 @@ init_mode (void) /* Internal Modes */ newmode.arithmetic = irma_none; newmode.size = 0; - newmode.align = 0; newmode.sign = 0; newmode.modulo_shift = 0; newmode.vector_elem = 0; @@ -765,7 +747,6 @@ init_mode (void) newmode.name = new_id_from_chars("F", 1); newmode.code = irm_F; newmode.sign = 1; - newmode.align = 32; newmode.size = 32; mode_F = register_mode(&newmode); @@ -774,7 +755,6 @@ init_mode (void) newmode.name = new_id_from_chars("D", 1); newmode.code = irm_D; newmode.sign = 1; - newmode.align = 64; newmode.size = 64; mode_D = register_mode(&newmode); @@ -783,7 +763,6 @@ init_mode (void) newmode.name = new_id_from_chars("E", 1); newmode.code = irm_E; newmode.sign = 1; - newmode.align = 128; newmode.size = 80; mode_E = register_mode(&newmode); @@ -796,7 +775,6 @@ init_mode (void) newmode.name = new_id_from_chars("Bs", 2); newmode.code = irm_Bs; newmode.sign = 1; - newmode.align = 8; newmode.size = 8; newmode.modulo_shift = 32; @@ -807,7 +785,6 @@ init_mode (void) newmode.code = irm_Bu; newmode.arithmetic = irma_twos_complement; newmode.sign = 0; - newmode.align = 8; newmode.size = 8; newmode.modulo_shift = 32; @@ -817,7 +794,6 @@ init_mode (void) newmode.name = new_id_from_chars("Hs", 2); newmode.code = irm_Hs; newmode.sign = 1; - newmode.align = 16; newmode.size = 16; newmode.modulo_shift = 32; @@ -827,7 +803,6 @@ init_mode (void) newmode.name = new_id_from_chars("Hu", 2); newmode.code = irm_Hu; newmode.sign = 0; - newmode.align = 16; newmode.size = 16; newmode.modulo_shift = 32; @@ -837,7 +812,6 @@ init_mode (void) newmode.name = new_id_from_chars("Is", 2); newmode.code = irm_Is; newmode.sign = 1; - newmode.align = 32; newmode.size = 32; newmode.modulo_shift = 32; @@ -847,7 +821,6 @@ init_mode (void) newmode.name = new_id_from_chars("Iu", 2); newmode.code = irm_Iu; newmode.sign = 0; - newmode.align = 32; newmode.size = 32; newmode.modulo_shift = 32; @@ -857,7 +830,6 @@ init_mode (void) newmode.name = new_id_from_chars("Ls", 2); newmode.code = irm_Ls; newmode.sign = 1; - newmode.align = 32; newmode.size = 64; newmode.modulo_shift = 64; @@ -867,7 +839,6 @@ init_mode (void) newmode.name = new_id_from_chars("Lu", 2); newmode.code = irm_Lu; newmode.sign = 0; - newmode.align = 32; newmode.size = 64; newmode.modulo_shift = 64; @@ -881,7 +852,6 @@ init_mode (void) newmode.name = new_id_from_chars("C", 1); newmode.code = irm_C; newmode.sign = 0; - newmode.align = 8; newmode.size = 8; newmode.modulo_shift = 32; @@ -891,7 +861,6 @@ init_mode (void) newmode.name = new_id_from_chars("U", 1); newmode.code = irm_U; newmode.sign = 0; - newmode.align = 16; newmode.size = 16; newmode.modulo_shift = 32; @@ -905,7 +874,6 @@ init_mode (void) newmode.name = new_id_from_chars("P", 1); newmode.code = irm_P; newmode.sign = 0; - newmode.align = 32; newmode.size = 32; newmode.modulo_shift = 0; @@ -915,17 +883,17 @@ init_mode (void) mode_P_mach = mode_P; } -ir_mode *find_unsigned_mode(const ir_mode *mode) -{ +/* find a signed mode for an unsigned integer mode */ +ir_mode *find_unsigned_mode(const ir_mode *mode) { ir_mode n = *mode; - assert(mode->sort == irms_int_number); + if (mode->sort != irms_int_number); n.sign = 0; return find_mode(&n); } -ir_mode *find_signed_mode(const ir_mode *mode) -{ +/* find an unsigned mode for a signed integer mode */ +ir_mode *find_signed_mode(const ir_mode *mode) { ir_mode n = *mode; assert(mode->sort == irms_int_number); @@ -933,6 +901,15 @@ ir_mode *find_signed_mode(const ir_mode *mode) return find_mode(&n); } +/* finds a integer mode with 2*n bits for an integer mode with n bits. */ +ir_mode *find_double_bits_int_mode(const ir_mode *mode) { + ir_mode n = *mode; + + assert(mode->sort == irms_int_number && mode->arithmetic == irma_twos_complement); + + n.size = 2*mode->size; + return find_mode(&n); +} void finish_mode(void) { obstack_free(&modes, 0); diff --git a/ir/ir/irmode.h b/ir/ir/irmode.h index 804dc327c..6ec83aa0f 100644 --- a/ir/ir/irmode.h +++ b/ir/ir/irmode.h @@ -48,7 +48,6 @@ * - ident *name: Name of this mode. Two modes are different if the name is different. * - mode_sort sort: sort of mode specifying possible usage kategories * - int size: size of the mode in Bits. - * - int align: byte alignment * - unsigned sign:1: signedness of this mode * - ... more to come * - modulo_shift specifies for modes of kind irms_int_number @@ -140,7 +139,6 @@ typedef enum { * @param name the name of the mode to be created * @param sort the mode_sort of the mode to be created * @param bit_size number of bits this mode allocate - * @param bit_align the alignment for an entity of this mode in bits * @param sign non-zero if this is a signed mode * @param arithmetic arithmetic operations possible with a mode * @param modulo_shift Is ignored for modes other than integer. @@ -157,9 +155,9 @@ typedef enum { * * @note * It is allowed to construct the default modes. So, a call - * new_ir_mode("Is", irms_int_number, 32, 4, 1, irma_twos_complement, 32) will return mode_Is. + * new_ir_mode("Is", irms_int_number, 32, 1, irma_twos_complement, 32) will return mode_Is. */ -ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int bit_align, int sign, mode_arithmetic arithmetic, unsigned int modulo_shift); +ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int sign, mode_arithmetic arithmetic, unsigned int modulo_shift); /** * Creates a new vector mode. @@ -168,7 +166,6 @@ ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int bit_ali * @param sort the mode_sort of the mode to be created * @param bit_size number of bits for one element of this mode * @param num_of_elem number of elements in this vector mode - * @param bit_align the alignment for an entity of this mode in bits * @param sign non-zero if this is a signed mode * @param arithmetic arithmetic operations possible with a mode * @param modulo_shift Is ignored for modes other than integer. @@ -182,7 +179,7 @@ ir_mode *new_ir_mode(const char *name, mode_sort sort, int bit_size, int bit_ali * @return * The new mode or NULL on error. */ -ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsigned num_of_elem, int bit_align, int sign, +ir_mode *new_ir_vector_mode(const char *name, mode_sort sort, int bit_size, unsigned num_of_elem, int sign, mode_arithmetic arithmetic, unsigned int modulo_shift ); /** @@ -216,13 +213,6 @@ int get_mode_size_bits(const ir_mode *mode); * If the size is not dividable by 8 returns -1. */ int get_mode_size_bytes(const ir_mode *mode); -/** Returns the alignment of values of the mode in bits. */ -int get_mode_align_bits(const ir_mode *mode); - -/** Returns the alignment of values of the mode in bytes. - * If the alignment is not dividable by 8 returns -1. */ -int get_mode_align_bytes(const ir_mode *mode); - /** Returns the signess of a mode. * * Returns the signess of a mode: 1 if mode is signed. */ @@ -427,12 +417,20 @@ int smaller_mode(const ir_mode *sm, const ir_mode *lm); /** * Returns a matching unsigned mode for a given integer signed mode. + * Returns NULL if no matching mode exists. */ ir_mode *find_unsigned_mode(const ir_mode *mode); /** * Returns a matching signed mode for a given integer unsigned mode. + * Returns NULL if no matching mode exists. */ ir_mode *find_signed_mode(const ir_mode *mode); +/** + * Returns an integer mode with 2*n bits for a given integer mode with n bits. + * Returns NULL if no matching mode exists. + */ +ir_mode *find_double_bits_int_mode(const ir_mode *mode); + #endif /* _IRMODE_H_ */ diff --git a/ir/ir/irmode_t.h b/ir/ir/irmode_t.h index e1cd2f28d..fc6cb6288 100644 --- a/ir/ir/irmode_t.h +++ b/ir/ir/irmode_t.h @@ -34,7 +34,6 @@ struct ir_mode { (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 @@ -42,10 +41,10 @@ struct ir_mode { of all bits and must be dividable by vector_elem */ /* ----------------------------------------------------------------------- */ - tarval *min; - tarval *max; - tarval *null; - tarval *one; + 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 */ void *link; /**< To store some intermediate information */ const void *tv_priv; /**< tarval module will save private data here */ }; @@ -84,16 +83,6 @@ __get_mode_size_bytes(const ir_mode *mode) { return size >> 3; } -static INLINE int -__get_mode_align_bits(const ir_mode *mode) { return mode->align; } - -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 int __get_mode_sign(const ir_mode *mode) { return mode->sign; } @@ -234,7 +223,6 @@ void finish_mode(void); #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) -- 2.20.1