be: inline arch_env_begin_codegeneration() into its only caller.
[libfirm] / ir / tr / tr_inheritance.c
index 0879b51..40b6ebe 100644 (file)
@@ -34,8 +34,6 @@
 #include "irgwalk.h"
 #include "irflag.h"
 
-DEBUG_ONLY(static firm_dbg_module_t *dbg;)
-
 /* ----------------------------------------------------------------------- */
 /* Resolve implicit inheritance.                                           */
 /* ----------------------------------------------------------------------- */
@@ -172,7 +170,7 @@ static int tr_inh_trans_cmp(const void *e1, const void *e2, size_t size)
  */
 static inline unsigned int tr_inh_trans_hash(const tr_inh_trans_tp *v)
 {
-       return HASH_PTR(v->kind);
+       return hash_ptr(v->kind);
 }
 
 /* This always completes successfully. */
@@ -183,11 +181,11 @@ static tr_inh_trans_tp *get_firm_kind_entry(const firm_kind *k)
 
        if (!tr_inh_trans_set) tr_inh_trans_set = new_set(tr_inh_trans_cmp, 128);
 
-       found = (tr_inh_trans_tp*)set_find(tr_inh_trans_set, &a, sizeof(a), tr_inh_trans_hash(&a));
+       found = set_find(tr_inh_trans_tp, tr_inh_trans_set, &a, sizeof(a), tr_inh_trans_hash(&a));
        if (!found) {
                a.directions[d_up]   = pset_new_ptr(16);
                a.directions[d_down] = pset_new_ptr(16);
-               found = (tr_inh_trans_tp*)set_insert(tr_inh_trans_set, &a, sizeof(a), tr_inh_trans_hash(&a));
+               found = set_insert(tr_inh_trans_tp, tr_inh_trans_set, &a, sizeof(a), tr_inh_trans_hash(&a));
        }
        return found;
 }
@@ -398,9 +396,7 @@ void compute_inh_transitive_closure(void)
 void free_inh_transitive_closure(void)
 {
        if (tr_inh_trans_set) {
-               tr_inh_trans_tp *elt;
-               for (elt = (tr_inh_trans_tp*)set_first(tr_inh_trans_set); elt != NULL;
-                    elt = (tr_inh_trans_tp*)set_next(tr_inh_trans_set)) {
+               foreach_set(tr_inh_trans_set, tr_inh_trans_tp, elt) {
                        del_pset(elt->directions[d_up]);
                        del_pset(elt->directions[d_down]);
                }
@@ -415,13 +411,13 @@ void free_inh_transitive_closure(void)
 ir_type *get_class_trans_subtype_first(const ir_type *tp)
 {
        assert_valid_state();
-       return (ir_type*)pset_first(get_type_map(tp, d_down));
+       return pset_first(ir_type, get_type_map(tp, d_down));
 }
 
 ir_type *get_class_trans_subtype_next(const ir_type *tp)
 {
        assert_valid_state();
-       return (ir_type*)pset_next(get_type_map(tp, d_down));
+       return pset_next(ir_type, get_type_map(tp, d_down));
 }
 
 int is_class_trans_subtype(const ir_type *tp, const ir_type *subtp)
@@ -435,13 +431,13 @@ int is_class_trans_subtype(const ir_type *tp, const ir_type *subtp)
 ir_type *get_class_trans_supertype_first(const ir_type *tp)
 {
        assert_valid_state();
-       return (ir_type*)pset_first(get_type_map(tp, d_up));
+       return pset_first(ir_type, get_type_map(tp, d_up));
 }
 
 ir_type *get_class_trans_supertype_next(const ir_type *tp)
 {
        assert_valid_state();
-       return (ir_type*)pset_next(get_type_map(tp, d_up));
+       return pset_next(ir_type, get_type_map(tp, d_up));
 }
 
 /* - overwrittenby ------------------------------------------------------- */
@@ -449,13 +445,13 @@ ir_type *get_class_trans_supertype_next(const ir_type *tp)
 ir_entity *get_entity_trans_overwrittenby_first(const ir_entity *ent)
 {
        assert_valid_state();
-       return (ir_entity*)pset_first(get_entity_map(ent, d_down));
+       return pset_first(ir_entity, get_entity_map(ent, d_down));
 }
 
 ir_entity *get_entity_trans_overwrittenby_next(const ir_entity *ent)
 {
        assert_valid_state();
-       return (ir_entity*)pset_next(get_entity_map(ent, d_down));
+       return pset_next(ir_entity, get_entity_map(ent, d_down));
 }
 
 /* - overwrites ---------------------------------------------------------- */
@@ -464,13 +460,13 @@ ir_entity *get_entity_trans_overwrittenby_next(const ir_entity *ent)
 ir_entity *get_entity_trans_overwrites_first(const ir_entity *ent)
 {
        assert_valid_state();
-       return (ir_entity*)pset_first(get_entity_map(ent, d_up));
+       return pset_first(ir_entity, get_entity_map(ent, d_up));
 }
 
 ir_entity *get_entity_trans_overwrites_next(const ir_entity *ent)
 {
        assert_valid_state();
-       return (ir_entity*)pset_next(get_entity_map(ent, d_up));
+       return pset_next(ir_entity, get_entity_map(ent, d_up));
 }
 
 
@@ -615,89 +611,3 @@ ir_class_cast_state get_irp_class_cast_state(void)
 {
        return irp->class_cast_state;
 }
-
-const char *get_class_cast_state_string(ir_class_cast_state s)
-{
-#define X(a)    case a: return #a
-       switch (s) {
-       X(ir_class_casts_any);
-       X(ir_class_casts_transitive);
-       X(ir_class_casts_normalized);
-       X(ir_class_casts_state_max);
-       default: return "invalid class cast state";
-       }
-#undef X
-}
-
-/* - State verification. ------------------------------------- */
-
-typedef struct ccs_env {
-       ir_class_cast_state expected_state;
-       ir_class_cast_state worst_situation;
-} ccs_env;
-
-/**
- * Walker: check Casts.
- */
-static void verify_irn_class_cast_state(ir_node *n, void *env)
-{
-       ccs_env             *ccs = (ccs_env *)env;
-       ir_class_cast_state this_state = ir_class_casts_any;
-       ir_type             *fromtype, *totype;
-
-       if (!is_Cast(n)) return;
-
-       fromtype = get_irn_typeinfo_type(get_Cast_op(n));
-       totype   = get_Cast_type(n);
-
-       while (is_Pointer_type(totype) && is_Pointer_type(fromtype)) {
-               totype   = get_pointer_points_to_type(totype);
-               fromtype = get_pointer_points_to_type(fromtype);
-       }
-
-       if (!is_Class_type(totype)) return;
-
-       if (is_SubClass_of(totype, fromtype) ||
-               is_SubClass_of(fromtype, totype)) {
-               this_state = ir_class_casts_transitive;
-               if ((get_class_supertype_index(totype, fromtype) != (size_t)-1) ||
-                   (get_class_supertype_index(fromtype, totype) != (size_t)-1) ||
-                   fromtype == totype) {
-                       this_state = ir_class_casts_normalized;
-               }
-       }
-
-       if (!(this_state >= ccs->expected_state)) {
-               ir_printf("  Node is %+F\n", n);
-               ir_printf("    totype   %+F\n", totype);
-               ir_printf("    fromtype %+F\n", fromtype);
-               ir_printf("    this_state: %s, exp. state: %s\n",
-                       get_class_cast_state_string(this_state),
-                       get_class_cast_state_string(ccs->expected_state));
-               assert(this_state >= ccs->expected_state &&
-                       "invalid state class cast state setting in graph");
-       }
-
-       if (this_state < ccs->worst_situation)
-               ccs->worst_situation = this_state;
-}
-
-void verify_irg_class_cast_state(ir_graph *irg)
-{
-       ccs_env env;
-
-       FIRM_DBG_REGISTER(dbg, "firm.tr.inheritance");
-
-       env.expected_state  = get_irg_class_cast_state(irg);
-       env.worst_situation = ir_class_casts_normalized;
-
-       irg_walk_graph(irg, NULL, verify_irn_class_cast_state, &env);
-
-       if ((env.worst_situation > env.expected_state)) {
-               DB((dbg, LEVEL_1, "Note:  class cast state is set lower than reqired "
-                   "in graph \n\t%+F\n", irg));
-               DB((dbg, LEVEL_1, "       state is %s, reqired is %s\n",
-                       get_class_cast_state_string(env.expected_state),
-                       get_class_cast_state_string(env.worst_situation)));
-       }
-}