}
/**
- * Returns true if node has no backarray, or
- * if size of backarray == size of in array.
+ * Returns nin-zero if node has no backarray, or
+ * if size of backarray == size of in array.
*/
-static INLINE bool legal_backarray (ir_node *n) {
+static INLINE int legal_backarray (ir_node *n) {
int *ba = mere_get_backarray(n);
if (ba && (ARR_LEN(ba) != ARR_LEN(get_irn_in(n))-1)) /* Use get_irn_in -- sensitive to view! */
- return false;
- return true;
+ return 0;
+ return 1;
}
}
-/** Returns true if the predecessor pos is a backedge. */
-bool is_backedge (ir_node *n, int pos) {
+/* Returns non-zero if the predecessor pos is a backedge. */
+int is_backedge (ir_node *n, int pos) {
int *ba = get_backarray (n);
if (ba) return ba[pos];
- return false;
+ return 0;
}
-/** Remarks that edge pos is a backedge. */
+/* Remarks that edge pos is a backedge. */
void set_backedge (ir_node *n, int pos) {
int *ba = get_backarray (n);
assert(ba && "can only set backedges at Phi, Filter, Block nodes.");
ba[pos] = 1;
}
-/** Remarks that edge pos is a backedge. */
+/* Remarks that edge pos is a backedge. */
void set_not_backedge (ir_node *n, int pos) {
int *ba = get_backarray (n);
assert(ba && "can only set backedges at Phi, Filter, Block nodes.");
ba[pos] = 0;
}
-/** Returns true if n has backedges. */
-bool has_backedges (ir_node *n) {
+/* Returns non-zero if n has backedges. */
+int has_backedges (ir_node *n) {
int i;
int *ba = get_backarray (n);
if (ba) {
int arity = get_irn_arity(n);
for (i = 0; i < arity; i++)
- if (ba[i]) return true;
+ if (ba[i]) return 1;
}
- return false;
+ return 0;
}
/** Sets all backedge information to zero. */
int i, arity;
int rem = get_interprocedural_view();
int *ba;
- set_interprocedural_view(false);
+ set_interprocedural_view(0);
ba = get_backarray (n);
if (ba) {
arity = get_irn_arity(n);
for (i = 0; i < arity; i++)
ba[i] = 0;
}
- set_interprocedural_view(true);
+ set_interprocedural_view(1);
ba = get_backarray (n);
if (ba) {
arity = get_irn_arity(n);
}
set_interprocedural_view(rem);
}
+
+int *new_backedge_arr(struct obstack *obst, int size) {
+ int *res = NEW_ARR_D (int, obst, size);
+ memset(res, 0, sizeof(int) * size);
+ return res;
+}
+
+/* TODO: add an ir_op operation */
+void new_backedge_info(ir_node *n) {
+ switch(get_irn_opcode(n)) {
+ case iro_Block:
+ n->attr.block.cg_backedge = NULL;
+ n->attr.block.backedge = new_backedge_arr(current_ir_graph->obst, get_irn_arity(n));
+ break;
+ case iro_Phi:
+ n->attr.phi_backedge = new_backedge_arr(current_ir_graph->obst, get_irn_arity(n));
+ break;
+ case iro_Filter:
+ n->attr.filter.backedge = new_backedge_arr(current_ir_graph->obst, get_irn_arity(n));
+ break;
+ default: ;
+ }
+}