#include "height.h"
#include "beabi.h"
+#include "bemodule.h"
#include "benode_t.h"
#include "besched_t.h"
* We need some special nodes:
* a source and a sink for all live-in and live-out values of a block
*/
-
enum {
iro_rss_Source,
iro_rss_Sink,
iro_rss_last
};
+/** The opcode of the rss_Source node once allocated. */
+static ir_op *op_rss_Source;
+/** The opcode of the rss_Sink node once allocated. */
+static ir_op *op_rss_Sink;
+
+/** The rss_Source node of the current graph. */
static ir_node *_source = NULL;
+/** The rss_Sink node of the current graph. */
static ir_node *_sink = NULL;
#define is_Source(irn) ((irn) == _source)
******************************************************************************/
/**
- * Acquire opcodes and create source and sink nodes.
+ * Acquire opcodes if needed and create source and sink nodes.
*/
static void init_rss_special_nodes(ir_graph *irg) {
- ir_node *block = get_irg_start_block(irg);
- int iro_rss_base = get_next_ir_opcodes(iro_rss_last);
- ir_op *op_rss_Source = new_ir_op(iro_rss_base + iro_rss_Source, "rss_Source", op_pin_state_pinned, irop_flag_none, oparity_zero, 0, 0, NULL);
- ir_op *op_rss_Sink = new_ir_op(iro_rss_base + iro_rss_Sink, "rss_Sink", op_pin_state_pinned, irop_flag_none, oparity_zero, 0, 0, NULL);
- _source = new_ir_node(NULL, irg, block, op_rss_Source, mode_ANY, 0, NULL);
- _sink = new_ir_node(NULL, irg, block, op_rss_Sink, mode_ANY, 0, NULL);
+ ir_node *block;
+
+ if (op_rss_Source == NULL) {
+ int iro_rss_base = get_next_ir_opcodes(iro_rss_last);
+ op_rss_Source = new_ir_op(iro_rss_base + iro_rss_Source, "rss_Source", op_pin_state_pinned, irop_flag_none, oparity_zero, 0, 0, NULL);
+ op_rss_Sink = new_ir_op(iro_rss_base + iro_rss_Sink, "rss_Sink", op_pin_state_pinned, irop_flag_none, oparity_zero, 0, 0, NULL);
+ }
+ block = get_irg_start_block(irg);
+ _source = new_ir_node(NULL, irg, block, op_rss_Source, mode_ANY, 0, NULL);
+ _sink = new_ir_node(NULL, irg, block, op_rss_Sink, mode_ANY, 0, NULL);
}
static int cmp_int(const void *a, const void *b) {
*
*****************************************************/
+#ifdef DEBUG_libfirm
static void dump_nodeset(nodeset *ns, const char *prefix) {
ir_node *irn;
foreach_nodeset(ns, irn) {
ir_fprintf(stderr, "%s%+F\n", prefix, irn);
}
}
+#endif
static void build_file_name(rss_t *rss, const char *suffix, size_t suf_len, char *buf, size_t len) {
const char *irg_name;
fprintf(f, "layoutalgorithm: mindepth\n");
fprintf(f, "manhattan_edges: yes\n\n");
- /* first: reset dumped flag of all nodes */
- foreach_plist(rss->nodes, el) {
- ir_node *irn = plist_element_get_value(el);
- rss_irn_t *rirn = get_rss_irn(rss, irn);
- rirn->dumped = 0;
+ {
+ /* reset dump_flag */
+ ir_node *irn;
+ foreach_phase_irn(&rss->ph, irn) {
+ rss_irn_t *node = get_rss_irn(rss, irn);
+ node->dumped = 0;
+ }
}
/* dump all nodes and their killers */
fprintf(f, "layoutalgorithm: mindepth\n");
fprintf(f, "manhattan_edges: yes\n\n");
+ {
+ /* reset dump_flag */
+ ir_node *irn;
+ foreach_phase_irn(&rss->ph, irn) {
+ rss_irn_t *node = get_rss_irn(rss, irn);
+ node->dumped = 0;
+ }
+ }
+
foreach_plist(rss->nodes, el) {
ir_node *irn = plist_element_get_value(el);
rss_irn_t *rirn = get_rss_irn(rss, irn);
if (max_ac && nodeset_find(max_ac, irn))
c1 = "color:yellow";
- if (rirn->chain)
- ir_fprintf(f, "node: { title: \"n%d\" label: \"%+F c%d\" %s }\n", get_irn_node_nr(irn), irn, rirn->chain->nr, c1);
- else
- ir_fprintf(f, "node: { title: \"n%d\" label: \"%+F\" %s }\n", get_irn_node_nr(irn), irn, c1);
- rirn->dumped = 1;
+ if (! rirn->dumped) {
+ if (rirn->chain)
+ ir_fprintf(f, "node: { title: \"n%d\" label: \"%+F c%d\" %s }\n", get_irn_node_nr(irn), irn, rirn->chain->nr, c1);
+ else
+ ir_fprintf(f, "node: { title: \"n%d\" label: \"%+F\" %s }\n", get_irn_node_nr(irn), irn, c1);
+ rirn->dumped = 1;
+ }
foreach_plist(rirn->pkiller_list, k_el) {
ir_node *pkiller = plist_element_get_value(k_el);
if (arch_irn_is(rss->arch_env, user, ignore))
continue;
- if (get_irn_mode(user) == mode_X) {
+ /*
+ (a) mode_X means Jump -> out_edge
+ (b) Phi as user of a normal node -> out-edge
+ */
+ if (get_irn_mode(user) == mode_X || is_Phi(user)) {
if (! *got_sink)
goto force_sink;
else
assert(! is_Proj(consumer) && "Cannot handle Projs");
- if (! is_Block(consumer) && get_nodes_block(consumer) == block) {
+ if (! is_Phi(consumer) && ! is_Block(consumer) && get_nodes_block(consumer) == block) {
if (! arch_irn_is(rss->arch_env, consumer, ignore) && ! plist_has_value(rss_irn->consumer_list, consumer)) {
plist_insert_back(rss_irn->consumer_list, consumer);
DBG((rss->dbg, LEVEL_2, "\t\tconsumer %+F\n", consumer));
}
}
+#ifdef DEBUG_libfirm
/* print the given cbc for debugging purpose */
static void debug_print_cbc(firm_dbg_module_t *mod, cbc_t *cbc) {
ir_node *n;
DBG((mod, LEVEL_3, "\t\t\t%+F -> %+F\n", ke->src, ke->tgt));
}
}
+#endif
/**
* Construct the bipartite decomposition.
rss_irn_t *u = get_rss_irn(rss, u_irn);
int p_change = 1;
int c_change = 1;
+ int vrfy_ok = 1;
cbc_t *cbc;
plist_element_t *el2;
if (k_edge->tgt == t_irn && ! nodeset_find(cbc->parents, val)) {
nodeset_insert(cbc->parents, val);
p_change = 1;
- DBG((rss->dbg, LEVEL_3, "\t\t\t%+F added to parents\n", val));
+ DBG((rss->dbg, LEVEL_3, "\t\t\t%+F added to parents (killed by %+F)\n", val, t_irn));
}
}
}
if (k_edge->src == s_irn && ! nodeset_find(cbc->children, val)) {
nodeset_insert(cbc->children, val);
c_change = 1;
- DBG((rss->dbg, LEVEL_3, "\t\t\t%+F added to children\n", val));
+ DBG((rss->dbg, LEVEL_3, "\t\t\t%+F added to children (kills %+F)\n", val, s_irn));
}
}
}
rss_irn_t *s = get_rss_irn(rss, s_irn);
s->visited = 1;
/* assure bipartite property */
+#if 0
if (nodeset_find(cbc->children, s_irn)) {
nodeset_remove(cbc->children, s_irn);
DBG((rss->dbg, LEVEL_3, "\t\t\t%+F removed from to children\n", s_irn));
}
+#endif
}
/* update edges */
pset_remove(epk, kedge_root, HASH_RSS_EDGE(kedge_root));
}
+ /* verify the cbc */
+ foreach_nodeset(cbc->parents, s_irn) {
+ int is_killed = 0;
+
+ foreach_pset(cbc->kill_edges, k_edge) {
+ if (k_edge->src == s_irn) {
+ is_killed = 1;
+ pset_break(cbc->kill_edges);
+ break;
+ }
+ }
+
+ if (! is_killed) {
+ vrfy_ok = 0;
+ ir_fprintf(stderr, "Warning: parent %+F is not killed in current cbc\n", s_irn);
+ }
+ }
+ assert(vrfy_ok && "Verification of CBC failed");
+
/* add the connected bipartite component */
if (nodeset_count(cbc->parents) > 0 && nodeset_count(cbc->children) > 0 && pset_count(cbc->kill_edges) > 0)
pset_insert(rss->cbc_set, cbc, (unsigned)cbc->nr);
ir_node *irn;
rss_edge_t min_benefit_edge;
rss_edge_t min_omega20_edge;
- rss_irn_t *ser_u_omega1, *ser_v_omega1;
- rss_irn_t *ser_u_omega20, *ser_v_omega20;
+ rss_irn_t *ser_u_omega1 = NULL, *ser_v_omega1 = NULL;
+ rss_irn_t *ser_u_omega20 = NULL, *ser_v_omega20 = NULL;
DBG((rss->dbg, LEVEL_1, "\tcomputing admissible serializations:\n"));
static void perform_value_serialization_heuristic(rss_t *rss) {
bitset_t *arch_nonign_bs = bitset_alloca(arch_register_class_n_regs(rss->cls));
bitset_t *abi_ign_bs = bitset_alloca(arch_register_class_n_regs(rss->cls));
- int available_regs, iteration, num_live;
+ int available_regs, iteration;
dvg_t dvg;
nodeset *sat_vals;
pset *ser_set = new_pset(cmp_rss_edges, 20);
be_abi_put_ignore_regs(rss->abi, rss->cls, abi_ign_bs);
bitset_andnot(arch_nonign_bs, abi_ign_bs);
available_regs = bitset_popcnt(arch_nonign_bs);
- //um_live = pset_count(rss->live_block);
+ //num_live = pset_count(rss->live_block);
//available_regs -= num_live < available_regs ? num_live : 0;
DBG((rss->dbg, LEVEL_1, "\n\t#available regs: %d\n\n", available_regs));
/**
* Register the options.
*/
-void rss_register_options(lc_opt_entry_t *grp) {
- static int run_once = 0;
- lc_opt_entry_t *rss_grp;
-
- if (! run_once) {
- run_once = 1;
- rss_grp = lc_opt_get_grp(grp, "rss");
+void be_init_schedrss(void) {
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+ lc_opt_entry_t *sched_grp = lc_opt_get_grp(be_grp, "sched");
+ lc_opt_entry_t *rss_grp = lc_opt_get_grp(sched_grp, "rss");
- lc_opt_add_table(rss_grp, rss_option_table);
- }
+ lc_opt_add_table(rss_grp, rss_option_table);
}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_schedrss);
#endif /* WITH_LIBCORE */
/**