/* Access routines for entities */
/* *************************************************************************** */
-/* The entities that can be accessed by this Sel node. */
-int get_Sel_n_accessed_entities(ir_node *sel) {
- return 1;
-}
-
-entity *get_Sel_accessed_entity(ir_node *sel, int pos) {
- return get_Sel_entity(sel);
-}
-
int get_entity_n_accesses(entity *ent) {
assert(ent && is_entity(ent));
/* *************************************************************************** */
-/* Access routines for nodes */
+/* Access routines for types */
+/* *************************************************************************** */
+
+/** Number of Alloc nodes that create an instance of this type */
+int get_type_n_allocations(type *tp) {
+ assert(tp && is_type(tp));
+
+ if (!tp->allocations) { tp->allocations = NEW_ARR_F(ir_node *, 0); }
+
+ return ARR_LEN(tp->allocations);
+}
+
+/** Alloc node that create an instance of this type */
+ir_node *get_type_allocation(type *tp, int pos) {
+ assert(0 <= pos && pos < get_type_n_allocations(tp));
+
+ return tp->allocations[pos];
+}
+
+void add_type_allocation(type *tp, ir_node *n) {
+ assert(tp && is_type(tp));
+ assert(n && is_ir_node(n));
+
+ if (!tp->allocations) tp->allocations = NEW_ARR_F(ir_node *, 0);
+
+ ARR_APP1(ir_node *, tp->allocations, n);
+}
+
+void set_type_allocation(type *tp, int pos, ir_node *n) {
+ assert(0 <= pos && pos < get_type_n_allocations(tp));
+ assert(n && is_ir_node(n));
+
+ tp->allocations[pos] = n;
+}
+
+
+
+
+/* *************************************************************************** */
+/* Access routines for irnodes */
/* *************************************************************************** */
+/* The entities that can be accessed by this Sel node. */
+int get_Sel_n_accessed_entities(ir_node *sel) {
+ return 1;
+}
+
+entity *get_Sel_accessed_entity(ir_node *sel, int pos) {
+ return get_Sel_entity(sel);
+}
+
/* An addr node is a SymConst or a Sel. */
int get_addr_n_entities(ir_node *addr) {
int n_ents;
return ent;
}
+
+int get_irn_loop_call_depth(ir_node *n) {
+ ir_graph *irg = get_irn_irg(n);
+ return get_irg_loop_depth(irg);
+}
+
+int get_irn_loop_depth(ir_node *n) {
+ return get_loop_depth(get_irn_loop(get_nodes_block(n)));
+}
+
+int get_irn_recursion_depth(ir_node *n) {
+ ir_graph *irg = get_irn_irg(n);
+ return get_irg_recursion_depth(irg);
+}
+
+
+/* *************************************************************************** */
+/* The heuristic */
+/* *************************************************************************** */
+
+int get_weighted_loop_depth(ir_node *n) {
+ int loop_call_depth = get_irn_loop_call_depth(n);
+ int loop_depth = get_irn_loop_depth(n);
+ int recursion_depth = get_irn_recursion_depth(n);
+
+ return loop_call_depth + loop_depth + recursion_depth;
+}
+
/* *************************************************************************** */
/* The analyses */
/* *************************************************************************** */
int i, n_ents;
ir_node *addr;
- if (get_irn_op(n) == op_Load) {
- addr = get_Load_ptr(n);
- } else if (get_irn_op(n) == op_Store) {
- addr = get_Store_ptr(n);
+ if (get_irn_op(n) == op_Alloc) {
+ add_type_allocation(get_Alloc_type(n), n);
+ return;
+ }
+
+ if (is_memop(n)) {
+ addr = get_memop_ptr(n);
+ } else if (get_irn_op(n) == op_Call) {
+ addr = get_Call_ptr(n);
+ if (get_irn_op(addr) != op_Sel) return; /* Sels before Calls mean a Load / polymorphic Call. */
} else {
return;
}
DEL_ARR_F(unrecognized_access);
unrecognized_access = NULL;
}
+
+
+
+/* *************************************************************************** */
+/* Auxiliary */
+/* *************************************************************************** */
+
+
+int is_jack_rts_class(type *t) {
+ ident *name = get_type_ident(t);
+
+ if (id_is_prefix(new_id_from_str("java/"), name)) return 1;
+ if (id_is_prefix(new_id_from_str("["), name)) return 1;
+ if (id_is_prefix(new_id_from_str("gnu/"), name)) return 1;
+ if (id_is_prefix(new_id_from_str("java/"), name)) return 1;
+
+ return 0;
+}