irgmod.h 2.6 KB
Newer Older
Götz Lindenmaier's avatar
Götz Lindenmaier committed
1
2
3
4
5
6
7
8
9
10
11
/*
 * Project:     libFIRM
 * File name:   ir/ir/irgmod.h
 * Purpose:     Support for ir graph modification.
 * Author:      Martin Trapp, Christian Schaefer
 * Modified by: Goetz Lindenmaier
 * Created:
 * CVS-ID:      $Id$
 * Copyright:   (c) 1998-2003 Universität Karlsruhe
 * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
 */
Christian Schäfer's avatar
Christian Schäfer committed
12

Michael Beck's avatar
Michael Beck committed
13
14
15
16
17
18
19
20
21
/**
 *
 * @file irgmod.h
 *
 * ir graph modification.
 *
 * @author Martin Trapp, Christian Schaefer
 */

Boris Boesler's avatar
Boris Boesler committed
22

Götz Lindenmaier's avatar
Götz Lindenmaier committed
23
24
25
# ifndef _IRGMOD_H_
# define _IRGMOD_H_

Götz Lindenmaier's avatar
Götz Lindenmaier committed
26
# include "irnode.h"
Christian Schäfer's avatar
Christian Schäfer committed
27

Florian Liekweg's avatar
Florian Liekweg committed
28
29
/** Exchanges two nodes by conserving edges leaving old (i.e.,
   pointers pointing to old).  Turns the old node into an Id. */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
30
void exchange (ir_node *old, ir_node *nw);
31

Götz Lindenmaier's avatar
Götz Lindenmaier committed
32
33
34
35
36
37
38
39
40
41
42
/** Turns a node into a "useless" Tuple.
 *
 *  Turns a node into a "useless" Tuple.  The Tuple node just forms a tuple
 *  from several inputs.  The predecessors of the tuple have to be
 *  set by hand.  The block predecessor automatically remains the same.
 *  This is useful if a node returning a tuple is removed, but the Projs
 *  extracting values from the tuple are not available.
 *
 *  @param node The node to be turned into a tuple.
 *  @param arity The number of values formed into a Tuple.
 */
Christian Schäfer's avatar
Christian Schäfer committed
43
44
void turn_into_tuple (ir_node *node, int arity);

Michael Beck's avatar
Michael Beck committed
45
/** Walks over the passed ir graph and collects all Phi nodes as a
Michael Beck's avatar
Michael Beck committed
46
47
48
49
  * list built with the link field in their corresponding block.
  * Further it collects all Proj nodes in a list of the node producing
  * the tuple. In case of nested tuples the Projs are collected in the
  * node producing the outermost Tuple.
Götz Lindenmaier's avatar
Götz Lindenmaier committed
50
  * All other link fields are cleared afterwards.
Michael Beck's avatar
Michael Beck committed
51
  */
52
53
void collect_phiprojs(ir_graph *irg);

Michael Beck's avatar
Michael Beck committed
54
/** Parts a block into two.  This is useful to insert other blocks within a
Michael Beck's avatar
Michael Beck committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 *  given block.
 *
 * Adds a new block (new_block) in the control flow before the block
 * (old_block) of node.  Moves node and its predecessors from old_block to
 * new_block.  Moves all Projs that depend on moved nodes and are in old_block
 * to new_block. Moves all Phi nodes from old_block to new_block.  To achieve
 * this the routine assumes that all Phi nodes are in a list (using the link
 * field) in the link field of old_block.  Further it assumes that all Proj nodes
 * are accessible by the link field of the nodes producing the Tuple. This
 * can be established by collect_phiprojs().  part_block conserves this property.
 * Adds a Jmp node to new_block that jumps to old_block.
 * Assumes that node is contained in current_ir_graph.  Sets current_block in
 * this ir_graph to new_block.
 *
 * @param node   The node were to break the block
 */
71
72
void part_block(ir_node *node);

Götz Lindenmaier's avatar
Götz Lindenmaier committed
73
#endif /* ifndef _IRGMOD_H_ */