3fb9d6faab2df5c1465d6e50ebfa4478a18d516d
[libfirm] / ir / be / bestate.h
1 /**
2  * @file
3  * @brief       Handles state switching. This is basically the belady spill
4  *              algorithm optimized for the 1-register case.
5  * @author      Matthias Braun
6  * @date        26.03.2007
7  * @version     $Id$
8  * Copyright:   (c) Universitaet Karlsruhe
9  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
10  */
11 #ifndef FIRM_BE_BESTATE_H
12 #define FIRM_BE_BESTATE_H
13
14 #include "irnode.h"
15 #include "beirg.h"
16 #include "bearch.h"
17
18 /**
19  * Callback that should create a spill for a certain value. Can return NULL
20  * if @p force == 0 and the value can be easily rematerialized
21  */
22 typedef ir_node* (*create_spill_func) (void *env, ir_node *value, int force);
23
24 /**
25  * Callback that should create a reload for a certain value
26  */
27 typedef ir_node* (*create_reload_func) (void *env, ir_node *value,
28                                         ir_node *spill, ir_node *before);
29
30 /**
31  * Some state is expressed as a register. nodes defining a value for this
32  * register are known states. You can connect these to nodes to express that a
33  * node needs the processor to be in a certain state.
34  * This functions asserts that the state is switched to fullfill all state
35  * requirements of nodes.
36  */
37 void be_assure_state(be_irg_t *birg, const arch_register_t *reg, void *func_env,
38                      create_spill_func spill_func,
39                      create_reload_func reload_func);
40
41 #endif