projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sparc: implement float->unsigned conversions
[libfirm]
/
ir
/
be
/
bestate.c
diff --git
a/ir/be/bestate.c
b/ir/be/bestate.c
index
823dec9
..
1e3bf3e
100644
(file)
--- a/
ir/be/bestate.c
+++ b/
ir/be/bestate.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,7
+23,6
@@
* algorithm optimized for the 1-register case.
* @author Matthias Braun
* @date 26.03.2007
* algorithm optimized for the 1-register case.
* @author Matthias Braun
* @date 26.03.2007
- * @version $Id$
*/
#include "config.h"
*/
#include "config.h"
@@
-38,7
+37,7
@@
#include "ircons_t.h"
#include "irgmod.h"
#include "irnodeset.h"
#include "ircons_t.h"
#include "irgmod.h"
#include "irnodeset.h"
-#include "irnodemap.h"
+#include "irnode
hash
map.h"
#include "adt/cpset.h"
#include "bearch.h"
#include "adt/cpset.h"
#include "bearch.h"
@@
-47,6
+46,7
@@
#include "belive_t.h"
#include "bemodule.h"
#include "benode.h"
#include "belive_t.h"
#include "bemodule.h"
#include "benode.h"
+#include "beirgmod.h"
#include "bessaconstr.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
#include "bessaconstr.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
@@
-66,7
+66,7
@@
typedef struct minibelady_env_t {
create_reload_func create_reload;
create_spill_func create_spill;
spill_info_t *spills;
create_reload_func create_reload;
create_spill_func create_spill;
spill_info_t *spills;
- ir_node
map_t
spill_infos;
+ ir_node
hashmap_t
spill_infos;
be_uses_t *uses; /**< env for the next-use magic */
} minibelady_env_t;
be_uses_t *uses; /**< env for the next-use magic */
} minibelady_env_t;
@@
-99,7
+99,7
@@
static inline spill_info_t *create_spill_info(minibelady_env_t *env, ir_node *st
spill_info->value = state;
spill_info->reloads = NEW_ARR_F(ir_node*, 0);
spill_info->value = state;
spill_info->reloads = NEW_ARR_F(ir_node*, 0);
- ir_nodemap_insert(&env->spill_infos, state, spill_info);
+ ir_node
hash
map_insert(&env->spill_infos, state, spill_info);
//ir_fprintf(stderr, "Insert %+F -> %p\n", state, spill_info);
spill_info->next = env->spills;
//ir_fprintf(stderr, "Insert %+F -> %p\n", state, spill_info);
spill_info->next = env->spills;
@@
-111,7
+111,7
@@
static inline spill_info_t *create_spill_info(minibelady_env_t *env, ir_node *st
static inline spill_info_t *get_spill_info(minibelady_env_t *env, const ir_node *node)
{
spill_info_t *spill_info
static inline spill_info_t *get_spill_info(minibelady_env_t *env, const ir_node *node)
{
spill_info_t *spill_info
- = (spill_info_t*) ir_nodemap_get(&env->spill_infos, node);
+ = (spill_info_t*) ir_node
hash
map_get(&env->spill_infos, node);
//ir_fprintf(stderr, "Get %+F -> %p\n", node, spill_info);
return spill_info;
}
//ir_fprintf(stderr, "Get %+F -> %p\n", node, spill_info);
return spill_info;
}
@@
-160,7
+160,8
@@
static void spill_phi(minibelady_env_t *env, ir_node *phi)
ir_graph *irg = get_irn_irg(phi);
ir_node *block = get_nodes_block(phi);
int arity = get_irn_arity(phi);
ir_graph *irg = get_irn_irg(phi);
ir_node *block = get_nodes_block(phi);
int arity = get_irn_arity(phi);
- ir_node **in = ALLOCAN(ir_node*, arity);
+ ir_node **phi_in = ALLOCAN(ir_node*, arity);
+ ir_node *dummy = new_r_Dummy(irg, mode_M);
ir_node *spill_to_kill = NULL;
spill_info_t *spill_info;
int i;
ir_node *spill_to_kill = NULL;
spill_info_t *spill_info;
int i;
@@
-175,13
+176,14
@@
static void spill_phi(minibelady_env_t *env, ir_node *phi)
/* create a new phi-M with bad preds */
for (i = 0; i < arity; ++i) {
/* create a new phi-M with bad preds */
for (i = 0; i < arity; ++i) {
-
in[i] = new_r_Unknown(irg, mode_M)
;
+
phi_in[i] = dummy
;
}
DBG((dbg, LEVEL_2, "\tcreate Phi-M for %+F\n", phi));
/* create a Phi-M */
}
DBG((dbg, LEVEL_2, "\tcreate Phi-M for %+F\n", phi));
/* create a Phi-M */
- spill_info->spill = new_r_Phi(block, arity, in, mode_M);
+ spill_info->spill = be_new_Phi(block, arity, phi_in, mode_M, NULL);
+ sched_add_after(block, spill_info->spill);
if (spill_to_kill != NULL) {
exchange(spill_to_kill, spill_info->spill);
if (spill_to_kill != NULL) {
exchange(spill_to_kill, spill_info->spill);
@@
-202,7
+204,7
@@
static void belady(minibelady_env_t *env, ir_node *block);
* Collects all values live-in at block @p block and all phi results in this
* block.
* Then it adds the best values (at most n_regs) to the blocks start_workset.
* Collects all values live-in at block @p block and all phi results in this
* block.
* Then it adds the best values (at most n_regs) to the blocks start_workset.
- * The phis among the remaining values get spilled: Introduce psudo-copies of
+ * The phis among the remaining values get spilled: Introduce ps
e
udo-copies of
* their args to break interference and make it possible to spill them to the
* same spill slot.
*/
* their args to break interference and make it possible to spill them to the
* same spill slot.
*/
@@
-259,7
+261,7
@@
static block_info_t *compute_block_start_state(minibelady_env_t *env, ir_node *b
continue;
DBG((dbg, LEVEL_2, "\t...checking %+F\n", node));
continue;
DBG((dbg, LEVEL_2, "\t...checking %+F\n", node));
- next_use = be_get_next_use(env->uses, first,
0,
node, 0);
+ next_use = be_get_next_use(env->uses, first, node, 0);
if (USES_IS_INFINITE(next_use.time)) {
DBG((dbg, LEVEL_2, "\tnot taken (dead)\n"));
if (USES_IS_INFINITE(next_use.time)) {
DBG((dbg, LEVEL_2, "\tnot taken (dead)\n"));
@@
-309,7
+311,7
@@
static block_info_t *compute_block_start_state(minibelady_env_t *env, ir_node *b
continue;
DBG((dbg, LEVEL_2, "\t...checking %+F\n", node));
continue;
DBG((dbg, LEVEL_2, "\t...checking %+F\n", node));
- next_use = be_get_next_use(env->uses, first,
0,
node, 0);
+ next_use = be_get_next_use(env->uses, first, node, 0);
if (USES_IS_INFINITE(next_use.time)) {
DBG((dbg, LEVEL_2, "\tnot taken (dead)\n"));
if (USES_IS_INFINITE(next_use.time)) {
DBG((dbg, LEVEL_2, "\tnot taken (dead)\n"));
@@
-404,8
+406,9
@@
static void belady(minibelady_env_t *env, ir_node *block)
}
/* create a reload to match state if necessary */
if (need_val != NULL && need_val != current_state) {
}
/* create a reload to match state if necessary */
if (need_val != NULL && need_val != current_state) {
+ ir_node *before = node;
DBG((dbg, LEVEL_3, "\t... reloading %+F\n", need_val));
DBG((dbg, LEVEL_3, "\t... reloading %+F\n", need_val));
- create_reload(env, need_val,
nod
e, current_state);
+ create_reload(env, need_val,
befor
e, current_state);
current_state = need_val;
}
current_state = need_val;
}
@@
-461,7
+464,7
@@
static ir_node *get_end_of_block_insertion_point(ir_node *block)
if (!is_cfop(last)) {
last = sched_next(last);
/* last node must be a cfop, only exception is the start block */
if (!is_cfop(last)) {
last = sched_next(last);
/* last node must be a cfop, only exception is the start block */
- assert(last
== get_irg_start_block(get_irn_irg(block)));
+ assert(last == get_irg_start_block(get_irn_irg(block)));
}
return last;
}
return last;
@@
-472,7
+475,7
@@
static ir_node *get_end_of_block_insertion_point(ir_node *block)
*/
static void fix_block_borders(ir_node *block, void *data)
{
*/
static void fix_block_borders(ir_node *block, void *data)
{
- minibelady_env_t *env = data;
+ minibelady_env_t *env =
(minibelady_env_t*)
data;
ir_graph *irg = get_irn_irg(block);
ir_node *startblock = get_irg_start_block(irg);
int i;
ir_graph *irg = get_irn_irg(block);
ir_node *startblock = get_irg_start_block(irg);
int i;
@@
-507,7
+510,7
@@
static void fix_block_borders(ir_node *block, void *data)
pred_info->end_state, need_state));
if (pred_info->end_state != need_state) {
pred_info->end_state, need_state));
if (pred_info->end_state != need_state) {
- ir_node *insert_point = get_end_of_block_insertion_point(pred);
+ ir_node *insert_point = get_end_of_block_insertion_point(pred);
DBG((dbg, LEVEL_3, " Creating reload for %+F\n", need_state));
DBG((dbg, LEVEL_3, " Creating reload for %+F\n", need_state));
@@
-516,20
+519,16
@@
static void fix_block_borders(ir_node *block, void *data)
}
}
}
}
-void be_assure_state(
be_irg_t *b
irg, const arch_register_t *reg, void *func_env,
+void be_assure_state(
ir_graph *
irg, const arch_register_t *reg, void *func_env,
create_spill_func create_spill,
create_reload_func create_reload)
{
minibelady_env_t env;
create_spill_func create_spill,
create_reload_func create_reload)
{
minibelady_env_t env;
- ir_graph *irg = be_get_birg_irg(birg);
spill_info_t *info;
spill_info_t *info;
- be_lv_t *lv = be_
assure
_liveness(irg);
+ be_lv_t *lv = be_
get_irg
_liveness(irg);
- be_liveness_assure_sets(lv);
- /* construct control flow loop tree */
- if (! (get_irg_loopinfo_state(irg) & loopinfo_cf_consistent)) {
- construct_cf_backedges(irg);
- }
+ be_assure_live_sets(irg);
+ assure_loopinfo(irg);
obstack_init(&env.obst);
env.reg = reg;
obstack_init(&env.obst);
env.reg = reg;
@@
-539,7
+538,7
@@
void be_assure_state(be_irg_t *birg, const arch_register_t *reg, void *func_env,
env.lv = be_get_irg_liveness(irg);
env.uses = be_begin_uses(irg, env.lv);
env.spills = NULL;
env.lv = be_get_irg_liveness(irg);
env.uses = be_begin_uses(irg, env.lv);
env.spills = NULL;
- ir_nodemap_init(&env.spill_infos);
+ ir_node
hash
map_init(&env.spill_infos);
assure_doms(irg);
ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED | IR_RESOURCE_IRN_LINK);
assure_doms(irg);
ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED | IR_RESOURCE_IRN_LINK);
@@
-557,7
+556,7
@@
void be_assure_state(be_irg_t *birg, const arch_register_t *reg, void *func_env,
info = env.spills;
while (info != NULL) {
be_ssa_construction_env_t senv;
info = env.spills;
while (info != NULL) {
be_ssa_construction_env_t senv;
-
in
t i, len;
+
size_
t i, len;
ir_node **phis;
be_ssa_construction_init(&senv, irg);
ir_node **phis;
be_ssa_construction_init(&senv, irg);
@@
-594,12
+593,12
@@
void be_assure_state(be_irg_t *birg, const arch_register_t *reg, void *func_env,
/* some nodes might be dead now. */
be_remove_dead_nodes_from_schedule(irg);
/* some nodes might be dead now. */
be_remove_dead_nodes_from_schedule(irg);
- ir_nodemap_destroy(&env.spill_infos);
+ ir_node
hash
map_destroy(&env.spill_infos);
be_end_uses(env.uses);
obstack_free(&env.obst, NULL);
}
be_end_uses(env.uses);
obstack_free(&env.obst, NULL);
}
-BE_REGISTER_MODULE_CONSTRUCTOR(be_init_state)
;
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_state)
void be_init_state(void)
{
FIRM_DBG_REGISTER(dbg, "firm.be.state");
void be_init_state(void)
{
FIRM_DBG_REGISTER(dbg, "firm.be.state");