+#include "bestatevent.h"
+#include "beirg_t.h"
+#include "error.h"
+
+#include "lc_opts.h"
+#include "lc_opts_enum.h"
+
+#define DUMP_BEFORE 1
+#define DUMP_AFTER 2
+#define DUMP_APPEL 4
+#define DUMP_ALL 2 * DUMP_APPEL - 1
+
+#define COST_FUNC_FREQ 1
+#define COST_FUNC_LOOP 2
+#define COST_FUNC_ALL_ONE 3
+
+static unsigned dump_flags = 0;
+static unsigned style_flags = 0;
+static unsigned do_stats = 0;
+static cost_fct_t cost_func = co_get_costs_exec_freq;
+static unsigned algo = CO_ALGO_HEUR4;
+static int improve = 1;
+
+static const lc_opt_enum_mask_items_t dump_items[] = {
+ { "before", DUMP_BEFORE },
+ { "after", DUMP_AFTER },
+ { "appel", DUMP_APPEL },
+ { "all", DUMP_ALL },
+ { NULL, 0 }
+};
+
+static const lc_opt_enum_mask_items_t style_items[] = {
+ { "color", CO_IFG_DUMP_COLORS },
+ { "labels", CO_IFG_DUMP_LABELS },
+ { "constr", CO_IFG_DUMP_CONSTR },
+ { "shape", CO_IFG_DUMP_SHAPE },
+ { "full", 2 * CO_IFG_DUMP_SHAPE - 1 },
+ { NULL, 0 }
+};
+
+static const lc_opt_enum_mask_items_t algo_items[] = {
+ { "none", CO_ALGO_NONE },
+ { "heur", CO_ALGO_HEUR },
+ { "heur2", CO_ALGO_HEUR2 },
+ { "heur3", CO_ALGO_HEUR3 },
+ { "heur4", CO_ALGO_HEUR4 },
+ { "ilp", CO_ALGO_ILP },
+ { NULL, 0 }
+};
+
+typedef int (*opt_funcptr)(void);
+
+static const lc_opt_enum_func_ptr_items_t cost_func_items[] = {
+ { "freq", (opt_funcptr) co_get_costs_exec_freq },
+ { "loop", (opt_funcptr) co_get_costs_loop_depth },
+ { "one", (opt_funcptr) co_get_costs_all_one },
+ { NULL, NULL }
+};
+
+static lc_opt_enum_mask_var_t dump_var = {
+ &dump_flags, dump_items
+};
+
+static lc_opt_enum_mask_var_t style_var = {
+ &style_flags, style_items
+};
+
+static lc_opt_enum_mask_var_t algo_var = {
+ &algo, algo_items
+};
+
+static lc_opt_enum_func_ptr_var_t cost_func_var = {
+ (opt_funcptr*) &cost_func, cost_func_items
+};
+
+static const lc_opt_table_entry_t options[] = {
+ LC_OPT_ENT_ENUM_INT ("algo", "select copy optimization algo", &algo_var),
+ LC_OPT_ENT_ENUM_FUNC_PTR ("cost", "select a cost function", &cost_func_var),
+ LC_OPT_ENT_ENUM_MASK ("dump", "dump ifg before or after copy optimization", &dump_var),
+ LC_OPT_ENT_ENUM_MASK ("style", "dump style for ifg dumping", &style_var),
+ LC_OPT_ENT_BOOL ("stats", "dump statistics after each optimization", &do_stats),
+ LC_OPT_ENT_BOOL ("improve", "run heur3 before if algo can exploit start solutions", &improve),
+ LC_OPT_LAST
+};