*** empty log message ***
[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 /*  ir_node * */
13 /*  arg_access (ir_mode *mode, long proj) */
14 /*  { */
15 /*    return new_r_Proj (current_ir_graph, current_ir_graph->start,  */
16 /*                   current_ir_graph->args, mode, proj); */
17 /*  } */
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, remove old one. */
32     /* !!!??? free old in_array */
33     node->in = NEW_ARR_D (ir_node *, current_ir_graph->obst, arity+1);
34   }
35 }
36
37 /* Insert irnode `new' in place of irnode `old'
38    Since `new' may be bigger than `old' replace `old'
39    by an op_Id which is smaller than everything */
40 inline void
41 exchange (ir_node *old, ir_node *new)
42 {
43   ir_node *block = old->in[0];
44
45   old->op = op_Id;
46   old->in = NEW_ARR_D (ir_node *, current_ir_graph->obst, 2);
47   old->in[0] = block;
48   old->in[1] = new;
49 }