fixed precedence constraint
[libfirm] / ir / be / beschedrss.c
index 11f9d7b..8df2838 100644 (file)
@@ -9,7 +9,7 @@
  * @cvs-id  $Id$
  */
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <limits.h>
 #include "height.h"
 
 #include "beabi.h"
+#include "bemodule.h"
 #include "benode_t.h"
 #include "besched_t.h"
 
-#ifdef WITH_LIBCORE
 #include <libcore/lc_opts.h>
 #include <libcore/lc_opts_enum.h>
-#endif /* WITH_LIBCORE */
 
 
 #define ARR_LEN_SAFE(arr) ((arr) != NULL ? ARR_LEN((arr)) : 0)
@@ -148,14 +147,20 @@ typedef struct _rss {
  * 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)
@@ -175,7 +180,6 @@ static rss_opts_t rss_options = {
        RSS_DUMP_NONE,
 };
 
-#ifdef WITH_LIBCORE
 static const lc_opt_enum_int_items_t dump_items[] = {
        { "none",  RSS_DUMP_NONE  },
        { "cbc",   RSS_DUMP_CBC   },
@@ -195,7 +199,6 @@ static const lc_opt_table_entry_t rss_option_table[] = {
        LC_OPT_ENT_ENUM_MASK("dump", "dump phases", &dump_var),
        { NULL }
 };
-#endif /* WITH_LIBCORE */
 
 /******************************************************************************
  *  _          _                    __                  _   _
@@ -209,15 +212,19 @@ static const lc_opt_table_entry_t rss_option_table[] = {
  ******************************************************************************/
 
 /**
- * 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) {
@@ -2071,22 +2078,18 @@ static void process_block(ir_node *block, void *env) {
        phase_free(&rss->ph);
 }
 
-#ifdef WITH_LIBCORE
 /**
  * Register the options.
  */
-void rss_register_options(lc_opt_entry_t *grp) {
-       static int     run_once = 0;
-       lc_opt_entry_t *rss_grp;
+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");
 
-       if (! run_once) {
-               run_once = 1;
-               rss_grp  = lc_opt_get_grp(grp, "rss");
-
-               lc_opt_add_table(rss_grp, rss_option_table);
-       }
+       lc_opt_add_table(rss_grp, rss_option_table);
 }
-#endif /* WITH_LIBCORE */
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_schedrss);
 
 /**
  * Preprocess the irg for scheduling.