From a297b28945282531a0c4828499b7f35cbac40b4d Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 8 Jun 2005 11:01:22 +0000 Subject: [PATCH] get_mode_minus_one() added [r5977] --- ir/ir/irmode.c | 45 ++++++++++++++++++++++++++++++--------------- ir/ir/irmode.h | 10 +++++++++- ir/ir/irmode_t.h | 1 + 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/ir/ir/irmode.c b/ir/ir/irmode.c index 79cc1c627..0f62449b8 100644 --- a/ir/ir/irmode.c +++ b/ir/ir/irmode.c @@ -24,7 +24,7 @@ # include "irmode_t.h" # include "ident.h" -# include "tv.h" +# include "tv_t.h" # include "obst.h" # include "irhooks.h" @@ -131,33 +131,37 @@ static void set_mode_values(ir_mode* mode) case irms_character: case irms_int_number: case irms_float_number: - mode->min = get_tarval_min(mode); - mode->max = get_tarval_max(mode); + mode->min = get_tarval_min(mode); + mode->max = get_tarval_max(mode); mode->null = get_tarval_null(mode); - mode->one = get_tarval_one(mode); + mode->one = get_tarval_one(mode); + mode->minus_one = get_tarval_minus_one(mode); break; case irms_internal_boolean: - mode->min = tarval_b_false; - mode->max = tarval_b_true; + mode->min = tarval_b_false; + mode->max = tarval_b_true; mode->null = tarval_b_false; - mode->one = tarval_b_true; + mode->one = tarval_b_true; + mode->minus_one = tarval_bad; break; case irms_reference: - mode->min = tarval_bad; - mode->max = tarval_bad; - mode->null = (get_mode_modecode(mode) == irm_P) ? tarval_P_void : tarval_bad; - mode->one = tarval_bad; + mode->min = tarval_bad; + mode->max = tarval_bad; + mode->null = get_tarval_null(mode); + mode->one = tarval_bad; + mode->minus_one = tarval_bad; break; case irms_auxiliary: case irms_memory: case irms_control_flow: - mode->min = tarval_bad; - mode->max = tarval_bad; + mode->min = tarval_bad; + mode->max = tarval_bad; mode->null = tarval_bad; - mode->one = tarval_bad; + mode->one = tarval_bad; + mode->minus_one = tarval_bad; break; } } @@ -490,6 +494,17 @@ get_mode_one (ir_mode *mode) return mode->one; } +tarval * +get_mode_minus_one (ir_mode *mode) +{ + ANNOUNCE(); + assert(mode); + assert(get_mode_modecode(mode) < num_modes); + assert(mode_is_data(mode)); + + return mode->minus_one; +} + tarval * get_mode_infinite(ir_mode *mode) { @@ -887,7 +902,7 @@ init_mode (void) mode_P = register_mode(&newmode); - /* set the machine specific modes to the predifined ones */ + /* set the machine specific modes to the predefined ones */ mode_P_mach = mode_P; } diff --git a/ir/ir/irmode.h b/ir/ir/irmode.h index 5d4992186..42b566c06 100644 --- a/ir/ir/irmode.h +++ b/ir/ir/irmode.h @@ -274,10 +274,18 @@ tarval *get_mode_null(ir_mode *mode); * * One, being the multiplicative neutral element, * is defined only for modes allowing multiplication, - * i.e. ints and op_pin_state_floats. + * i.e. ints and floats. */ tarval *get_mode_one(ir_mode *mode); +/** + * Returns the value Minus One, represented in this mode. + * + * Minus One is defined only for modes allowing + * multiplication with signed values, i.e. signed ints and floats. + */ +tarval *get_mode_minus_one(ir_mode *mode); + /** * Returns the positive infinite value of a mode. * diff --git a/ir/ir/irmode_t.h b/ir/ir/irmode_t.h index fc6cb6288..188aa2c79 100644 --- a/ir/ir/irmode_t.h +++ b/ir/ir/irmode_t.h @@ -45,6 +45,7 @@ struct ir_mode { 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 */ void *link; /**< To store some intermediate information */ const void *tv_priv; /**< tarval module will save private data here */ }; -- 2.20.1