1 /* Copyright (C) 2002 by Universitaet Karlsruhe
2 ** All rights reserved.
4 ** Authors: Goetz Lindenmaier
6 ** irbackedges.c Access function for backedges.
14 /**********************************************************************/
15 /** Backedge information. **/
16 /**********************************************************************/
19 /* Returns backarray if the node can have backedges. Else returns
21 inline int *get_backarray(ir_node *n) {
22 switch(get_irn_opcode(n)) {
24 if (interprocedural_view && n->attr.block.in_cg) {
25 assert(n->attr.block.cg_backedge && "backedge array not allocated!");
26 return n->attr.block.cg_backedge;
28 assert(n->attr.block.backedge && "backedge array not allocated!");
29 return n->attr.block.backedge;
33 assert(n->attr.phi_backedge && "backedge array not allocated!");
34 return n->attr.phi_backedge;
37 if (interprocedural_view) {
38 assert(n->attr.filter.backedge && "backedge array not allocated!");
39 return n->attr.filter.backedge;
47 /* Returns true if the predesessor pos is a backedge. */
48 bool is_backedge (ir_node *n, int pos) {
49 int *ba = get_backarray (n);
50 if (ba) return ba[pos];
54 /* Remarks that edge pos is a backedge. */
55 void set_backedge (ir_node *n, int pos) {
56 int *ba = get_backarray (n);
57 assert(ba && "can only set backedges at Phi, Filter, Block nodes.");
61 /* Remarks that edge pos is a backedge. */
62 void set_not_backedge (ir_node *n, int pos) {
63 int *ba = get_backarray (n);
64 assert(ba && "can only set backedges at Phi, Filter, Block nodes.");
68 /* Returns true if n has backedges. */
69 bool has_backedges (ir_node *n) {
71 int *ba = get_backarray (n);
73 for (i = 0; i < get_irn_arity(n); i++)
74 if (ba[i]) return true;
78 /* Sets all backedge information to zero. */
79 void clear_backedges (ir_node *n) {
80 int i, rem = interprocedural_view;
82 interprocedural_view = 0;
83 ba = get_backarray (n);
85 for (i = 0; i < get_irn_arity(n); i++)
87 interprocedural_view = 1;
88 ba = get_backarray (n);
90 for (i = 0; i < get_irn_arity(n); i++)
92 interprocedural_view = rem;