4 * Copyright: (c) Universitaet Karlsruhe
5 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
7 * Common stuff used by all ILP fomulations.
11 #ifndef _BECOPYILP_T_H
12 #define _BECOPYILP_T_H
14 #include "firm_config.h"
18 #include "becopyopt_t.h"
21 /******************************************************************************
24 | (___ _ _______ _ __ ___ __| |_ _ ___| |_ _ ___ _ __
25 \___ \| |_ / _ \ | '__/ _ \/ _` | | | |/ __| __| |/ _ \| '_ \
26 ____) | |/ / __/ | | | __/ (_| | |_| | (__| |_| | (_) | | | |
27 |_____/|_/___\___| |_| \___|\__,_|\__,_|\___|\__|_|\___/|_| |_|
29 *****************************************************************************/
31 typedef struct _coloring_suffix_t coloring_suffix_t;
33 struct _coloring_suffix_t {
34 coloring_suffix_t *next;
38 typedef struct _size_red_t {
40 pset *all_removed; /**< All nodes removed during problem size reduction */
41 coloring_suffix_t *col_suff; /**< Coloring suffix. Reverse would be a PEO prefix */
46 * Just prepare. Do nothing yet.
48 size_red_t *new_size_red(copy_opt_t *co);
51 * Checks if a node has already been removed
53 #define sr_is_removed(sr, irn) pset_find_ptr((sr)->all_removed, irn)
56 * Virtually remove all nodes not related to the problem
57 * (simplicial AND not adjacent to a equal-color-edge)
59 void sr_remove(size_red_t *sr);
62 * Virtually reinsert the nodes removed before and color them
64 void sr_reinsert(size_red_t *sr);
69 void free_size_red(size_red_t *sr);
72 * TODO: This search is necessary because during the construction of the
73 * units (ou's) args could be merged and weights are accumulated.
76 static INLINE int co_ilp_get_costs(copy_opt_t *co, ir_node *root, ir_node *arg) {
80 /* search optimization unit for phi */
81 list_for_each_entry(unit_t, curr, &co->units, units)
82 if (curr->nodes[0] == root) {
84 for (i=1; i<curr->node_count; ++i)
85 if (curr->nodes[i] == arg)
86 return curr->costs[i];
88 assert(0 && "irn must occur in this ou");
91 assert(0 && "phi must be found in a ou");
95 /******************************************************************************
97 / ____| (_) |_ _| | | __ \
98 | | __ ___ _ __ ___ _ __ _ ___ | | | | | |__) |
99 | | |_ |/ _ \ '_ \ / _ \ '__| |/ __| | | | | | ___/
100 | |__| | __/ | | | __/ | | | (__ _| |_| |____| |
101 \_____|\___|_| |_|\___|_| |_|\___| |_____|______|_|
103 *****************************************************************************/
108 #define LPP_SOLVE_NET
111 # include <lpp/lpp_net.h>
113 # include <lpp/lpp_cplex.h>
116 #define EPSILON 0.00001
118 typedef struct _ilp_env_t ilp_env_t;
120 typedef void(*ilp_callback)(ilp_env_t*);
123 const copy_opt_t *co; /**< the copy opt problem */
124 size_red_t *sr; /**< problem size reduction. removes simple nodes */
125 lpp_t *lp; /**< the linear programming problem */
131 ilp_env_t *new_ilp_env(copy_opt_t *co, ilp_callback build, ilp_callback apply, void *env);
133 lpp_sol_state_t ilp_go(ilp_env_t *ienv);
135 void free_ilp_env(ilp_env_t *ienv);
138 #define name_cdd(buf, char1, int1, int2) \
139 (snprintf(buf, sizeof(buf), "%c_%d_%d", char1, int1, int2), buf)
141 #define name_cdd_sorted(buf, char1, int1, int2) \
142 name_cdd(buf, char1, MIN(int1, int2), MAX(int1, int2))