57f2e1dd625f80ea0301c2effee22f1ef40f9bff
[libfirm] / ir / ir / irgmod.h
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
3 **
4 ** Authors: Martin Trapp, Christian Schaefer
5 **
6 ** irgmod.h: ir graph modification
7 */
8
9 # ifndef _IRGMOD_H_
10 # define _IRGMOD_H_
11
12 # include "irnode.h"
13
14 /* Turns a node into a "useless" Tuple.  The Tuple node just forms a tuple
15    from several inputs.  The predecessors of the tuple have to be
16    set by hand.  The block predecessor automatically remains the same.
17    This is useful if a node returning a tuple is removed, but the Projs
18    extracting values from the tuple are not available. */
19 void turn_into_tuple (ir_node *node, int arity);
20
21 /* Exchanges two nodes by conserving edges leaving old (i.e., pointers
22    pointing to old).  Turns the old node into an Id. Requires that
23    current_ir_graph is set properly. */
24 inline void exchange (ir_node *old, ir_node *new);
25
26 /* Walks over the passed ir graph and collects all Phi nodes as a
27    list built with the link field in their corresponding block.
28    Further it collects all Proj nodes in a list of the node producing
29    the tuple. In case of nested tuples the Projs are collected in the
30    node producing the outermost Tuple. */
31 void collect_phiprojs(ir_graph *irg);
32
33 /* Parts a block into two.  This is useful to insert other blocks within a
34    given block.
35    Adds a new block (new_block) in the control flow before the block
36    (old_block) of node.  Moves node and its predecessors from old_block to
37    new_block.  Moves all Projs that depend on moved nodes and are in old_block
38    to new_block. Moves all Phi nodes from old_block to new_block.  To achieve
39    this the routine assumes that all Phi nodes are in a list (using the link
40    field) in the link field of old_block.  Further it assumes that all Proj nodes
41    are accessible by the link field of the nodes producing the Tuple. This
42    can be established by collect_phiprojs().  part_block conserves this property.
43    Adds a Jmp node to new_block that jumps to old_block.
44    Assumes that node is contained in current_ir_graph.  Sets current_block in
45    this ir_graph to new_block. */
46 void part_block(ir_node *node);
47
48 #endif /* ifndef _IRGMOD_H_ */