Next step of refactoring
[libfirm] / ir / be / becopyopt.h
1 /**
2  * Author:      Daniel Grund
3  * Date:                11.04.2005
4  * Copyright:   (c) Universitaet Karlsruhe
5  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
6  *
7  * Main file for the optimization reducing the copies needed for:
8  * - Phi coalescing
9  * - Register-constrained nodes
10  * - Two-address code instructions
11  */
12
13 #ifndef _BECOPYOPT_H
14 #define _BECOPYOPT_H
15
16 #include "irnode.h"
17 #include "bechordal.h"
18
19
20 typedef int(*cost_fct_t)(ir_node*, ir_node*, int);
21
22 typedef struct _copy_opt_t copy_opt_t;
23
24 /**
25  * Has to be called during the firm init phase
26  */
27 void be_copy_opt_init(void);
28
29 /**
30  * Generate the problem. Collect all information and optimizable nodes.
31  */
32 copy_opt_t *new_copy_opt(be_chordal_env_t *chordal_env, cost_fct_t get_costs);
33
34 /**
35  * Free the space used...
36  */
37 void free_copy_opt(copy_opt_t *co);
38
39 /**
40  * Computes the costs of a copy according to loop depth
41  * @param pos:  the argument position of arg in the root arguments
42  * @return Must be >= 0 in all cases.
43  */
44 int co_get_costs_loop_depth(ir_node *root, ir_node* arg, int pos);
45
46 /**
47  * All costs equal 1. Using this will reduce the _number_ of copies.
48  * @return Must be >= 0 in all cases.
49  */
50 int co_get_costs_all_one(ir_node *root, ir_node* arg, int pos);
51
52 /**
53  * Solves the problem using a heuristic approach
54  */
55 int co_solve_heuristic(copy_opt_t *co);
56
57 /**
58  * Solves the problem using mixed integer programming
59  * @returns 1 iff solution state was optimal
60  */
61 int co_solve_ilp1(copy_opt_t *co, double time_limit);
62
63 /**
64  * Solves the problem using mixed integer programming
65  * @returns 1 iff solution state was optimal
66  */
67 int co_solve_ilp2(copy_opt_t *co, double time_limit);
68
69 /**
70  * Compares different solutions of the same problem
71  */
72 void co_compare_solvers(be_chordal_env_t *chordal_env);
73
74 #endif