Added routine to update backedge array if in array changes. untested.
[libfirm] / ir / ana / irbackedge_t.h
1 #ifndef _IRBACKEDGE_T_H_
2 #define _IRBACKEDGE_T_H_
3
4 # include "string.h"
5
6 static INLINE int * new_backedge_arr(struct obstack *obst, int size) {
7   int *res = NEW_ARR_D (int, obst, size);
8   memset(res, 0, sizeof(int) * size);
9   return res;
10 }
11
12
13 static INLINE void fix_backedges(struct obstack *obst, ir_node *n) {
14   opcode opc = get_irn_opcode(n);
15   int ** arr = NULL;
16   if (opc == iro_Phi)    arr = &n->attr.phi_backedge;
17   if ((opc == iro_Block) && !interprocedural_view)
18                          arr = &n->attr.block.backedge;
19   if ((opc == iro_Block) && interprocedural_view)
20                          arr = &n->attr.block.cg_backedge;
21   if (opc == iro_Filter) arr = &n->attr.filter.backedge;
22
23   if (ARR_LEN(arr) != ARR_LEN(get_irn_in(n))-1)
24     *arr = new_backedge_arr(obst, ARR_LEN(get_irn_in(n))-1);
25 }
26
27 #endif /* _IRBACKEDGE_T_H_ */