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"
16 #include "becopyopt_t.h"
18 /******************************************************************************
21 | (___ _ _______ _ __ ___ __| |_ _ ___| |_ _ ___ _ __
22 \___ \| |_ / _ \ | '__/ _ \/ _` | | | |/ __| __| |/ _ \| '_ \
23 ____) | |/ / __/ | | | __/ (_| | |_| | (__| |_| | (_) | | | |
24 |_____/|_/___\___| |_| \___|\__,_|\__,_|\___|\__|_|\___/|_| |_|
26 *****************************************************************************/
28 typedef struct size_red_t {
30 ir_node **col_suff; /**< Coloring suffix. A PEO prefix. */
31 ir_nodeset_t all_removed; /**< All nodes removed during problem size reduction */
35 * Checks if a node has already been removed
37 static inline bool sr_is_removed(size_red_t const *const sr, ir_node const *const irn)
39 return ir_nodeset_contains(&sr->all_removed, irn);
43 * TODO: This search is necessary because during the construction of the
44 * units (ou's) args could be merged and weights are accumulated.
47 static inline int co_ilp_get_costs(copy_opt_t *co, ir_node *root, ir_node *arg) {
50 /* search optimization unit for phi */
51 list_for_each_entry(unit_t, curr, &co->units, units)
52 if (curr->nodes[0] == root) {
54 for (i = 1; i < curr->node_count; ++i)
55 if (curr->nodes[i] == arg)
56 return curr->costs[i];
58 assert(0 && "irn must occur in this ou");
61 assert(0 && "phi must be found in a ou");
65 /******************************************************************************
67 / ____| (_) |_ _| | | __ \
68 | | __ ___ _ __ ___ _ __ _ ___ | | | | | |__) |
69 | | |_ |/ _ \ '_ \ / _ \ '__| |/ __| | | | | | ___/
70 | |__| | __/ | | | __/ | | | (__ _| |_| |____| |
71 \_____|\___|_| |_|\___|_| |_|\___| |_____|______|_|
73 *****************************************************************************/
78 #define EPSILON 0.00001
80 typedef struct ilp_env_t ilp_env_t;
82 typedef void(*ilp_callback)(ilp_env_t*);
85 const copy_opt_t *co; /**< the copy opt problem */
86 size_red_t *sr; /**< problem size reduction. removes simple nodes */
87 lpp_t *lp; /**< the linear programming problem */
93 ilp_env_t *new_ilp_env(copy_opt_t *co, ilp_callback build, ilp_callback apply, void *env);
95 lpp_sol_state_t ilp_go(ilp_env_t *ienv);
97 void free_ilp_env(ilp_env_t *ienv);