autoconf stuff
[libfirm] / ir / ir / irgmod.c
1
2 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
3 ** All rights reserved.
4 **
5 ** Authors: Martin Trapp, Christian Schaefer
6 **
7 ** irgmod: ir graph modification
8 */
9
10 #ifdef HAVE_CONFIG_H
11 # include <config.h>
12 #endif
13
14 # include "irnode_t.h"
15 # include "irgraph_t.h"
16 # include "irgmod.h"
17 # include "array.h"
18
19 /* Turns a node into a "useless" Tuple.  The Tuple just forms a tuple
20    from several inputs.
21    This is useful if a node returning a tuple is removed, but the Projs
22    extracting values from the tuple are not available. */
23 void
24 turn_into_tuple (ir_node *node, int arity)
25 {
26   assert(node);
27   set_irn_op(node, op_Tuple);
28   if (get_irn_arity(node) == arity) {
29     /* keep old array */
30   } else {
31     /* Allocate new array, don't free old in_array, it's on the obstack. */
32     ir_node *block = get_nodes_Block(node);
33     node->in = NEW_ARR_D (ir_node *, current_ir_graph->obst, arity+1);
34     set_nodes_Block(node, block);
35   }
36 }
37
38 /* Insert irnode `new' in place of irnode `old'
39    Since `new' may be bigger than `old' replace `old'
40    by an op_Id which is smaller than everything */
41 inline void
42 exchange (ir_node *old, ir_node *new)
43 {
44   ir_node *block = old->in[0];
45
46   old->op = op_Id;
47   old->in = NEW_ARR_D (ir_node *, current_ir_graph->obst, 2);
48   old->in[0] = block;
49   old->in[1] = new;
50 }