projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improved doxygen docu.
[libfirm]
/
ir
/
be
/
bestat.c
diff --git
a/ir/be/bestat.c
b/ir/be/bestat.c
index
03a16a6
..
762658d
100644
(file)
--- a/
ir/be/bestat.c
+++ b/
ir/be/bestat.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 1995-20
08
University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-20
11
University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
*
* This file is part of libFirm.
*
@@
-23,9
+23,7
@@
* @author Christian Wuerdig, Matthias Braun
* @version $Id$
*/
* @author Christian Wuerdig, Matthias Braun
* @version $Id$
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config.h"
-#endif
#include <time.h>
#include <time.h>
@@
-39,22
+37,22
@@
#include "statev.h"
#include "error.h"
#include "statev.h"
#include "error.h"
-#include "bearch
_t
.h"
-#include "beirg
_t
.h"
+#include "bearch.h"
+#include "beirg.h"
#include "bestat.h"
#include "belive_t.h"
#include "besched.h"
#include "bestat.h"
#include "belive_t.h"
#include "besched.h"
-#include "benode
_t
.h"
+#include "benode.h"
typedef struct pressure_walker_env_t pressure_walker_env_t;
struct pressure_walker_env_t {
typedef struct pressure_walker_env_t pressure_walker_env_t;
struct pressure_walker_env_t {
-
be_irg_t *b
irg;
+
ir_graph *
irg;
be_lv_t *lv;
double insn_count;
double regpressure;
be_lv_t *lv;
double insn_count;
double regpressure;
-
int
max_pressure;
+
size_t
max_pressure;
const arch_register_class_t *cls;
};
const arch_register_class_t *cls;
};
@@
-62,55
+60,54
@@
static void check_reg_pressure_class(pressure_walker_env_t *env,
ir_node *block,
const arch_register_class_t *cls)
{
ir_node *block,
const arch_register_class_t *cls)
{
- be_irg_t *birg = env->birg;
- ir_graph *irg = be_get_birg_irg(birg);
- const arch_env_t *aenv = be_get_birg_arch_env(birg);
- ir_node *irn;
- ir_nodeset_t live_nodes;
- int max_live;
+ ir_graph *irg = env->irg;
+ ir_node *irn;
+ ir_nodeset_t live_nodes;
+ size_t max_live;
ir_nodeset_init(&live_nodes);
ir_nodeset_init(&live_nodes);
- be_liveness_end_of_block(env->lv,
aenv,
cls, block, &live_nodes);
+ be_liveness_end_of_block(env->lv, cls, block, &live_nodes);
max_live = ir_nodeset_size(&live_nodes);
env->regpressure += max_live;
sched_foreach_reverse(block, irn) {
max_live = ir_nodeset_size(&live_nodes);
env->regpressure += max_live;
sched_foreach_reverse(block, irn) {
-
in
t cnt;
+
size_
t cnt;
- if(is_Phi(irn))
+ if
(is_Phi(irn))
break;
break;
- be_liveness_transfer(
aenv,
cls, irn, &live_nodes);
+ be_liveness_transfer(cls, irn, &live_nodes);
cnt = ir_nodeset_size(&live_nodes);
max_live = cnt < max_live ? max_live : cnt;
env->regpressure += cnt;
env->insn_count++;
}
cnt = ir_nodeset_size(&live_nodes);
max_live = cnt < max_live ? max_live : cnt;
env->regpressure += cnt;
env->insn_count++;
}
- if(max_live > env->max_pressure)
+ if
(max_live > env->max_pressure)
env->max_pressure = max_live;
stat_be_block_regpressure(irg, block, max_live, cls->name);
ir_nodeset_destroy(&live_nodes);
}
env->max_pressure = max_live;
stat_be_block_regpressure(irg, block, max_live, cls->name);
ir_nodeset_destroy(&live_nodes);
}
-static void stat_reg_pressure_block(ir_node *block, void *data) {
- pressure_walker_env_t *env = data;
+static void stat_reg_pressure_block(ir_node *block, void *data)
+{
+ pressure_walker_env_t *env = (pressure_walker_env_t*)data;
check_reg_pressure_class(env, block, env->cls);
}
check_reg_pressure_class(env, block, env->cls);
}
-void be_do_stat_reg_pressure(be_irg_t *birg, const arch_register_class_t *cls) {
+void be_do_stat_reg_pressure(ir_graph *irg, const arch_register_class_t *cls)
+{
pressure_walker_env_t env;
pressure_walker_env_t env;
- ir_graph *irg = be_get_birg_irg(birg);
double average_pressure;
double average_pressure;
- env.
birg = b
irg;
+ env.
irg =
irg;
env.insn_count = 0;
env.max_pressure = 0;
env.regpressure = 0;
env.insn_count = 0;
env.max_pressure = 0;
env.regpressure = 0;
- be_liveness_assure_sets(be_assure_liveness(
b
irg));
- env.lv = be_get_
birg_liveness(b
irg);
+ be_liveness_assure_sets(be_assure_liveness(irg));
+ env.lv = be_get_
irg_liveness(
irg);
env.cls = cls;
/* Collect register pressure information for each block */
env.cls = cls;
/* Collect register pressure information for each block */
@@
-124,15
+121,14
@@
void be_do_stat_reg_pressure(be_irg_t *birg, const arch_register_class_t *cls) {
-typedef struct _estimate_irg_costs_env_t {
- const arch_env_t *arch_env;
+typedef struct estimate_irg_costs_env_t {
ir_exec_freq *execfreqs;
double costs;
} estimate_irg_costs_env_t;
static void estimate_block_costs(ir_node *block, void *data)
{
ir_exec_freq *execfreqs;
double costs;
} estimate_irg_costs_env_t;
static void estimate_block_costs(ir_node *block, void *data)
{
- estimate_irg_costs_env_t *env = data;
+ estimate_irg_costs_env_t *env =
(estimate_irg_costs_env_t*)
data;
ir_node *node;
double costs = 0.0;
ir_node *node;
double costs = 0.0;
@@
-143,11
+139,10
@@
static void estimate_block_costs(ir_node *block, void *data)
env->costs += costs * get_block_execfreq(env->execfreqs, block);
}
env->costs += costs * get_block_execfreq(env->execfreqs, block);
}
-double be_estimate_irg_costs(ir_graph *irg,
const arch_env_t *arch_env,
ir_exec_freq *execfreqs)
+double be_estimate_irg_costs(ir_graph *irg, ir_exec_freq *execfreqs)
{
estimate_irg_costs_env_t env;
{
estimate_irg_costs_env_t env;
- env.arch_env = arch_env;
env.execfreqs = execfreqs;
env.costs = 0.0;
env.execfreqs = execfreqs;
env.costs = 0.0;
@@
-158,41
+153,37
@@
double be_estimate_irg_costs(ir_graph *irg, const arch_env_t *arch_env, ir_exec_
-static be_node_stats_t *stats;
-
static void node_stat_walker(ir_node *irn, void *data)
{
static void node_stat_walker(ir_node *irn, void *data)
{
-
(void)
data;
+
be_node_stats_t *const stats = (be_node_stats_t*)
data;
/* if the node is a normal phi */
/* if the node is a normal phi */
- if(is_Phi(irn)) {
+ if
(is_Phi(irn)) {
if (get_irn_mode(irn) == mode_M) {
(*stats)[BE_STAT_MEM_PHIS]++;
} else {
(*stats)[BE_STAT_PHIS]++;
}
if (get_irn_mode(irn) == mode_M) {
(*stats)[BE_STAT_MEM_PHIS]++;
} else {
(*stats)[BE_STAT_PHIS]++;
}
- } else {
+ } else
if (!is_Proj(irn))
{
arch_irn_class_t classify = arch_irn_classify(irn);
arch_irn_class_t classify = arch_irn_classify(irn);
- if(classify & arch_irn_class_spill)
+ if
(classify & arch_irn_class_spill)
(*stats)[BE_STAT_SPILLS]++;
(*stats)[BE_STAT_SPILLS]++;
- if(classify & arch_irn_class_reload)
+ if
(classify & arch_irn_class_reload)
(*stats)[BE_STAT_RELOADS]++;
(*stats)[BE_STAT_RELOADS]++;
- if(classify & arch_irn_class_remat)
+ if
(classify & arch_irn_class_remat)
(*stats)[BE_STAT_REMATS]++;
(*stats)[BE_STAT_REMATS]++;
- if(classify & arch_irn_class_copy)
+ if
(classify & arch_irn_class_copy)
(*stats)[BE_STAT_COPIES]++;
(*stats)[BE_STAT_COPIES]++;
- if(classify & arch_irn_class_perm)
+ if
(classify & arch_irn_class_perm)
(*stats)[BE_STAT_PERMS]++;
}
}
(*stats)[BE_STAT_PERMS]++;
}
}
-void be_collect_node_stats(be_node_stats_t *new_stats,
be_irg_t *b
irg)
+void be_collect_node_stats(be_node_stats_t *new_stats,
ir_graph *
irg)
{
{
- stats = new_stats;
-
- memset(stats, 0, sizeof(*stats));
- irg_walk_graph(birg->irg, NULL, node_stat_walker, NULL);
+ memset(new_stats, 0, sizeof(*new_stats));
+ irg_walk_graph(irg, NULL, node_stat_walker, new_stats);
}
void be_subtract_node_stats(be_node_stats_t *stats, be_node_stats_t *sub)
}
void be_subtract_node_stats(be_node_stats_t *stats, be_node_stats_t *sub)
@@
-210,7
+201,7
@@
void be_copy_node_stats(be_node_stats_t *dest, be_node_stats_t *src)
static const char *get_stat_name(enum be_stat_tag_t tag)
{
static const char *get_stat_name(enum be_stat_tag_t tag)
{
- switch(tag) {
+ switch
(tag) {
case BE_STAT_PHIS: return "phis";
case BE_STAT_MEM_PHIS: return "mem_phis";
case BE_STAT_COPIES: return "copies";
case BE_STAT_PHIS: return "phis";
case BE_STAT_MEM_PHIS: return "mem_phis";
case BE_STAT_COPIES: return "copies";
@@
-224,10
+215,10
@@
static const char *get_stat_name(enum be_stat_tag_t tag)
void be_emit_node_stats(be_node_stats_t *stats, const char *prefix)
{
void be_emit_node_stats(be_node_stats_t *stats, const char *prefix)
{
- static char buf[256];
-
int
i;
+ static char
buf[256];
+
be_stat_tag_t
i;
- for (i =
0
; i < BE_STAT_COUNT; ++i) {
+ for (i =
BE_STAT_FIRST
; i < BE_STAT_COUNT; ++i) {
snprintf(buf, sizeof(buf), "%s%s", prefix, get_stat_name(i));
stat_ev_dbl(buf, (*stats)[i]);
}
snprintf(buf, sizeof(buf), "%s%s", prefix, get_stat_name(i));
stat_ev_dbl(buf, (*stats)[i]);
}
@@
-237,12
+228,12
@@
void be_emit_node_stats(be_node_stats_t *stats, const char *prefix)
static void insn_count_walker(ir_node *irn, void *data)
{
static void insn_count_walker(ir_node *irn, void *data)
{
- unsigned long *cnt = data;
+ unsigned long *cnt =
(unsigned long*)
data;
- switch(get_irn_opcode(irn)) {
+ switch
(get_irn_opcode(irn)) {
case iro_Proj:
case iro_Phi:
case iro_Proj:
case iro_Phi:
- case
ir
o_Start:
+ case
be
o_Start:
case iro_End:
break;
default:
case iro_End:
break;
default:
@@
-259,7
+250,7
@@
unsigned long be_count_insns(ir_graph *irg)
static void block_count_walker(ir_node *node, void *data)
{
static void block_count_walker(ir_node *node, void *data)
{
- unsigned long *cnt = data;
+ unsigned long *cnt =
(unsigned long*)
data;
if (node == get_irg_end_block(current_ir_graph))
return;
(*cnt)++;
if (node == get_irg_end_block(current_ir_graph))
return;
(*cnt)++;