From 602a065664be1be0038b551da457ce228207a80b Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Sun, 24 Aug 2008 11:22:41 +0000 Subject: [PATCH] - add QuotC - fixed floating point constant classification [r21404] --- ir/stat/const_stat.c | 24 ++++++++++++++++-------- ir/stat/firmstat.c | 24 +++++++++++++++++++----- ir/stat/firmstat_t.h | 3 ++- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/ir/stat/const_stat.c b/ir/stat/const_stat.c index cde1994a4..4fd5b200b 100644 --- a/ir/stat/const_stat.c +++ b/ir/stat/const_stat.c @@ -72,20 +72,28 @@ static float_classify_t classify_float_value(tarval *tv) { return STAT_FC_1; else if (tv == get_mode_one(mode)) return STAT_FC_1; - + else if (tarval_ieee754_zero_mantissa(tv)) { + int exp = tarval_ieee754_get_exponent(tv); + + if (exp == 1) + return STAT_FC_2; + else if (exp == -1) + return STAT_FC_0_5; + return STAT_FC_POWER_OF_TWO; + } return STAT_FC_OTHER; } /* return a human readable name for an float classification */ const char *stat_fc_name(float_classify_t classification) { switch (classification) { - case STAT_FC_0: return "0.0"; - case STAT_FC_1: return "1.0"; - case STAT_FC_2: return "2.0"; - case STAT_FC_0_5: return "0.5"; - case STAT_FC_EXACT: return "exact"; - case STAT_FC_OTHER: return "other"; - default: return ""; + case STAT_FC_0: return "0.0"; + case STAT_FC_1: return "1.0"; + case STAT_FC_2: return "2.0"; + case STAT_FC_0_5: return "0.5"; + case STAT_FC_POWER_OF_TWO: return "2.0^x"; + case STAT_FC_OTHER: return "other"; + default: return ""; } } diff --git a/ir/stat/firmstat.c b/ir/stat/firmstat.c index 2bef6616b..f665ee943 100644 --- a/ir/stat/firmstat.c +++ b/ir/stat/firmstat.c @@ -73,6 +73,9 @@ static ir_op _op_ModC; /** The Div by Const node. */ static ir_op _op_DivModC; +/** The Quot by Const node. */ +static ir_op _op_QuotC; + /** The memory Proj node. */ static ir_op _op_ProjM; @@ -96,7 +99,7 @@ static ir_op _op_SelSelSel; /** * global status */ -static const int status_disable = 0; +static const unsigned status_disable = 0; static stat_info_t *status = (stat_info_t *)&status_disable; /** @@ -564,29 +567,35 @@ static ir_op *stat_get_irn_op(ir_node *node) } /* if */ break; case iro_Mul: - if (get_irn_op(get_Mul_left(node)) == op_Const || get_irn_op(get_Mul_right(node)) == op_Const) { + if (is_Const(get_Mul_left(node)) || is_Const(get_Mul_right(node))) { /* special case, a Multiply by a const, count on extra counter */ op = status->op_MulC ? status->op_MulC : op; } /* if */ break; case iro_Div: - if (get_irn_op(get_Div_right(node)) == op_Const) { + if (is_Const(get_Div_right(node))) { /* special case, a division by a const, count on extra counter */ op = status->op_DivC ? status->op_DivC : op; } /* if */ break; case iro_Mod: - if (get_irn_op(get_Mod_right(node)) == op_Const) { + if (is_Const(get_Mod_right(node))) { /* special case, a module by a const, count on extra counter */ op = status->op_ModC ? status->op_ModC : op; } /* if */ break; case iro_DivMod: - if (get_irn_op(get_DivMod_right(node)) == op_Const) { + if (is_Const(get_DivMod_right(node))) { /* special case, a division/modulo by a const, count on extra counter */ op = status->op_DivModC ? status->op_DivModC : op; } /* if */ break; + case iro_Quot: + if (is_Const(get_Quot_right(node))) { + /* special case, a floating point division by a const, count on extra counter */ + op = status->op_QuotC ? status->op_QuotC : op; + } /* if */ + break; case iro_Sel: if (get_irn_op(get_Sel_ptr(node)) == op_Sel) { /* special case, a Sel of a Sel, count on extra counter */ @@ -2230,6 +2239,9 @@ void firm_init_stat(unsigned enable_options) _op_DivModC.code = --num; _op_DivModC.name = new_id_from_chars(X("DivModC")); + _op_QuotC.code = --num; + _op_QuotC.name = new_id_from_chars(X("QuotC")); + status->op_Phi0 = &_op_Phi0; status->op_PhiM = &_op_PhiM; status->op_ProjM = &_op_ProjM; @@ -2237,6 +2249,7 @@ void firm_init_stat(unsigned enable_options) status->op_DivC = &_op_DivC; status->op_ModC = &_op_ModC; status->op_DivModC = &_op_DivModC; + status->op_QuotC = &_op_QuotC; } else { status->op_Phi0 = NULL; status->op_PhiM = NULL; @@ -2245,6 +2258,7 @@ void firm_init_stat(unsigned enable_options) status->op_DivC = NULL; status->op_ModC = NULL; status->op_DivModC = NULL; + status->op_QuotC = NULL; } /* if */ /* for Florian: count the Sel depth */ diff --git a/ir/stat/firmstat_t.h b/ir/stat/firmstat_t.h index 32b03f363..5757f9ca7 100644 --- a/ir/stat/firmstat_t.h +++ b/ir/stat/firmstat_t.h @@ -255,7 +255,7 @@ typedef enum _float_classify_t { STAT_FC_1, /**< the float value 1.0 */ STAT_FC_2, /**< the float value 2.0 */ STAT_FC_0_5, /**< the float value 0.5 */ - STAT_FC_EXACT, /**< an exact value */ + STAT_FC_POWER_OF_TWO, /**< another 2^x value */ STAT_FC_OTHER, /**< all other values */ STAT_FC_MAX /**< last value */ } float_classify_t; @@ -331,6 +331,7 @@ typedef struct _statistic_info_t { ir_op *op_DivC; /**< pseudo op for division by const */ ir_op *op_ModC; /**< pseudo op for modulo by const */ ir_op *op_DivModC; /**< pseudo op for DivMod by const */ + ir_op *op_QuotC; /**< pseudo op for floating point division by const */ ir_op *op_SelSel; /**< pseudo op for Sel(Sel) */ ir_op *op_SelSelSel; /**< pseudo op for Sel(Sel(Sel)) */ dumper_t *dumper; /**< list of dumper */ -- 2.20.1