Bugfixes
[libfirm] / ir / be / beutil.h
1
2 #ifndef _BEUTIL_H
3 #define _BEUTIL_H
4
5 #include <stdio.h>
6
7 #include "irnode.h"
8 #include "config.h"
9
10 /** Undefine this to disable debugging mode. */
11 #define BE_DEBUG 1
12
13 /**
14  * Check, if a node produces or consumes a data value.
15  * If it does, it is significant for scheduling and register allocation.
16  * A node produces/consumes a data value, if one of its operands is of
17  * mode datab, or his retuning mode is of mode datab.
18  * @param irn The node to check for.
19  * @return 1, if the node is a data node, 0 if not.
20  */
21 static INLINE int is_data_node(const ir_node *irn)
22 {
23         int i, n;
24
25         /* If the node produces a data value, return immediately. */
26         if(mode_is_datab(get_irn_mode(irn)))
27                 return 1;
28
29         /* else check, if it takes a data value, if that is so, return */
30         for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
31                 ir_node *op = get_irn_n(irn, i);
32                 if(mode_is_datab(get_irn_mode(op)))
33                         return 1;
34         }
35
36         /* Else the node does not produce/consume a data value */
37         return 0;
38 }
39
40 /**
41  * Make each constant local to its use.
42  * This duplicates all constants in order to simulate a realistic
43  * register pressure.
44  * @param irg The graph.
45  */
46 void localize_consts(ir_graph *irg);
47
48 /**
49  * Dump a vcg graph containing the controlflow graph, the schedule and
50  * allocated registers.
51  * @param irg The irg. Note that scheduling, register allocation must
52  * have been performed.
53  */
54 void dump_allocated_irg(ir_graph *irg, char *suffix);
55
56 #endif