4 * Copyright: (c) Universitaet Karlsruhe
5 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
7 * Header for copy optimization problem. Analysis and set up of the problem.
19 #include "sp_matrix.h"
30 #include "bechordal_t.h"
33 #define DEBUG_IRG "NONE spec.c__main__datab"
34 #define DEBUG_LVL_CO LEVEL_1
35 #define DEBUG_LVL_HEUR LEVEL_1
36 #define DEBUG_LVL_ILP LEVEL_1
39 * Data representing the problem of copy minimization.
41 typedef struct _copy_opt_t {
42 be_chordal_env_t *chordal_env;
43 char *name; /**< ProgName__IrgName__RegClass */
44 struct list_head units; /**< all units to optimize in right order */
45 pset *roots; /**< used only temporary for detecting multiple appends */
50 * A single unit of optimization. Lots of these form a copy-opt problem
52 typedef struct _unit_t {
53 struct list_head units; /**< chain for all units */
54 copy_opt_t *co; /**< the copy_opt this unit belongs to */
55 int interf; /**< number of nodes dropped due to interference */
56 int node_count; /**< size of the nodes array */
57 ir_node **nodes; /**< [0] is the root-node, others are non interfering args of it. */
58 int ifg_mis_size; /**< size of a mis considering only ifg (not coloring conflicts) */
61 struct list_head queue; /**< list of (mis/color) sorted by size of mis */
65 #define set_irn_col(co, irn, col) \
66 arch_set_irn_register(co->chordal_env->arch_env, irn, 0, arch_register_for_index(co->chordal_env->cls, col))
68 #define get_irn_col(co, irn) \
69 arch_register_get_index(arch_get_irn_register(co->chordal_env->arch_env, irn, 0))
73 * Generate the problem. Collect all infos and optimizable nodes.
75 copy_opt_t *new_copy_opt(be_chordal_env_t *chordal_env);
80 void free_copy_opt(copy_opt_t *co);
83 #define is_Perm(arch_env, irn) (arch_irn_classify(arch_env, irn) == arch_irn_class_perm)
86 * A copy is a proj haning out of perm node
88 #define is_Copy(arch_env, irn) (is_Proj(irn) && is_Perm(arch_env, get_Proj_pred(irn)))
91 * returns the corresponding argument of the perm node for a copy
93 #define get_Copy_src(irn) (get_irn_n(get_Proj_pred(irn), get_Proj_proj(irn)))
96 * Checks if a node is optimizable, viz. is a target of a 'copy-op'
98 #define is_optimizable(arch_env, irn) (is_Phi(irn) || is_Copy(arch_env, irn))
101 * Checks if the irn is a non-interfering argument of a node which 'is_optimizable'
103 int is_optimizable_arg(const copy_opt_t *co, ir_node *irn);
107 * Returns the current number of copies needed
109 int co_get_copy_count(const copy_opt_t *co);
112 * Returns a lower bound for the number of copies needed based on interfering
113 * arguments and the size of a max indep. set (only ifg-edges) of the other args.
115 int co_get_lower_bound(const copy_opt_t *co);
118 * Returns the number of arguments interfering with their root node. This also
119 * is a (worse) lower bound for the number of copies needed.
121 int co_get_interferer_count(const copy_opt_t *co);
124 * Solves the problem using a heuristic approach
126 void co_heur_opt(copy_opt_t *co);
129 * Solves the problem using mixed integer programming
131 void co_ilp_opt(copy_opt_t *co);
134 * Checks the register allocation for correctness
136 void co_check_allocation(copy_opt_t *co);