1 /* Copyright (C) 2002 by Universitaet Karlsruhe
2 ** All rights reserved.
4 ** Authors: Goetz Lindenmaier
6 ** irloops.h: Computes backedges in the control and data flow.
7 ** Only Block and Phi/Filter nodes can have incoming backedges.
8 ** Constructs loops data structure: indicates loop nesting.
20 /** @@@ Interprocedural backedges ... ???? **/
22 /**********************************************************************/
23 /** Backedge information. **/
25 /** Predecessors of Block, Phi and interprocedural Filter nodes can **/
26 /** have backedges. If loop information is computed, this **/
27 /** information is computed, too. **/
28 /** The backedge information can only be used if the graph is not in **/
29 /** phase phase_building. **/
30 /**********************************************************************/
32 /* Returns true if the predesessor pos is a backedge. */
33 bool is_backedge (ir_node *n, int pos);
34 /* Remarks that edge pos is a backedge. */
35 void set_backedge (ir_node *n, int pos);
36 /* Remarks that edge pos is not a backedge. */
37 void set_not_backedge (ir_node *n, int pos);
38 /* Returns true if n has backedges. */
39 bool has_backedges (ir_node *n);
40 /* Sets backedge information to zero. */
41 void clear_backedges (ir_node *n);
43 /**********************************************************************/
44 /** The loops datastructure **/
46 /** The loops datastructure represents circles in the intermediate **/
47 /** representation. It does not represent loops in the terms of a **/
48 /** source program. **/
49 /** Each ir_graph can contain one outermost loop datastructure. **/
50 /** loop is the entry point to the nested loops. **/
51 /** The loop datastructure contains a field indicating the depth of **/
52 /** the loop within the nesting. Further it contains a list of the **/
53 /** loops with nesting depth -1. Finally it contains a list of all **/
54 /** nodes in the loop. **/
55 /* @@@ We could add a field pointing from a node to the containing loop,
56 this would cost a lot of memory, though. */
57 /**********************************************************************/
59 typedef struct ir_loop ir_loop;
61 void set_irg_loop(ir_graph *irg, ir_loop *l);
62 ir_loop *get_irg_loop(ir_graph *irg);
64 /* Returns the loop n is contained in.
65 assumes current_ir_graph set properly. */
66 ir_loop *get_irn_loop(ir_node *n);
68 /* Returns outer loop, itself if outermost. */
69 ir_loop *get_loop_outer_loop (ir_loop *loop);
70 /* Returns nesting depth of this loop */
71 int get_loop_depth (ir_loop *loop);
73 /* Sons are the inner loops contained in this loop. */
74 /* Returns the number of inner loops */
75 int get_loop_n_sons (ir_loop *loop);
76 ir_loop *get_loop_son (ir_loop *loop, int pos);
77 /* Returns the number of nodes contained in loop. */
78 int get_loop_n_nodes (ir_loop *loop);
79 ir_node *get_loop_node (ir_loop *loop, int pos);
82 /**********************************************************************/
83 /* Constructing and destructing the loop/backedge information. **/
84 /**********************************************************************/
86 /* Constructs backedge information for irg. In interprocedural view constructs
87 backedges for all methods called by irg, too.
88 @@@ I'm not sure what happens if irg is within a recursion in iterproc_view.
89 @@@ Interprocedural backedge construction is not yet functioning!!!
91 void construct_backedges(ir_graph *irg);
93 #endif /* _IRLOOP_H_ */