2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Common stuff used by all ILP formulations.
23 * @author Daniel Grund
27 #ifndef FIRM_BE_BECOPYILP_T_H
28 #define FIRM_BE_BECOPYILP_T_H
30 #include "firm_types.h"
32 #include "becopyopt_t.h"
34 /******************************************************************************
37 | (___ _ _______ _ __ ___ __| |_ _ ___| |_ _ ___ _ __
38 \___ \| |_ / _ \ | '__/ _ \/ _` | | | |/ __| __| |/ _ \| '_ \
39 ____) | |/ / __/ | | | __/ (_| | |_| | (__| |_| | (_) | | | |
40 |_____/|_/___\___| |_| \___|\__,_|\__,_|\___|\__|_|\___/|_| |_|
42 *****************************************************************************/
44 typedef struct _coloring_suffix_t coloring_suffix_t;
46 struct _coloring_suffix_t {
47 coloring_suffix_t *next;
51 typedef struct _size_red_t {
53 pset *all_removed; /**< All nodes removed during problem size reduction */
54 coloring_suffix_t *col_suff; /**< Coloring suffix. Reverse would be a PEO prefix */
59 * Just prepare. Do nothing yet.
61 size_red_t *new_size_red(copy_opt_t *co);
64 * Checks if a node has already been removed
66 #define sr_is_removed(sr, irn) pset_find_ptr((sr)->all_removed, irn)
69 * Virtually remove all nodes not related to the problem
70 * (simplicial AND not adjacent to a equal-color-edge)
72 void sr_remove(size_red_t *sr);
75 * Virtually reinsert the nodes removed before and color them
77 void sr_reinsert(size_red_t *sr);
82 void free_size_red(size_red_t *sr);
85 * TODO: This search is necessary because during the construction of the
86 * units (ou's) args could be merged and weights are accumulated.
89 static inline int co_ilp_get_costs(copy_opt_t *co, ir_node *root, ir_node *arg) {
93 /* search optimization unit for phi */
94 list_for_each_entry(unit_t, curr, &co->units, units)
95 if (curr->nodes[0] == root) {
97 for (i = 1; i < curr->node_count; ++i)
98 if (curr->nodes[i] == arg)
99 return curr->costs[i];
101 assert(0 && "irn must occur in this ou");
104 assert(0 && "phi must be found in a ou");
108 /******************************************************************************
109 _____ _ _____ _ _____
110 / ____| (_) |_ _| | | __ \
111 | | __ ___ _ __ ___ _ __ _ ___ | | | | | |__) |
112 | | |_ |/ _ \ '_ \ / _ \ '__| |/ __| | | | | | ___/
113 | |__| | __/ | | | __/ | | | (__ _| |_| |____| |
114 \_____|\___|_| |_|\___|_| |_|\___| |_____|______|_|
116 *****************************************************************************/
121 #define LPP_SOLVE_NET
124 # include <lpp/lpp_net.h>
126 # include <lpp/lpp_cplex.h>
129 #define EPSILON 0.00001
131 typedef struct _ilp_env_t ilp_env_t;
133 typedef void(*ilp_callback)(ilp_env_t*);
136 const copy_opt_t *co; /**< the copy opt problem */
137 size_red_t *sr; /**< problem size reduction. removes simple nodes */
138 lpp_t *lp; /**< the linear programming problem */
144 ilp_env_t *new_ilp_env(copy_opt_t *co, ilp_callback build, ilp_callback apply, void *env);
146 lpp_sol_state_t ilp_go(ilp_env_t *ienv);
148 void free_ilp_env(ilp_env_t *ienv);
151 #define name_cdd(buf, char1, int1, int2) \
152 (snprintf(buf, sizeof(buf), "%c_%d_%d", char1, int1, int2), buf)
154 #define name_cdd_sorted(buf, char1, int1, int2) \
155 name_cdd(buf, char1, MIN(int1, int2), MAX(int1, int2))
157 #endif /* WITH_ILP */
159 #endif /* FIRM_BE_BECOPYILP_T_H */