2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Common stuff used by all ILP formulations.
12 #ifndef FIRM_BE_BECOPYILP_T_H
13 #define FIRM_BE_BECOPYILP_T_H
15 #include "firm_types.h"
17 #include "becopyopt_t.h"
19 /******************************************************************************
22 | (___ _ _______ _ __ ___ __| |_ _ ___| |_ _ ___ _ __
23 \___ \| |_ / _ \ | '__/ _ \/ _` | | | |/ __| __| |/ _ \| '_ \
24 ____) | |/ / __/ | | | __/ (_| | |_| | (__| |_| | (_) | | | |
25 |_____/|_/___\___| |_| \___|\__,_|\__,_|\___|\__|_|\___/|_| |_|
27 *****************************************************************************/
29 typedef struct coloring_suffix_t coloring_suffix_t;
31 struct coloring_suffix_t {
32 coloring_suffix_t *next;
36 typedef struct size_red_t {
38 pset *all_removed; /**< All nodes removed during problem size reduction */
39 coloring_suffix_t *col_suff; /**< Coloring suffix. Reverse would be a PEO prefix */
44 * Checks if a node has already been removed
46 #define sr_is_removed(sr, irn) pset_find_ptr((sr)->all_removed, irn)
49 * TODO: This search is necessary because during the construction of the
50 * units (ou's) args could be merged and weights are accumulated.
53 static inline int co_ilp_get_costs(copy_opt_t *co, ir_node *root, ir_node *arg) {
56 /* search optimization unit for phi */
57 list_for_each_entry(unit_t, curr, &co->units, units)
58 if (curr->nodes[0] == root) {
60 for (i = 1; i < curr->node_count; ++i)
61 if (curr->nodes[i] == arg)
62 return curr->costs[i];
64 assert(0 && "irn must occur in this ou");
67 assert(0 && "phi must be found in a ou");
71 /******************************************************************************
73 / ____| (_) |_ _| | | __ \
74 | | __ ___ _ __ ___ _ __ _ ___ | | | | | |__) |
75 | | |_ |/ _ \ '_ \ / _ \ '__| |/ __| | | | | | ___/
76 | |__| | __/ | | | __/ | | | (__ _| |_| |____| |
77 \_____|\___|_| |_|\___|_| |_|\___| |_____|______|_|
79 *****************************************************************************/
84 #define EPSILON 0.00001
86 typedef struct ilp_env_t ilp_env_t;
88 typedef void(*ilp_callback)(ilp_env_t*);
91 const copy_opt_t *co; /**< the copy opt problem */
92 size_red_t *sr; /**< problem size reduction. removes simple nodes */
93 lpp_t *lp; /**< the linear programming problem */
99 ilp_env_t *new_ilp_env(copy_opt_t *co, ilp_callback build, ilp_callback apply, void *env);
101 lpp_sol_state_t ilp_go(ilp_env_t *ienv);
103 void free_ilp_env(ilp_env_t *ienv);