void
set_irn_in (ir_node *node, int arity, ir_node **in) {
+ int i;
ir_node *** arr;
assert(node);
if (get_interprocedural_view()) { /* handle Filter and Block specially */
} else {
arr = &node->in;
}
- if (arity != ARR_LEN(*arr) - 1) {
+
+ 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);
+ else
+ edges_notify_edge(node, i, in[i], NULL, current_ir_graph);
+ }
+ for(;i < ARR_LEN(*arr)-1; i++) {
+ edges_notify_edge(node, i, NULL, (*arr)[i+1], current_ir_graph);
+ }
+
+ if (arity != ARR_LEN(*arr) - 1) {
ir_node * block = (*arr)[0];
*arr = NEW_ARR_D(ir_node *, current_ir_graph->obst, arity + 1);
(*arr)[0] = block;
}
fix_backedges(current_ir_graph->obst, node);
+
memcpy((*arr) + 1, in, sizeof(ir_node *) * arity);
}
return node->attr.i;
}
-type *
+ir_type *
get_irn_call_attr (ir_node *node)
{
assert (node->op == op_Call);
/* Test whether arbitrary node is frame pointer, i.e. Proj(pn_Start_P_frame_base)
* from Start. If so returns frame type, else Null. */
-type *is_frame_pointer(ir_node *n) {
+ir_type *is_frame_pointer(ir_node *n) {
if ((get_irn_op(n) == op_Proj) &&
(get_Proj_proj(n) == pn_Start_P_frame_base)) {
ir_node *start = get_Proj_pred(n);
/* Test whether arbitrary node is globals pointer, i.e. Proj(pn_Start_P_globals)
* from Start. If so returns global type, else Null. */
-type *is_globals_pointer(ir_node *n) {
+ir_type *is_globals_pointer(ir_node *n) {
if ((get_irn_op(n) == op_Proj) &&
(get_Proj_proj(n) == pn_Start_P_globals)) {
ir_node *start = get_Proj_pred(n);
return _get_Block_cfgpred_block(node, pos);
}
-bool
+int
get_Block_matured (ir_node *node) {
assert (node->op == op_Block);
- return node->attr.block.matured;
+ return (int)node->attr.block.matured;
}
void
-set_Block_matured (ir_node *node, bool matured) {
+set_Block_matured (ir_node *node, int matured) {
assert (node->op == op_Block);
node->attr.block.matured = matured;
}
node->attr.block.in_cg[0] = NULL;
node->attr.block.cg_backedge = new_backedge_arr(current_ir_graph->obst, arity);
{
- /* Fix backedge array. fix_backedges operates depending on
+ /* Fix backedge array. fix_backedges() operates depending on
interprocedural_view. */
int ipv = get_interprocedural_view();
- set_interprocedural_view(true);
+ set_interprocedural_view(1);
fix_backedges(current_ir_graph->obst, node);
set_interprocedural_view(ipv);
}
/* The source language type. Must be an atomic type. Mode of type must
be mode of node. For tarvals from entities type must be pointer to
entity type. */
-type *
+ir_type *
get_Const_type (ir_node *node) {
assert (node->op == op_Const);
return node->attr.con.tp;
}
void
-set_Const_type (ir_node *node, type *tp) {
+set_Const_type (ir_node *node, ir_type *tp) {
assert (node->op == op_Const);
if (tp != firm_unknown_type) {
assert (is_atomic_type(tp));
node->attr.i.num = num;
}
-type *
+ir_type *
get_SymConst_type (ir_node *node) {
assert ( (node->op == op_SymConst)
&& ( get_SymConst_kind(node) == symconst_type_tag
}
void
-set_SymConst_type (ir_node *node, type *tp) {
+set_SymConst_type (ir_node *node, ir_type *tp) {
assert ( (node->op == op_SymConst)
&& ( get_SymConst_kind(node) == symconst_type_tag
|| get_SymConst_kind(node) == symconst_size));
node->attr.i.sym = sym;
}
-type *
+ir_type *
get_SymConst_value_type (ir_node *node) {
assert (node->op == op_SymConst);
if (node->attr.i.tp) node->attr.i.tp = skip_tid(node->attr.i.tp);
}
void
-set_SymConst_value_type (ir_node *node, type *tp) {
+set_SymConst_value_type (ir_node *node, ir_type *tp) {
assert (node->op == op_SymConst);
node->attr.i.tp = tp;
}
node->attr.s.ent = ent;
}
-type *
-get_InstOf_ent (ir_node *node) {
+ir_type *
+get_InstOf_type (ir_node *node) {
assert (node->op = op_InstOf);
- return (node->attr.io.ent);
+ return (node->attr.io.type);
}
void
-set_InstOf_ent (ir_node *node, type *ent) {
+set_InstOf_type (ir_node *node, ir_type *type) {
assert (node->op = op_InstOf);
- node->attr.io.ent = ent;
+ node->attr.io.type = type;
}
ir_node *
set_irn_n(node, pos + CALL_PARAM_OFFSET, param);
}
-type *
+ir_type *
get_Call_type (ir_node *node) {
assert (node->op == op_Call);
return node->attr.call.cld_tp = skip_tid(node->attr.call.cld_tp);
}
void
-set_Call_type (ir_node *node, type *tp) {
+set_Call_type (ir_node *node, ir_type *tp) {
assert (node->op == op_Call);
assert ((get_unknown_type() == tp) || is_Method_type(tp));
node->attr.call.cld_tp = tp;
UNOP(Conv)
UNOP(Cast)
-type *
+ir_type *
get_Cast_type (ir_node *node) {
assert (node->op == op_Cast);
return node->attr.cast.totype;
}
void
-set_Cast_type (ir_node *node, type *to_tp) {
+set_Cast_type (ir_node *node, ir_type *to_tp) {
assert (node->op == op_Cast);
node->attr.cast.totype = to_tp;
}
* Returns true if the Cast node casts a class type to a super type.
*/
int is_Cast_upcast(ir_node *node) {
- type *totype = get_Cast_type(node);
- type *fromtype = get_irn_typeinfo_type(get_Cast_op(node));
+ ir_type *totype = get_Cast_type(node);
+ ir_type *fromtype = get_irn_typeinfo_type(get_Cast_op(node));
ir_graph *myirg = get_irn_irg(node);
assert(get_irg_typeinfo_state(myirg) == ir_typeinfo_consistent);
assert(fromtype);
- if (!is_Class_type(totype)) return false;
- return is_subclass_of(fromtype, totype);
+ if (!is_Class_type(totype)) return 0;
+ return is_SubClass_of(fromtype, totype);
}
/* Checks for downcast.
* Returns true if the Cast node casts a class type to a sub type.
*/
int is_Cast_downcast(ir_node *node) {
- type *totype = get_Cast_type(node);
- type *fromtype = get_irn_typeinfo_type(get_Cast_op(node));
+ ir_type *totype = get_Cast_type(node);
+ ir_type *fromtype = get_irn_typeinfo_type(get_Cast_op(node));
assert(get_irg_typeinfo_state(get_irn_irg(node)) == ir_typeinfo_consistent);
assert(fromtype);
assert(fromtype);
- if (!is_Class_type(totype)) return false;
- return is_subclass_of(totype, fromtype);
+ if (!is_Class_type(totype)) return 0;
+ return is_SubClass_of(totype, fromtype);
}
int
set_irn_n(node, 1, size);
}
-type *
+ir_type *
get_Alloc_type (ir_node *node) {
assert (node->op == op_Alloc);
return node->attr.a.type = skip_tid(node->attr.a.type);
}
void
-set_Alloc_type (ir_node *node, type *tp) {
+set_Alloc_type (ir_node *node, ir_type *tp) {
assert (node->op == op_Alloc);
node->attr.a.type = tp;
}
set_irn_n(node, 2, size);
}
-type *
+ir_type *
get_Free_type (ir_node *node) {
assert (node->op == op_Free);
return node->attr.f.type = skip_tid(node->attr.f.type);
}
void
-set_Free_type (ir_node *node, type *tp) {
+set_Free_type (ir_node *node, ir_type *tp) {
assert (node->op == op_Free);
node->attr.f.type = tp;
}
set_irn_n(node, pos, pred);
}
-type *get_Proj_type(ir_node *n)
+ir_type *get_Proj_type(ir_node *n)
{
- type *tp = NULL;
+ ir_type *tp = NULL;
ir_node *pred = get_Proj_pred(n);
switch (get_irn_opcode(pred)) {
assert(get_irn_mode(pred) == mode_T);
pred_pred = get_Proj_pred(pred);
if (get_irn_op(pred_pred) == op_Start) {
- type *mtp = get_entity_type(get_irg_entity(get_irn_irg(pred_pred)));
+ ir_type *mtp = get_entity_type(get_irg_entity(get_irn_irg(pred_pred)));
tp = get_method_param_type(mtp, get_Proj_proj(n));
} else if (get_irn_op(pred_pred) == op_Call) {
- type *mtp = get_Call_type(pred_pred);
+ ir_type *mtp = get_Call_type(pred_pred);
tp = get_method_res_type(mtp, get_Proj_proj(n));
}
} break;
node->in[3] = ir_true;
}
+/* CopyB support */
+ir_node *get_CopyB_mem (ir_node *node) {
+ assert (node->op == op_CopyB);
+ return get_irn_n(node, 0);
+}
+
+void set_CopyB_mem (ir_node *node, ir_node *mem) {
+ assert (node->op == op_CopyB);
+ set_irn_n(node, 0, mem);
+}
+
+ir_node *get_CopyB_dst (ir_node *node) {
+ assert (node->op == op_CopyB);
+ return get_irn_n(node, 1);
+}
+
+void set_CopyB_dst (ir_node *node, ir_node *dst) {
+ assert (node->op == op_CopyB);
+ set_irn_n(node, 1, dst);
+}
+
+ir_node *get_CopyB_src (ir_node *node) {
+ assert (node->op == op_CopyB);
+ return get_irn_n(node, 2);
+}
+
+void set_CopyB_src (ir_node *node, ir_node *src) {
+ assert (node->op == op_CopyB);
+ set_irn_n(node, 2, src);
+}
+
+ir_type *get_CopyB_type(ir_node *node) {
+ assert (node->op == op_CopyB);
+ return node->attr.copyb.data_type;
+}
+
+void set_CopyB_type(ir_node *node, ir_type *data_type) {
+ assert (node->op == op_CopyB && data_type);
+ node->attr.copyb.data_type = data_type;
+}
+
+/* Bound support */
+
+/* Returns the memory input of a Bound operation. */
+ir_node *get_Bound_mem(ir_node *bound) {
+ assert (bound->op == op_Bound);
+ return get_irn_n(bound, 0);
+}
+
+void set_Bound_mem (ir_node *bound, ir_node *mem) {
+ assert (bound->op == op_Bound);
+ set_irn_n(bound, 0, mem);
+}
+
+/* Returns the index input of a Bound operation. */
+ir_node *get_Bound_index(ir_node *bound) {
+ assert (bound->op == op_Bound);
+ return get_irn_n(bound, 1);
+}
+
+void set_Bound_index(ir_node *bound, ir_node *idx) {
+ assert (bound->op == op_Bound);
+ set_irn_n(bound, 1, idx);
+}
+
+/* Returns the lower bound input of a Bound operation. */
+ir_node *get_Bound_lower(ir_node *bound) {
+ assert (bound->op == op_Bound);
+ return get_irn_n(bound, 2);
+}
+
+void set_Bound_lower(ir_node *bound, ir_node *lower) {
+ assert (bound->op == op_Bound);
+ set_irn_n(bound, 2, lower);
+}
+
+/* Returns the upper bound input of a Bound operation. */
+ir_node *get_Bound_upper(ir_node *bound) {
+ assert (bound->op == op_Bound);
+ return get_irn_n(bound, 3);
+}
+
+void set_Bound_upper(ir_node *bound, ir_node *upper) {
+ assert (bound->op == op_Bound);
+ set_irn_n(bound, 3, upper);
+}
+
+/* returns the graph of a node */
ir_graph *
get_irn_irg(const ir_node *node) {
/*
#if 0
/* This should compact Id-cycles to self-cycles. It has the same (or less?) complexity
- than any other approach, as Id chains are resolved and all point to the real node, or
- all id's are self loops. */
+ * than any other approach, as Id chains are resolved and all point to the real node, or
+ * all id's are self loops.
+ *
+ * Moreover, it CANNOT be switched off using get_opt_normalize() ...
+ */
ir_node *
skip_Id (ir_node *node) {
/* don't assert node !!! */
- if (!get_opt_normalize()) return node;
-
/* Don't use get_Id_pred: We get into an endless loop for
self-referencing Ids. */
if (node && (node->op == op_Id) && (node != node->in[0+1])) {
}
#else
/* This should compact Id-cycles to self-cycles. It has the same (or less?) complexity
- than any other approach, as Id chains are resolved and all point to the real node, or
- all id's are self loops. */
+ * than any other approach, as Id chains are resolved and all point to the real node, or
+ * all id's are self loops.
+ *
+ * Note: This function takes 10% of mostly ANY the compiler run, so it's
+ * a little bit "hand optimized".
+ *
+ * Moreover, it CANNOT be switched off using get_opt_normalize() ...
+ */
ir_node *
skip_Id (ir_node *node) {
ir_node *pred;
if (!node || (node->op != op_Id)) return node;
- if (!get_opt_normalize()) return node;
-
- /* Don't use get_Id_pred: We get into an endless loop for
+ /* Don't use get_Id_pred(): We get into an endless loop for
self-referencing Ids. */
pred = node->in[0+1];
}
#endif
+void skip_Id_and_store(ir_node **node) {
+ ir_node *n = *node;
+
+ if (!n || (n->op != op_Id)) return;
+
+ /* Don't use get_Id_pred(): We get into an endless loop for
+ self-referencing Ids. */
+ *node = skip_Id(n);
+}
+
int
(is_Bad)(const ir_node *node) {
return _is_Bad(node);
return _is_irn_forking(node);
}
-type *(get_irn_type)(ir_node *node) {
+/* Return the type associated with the value produced by n
+ * if the node remarks this type as it is the case for
+ * Cast, Const, SymConst and some Proj nodes. */
+ir_type *(get_irn_type)(ir_node *node) {
return _get_irn_type(node);
}
+/* Return the type attribute of a node n (SymConst, Call, Alloc, Free,
+ Cast) or NULL.*/
+ir_type *(get_irn_type_attr)(ir_node *node) {
+ return _get_irn_type_attr(node);
+}
+
+/* Return the entity attribute of a node n (SymConst, Sel) or NULL. */
+entity *(get_irn_entity_attr)(ir_node *node) {
+ return _get_irn_entity_attr(node);
+}
+
/* Returns non-zero for constant-like nodes. */
int (is_irn_constlike)(const ir_node *node) {
return _is_irn_constlike(node);
}
+/*
+ * Returns non-zero for nodes that are allowed to have keep-alives and
+ * are neither Block nor PhiM.
+ */
+int (is_irn_keep)(const ir_node *node) {
+ return _is_irn_keep(node);
+}
+
/* Gets the string representation of the jump prediction .*/
const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred)
{
_set_Cond_jmp_pred(cond, pred);
}
-/** the get_type operation must be always implemented */
-static type *get_Null_type(ir_node *n) {
+/** the get_type operation must be always implemented and return a firm type */
+static ir_type *get_Default_type(ir_node *n) {
+ return get_unknown_type();
+}
+
+/* Sets the get_type operation for an ir_op_ops. */
+ir_op_ops *firm_set_default_get_type(opcode code, ir_op_ops *ops)
+{
+ switch (code) {
+ case iro_Const: ops->get_type = get_Const_type; break;
+ case iro_SymConst: ops->get_type = get_SymConst_value_type; break;
+ case iro_Cast: ops->get_type = get_Cast_type; break;
+ case iro_Proj: ops->get_type = get_Proj_type; break;
+ default:
+ /* not allowed to be NULL */
+ if (! ops->get_type)
+ ops->get_type = get_Default_type;
+ break;
+ }
+ return ops;
+}
+
+/** Return the attribute type of a SymConst node if exists */
+static ir_type *get_SymConst_attr_type(ir_node *self) {
+ symconst_kind kind = get_SymConst_kind(self);
+ if (kind == symconst_type_tag || kind == symconst_size)
+ return get_SymConst_type(self);
+ return NULL;
+}
+
+/** Return the attribute entity of a SymConst node if exists */
+static entity *get_SymConst_attr_entity(ir_node *self) {
+ symconst_kind kind = get_SymConst_kind(self);
+ if (kind == symconst_addr_ent)
+ return get_SymConst_entity(self);
+ return NULL;
+}
+
+/** the get_type_attr operation must be always implemented */
+static ir_type *get_Null_type(ir_node *n) {
+ return firm_unknown_type;
+}
+
+/* Sets the get_type operation for an ir_op_ops. */
+ir_op_ops *firm_set_default_get_type_attr(opcode code, ir_op_ops *ops)
+{
+ switch (code) {
+ case iro_SymConst: ops->get_type_attr = get_SymConst_attr_type; break;
+ case iro_Call: ops->get_type_attr = get_Call_type; break;
+ case iro_Alloc: ops->get_type_attr = get_Alloc_type; break;
+ case iro_Free: ops->get_type_attr = get_Free_type; break;
+ case iro_Cast: ops->get_type_attr = get_Cast_type; break;
+ default:
+ /* not allowed to be NULL */
+ if (! ops->get_type_attr)
+ ops->get_type_attr = get_Null_type;
+ break;
+ }
+ return ops;
+}
+
+/** the get_entity_attr operation must be always implemented */
+static entity *get_Null_ent(ir_node *n) {
return NULL;
}
-/* set the get_type operation */
-ir_op *firm_set_default_get_type(ir_op *op)
+/* Sets the get_type operation for an ir_op_ops. */
+ir_op_ops *firm_set_default_get_entity_attr(opcode code, ir_op_ops *ops)
{
- switch (op->code) {
- case iro_Const: op->get_type = get_Const_type; break;
- case iro_SymConst: op->get_type = get_SymConst_value_type; break;
- case iro_Cast: op->get_type = get_Cast_type; break;
- case iro_Proj: op->get_type = get_Proj_type; break;
- default: op->get_type = get_Null_type; break;
+ switch (code) {
+ case iro_SymConst: ops->get_entity_attr = get_SymConst_attr_entity; break;
+ case iro_Sel: ops->get_entity_attr = get_Sel_entity; break;
+ default:
+ /* not allowed to be NULL */
+ if (! ops->get_entity_attr)
+ ops->get_entity_attr = get_Null_ent;
+ break;
}
- return op;
+ return ops;
}
#ifdef DEBUG_libfirm