Commit aa7c5e02 authored by Matthias Braun's avatar Matthias Braun
Browse files

Remove firmstat

It is barely used but cross cuts into most libfirm components and
therefore isn't maintenance free.

The statev framework stays obviously.
parent ec1b7914
...@@ -237,13 +237,6 @@ set(SOURCES ...@@ -237,13 +237,6 @@ set(SOURCES
ir/opt/scalar_replace.c ir/opt/scalar_replace.c
ir/opt/tailrec.c ir/opt/tailrec.c
ir/opt/unreachable.c ir/opt/unreachable.c
ir/stat/const_stat.c
ir/stat/dags.c
ir/stat/distrib.c
ir/stat/firmstat.c
ir/stat/pattern.c
ir/stat/pattern_dmp.c
ir/stat/stat_dmp.c
ir/stat/stat_timing.c ir/stat/stat_timing.c
ir/stat/statev.c ir/stat/statev.c
ir/tr/entity.c ir/tr/entity.c
...@@ -448,7 +441,6 @@ set(INSTALL_HEADERS ...@@ -448,7 +441,6 @@ set(INSTALL_HEADERS
include/libfirm/firm.h include/libfirm/firm.h
include/libfirm/firm_common.h include/libfirm/firm_common.h
include/libfirm/firm_types.h include/libfirm/firm_types.h
include/libfirm/firmstat.h
include/libfirm/heights.h include/libfirm/heights.h
include/libfirm/ident.h include/libfirm/ident.h
include/libfirm/irarch.h include/libfirm/irarch.h
......
...@@ -74,7 +74,6 @@ ...@@ -74,7 +74,6 @@
#include "dbginfo.h" #include "dbginfo.h"
#include "execfreq.h" #include "execfreq.h"
#include "firm_common.h" #include "firm_common.h"
#include "firmstat.h"
#include "firm_types.h" #include "firm_types.h"
#include "heights.h" #include "heights.h"
#include "ident.h" #include "ident.h"
......
/*
* This file is part of libFirm.
* Copyright (C) 2012 University of Karlsruhe.
*/
/**
* @file
* @brief Statistics for Firm.
* @author Michael Beck
*/
#ifndef FIRM_STAT_FIRMSTAT_H
#define FIRM_STAT_FIRMSTAT_H
#include "firm_types.h"
#include "begin.h"
/**
* Dump a snapshot of the statistic values.
* Never called from libFirm should be called from user.
*
* @param fname base name of the statistic output file
* @param phase a phase name. Prefix will be firmstat-\<phase\>-
*/
FIRM_API void stat_dump_snapshot(const char *fname, const char *phase);
/**
* initialize the statistics module.
* Should be called directly after ir_init
*/
FIRM_API void firm_init_stat(void);
/**
* terminates the statistics module, frees all memory
*/
FIRM_API void stat_term(void);
/**
* returns 1 if statistic module is active, 0 otherwise
*/
FIRM_API int stat_is_active(void);
#include "end.h"
#endif
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "irtools.h" #include "irtools.h"
#include "irverify.h" #include "irverify.h"
#include "iroptimize.h" #include "iroptimize.h"
#include "firmstat.h"
#include "execfreq_t.h" #include "execfreq_t.h"
#include "irprofile.h" #include "irprofile.h"
#include "ircons.h" #include "ircons.h"
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "panic.h" #include "panic.h"
#include "execfreq.h" #include "execfreq.h"
#include "firmstat_t.h"
#include "irgwalk.h" #include "irgwalk.h"
#include "irhooks.h" #include "irhooks.h"
#include "irnode_t.h" #include "irnode_t.h"
...@@ -58,7 +57,6 @@ static void check_reg_pressure_class(pressure_walker_env_t *env, ...@@ -58,7 +57,6 @@ static void check_reg_pressure_class(pressure_walker_env_t *env,
if (max_live > env->max_pressure) if (max_live > env->max_pressure)
env->max_pressure = max_live; env->max_pressure = max_live;
stat_be_block_regpressure(env->irg, block, max_live, cls->name);
ir_nodeset_destroy(&live_nodes); ir_nodeset_destroy(&live_nodes);
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "iredges_t.h" #include "iredges_t.h"
#include "pdeq.h" #include "pdeq.h"
#include "panic.h" #include "panic.h"
#include "firmstat_t.h"
#include "bearch.h" #include "bearch.h"
#include "besched.h" #include "besched.h"
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "irprintf.h" #include "irprintf.h"
#include "irdump.h" #include "irdump.h"
#include "panic.h" #include "panic.h"
#include "firmstat_t.h"
#include "be_t.h" #include "be_t.h"
#include "bediagnostic.h" #include "bediagnostic.h"
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "irgraph_t.h" #include "irgraph_t.h"
#include "type_t.h" #include "type_t.h"
#include "entity_t.h" #include "entity_t.h"
#include "firmstat.h"
#include "irarch.h" #include "irarch.h"
#include "irhooks.h" #include "irhooks.h"
#include "iredges_t.h" #include "iredges_t.h"
...@@ -38,7 +37,6 @@ ...@@ -38,7 +37,6 @@
#include "be_t.h" #include "be_t.h"
#include "irtools.h" #include "irtools.h"
#include "execfreq_t.h" #include "execfreq_t.h"
#include "firmstat_t.h"
/* returns the firm root */ /* returns the firm root */
lc_opt_entry_t *firm_opt_get_root(void) lc_opt_entry_t *firm_opt_get_root(void)
...@@ -74,7 +72,6 @@ void ir_init(void) ...@@ -74,7 +72,6 @@ void ir_init(void)
arch_dep_set_opts(arch_dep_none); arch_dep_set_opts(arch_dep_none);
init_execfreq(); init_execfreq();
init_stat();
firm_be_init(); firm_be_init();
#ifdef DEBUG_libfirm #ifdef DEBUG_libfirm
......
...@@ -14,41 +14,6 @@ ...@@ -14,41 +14,6 @@
#include <stdio.h> #include <stdio.h>
#include "firm_types.h" #include "firm_types.h"
/**
* options for the hook_merge_nodes hook
*/
typedef enum {
HOOK_OPT_DEAD_BLOCK, /**< a block was removed because it's dead */
HOOK_OPT_STG, /**< straightening optimization */
HOOK_OPT_IFSIM, /**< if simplification */
HOOK_OPT_CONST_EVAL, /**< constant evaluation */
HOOK_OPT_ALGSIM, /**< algebraic simplification */
HOOK_OPT_PHI, /**< Phi optimization */
HOOK_OPT_SYNC, /**< Sync optimization */
HOOK_OPT_WAW, /**< Write-After-Write optimization */
HOOK_OPT_WAR, /**< Write-After-Read optimization */
HOOK_OPT_RAW, /**< Read-After-Write optimization */
HOOK_OPT_RAR, /**< Read-After-Read optimization */
HOOK_OPT_RC, /**< Read-a-Const optimization */
HOOK_OPT_TUPLE, /**< Tuple optimization */
HOOK_OPT_ID, /**< ID optimization */
HOOK_OPT_CSE, /**< common subexpression elimination */
HOOK_OPT_STRENGTH_RED,/**< strength reduction */
HOOK_OPT_ARCH_DEP, /**< architecture dependent optimization */
HOOK_OPT_REASSOC, /**< reassociation */
HOOK_OPT_POLY_CALL, /**< polymorphic call optimization */
HOOK_OPT_IF_CONV, /**< an if conversion was tried */
HOOK_OPT_FUNC_CALL, /**< a real function call was removed */
HOOK_OPT_CONFIRM, /**< a value was substituted by another due to a Confirm */
HOOK_OPT_CONFIRM_C, /**< a value was substituted by a const due to a Confirm */
HOOK_OPT_CONFIRM_E, /**< a value was evaluated due to a Confirm */
HOOK_OPT_EXC_REM, /**< a exception edge was removed due to a Confirmation prove */
HOOK_OPT_NORMALIZE, /**< a commutative node was normalized */
HOOK_LOWERED, /**< lowered */
HOOK_BACKEND, /**< a backend transformation */
HOOK_OPT_LAST
} hook_opt_kind;
/** /**
* A generic function type. * A generic function type.
*/ */
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "irhooks.h" #include "irhooks.h"
#include "array.h" #include "array.h"
#include "panic.h" #include "panic.h"
#include "pattern_dmp.h"
#include "strcalc.h" #include "strcalc.h"
/** Obstack to hold all modes. */ /** Obstack to hold all modes. */
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "constbits.h" #include "constbits.h"
#include "dbginfo_t.h" #include "dbginfo_t.h"
#include "debug.h" #include "debug.h"
#include "firmstat.h"
#include "ircons_t.h" #include "ircons_t.h"
#include "irdump.h" #include "irdump.h"
#include "iredges_t.h" #include "iredges_t.h"
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "panic.h" #include "panic.h"
#include "be.h" #include "be.h"
#include "util.h" #include "util.h"
#include "firmstat_t.h"
#include "tv_t.h" #include "tv_t.h"
/** Walker environment. */ /** Walker environment. */
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#include "panic.h" #include "panic.h"
#include "irnodeset.h" #include "irnodeset.h"
#include "tv_t.h" #include "tv_t.h"
#include "firmstat_t.h"
#include "irprintf.h" #include "irprintf.h"
#include "irdump.h" #include "irdump.h"
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "tv_t.h" #include "tv_t.h"
#include "valueset.h" #include "valueset.h"
#include "irloop.h" #include "irloop.h"
#include "firmstat_t.h"
#include "irgraph_t.h" #include "irgraph_t.h"
#include "irnode_t.h" #include "irnode_t.h"
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "bitfiddle.h" #include "bitfiddle.h"
#include "be.h" #include "be.h"
#include "panic.h" #include "panic.h"
#include "firmstat_t.h"
#include "entity_t.h" #include "entity_t.h"
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "dbginfo_t.h" #include "dbginfo_t.h"
#include "irhooks.h" #include "irhooks.h"
#include "firmstat.h"
#include "util.h" #include "util.h"
/** /**
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "iroptimize.h" #include "iroptimize.h"
#include "iropt_dbg.h" #include "iropt_dbg.h"
#include "vrp.h" #include "vrp.h"
#include "firmstat_t.h"
#undef AVOID_PHIB #undef AVOID_PHIB
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "array.h" #include "array.h"
#include "debug.h" #include "debug.h"
#include "panic.h" #include "panic.h"
#include "firmstat_t.h"
#include "hashptr.h" #include "hashptr.h"
#include "ircons.h" #include "ircons.h"
#include "irdom.h" #include "irdom.h"
...@@ -27,6 +26,7 @@ ...@@ -27,6 +26,7 @@
#include "irflag_t.h" #include "irflag_t.h"
#include "irgmod.h" #include "irgmod.h"
#include "irgwalk.h" #include "irgwalk.h"
#include "irhooks.h"
#include "irloop_t.h" #include "irloop_t.h"
#include "irop_t.h" #include "irop_t.h"
#include "iroptimize.h" #include "iroptimize.h"
......
/*
* This file is part of libFirm.
* Copyright (C) 2012 University of Karlsruhe.
*/
/**
* @file
* @brief Statistic functions for constant counting.
* @author Michael Beck
*/
#include "firmstat_t.h"
#include "tv_t.h"
#include "util.h"
/**
* calculated the dual logarithm of |value|
*/
static unsigned log2abs(long value)
{
unsigned res = 0;
if (value < 0)
value = -value;
if (value > 0xFFFF) {
res += 16;
value >>= 16;
}
if (value > 0xFF) {
res += 8;
value >>= 8;
}
if (value > 0xF) {
res += 4;
value >>= 4;
}
if (value > 3) {
res += 2;
value >>= 2;
}
if (value > 1) {
res += 1;
}
return res;
}
/**
* classify the value of a float tarval
*/
static float_classify_t classify_float_value(ir_tarval *tv)
{
ir_mode *mode = get_tarval_mode(tv);
if (tv == get_mode_null(mode)) {
return STAT_FC_0;
} else if (tv == get_mode_one(mode)) {
return STAT_FC_1;
} else if (tarval_is_finite(tv) && tarval_zero_mantissa(tv)) {
int exp = tarval_get_exponent(tv);
if (! tarval_is_negative(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_POWER_OF_TWO: return "2.0^x";
case STAT_FC_OTHER: return "other";
default: return "<UNKNOWN>";
}
}
/* update info on Consts */
void stat_update_const(stat_info_t *status, ir_node *node, graph_entry_t *graph)
{
ir_mode *mode = get_irn_mode(node);
ir_tarval *tv;
unsigned bits;
(void) graph;
if (mode_is_int(mode)) {
tv = get_Const_tarval(node);
/* FIXME: */
if (! tarval_is_long(tv))
return;
bits = log2abs(get_tarval_long(tv));
if (bits > ARRAY_SIZE(status->const_info.int_bits_count))
bits = ARRAY_SIZE(status->const_info.int_bits_count);
cnt_inc(&status->const_info.int_bits_count[bits]);
} else if (mode_is_float(mode)) {
tv = get_Const_tarval(node);
cnt_inc(&status->const_info.floats[classify_float_value(tv)]);
} else {
/* something different */
cnt_inc(&status->const_info.others);
}
}
/* clears the const statistics for a new snapshot */
void stat_const_clear(stat_info_t *status)
{
size_t i;
for (i = 0; i < ARRAY_SIZE(status->const_info.int_bits_count); ++i)
cnt_clr(&status->const_info.int_bits_count[i]);
for (i = 0; i < ARRAY_SIZE(status->const_info.floats); ++i)
cnt_clr(&status->const_info.floats[i]);
cnt_clr(&status->const_info.others);
}
/* initialize the Const statistic. */
void stat_init_const_cnt(stat_info_t *status)
{
(void) status;
/* currently nothing */
}
/*
* This file is part of libFirm.
* Copyright (C) 2012 University of Karlsruhe.
*/
/**
* @file
* @brief Statistics for Firm. Counter implementation.
* @author Michael Beck
*/
#ifndef FIRM_STAT_COUNTER_H
#define FIRM_STAT_COUNTER_H
#include <string.h>
#include <limits.h>
/*
* 32 bit should be enough for most cases
*/
#ifndef STAT_CNT_NUM
#define STAT_CNT_NUM 1
#endif
typedef struct counter_t {
unsigned cnt[STAT_CNT_NUM];
} counter_t;
/** initializes a counter with zero */
#define ZERO_CNT { { 0 } }
/**
* increase a counter
*/
static inline void cnt_inc(counter_t *cnt)
{
int i;
for (i = 0; i < STAT_CNT_NUM; ++i) {
if (++cnt->cnt[i])
break;
}
}
/**
* decrease a counter
*/
static inline void cnt_dec(counter_t *cnt)
{
int i;
for (i = 0; i < STAT_CNT_NUM; ++i) {
if (--cnt->cnt[i] != (unsigned) -1)
break;
}
}
/**
* set a counter to zero
*/
static inline void cnt_clr(counter_t *cnt)
{
memset(cnt->cnt, 0, sizeof(cnt->cnt));
}
/**
* add a counter to another
*/
static inline void cnt_add(counter_t *dst, const counter_t *src)
{
int i, carry = 0;
for (i = 0; i < STAT_CNT_NUM; ++i) {
unsigned x = dst->cnt[i];
unsigned y = src->cnt[i];
unsigned a = x + y + carry;
carry = (int)((x & y) | ((x | y) & ~a)) < 0 ? 1 : 0;
dst->cnt[i] = a;
}
}
/**
* add an (positive) integer to an counter
*/
static inline void cnt_add_i(counter_t *dst, int src)
{
int i;
unsigned carry = src;
for (i = 0; i < STAT_CNT_NUM; ++i) {
unsigned a = dst->cnt[i] + carry;
carry = a < dst->cnt[i];
dst->cnt[i] = a;
if (! carry)
break;
}
}
/**
* compare two counter
*/
static inline int cnt_cmp(const counter_t *a, const counter_t *b)
{
int i;
unsigned va = 0;
unsigned vb = 0;
for (i = STAT_CNT_NUM - 1 ; i >= 0; --i) {
va = a->cnt[i];
vb = b->cnt[i];
if (va != vb)
break;
}
if (va != vb)
return va < vb ? -1 : 1;
return 0;
}