/* some constants fixing the positions of nodes predecessors
in the in array */
-#define CALL_PARAM_OFFSET 2
-#define BUILDIN_PARAM_OFFSET 1
-#define SEL_INDEX_OFFSET 2
-#define RETURN_RESULT_OFFSET 1 /* mem is not a result */
+#define CALL_PARAM_OFFSET (n_Call_max+1)
+#define BUILTIN_PARAM_OFFSET (n_Builtin_max+1)
+#define SEL_INDEX_OFFSET (n_Sel_max+1)
+#define RETURN_RESULT_OFFSET (n_Return_max+1)
#define END_KEEPALIVE_OFFSET 0
static const char *relation_names [] = {
fix_backedges(irg->obst, node);
memcpy((*pOld_in) + 1, in, sizeof(ir_node *) * arity);
+
+ /* update irg flags */
+ set_irg_outs_inconsistent(irg);
+ set_irg_loopinfo_inconsistent(irg);
}
ir_node *(get_irn_n)(const ir_node *node, int n)
edges_notify_edge(node, n, in, node->in[n + 1], irg);
node->in[n + 1] = in;
+
+ /* update irg flags */
+ set_irg_outs_inconsistent(irg);
+ set_irg_loopinfo_inconsistent(irg);
}
int add_irn_n(ir_node *node, ir_node *in)
return NULL;
}
-/* Test whether arbitrary node is tls pointer, i.e. Proj(pn_Start_P_tls)
- * from Start. If so returns tls type, else Null. */
-ir_type *is_tls_pointer(const ir_node *n)
-{
- if (is_Proj(n) && (get_Proj_proj(n) == pn_Start_P_tls)) {
- ir_node *start = get_Proj_pred(n);
- if (is_Start(start)) {
- return get_tls_type();
- }
- }
- return NULL;
-}
-
ir_node **get_Block_cfgpred_arr(ir_node *node)
{
assert(is_Block(node));
return _Block_block_visited(node);
}
-ir_node *(set_Block_dead)(ir_node *block)
-{
- return _set_Block_dead(block);
-}
-
-int (is_Block_dead)(const ir_node *block)
-{
- return _is_Block_dead(block);
-}
-
ir_extblk *get_Block_extbb(const ir_node *block)
{
ir_extblk *res;
end->in[1 + END_KEEPALIVE_OFFSET + i] = in[i];
edges_notify_edge(end, END_KEEPALIVE_OFFSET + i, end->in[1 + END_KEEPALIVE_OFFSET + i], NULL, irg);
}
+
+ /* update irg flags */
+ set_irg_outs_inconsistent(irg);
}
/* Set new keep-alives from old keep-alives, skipping irn */
}
/* now n - 1 keeps, 1 block input */
ARR_RESIZE(ir_node *, end->in, (n - 1) + 1 + END_KEEPALIVE_OFFSET);
+
+ /* update irg flags */
+ set_irg_outs_inconsistent(irg);
}
/* remove Bads, NoMems and doublets from the keep-alive set */
pset_new_t keeps;
int idx, n = get_End_n_keepalives(end);
ir_graph *irg;
+ bool changed = false;
if (n <= 0)
return;
ir_node *ka = get_End_keepalive(end, idx);
if (is_Bad(ka) || is_NoMem(ka) || pset_new_contains(&keeps, ka)) {
+ changed = true;
/* remove the edge */
edges_notify_edge(end, idx, NULL, ka, irg);
ARR_RESIZE(ir_node *, end->in, n + 1 + END_KEEPALIVE_OFFSET);
pset_new_destroy(&keeps);
+
+ if (changed) {
+ set_irg_outs_inconsistent(irg);
+ }
}
void free_End(ir_node *end)
ir_node **get_Builtin_param_arr(ir_node *node)
{
assert(is_Builtin(node));
- return &get_irn_in(node)[BUILDIN_PARAM_OFFSET + 1];
+ return &get_irn_in(node)[BUILTIN_PARAM_OFFSET + 1];
}
int get_Builtin_n_params(const ir_node *node)
{
assert(is_Builtin(node));
- return (get_irn_arity(node) - BUILDIN_PARAM_OFFSET);
+ return (get_irn_arity(node) - BUILTIN_PARAM_OFFSET);
}
ir_node *get_Builtin_param(const ir_node *node, int pos)
{
assert(is_Builtin(node));
- return get_irn_n(node, pos + BUILDIN_PARAM_OFFSET);
+ return get_irn_n(node, pos + BUILTIN_PARAM_OFFSET);
}
void set_Builtin_param(ir_node *node, int pos, ir_node *param)
{
assert(is_Builtin(node));
- set_irn_n(node, pos + BUILDIN_PARAM_OFFSET, param);
+ set_irn_n(node, pos + BUILTIN_PARAM_OFFSET, param);
}
/* Returns a human readable string for the ir_builtin_kind. */
(node->attr.call.callee_arr != NULL));
}
-int get_Call_n_callees(const ir_node *node)
+size_t get_Call_n_callees(const ir_node *node)
{
assert(is_Call(node) && node->attr.call.callee_arr);
return ARR_LEN(node->attr.call.callee_arr);
}
-ir_entity *get_Call_callee(const ir_node *node, int pos)
+ir_entity *get_Call_callee(const ir_node *node, size_t pos)
{
- assert(pos >= 0 && pos < get_Call_n_callees(node));
+ assert(pos < get_Call_n_callees(node));
return node->attr.call.callee_arr[pos];
}
-void set_Call_callee_arr(ir_node *node, const int n, ir_entity ** arr)
+void set_Call_callee_arr(ir_node *node, size_t n, ir_entity ** arr)
{
ir_graph *irg = get_irn_irg(node);
node->attr.call.callee_arr = NULL;
}
-/*
- * Returns non-zero if a Call is surely a self-recursive Call.
- * Beware: if this functions returns 0, the call might be self-recursive!
- */
-int is_self_recursive_Call(const ir_node *call)
-{
- const ir_node *callee = get_Call_ptr(call);
-
- if (is_SymConst_addr_ent(callee)) {
- const ir_entity *ent = get_SymConst_entity(callee);
- const ir_graph *irg = get_entity_irg(ent);
- if (irg == get_irn_irg(call))
- return 1;
- }
- return 0;
-}
-
/* Checks for upcast.
*
* Returns true if the Cast node casts a class type to a super type.
ir_node *get_memop_mem(const ir_node *node)
{
assert(is_memop(node));
+ assert(n_Load_mem == 0 && n_Store_mem == 0);
return get_irn_n(node, 0);
}
void set_memop_mem(ir_node *node, ir_node *mem)
{
assert(is_memop(node));
+ assert(n_Load_mem == 0 && n_Store_mem == 0);
set_irn_n(node, 0, mem);
}
ir_node *get_memop_ptr(const ir_node *node)
{
assert(is_memop(node));
+ assert(n_Load_mem == 1 && n_Store_mem == 1);
return get_irn_n(node, 1);
}
void set_memop_ptr(ir_node *node, ir_node *ptr)
{
assert(is_memop(node));
+ assert(n_Load_mem == 1 && n_Store_mem == 1);
set_irn_n(node, 1, ptr);
}
-ir_volatility get_Load_volatility(const ir_node *node)
-{
- assert(is_Load(node));
- return (ir_volatility)node->attr.load.volatility;
-}
-
-void set_Load_volatility(ir_node *node, ir_volatility volatility)
-{
- assert(is_Load(node));
- node->attr.load.volatility = volatility;
-}
-
-ir_align get_Load_align(const ir_node *node)
-{
- assert(is_Load(node));
- return (ir_align)node->attr.load.aligned;
-}
-
-void set_Load_align(ir_node *node, ir_align align)
-{
- assert(is_Load(node));
- node->attr.load.aligned = align;
-}
-
-
-ir_volatility get_Store_volatility(const ir_node *node)
-{
- assert(is_Store(node));
- return (ir_volatility)node->attr.store.volatility;
-}
-
-void set_Store_volatility(ir_node *node, ir_volatility volatility)
-{
- assert(is_Store(node));
- node->attr.store.volatility = volatility;
-}
-
-ir_align get_Store_align(const ir_node *node)
-{
- assert(is_Store(node));
- return (ir_align)node->attr.store.aligned;
-}
-
-void set_Store_align(ir_node *node, ir_align align)
-{
- assert(is_Store(node));
- node->attr.store.aligned = align;
-}
-
ir_node **get_Sync_preds_arr(ir_node *node)
{
return _is_arg_Proj(node);
}
+int is_x_except_Proj(const ir_node *node)
+{
+ ir_node *pred;
+ if (!is_Proj(node))
+ return false;
+ pred = get_Proj_pred(node);
+ if (!is_fragile_op(pred))
+ return false;
+ return get_Proj_proj(node) == pred->op->pn_x_except;
+}
+
+int is_x_regular_Proj(const ir_node *node)
+{
+ ir_node *pred;
+ if (!is_Proj(node))
+ return false;
+ pred = get_Proj_pred(node);
+ if (!is_fragile_op(pred))
+ return false;
+ return get_Proj_proj(node) == pred->op->pn_x_regular;
+}
+
+void ir_set_throws_exception(ir_node *node, int throws_exception)
+{
+ except_attr *attr = &node->attr.except;
+ assert(is_fragile_op(node));
+ attr->throws_exception = throws_exception;
+}
+
+int ir_throws_exception(const ir_node *node)
+{
+ const except_attr *attr = &node->attr.except;
+ assert(is_fragile_op(node));
+ return attr->throws_exception;
+}
+
ir_node **get_Tuple_preds_arr(ir_node *node)
{
assert(is_Tuple(node));
/* Returns true if the operation manipulates control flow. */
int is_cfop(const ir_node *node)
{
+ if (is_fragile_op(node) && ir_throws_exception(node))
+ return true;
+
return is_op_cfopcode(get_irn_op(node));
}
+int is_unknown_jump(const ir_node *node)
+{
+ return is_op_unknown_jump(get_irn_op(node));
+}
+
/* Returns true if the operation can change the control flow because
of an exception. */
int is_fragile_op(const ir_node *node)
ir_node *get_fragile_op_mem(ir_node *node)
{
assert(node && is_fragile_op(node));
-
- switch (get_irn_opcode(node)) {
- case iro_Call :
- case iro_Div :
- case iro_Mod :
- case iro_Load :
- case iro_Store :
- case iro_Alloc :
- case iro_Bound :
- case iro_CopyB :
- return get_irn_n(node, pn_Generic_M);
- case iro_Bad :
- case iro_Unknown:
- return node;
- default:
- panic("should not be reached");
- }
+ return get_irn_n(node, node->op->fragile_mem_index);
}
/* Returns true if the operation is a forking control flow operation. */
}
/* Sets the get_type operation for an ir_op_ops. */
-ir_op_ops *firm_set_default_get_type_attr(ir_opcode code, ir_op_ops *ops)
+ir_op_ops *firm_set_default_get_type_attr(unsigned code, ir_op_ops *ops)
{
switch (code) {
case iro_SymConst: ops->get_type_attr = get_SymConst_attr_type; break;
}
/* Sets the get_type operation for an ir_op_ops. */
-ir_op_ops *firm_set_default_get_entity_attr(ir_opcode code, ir_op_ops *ops)
+ir_op_ops *firm_set_default_get_entity_attr(unsigned code, ir_op_ops *ops)
{
switch (code) {
case iro_SymConst: ops->get_entity_attr = get_SymConst_attr_entity; break;