#include "iredges_t.h"
#include "irhooks.h"
+#include "irtools.h"
/* some constants fixing the positions of nodes predecessors
in the in array */
#define END_KEEPALIVE_OFFSET 0
static const char *pnc_name_arr [] = {
- "False", "Eq", "Lt", "Le",
- "Gt", "Ge", "Lg", "Leg", "Uo",
- "Ue", "Ul", "Ule", "Ug", "Uge",
- "Ne", "True"
+ "pn_Cmp_False", "pn_Cmp_Eq", "pn_Cmp_Lt", "pn_Cmp_Le",
+ "pn_Cmp_Gt", "pn_Cmp_Ge", "pn_Cmp_Lg", "pn_Cmp_Leg",
+ "pn_Cmp_Uo", "pn_Cmp_Ue", "pn_Cmp_Ul", "pn_Cmp_Ule",
+ "pn_Cmp_Ug", "pn_Cmp_Uge", "pn_Cmp_Ne", "pn_Cmp_True"
};
/**
memset(p, 0, node_size);
res = (ir_node *) (p + firm_add_node_size);
- res->kind = k_ir_node;
- res->op = op;
- res->mode = mode;
- res->visited = 0;
- res->link = NULL;
+ res->kind = k_ir_node;
+ res->op = op;
+ res->mode = mode;
+ res->visited = 0;
+ res->node_idx = get_irg_next_node_idx(irg);
+ res->link = NULL;
if (arity < 0) {
res->in = NEW_ARR_F (ir_node *, 1); /* 1: space for block */
} else {
#if FIRM_EDGES_INPLACE
{
- int i, n;
- int not_a_block = is_no_Block(res);
+ int i;
+ int is_bl = is_Block(res);
INIT_LIST_HEAD(&res->edge_info.outs_head);
- if(!not_a_block)
+ if(is_bl)
INIT_LIST_HEAD(&res->attr.block.succ_head);
- for (i = 0, n = arity + not_a_block; i < n; ++i)
- edges_notify_edge(res, i - not_a_block, res->in[i], NULL, irg);
+ for (i = is_bl; i <= arity; ++i)
+ edges_notify_edge(res, i - 1, res->in[i], NULL, irg);
}
#endif
set_irn_in (ir_node *node, int arity, ir_node **in) {
int i;
ir_node *** arr;
+ ir_graph *irg = current_ir_graph;
assert(node);
if (get_interprocedural_view()) { /* handle Filter and Block specially */
if (get_irn_opcode(node) == iro_Filter) {
for (i = 0; i < arity; i++) {
if (i < ARR_LEN(*arr)-1)
- edges_notify_edge(node, i, in[i], (*arr)[i+1], current_ir_graph);
+ edges_notify_edge(node, i, in[i], (*arr)[i+1], irg);
else
- edges_notify_edge(node, i, in[i], NULL, current_ir_graph);
+ edges_notify_edge(node, i, in[i], NULL, irg);
}
for(;i < ARR_LEN(*arr)-1; i++) {
- edges_notify_edge(node, i, NULL, (*arr)[i+1], current_ir_graph);
+ edges_notify_edge(node, i, NULL, (*arr)[i+1], irg);
}
if (arity != ARR_LEN(*arr) - 1) {
ir_node * block = (*arr)[0];
- *arr = NEW_ARR_D(ir_node *, current_ir_graph->obst, arity + 1);
+ *arr = NEW_ARR_D(ir_node *, irg->obst, arity + 1);
(*arr)[0] = block;
}
- fix_backedges(current_ir_graph->obst, node);
+ fix_backedges(irg->obst, node);
memcpy((*arr) + 1, in, sizeof(ir_node *) * arity);
}
}
ir_op *
-(get_irn_op)(const ir_node *node)
-{
+(get_irn_op)(const ir_node *node) {
return _get_irn_op(node);
}
/* should be private to the library: */
void
-set_irn_op (ir_node *node, ir_op *op)
-{
- assert (node);
- node->op = op;
+(set_irn_op)(ir_node *node, ir_op *op) {
+ _set_irn_op(node, op);
}
opcode
/* Outputs a unique number for this node */
-long
-get_irn_node_nr(const ir_node *node) {
+long get_irn_node_nr(const ir_node *node) {
assert(node);
#ifdef DEBUG_libfirm
return node->node_nr;
#else
- return (long)node;
+ return (long)PTR_TO_INT(node);
#endif
}
return &node->attr;
}
+unsigned (get_irn_idx)(const ir_node *node) {
+ assert(is_ir_node(node));
+ return _get_irn_idx(node);
+}
+
/** manipulate fields of individual nodes **/
/* this works for all except Block */
int
(get_Block_n_cfgpreds)(ir_node *node) {
- return get_Block_n_cfgpreds(node);
+ return _get_Block_n_cfgpreds(node);
}
ir_node *
(get_Block_cfgpred)(ir_node *node, int pos) {
- return get_Block_cfgpred(node, pos);
+ return _get_Block_cfgpred(node, pos);
}
void
}
ir_extblk *get_Block_extbb(const ir_node *block) {
+ ir_extblk *res;
assert(is_Block(block));
- return block->attr.block.extblk;
+ res = block->attr.block.extblk;
+ assert(res == NULL || is_ir_extbb(res));
+ return res;
}
void set_Block_extbb(ir_node *block, ir_extblk *extblk) {
assert(is_Block(block));
+ assert(extblk == NULL || is_ir_extbb(extblk));
block->attr.block.extblk = extblk;
}
-void
-set_Start_irg(ir_node *node, ir_graph *irg) {
- assert(node->op == op_Start);
- assert(is_ir_graph(irg));
- assert(0 && " Why set irg? -- use set_irn_irg");
-}
-
int
get_End_n_keepalives(ir_node *end) {
assert (end->op == op_End);
set_irn_n(node, pos + RETURN_RESULT_OFFSET, res);
}
-ir_node *
-get_Raise_mem (ir_node *node) {
- assert (node->op == op_Raise);
- return get_irn_n(node, 0);
-}
-
-void
-set_Raise_mem (ir_node *node, ir_node *mem) {
- assert (node->op == op_Raise);
- set_irn_n(node, 0, mem);
-}
-
-ir_node *
-get_Raise_exo_ptr (ir_node *node) {
- assert (node->op == op_Raise);
- return get_irn_n(node, 1);
-}
-
-void
-set_Raise_exo_ptr (ir_node *node, ir_node *exo_ptr) {
- assert (node->op == op_Raise);
- set_irn_n(node, 1, exo_ptr);
-}
-
tarval *(get_Const_tarval)(ir_node *node) {
return _get_Const_tarval(node);
}
node->attr.s.ent = ent;
}
-ir_type *
-get_InstOf_type (ir_node *node) {
- assert (node->op = op_InstOf);
- return (node->attr.io.type);
-}
-
-void
-set_InstOf_type (ir_node *node, ir_type *type) {
- assert (node->op = op_InstOf);
- node->attr.io.type = type;
-}
-
-ir_node *
-get_InstOf_store (ir_node *node) {
- assert (node->op = op_InstOf);
- return (get_irn_n (node, 0));
-}
-
-void
-set_InstOf_store (ir_node *node, ir_node *obj) {
- assert (node->op = op_InstOf);
- set_irn_n (node, 0, obj);
-}
-
-ir_node *
-get_InstOf_obj (ir_node *node) {
- assert (node->op = op_InstOf);
- return (get_irn_n (node, 1));
-}
-
-void
-set_InstOf_obj (ir_node *node, ir_node *obj) {
- assert (node->op = op_InstOf);
- set_irn_n (node, 1, obj);
-}
-
/* For unary and binary arithmetic operations the access to the
operands can be factored out. Left is the first, right the
case iro_Call: break;
case iro_Load: {
ir_node *a = get_Load_ptr(pred);
- if (get_irn_op(a) == op_Sel)
+ if (is_Sel(a))
tp = get_entity_type(get_Sel_entity(a));
} break;
default:
/* Mux support */
ir_node *get_Mux_sel (ir_node *node) {
+ if (node->op == op_Psi) {
+ assert(get_irn_arity(node) == 3);
+ return get_Psi_cond(node, 0);
+ }
assert(node->op == op_Mux);
return node->in[1];
}
void set_Mux_sel (ir_node *node, ir_node *sel) {
- assert(node->op == op_Mux);
- node->in[1] = sel;
+ if (node->op == op_Psi) {
+ assert(get_irn_arity(node) == 3);
+ set_Psi_cond(node, 0, sel);
+ }
+ else {
+ assert(node->op == op_Mux);
+ node->in[1] = sel;
+ }
}
ir_node *get_Mux_false (ir_node *node) {
+ if (node->op == op_Psi) {
+ assert(get_irn_arity(node) == 3);
+ return get_Psi_default(node);
+ }
assert(node->op == op_Mux);
return node->in[2];
}
void set_Mux_false (ir_node *node, ir_node *ir_false) {
- assert(node->op == op_Mux);
- node->in[2] = ir_false;
+ if (node->op == op_Psi) {
+ assert(get_irn_arity(node) == 3);
+ set_Psi_default(node, ir_false);
+ }
+ else {
+ assert(node->op == op_Mux);
+ node->in[2] = ir_false;
+ }
}
ir_node *get_Mux_true (ir_node *node) {
+ if (node->op == op_Psi) {
+ assert(get_irn_arity(node) == 3);
+ return get_Psi_val(node, 0);
+ }
assert(node->op == op_Mux);
return node->in[3];
}
void set_Mux_true (ir_node *node, ir_node *ir_true) {
- assert(node->op == op_Mux);
- node->in[3] = ir_true;
+ if (node->op == op_Psi) {
+ assert(get_irn_arity(node) == 3);
+ set_Psi_val(node, 0, ir_true);
+ }
+ else {
+ assert(node->op == op_Mux);
+ node->in[3] = ir_true;
+ }
+}
+
+/* Psi support */
+ir_node *get_Psi_cond (ir_node *node, int pos) {
+ int num_conds = get_Psi_n_conds(node);
+ assert(node->op == op_Psi);
+ assert(pos < num_conds);
+ return node->in[1 + 2 * pos];
+}
+
+void set_Psi_cond (ir_node *node, int pos, ir_node *cond) {
+ int num_conds = get_Psi_n_conds(node);
+ assert(node->op == op_Psi);
+ assert(pos < num_conds);
+ node->in[1 + 2 * pos] = cond;
+}
+
+ir_node *get_Psi_val (ir_node *node, int pos) {
+ int num_vals = get_Psi_n_conds(node);
+ assert(node->op == op_Psi);
+ assert(pos < num_vals);
+ return node->in[1 + 2 * pos + 1];
+}
+
+void set_Psi_val (ir_node *node, int pos, ir_node *val) {
+ int num_vals = get_Psi_n_conds(node);
+ assert(node->op == op_Psi);
+ assert(pos < num_vals);
+ node->in[1 + 2 * pos + 1] = val;
+}
+
+ir_node *get_Psi_default(ir_node *node) {
+ int def_pos = get_irn_arity(node);
+ assert(node->op == op_Psi);
+ return node->in[def_pos];
+}
+
+void set_Psi_default(ir_node *node, ir_node *val) {
+ int def_pos = get_irn_arity(node);
+ assert(node->op == op_Psi);
+ node->in[def_pos] = node;
+}
+
+int (get_Psi_n_conds)(ir_node *node) {
+ return _get_Psi_n_conds(node);
}
/* CopyB support */
node->attr.copyb.data_type = data_type;
}
+
+ir_type *
+get_InstOf_type (ir_node *node) {
+ assert (node->op = op_InstOf);
+ return node->attr.io.type;
+}
+
+void
+set_InstOf_type (ir_node *node, ir_type *type) {
+ assert (node->op = op_InstOf);
+ node->attr.io.type = type;
+}
+
+ir_node *
+get_InstOf_store (ir_node *node) {
+ assert (node->op = op_InstOf);
+ return get_irn_n(node, 0);
+}
+
+void
+set_InstOf_store (ir_node *node, ir_node *obj) {
+ assert (node->op = op_InstOf);
+ set_irn_n(node, 0, obj);
+}
+
+ir_node *
+get_InstOf_obj (ir_node *node) {
+ assert (node->op = op_InstOf);
+ return get_irn_n(node, 1);
+}
+
+void
+set_InstOf_obj (ir_node *node, ir_node *obj) {
+ assert (node->op = op_InstOf);
+ set_irn_n(node, 1, obj);
+}
+
+/* Returns the memory input of a Raise operation. */
+ir_node *
+get_Raise_mem (ir_node *node) {
+ assert (node->op == op_Raise);
+ return get_irn_n(node, 0);
+}
+
+void
+set_Raise_mem (ir_node *node, ir_node *mem) {
+ assert (node->op == op_Raise);
+ set_irn_n(node, 0, mem);
+}
+
+ir_node *
+get_Raise_exo_ptr (ir_node *node) {
+ assert (node->op == op_Raise);
+ return get_irn_n(node, 1);
+}
+
+void
+set_Raise_exo_ptr (ir_node *node, ir_node *exo_ptr) {
+ assert (node->op == op_Raise);
+ set_irn_n(node, 1, exo_ptr);
+}
+
/* Bound support */
/* Returns the memory input of a Bound operation. */
return _is_Block(node);
}
-/* returns true if node is a Unknown node. */
+/* returns true if node is an Unknown node. */
int
(is_Unknown)(const ir_node *node) {
return _is_Unknown(node);
}
+/* returns true if node is a Return node. */
+int
+(is_Return)(const ir_node *node) {
+ return _is_Return(node);
+}
+
+/* returns true if node is a Call node. */
+int
+(is_Call)(const ir_node *node) {
+ return _is_Call(node);
+}
+
+/* returns true if node is a Sel node. */
+int
+(is_Sel)(const ir_node *node) {
+ return _is_Sel(node);
+}
+
+/* returns true if node is a Mux node or a Psi with only one condition. */
+int
+(is_Mux)(const ir_node *node) {
+ return _is_Mux(node);
+}
+
int
is_Proj (const ir_node *node) {
assert(node);
return _is_irn_keep(node);
}
+/* Returns non-zero for nodes that are machine operations. */
+int (is_irn_machine_op)(const ir_node *node) {
+ return _is_irn_machine_op(node);
+}
+
+/* Returns non-zero for nodes that are machine operands. */
+int (is_irn_machine_operand)(const ir_node *node) {
+ return _is_irn_machine_operand(node);
+}
+
+/* Returns non-zero for nodes that have the n'th user machine flag set. */
+int (is_irn_machine_user)(const ir_node *node, unsigned n) {
+ return _is_irn_machine_user(node, n);
+}
+
+
/* Gets the string representation of the jump prediction .*/
const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred)
{