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