Remove unused vars
[libfirm] / ir / be / becopyilp_t.h
1 /**
2  * Author:      Daniel Grund
3  * Date:                28.02.2006
4  * Copyright:   (c) Universitaet Karlsruhe
5  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
6  *
7  * Common stuff used by all ILP fomulations.
8  *
9  */
10
11 #ifndef _BECOPYILP_T_H
12 #define _BECOPYILP_T_H
13
14 #include "firm_config.h"
15
16 #ifdef HAVE_ALLOCA_H
17 #include <alloca.h>
18 #endif
19 #ifdef HAVE_MALLOC_H
20 #include <malloc.h>
21 #endif
22
23 #include "irnode_t.h"
24 #include "pset.h"
25 #include "becopyopt_t.h"
26
27 /******************************************************************************
28     _____ _                        _            _   _
29    / ____(_)                      | |          | | (_)
30   | (___  _ _______   _ __ ___  __| |_   _  ___| |_ _  ___  _ __
31    \___ \| |_  / _ \ | '__/ _ \/ _` | | | |/ __| __| |/ _ \| '_ \
32    ____) | |/ /  __/ | | |  __/ (_| | |_| | (__| |_| | (_) | | | |
33   |_____/|_/___\___| |_|  \___|\__,_|\__,_|\___|\__|_|\___/|_| |_|
34
35  *****************************************************************************/
36
37 typedef struct _coloring_suffix_t coloring_suffix_t;
38
39 struct _coloring_suffix_t {
40         coloring_suffix_t *next;
41         ir_node *irn;
42 };
43
44 typedef struct _size_red_t {
45         copy_opt_t *co;
46         pset *all_removed;                              /**< All nodes removed during problem size reduction */
47         coloring_suffix_t *col_suff;    /**< Coloring suffix. Reverse would be a PEO prefix */
48         struct obstack ob;
49 } size_red_t;
50
51 /**
52  * Just prepare. Do nothing yet.
53  */
54 size_red_t *new_size_red(copy_opt_t *co);
55
56 /**
57  * Checks if a node has already been removed
58  */
59 #define sr_is_removed(sr, irn)          pset_find_ptr((sr)->all_removed, irn)
60
61 /**
62  * Virtually remove all nodes not related to the problem
63  * (simplicial AND not adjacent to a equal-color-edge)
64  */
65 void sr_remove(size_red_t *sr);
66
67 /**
68  * Virtually reinsert the nodes removed before and color them
69  */
70 void sr_reinsert(size_red_t *sr);
71
72 /**
73  * Free all space...
74  */
75 void free_size_red(size_red_t *sr);
76
77 /**
78  * TODO: This search is necessary because during the construction of the
79  *       units (ou's) args could be merged and weights are accumulated.
80  *       Is this necessary?
81  */
82 static INLINE int co_ilp_get_costs(copy_opt_t *co, ir_node *root, ir_node *arg) {
83         int i;
84         unit_t *curr;
85
86         /* search optimization unit for phi */
87         list_for_each_entry(unit_t, curr, &co->units, units)
88                 if (curr->nodes[0] == root) {
89
90                         for (i=1; i<curr->node_count; ++i)
91                                 if (curr->nodes[i] == arg)
92                                         return curr->costs[i];
93
94                                 assert(0 && "irn must occur in this ou");
95                 }
96
97         assert(0 && "phi must be found in a ou");
98         return 0;
99 }
100
101 /******************************************************************************
102     _____                      _        _____ _      _____
103    / ____|                    (_)      |_   _| |    |  __ \
104   | |  __  ___ _ __   ___ _ __ _  ___    | | | |    | |__) |
105   | | |_ |/ _ \ '_ \ / _ \ '__| |/ __|   | | | |    |  ___/
106   | |__| |  __/ | | |  __/ |  | | (__   _| |_| |____| |
107    \_____|\___|_| |_|\___|_|  |_|\___| |_____|______|_|
108
109  *****************************************************************************/
110
111 #include <lpp/lpp.h>
112
113 #define LPP_SOLVE_NET
114
115 #ifdef LPP_SOLVE_NET
116 #  include <lpp/lpp_net.h>
117 #else
118 #  include <lpp/lpp_cplex.h>
119 #endif
120
121 #define EPSILON 0.00001
122
123 typedef struct _ilp_env_t ilp_env_t;
124
125 typedef void(*ilp_callback)(ilp_env_t*);
126
127 struct _ilp_env_t {
128         const copy_opt_t *co;                   /**< the copy opt problem */
129         size_red_t *sr;                                 /**< problem size reduction. removes simple nodes */
130         lpp_t *lp;                                              /**< the linear programming problem */
131         void *env;
132         ilp_callback build;
133         ilp_callback apply;
134 };
135
136 ilp_env_t *new_ilp_env(copy_opt_t *co, ilp_callback build, ilp_callback apply, void *env);
137
138 lpp_sol_state_t ilp_go(ilp_env_t *ienv);
139
140 void free_ilp_env(ilp_env_t *ienv);
141
142
143 #define name_cdd(buf, char1, int1, int2) \
144                         (snprintf(buf, sizeof(buf), "%c_%d_%d", char1, int1, int2), buf)
145
146 #define name_cdd_sorted(buf, char1, int1, int2) \
147                         name_cdd(buf, char1, MIN(int1, int2), MAX(int1, int2))
148
149 #endif