7e0029cbebe3ddffe668b46358948b952cd5ab93
[libfirm] / ir / be / bestate.h
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Handles state switching. This is basically the belady spill
23  *              algorithm optimized for the 1-register case.
24  * @author      Matthias Braun
25  * @date        26.03.2007
26  * @version     $Id$
27  * Copyright:   (c) Universitaet Karlsruhe
28  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
29  */
30 #ifndef FIRM_BE_BESTATE_H
31 #define FIRM_BE_BESTATE_H
32
33 #include "irnode.h"
34 #include "beirg.h"
35 #include "bearch_t.h"
36
37 /**
38  * Callback that should create a spill for a certain value. Can return NULL
39  * if @p force == 0 and the value can be easily rematerialized
40  */
41 typedef ir_node* (*create_spill_func) (void *env, ir_node *value, int force,
42                                        ir_node *after);
43
44 /**
45  * Callback that should create a reload for a certain value
46  */
47 typedef ir_node* (*create_reload_func) (void *env, ir_node *value,
48                                         ir_node *spill, ir_node *before,
49                                         ir_node *last_value);
50
51 /**
52  * Some state is expressed as a register. nodes defining a value for this
53  * register are known states. You can connect these to nodes to express that a
54  * node needs the processor to be in a certain state.
55  * This functions asserts that the state is switched to fullfill all state
56  * requirements of nodes.
57  */
58 void be_assure_state(be_irg_t *birg, const arch_register_t *reg, void *func_env,
59                      create_spill_func spill_func,
60                      create_reload_func reload_func);
61
62 #endif