Commit 7a9a11e3 authored by Matthias Braun's avatar Matthias Braun
Browse files

improve sched_info datastructure, saving space and making it more efficient

[r25982]
parent e9b83cc6
......@@ -702,7 +702,7 @@ static inline void notified_sched_add_before(be_ilpsched_env_t *env,
const ir_node *before, const ir_node *irn, unsigned cycle)
{
be_ilp_sched_node_scheduled(env->sel, irn, cycle, env->block_env);
sched_add_before(before, irn);
sched_add_before((ir_node*) before, (ir_node*) irn);
}
/**
......@@ -754,15 +754,13 @@ static void add_to_sched(be_ilpsched_env_t *env, const ir_node *block, const ir_
static void apply_solution(be_ilpsched_env_t *env, lpp_t *lpp, ir_node *block) {
be_ilpsched_irn_t *block_node = get_ilpsched_irn(env, block);
ilpsched_block_attr_t *ba = get_ilpsched_block_attr(block_node);
sched_info_t *info = get_irn_sched_info(block);
be_ilpsched_irn_t **sched_nodes;
unsigned i, l;
ir_node *cfop, *irn;
const ir_edge_t *edge;
/* init block schedule list */
INIT_LIST_HEAD(&info->list);
info->scheduled = 1;
sched_init_block(block);
/* collect nodes and their scheduling time step */
sched_nodes = NEW_ARR_F(be_ilpsched_irn_t *, 0);
......
......@@ -46,9 +46,8 @@ void be_info_new_node(ir_node *node)
sinfo = &info->sched_info;
memset(info, 0, sizeof(*info));
sinfo->idx = get_irn_idx(node);
INIT_LIST_HEAD(&sinfo->list);
sinfo->next = NULL;
sinfo->prev = NULL;
if (is_Phi(node)) {
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1);
......
......@@ -39,10 +39,9 @@ typedef unsigned int sched_timestep_t;
* every block schedule list is the Block list.
*/
typedef struct sched_info_t {
struct list_head list; /**< The list head to list the nodes in a schedule. */
unsigned idx; /**< The node index of the nodes this schedule info belongs to. */
sched_timestep_t time_step; /**< If a is after b in a schedule, its time step is larger than b's. */
unsigned scheduled : 1; /**< 1, if the node is in the schedule of the block, 0 else. */
ir_node *next;
ir_node *prev;
sched_timestep_t time_step; /**< If a is after b in a schedule, its time step is larger than b's. */
} sched_info_t;
typedef struct reg_out_info_t {
......
......@@ -440,7 +440,7 @@ static void lower_perm_node(ir_node *irn, lower_env_t *env)
arch_set_irn_register(res1, cycle.elems[i]);
/* insert the copy/exchange node in schedule after the magic schedule node (see above) */
sched_add_after(sched_point, cpyxchg);
sched_add_after(skip_Proj(sched_point), cpyxchg);
DB((dbg, LEVEL_1, "replacing %+F with %+F, placed new node after %+F\n", irn, cpyxchg, sched_point));
......@@ -459,7 +459,7 @@ static void lower_perm_node(ir_node *irn, lower_env_t *env)
exchange(res2, cpyxchg);
/* insert the copy/exchange node in schedule after the magic schedule node (see above) */
sched_add_after(sched_point, cpyxchg);
sched_add_after(skip_Proj(sched_point), cpyxchg);
/* set the new scheduling point */
sched_point = cpyxchg;
......@@ -549,7 +549,7 @@ static void gen_assure_different_pattern(ir_node *irn, ir_node *other_different,
assert(sched_is_scheduled(irn) && "need schedule to assure constraints");
if (! sched_is_scheduled(cpy))
sched_add_before(skip_Proj(irn), cpy);
sched_add_after(irn, keep);
sched_add_after(skip_Proj(irn), keep);
/* insert the other different and it's copies into the map */
entry = ir_nodemap_get(op_set, other_different);
......
......@@ -53,12 +53,12 @@ FIRM_IMPL1(sched_prev, ir_node *, const ir_node *)
FIRM_IMPL1(sched_is_scheduled, int, const ir_node *)
FIRM_IMPL1(sched_first, ir_node *, const ir_node *)
FIRM_IMPL1(sched_last, ir_node *, const ir_node *)
FIRM_IMPL2_VOID(sched_add_after, const ir_node *, const ir_node *)
FIRM_IMPL2_VOID(sched_add_before, const ir_node *, const ir_node *)
FIRM_IMPL1_VOID(sched_init_block, const ir_node *)
FIRM_IMPL1_VOID(sched_reset, const ir_node *)
FIRM_IMPL2_VOID(sched_add_after, ir_node *, ir_node *)
FIRM_IMPL2_VOID(sched_add_before, ir_node *, ir_node *)
FIRM_IMPL1_VOID(sched_init_block, ir_node *)
FIRM_IMPL1_VOID(sched_remove, ir_node *)
FIRM_IMPL1_VOID(sched_reset, ir_node *)
FIRM_IMPL2(sched_comes_after, int, const ir_node *, const ir_node *)
FIRM_IMPL1_VOID(sched_remove, const ir_node *)
size_t sched_irn_data_offset = 0;
......
......@@ -48,13 +48,13 @@ ir_node *sched_next(const ir_node *irn);
ir_node *sched_prev(const ir_node *irn);
ir_node *sched_first(const ir_node *block);
ir_node *sched_last(const ir_node *block);
void sched_add_before(const ir_node *before, const ir_node *irn);
void sched_add_after(const ir_node *after, const ir_node *irn);
void sched_init_block(const ir_node *block);
void sched_reset(const ir_node *node);
void sched_remove(const ir_node *irn);
void sched_add_before(ir_node *before, ir_node *irn);
void sched_add_after(ir_node *after, ir_node *irn);
void sched_init_block(ir_node *block);
void sched_reset(ir_node *node);
void sched_remove(ir_node *irn);
#define sched_is_end(irn) is_Block(irn)
#define sched_is_end(irn) is_Block(irn)
#define sched_is_begin(irn) is_Block(irn)
#define sched_foreach_from(from, irn) \
......
......@@ -20,7 +20,7 @@
/**
* @file
* @brief Scheduling utilities for nodes in Blocks and Blocks.
* @author Sebastian Hack
* @author Sebastian Hack, Matthias Braun
* @version $Id$
*/
#ifndef FIRM_BE_BESCHED_T_H
......@@ -38,9 +38,7 @@
#include "besched.h"
#include "beinfo.h"
#define _sched_entry(list_head) (list_entry(list_head, sched_info_t, list))
#define get_irn_sched_info(irn) (&be_get_info(skip_Proj_const(irn))->sched_info)
#define get_sched_info_irn(irg, sched_info) get_idx_irn((irg), (sched_info)->idx)
/**
* Returns non-zero if schedule information is available
......@@ -59,7 +57,7 @@ static inline int _have_sched_info(const ir_graph *irg)
*/
static inline int _sched_is_scheduled(const ir_node *irn)
{
return get_irn_sched_info(irn)->scheduled;
return get_irn_sched_info(irn)->next != NULL;
}
/**
......@@ -100,10 +98,9 @@ static inline int to_appear_in_schedule(const ir_node *irn)
*/
static inline int _sched_has_next(const ir_node *irn)
{
const ir_node *block = is_Block(irn) ? irn : get_nodes_block(irn);
const sched_info_t *info = get_irn_sched_info(irn);
const sched_info_t *block_info = get_irn_sched_info(block);
return info->list.next != &block_info->list;
const sched_info_t *info = get_irn_sched_info(irn);
const ir_node *block = is_Block(irn) ? irn : get_nodes_block(irn);
return info->next != block;
}
/**
......@@ -113,10 +110,9 @@ static inline int _sched_has_next(const ir_node *irn)
*/
static inline int _sched_has_prev(const ir_node *irn)
{
const ir_node *block = is_Block(irn) ? irn : get_nodes_block(irn);
const sched_info_t *info = get_irn_sched_info(irn);
const sched_info_t *block_info = get_irn_sched_info(block);
return info->list.prev != &block_info->list;
const sched_info_t *info = get_irn_sched_info(irn);
const ir_node *block = is_Block(irn) ? irn : get_nodes_block(irn);
return info->prev != block;
}
/**
......@@ -127,7 +123,7 @@ static inline int _sched_has_prev(const ir_node *irn)
static inline ir_node *_sched_next(const ir_node *irn)
{
const sched_info_t *info = get_irn_sched_info(irn);
return get_sched_info_irn(get_irn_irg(irn), _sched_entry(info->list.next));
return info->next;
}
/**
......@@ -139,7 +135,7 @@ static inline ir_node *_sched_next(const ir_node *irn)
static inline ir_node *_sched_prev(const ir_node *irn)
{
const sched_info_t *info = get_irn_sched_info(irn);
return get_sched_info_irn(get_irn_irg(irn), _sched_entry(info->list.prev));
return info->prev;
}
/**
......@@ -174,18 +170,24 @@ void sched_renumber(const ir_node *block);
static inline void _sched_set_time_stamp(const ir_node *irn)
{
sched_info_t *inf = get_irn_sched_info(irn);
sched_timestep_t before_ts = _sched_entry(inf->list.prev)->time_step;
sched_timestep_t after_ts = _sched_entry(inf->list.next)->time_step;
sched_info_t *info = get_irn_sched_info(irn);
const sched_info_t *prev_info = get_irn_sched_info(info->prev);
const sched_info_t *next_info = get_irn_sched_info(info->next);
sched_timestep_t before_ts = prev_info->time_step;
sched_timestep_t after_ts = next_info->time_step;
/*
* If we are the last, we can give us a big time step,
* else we have to compute our time step from our
* neighbours.
*/
if(before_ts >= after_ts)
inf->time_step = before_ts + SCHED_INITIAL_GRANULARITY;
else {
if(before_ts >= after_ts) {
info->time_step = before_ts + SCHED_INITIAL_GRANULARITY;
/* overflow? */
if (info->time_step <= before_ts) {
sched_renumber(get_nodes_block(irn));
}
} else {
sched_timestep_t ts = (before_ts + after_ts) / 2;
/*
......@@ -195,7 +197,7 @@ static inline void _sched_set_time_stamp(const ir_node *irn)
if(ts == before_ts || ts == after_ts)
sched_renumber(get_nodes_block(irn));
else
inf->time_step = ts;
info->time_step = ts;
}
}
......@@ -205,15 +207,23 @@ static inline void _sched_set_time_stamp(const ir_node *irn)
* @param irn The node to add.
* @return The given node.
*/
static inline void _sched_add_before(const ir_node *before, const ir_node *irn)
static inline void _sched_add_before(ir_node *before, ir_node *irn)
{
sched_info_t *info = get_irn_sched_info(irn);
sched_info_t *info = get_irn_sched_info(irn);
ir_node *next = before;
sched_info_t *next_info = get_irn_sched_info(next);
ir_node *prev = next_info->prev;
sched_info_t *prev_info = get_irn_sched_info(prev);
assert(_sched_is_scheduled(before));
assert(!_sched_is_scheduled(irn));
assert(!is_Proj(before));
assert(!is_Proj(irn));
list_add_tail(&info->list, &get_irn_sched_info(before)->list);
info->prev = prev;
info->next = next;
prev_info->next = irn;
next_info->prev = irn;
_sched_set_time_stamp(irn);
info->scheduled = 1;
}
/**
......@@ -222,41 +232,57 @@ static inline void _sched_add_before(const ir_node *before, const ir_node *irn)
* @param irn The node to add.
* @return The given node.
*/
static inline void _sched_add_after(const ir_node *after, const ir_node *irn)
static inline void _sched_add_after(ir_node *after, ir_node *irn)
{
sched_info_t *info = get_irn_sched_info(irn);
sched_info_t *info = get_irn_sched_info(irn);
ir_node *prev = after;
sched_info_t *prev_info = get_irn_sched_info(prev);
ir_node *next = prev_info->next;
sched_info_t *next_info = get_irn_sched_info(next);
assert(_sched_is_scheduled(after));
assert(!_sched_is_scheduled(irn));
assert(!is_Proj(after));
assert(!is_Proj(irn));
list_add(&info->list, &get_irn_sched_info(after)->list);
info->prev = prev;
info->next = next;
prev_info->next = irn;
next_info->prev = irn;
_sched_set_time_stamp(irn);
info->scheduled = 1;
}
static inline void _sched_init_block(const ir_node *block)
static inline void _sched_init_block(ir_node *block)
{
sched_info_t *info = get_irn_sched_info(block);
assert(info->scheduled == 0 && info->time_step == 0);
INIT_LIST_HEAD(&info->list);
info->scheduled = 1;
assert(info->next == NULL && info->time_step == 0);
info->next = block;
info->prev = block;
}
static inline void _sched_reset(const ir_node *node)
static inline void _sched_reset(ir_node *node)
{
sched_info_t *info = get_irn_sched_info(node);
info->scheduled = 0;
info->next = NULL;
info->prev = NULL;
}
/**
* Remove a node from the scheduled.
* @param irn The node.
*/
static inline void _sched_remove(const ir_node *irn)
static inline void _sched_remove(ir_node *irn)
{
sched_info_t *info = get_irn_sched_info(irn);
list_del(&info->list);
INIT_LIST_HEAD(&info->list);
info->scheduled = 0;
sched_info_t *info = get_irn_sched_info(irn);
ir_node *prev = info->prev;
ir_node *next = info->next;
sched_info_t *prev_info = get_irn_sched_info(prev);
sched_info_t *next_info = get_irn_sched_info(next);
assert(_sched_is_scheduled(irn));
prev_info->next = next;
next_info->prev = prev;
info->next = NULL;
info->prev = NULL;
}
/**
......
......@@ -445,7 +445,7 @@ static void spill_irn(spill_env_t *env, spill_info_t *spillinfo)
after = skip_keeps_phis(after);
spill->spill = be_spill(block, to_spill);
sched_add_after(after, spill->spill);
sched_add_after(skip_Proj(after), spill->spill);
DB((dbg, LEVEL_1, "\t%+F after %+F\n", spill->spill, after));
#ifdef FIRM_STATISTICS
env->spill_count++;
......
......@@ -115,7 +115,7 @@ static ir_node *create_fpu_mode_spill(void *env, ir_node *state, int force,
set_ia32_ls_mode(spill, mode_Iu);
set_ia32_use_frame(spill);
sched_add_after(after, spill);
sched_add_after(skip_Proj(after), spill);
}
return spill;
......
......@@ -500,7 +500,7 @@ static void peephole_IncSP_Store_to_push(ir_node *irn)
if (first_push == NULL)
first_push = push;
sched_add_after(curr_sp, push);
sched_add_after(skip_Proj(curr_sp), push);
/* create stackpointer Proj */
curr_sp = new_r_Proj(irg, block, push, spmode, pn_ia32_Push_stack);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment