More missing config.h
[libfirm] / ir / be / ia32 / ia32_util.c
1 /**
2  * Contains implementation of some useful functions for ia32 backend.
3  * @author Christian Wuerdig
4  * $Id$
5  */
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #endif
9
10 #include <assert.h>
11
12 #include "irnode.h"
13 #include "iredges.h"
14
15 #include "ia32_util.h"
16
17 /**
18  * Returns the first Proj with given mode connected to irn.
19  * @param irn  The irn
20  * @param First proj with mode == mode or NULL if none found
21  */
22 ir_node *ia32_get_proj_for_mode(const ir_node *irn, ir_mode *mode) {
23         const ir_edge_t *edge;
24         ir_node         *src;
25
26         assert(get_irn_mode(irn) == mode_T && "expected mode_T node");
27
28         foreach_out_edge(irn, edge) {
29                 src = get_edge_src_irn(edge);
30
31                 assert(is_Proj(src) && "Proj expected");
32
33                 if (get_irn_mode(src) == mode_M)
34                         return src;
35         }
36
37         return NULL;
38 }
39
40 /**
41  * Returns the first Proj with mode != mode_M connected to irn.
42  * @param irn  The irn
43  * @param First proj with mode != mode_M or NULL if none found
44  */
45 ir_node *ia32_get_res_proj(const ir_node *irn) {
46         const ir_edge_t *edge;
47         ir_node         *src;
48
49         assert(get_irn_mode(irn) == mode_T && "expected mode_T node");
50
51         foreach_out_edge(irn, edge) {
52                 src = get_edge_src_irn(edge);
53
54                 assert(is_Proj(src) && "Proj expected");
55
56                 if (get_irn_mode(src) != mode_M)
57                         return src;
58         }
59
60         return NULL;
61 }