restructured to allow easier debug
[libfirm] / ir / tr / tr_inheritance.c
1 /**
2  *
3  * @file tr_inheritance.c
4  *
5  * Project:     libFIRM                                                   <br>
6  * File name:   ir/tr/tr_inheritance.c                                    <br>
7  * Purpose:     Utility routines for inheritance representation           <br>
8  * Author:      Goetz Lindenmaier                                         <br>
9  * Modified by:                                                           <br>
10  * Created:                                                               <br>
11  * Copyright:   (c) 2001-2005 Universität Karlsruhe                       <br>
12  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE. <br>
13  * CVS-ID:      $Id$
14  *
15  *
16  *
17  *  @see  type.h entity.h
18  */
19
20 #include "type.h"
21 #include "entity.h"
22 #include "typewalk.h"
23 #include "irgraph_t.h"
24 #include "irprog_t.h"
25 #include "pset.h"
26 #include "set.h"
27 #include "mangle.h"
28 #include "irgwalk.h"
29 #include "irflag.h"
30 //#include ".h"
31
32
33 /* ----------------------------------------------------------------------- */
34 /* Resolve implicit inheritance.                                           */
35 /* ----------------------------------------------------------------------- */
36
37 ident *default_mangle_inherited_name(entity *super, ir_type *clss) {
38   return mangle_u(new_id_from_str("inh"), mangle_u(get_type_ident(clss), get_entity_ident(super)));
39 }
40
41 /** Replicates all entities in all super classes that are not overwritten
42    by an entity of this class. */
43 static void copy_entities_from_superclass(ir_type *clss, void *env)
44 {
45   int i, j, k, l;
46   int overwritten;
47   ir_type *super, *inhenttype;
48   entity *inhent, *thisent;
49   mangle_inherited_name_func *mfunc = *(mangle_inherited_name_func **)env;
50
51   for(i = 0; i < get_class_n_supertypes(clss); i++) {
52     super = get_class_supertype(clss, i);
53     assert(is_Class_type(super) && "not a class");
54     for(j = 0; j < get_class_n_members(super); j++) {
55       inhent = get_class_member(super, j);
56       inhenttype = get_entity_type(inhent);
57       /* check whether inhent is already overwritten */
58       overwritten = 0;
59       for (k = 0; (k < get_class_n_members(clss)) && (overwritten == 0); k++) {
60         thisent = get_class_member(clss, k);
61         for(l = 0; l < get_entity_n_overwrites(thisent); l++) {
62           if(inhent == get_entity_overwrites(thisent, l)) {
63             /* overwritten - do not copy */
64             overwritten = 1;
65             break;
66           }
67         }
68       }
69       /* Inherit entity */
70       if (!overwritten) {
71         thisent = copy_entity_own(inhent, clss);
72         add_entity_overwrites(thisent, inhent);
73         if (get_entity_peculiarity(inhent) == peculiarity_existent)
74           set_entity_peculiarity(thisent, peculiarity_inherited);
75         set_entity_ld_ident(thisent, mfunc(inhent, clss));
76         if (get_entity_variability(inhent) == variability_constant) {
77           assert(is_atomic_entity(inhent) &&  /* @@@ */
78                  "Inheritance of constant, compound entities not implemented");
79           set_entity_variability(thisent, variability_constant);
80           set_atomic_ent_value(thisent, get_atomic_ent_value(inhent));
81         }
82       }
83     }
84   }
85 }
86
87 /* Resolve implicit inheritance.
88  *
89  *  Resolves the implicit inheritance supplied by firm.
90  */
91 void resolve_inheritance(mangle_inherited_name_func *mfunc) {
92   if (!mfunc)
93     mfunc = default_mangle_inherited_name;
94   class_walk_super2sub(copy_entities_from_superclass, NULL, (void *)&mfunc);
95 }
96
97
98 /* ----------------------------------------------------------------------- */
99 /* The transitive closure of the subclass/superclass and                   */
100 /* overwrites/overwrittenby relation.                                      */
101 /*                                                                         */
102 /* A walk over the ir (O(#types+#entities)) computes the transitive        */
103 /* closure.  Adding a new type/entity or changing the basic relations in   */
104 /* some other way invalidates the transitive closure, i.e., it is not      */
105 /* updated by the basic functions.                                         */
106 /*                                                                         */
107 /* All functions are named as their counterparts for the basic relations,  */
108 /* adding the infix 'trans_'.                                              */
109 /* ----------------------------------------------------------------------- */
110
111 void                        set_irp_inh_transitive_closure_state(inh_transitive_closure_state s) {
112   irp->inh_trans_closure_state = s;
113 }
114 void                        invalidate_irp_inh_transitive_closure_state(void) {
115   if (irp->inh_trans_closure_state == inh_transitive_closure_valid)
116     irp->inh_trans_closure_state = inh_transitive_closure_invalid;
117 }
118 inh_transitive_closure_state get_irp_inh_transitive_closure_state(void) {
119   return irp->inh_trans_closure_state;
120 }
121
122 static void assert_valid_state(void) {
123   assert(irp->inh_trans_closure_state == inh_transitive_closure_valid ||
124          irp->inh_trans_closure_state == inh_transitive_closure_invalid);
125 }
126
127 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
128 /* There is a set that extends each entity/type with two new               */
129 /* fields:  one for the upwards directed relation: 'up' (supertype,        */
130 /* overwrites) and one for the downwards directed relation: 'down' (sub-   */
131 /* type, overwrittenby.  These fields contain psets (and maybe later       */
132 /* arrays) listing all subtypes...                                         */
133 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
134
135 typedef enum {
136   d_up   = 0,
137   d_down = 1,
138 } dir;
139
140 typedef struct {
141   firm_kind *kind;   /* An entity or type. */
142   pset *directions[2];
143 } tr_inh_trans_tp;
144
145 /* We use this set for all types and entities.  */
146 static set *tr_inh_trans_set = NULL;
147
148 static int tr_inh_trans_cmp(const void *e1, const void *e2, size_t size) {
149   tr_inh_trans_tp *ef1 = (tr_inh_trans_tp *)e1;
150   tr_inh_trans_tp *ef2 = (tr_inh_trans_tp *)e2;
151   return (ef1->kind != ef2->kind);
152 }
153
154 static INLINE unsigned int tr_inh_trans_hash(void *e) {
155   tr_inh_trans_tp *v = e;
156   return HASH_PTR(v->kind);
157 }
158
159 /* This always completes successfully. */
160 static tr_inh_trans_tp* get_firm_kind_entry(firm_kind *k) {
161   tr_inh_trans_tp a, *found;
162   a.kind = k;
163
164   if (!tr_inh_trans_set) tr_inh_trans_set = new_set(tr_inh_trans_cmp, 128);
165
166   found = set_find(tr_inh_trans_set, &a, sizeof(a), tr_inh_trans_hash(&a));
167   if (!found) {
168     a.directions[d_up]   = pset_new_ptr(16);
169     a.directions[d_down] = pset_new_ptr(16);
170     found = set_insert(tr_inh_trans_set, &a, sizeof(a), tr_inh_trans_hash(&a));
171   }
172   return found;
173 }
174
175 static pset *get_entity_map(entity *ent, dir d) {
176   tr_inh_trans_tp *found;
177
178   assert(is_entity(ent));
179   found = get_firm_kind_entry((firm_kind *)ent);
180   return found->directions[d];
181 }
182 /*
183 static void  add_entity_map(entity *ent, dir d, entity *new) {
184   tr_inh_trans_tp *found;
185
186   assert(is_entity(ent) && is_entity(new));
187   tr_inh_trans_tp *found = get_firm_kind_entry((firm_kind *)ent);
188   pset_insert_ptr(found->directions[d], new);
189 }
190 */
191 static pset *get_type_map(ir_type *tp, dir d) {
192   tr_inh_trans_tp *found;
193
194   assert(is_type(tp));
195   found = get_firm_kind_entry((firm_kind *)tp);
196   return found->directions[d];
197 }
198 /*
199 static void  add_type_map(ir_type *tp, dir d, type *new) {
200   tr_inh_trans_tp *found;
201
202   assert(is_type(tp) && is_type(new));
203   found = get_firm_kind_entry((firm_kind *)tp);
204   pset_insert_ptr(found->directions[d], new);
205 }
206 */
207
208
209 /**
210  * Walk over all types reachable from tp in the sub/supertype
211  * relation and compute the closure for the two downwards directed
212  * relations.
213  *
214  * The walk in the dag formed by the relation is tricky:  We must visit
215  * all subtypes before visiting the supertypes.  So we first walk down.
216  * Then we can compute the closure for this type.  Then we walk up.
217  * As we call ourselves recursive, and walk in both directions, there
218  * can be cycles.  So we have to make sure, that if we visit a node
219  * a second time (in a walk up) we do nothing.  For this we increment
220  * the master visited flag twice.
221  * If the type is marked with master_flag_visited-1 it is on the stack.
222  * If it is marked with master_flag_visited it is fully processed.
223  *
224  * Well, we still miss some candidates ... */
225 static void compute_down_closure(ir_type *tp) {
226   pset *myset, *subset;
227   int i, n_subtypes, n_members, n_supertypes;
228   unsigned long master_visited = get_master_type_visited();
229
230   assert(is_Class_type(tp));
231
232   set_type_visited(tp, master_visited-1);
233
234   /* Recursive descend. */
235   n_subtypes = get_class_n_subtypes(tp);
236   for (i = 0; i < n_subtypes; ++i) {
237     ir_type *stp = get_class_subtype(tp, i);
238     if (get_type_visited(stp) < master_visited-1) {
239       compute_down_closure(stp);
240     }
241   }
242
243   /* types */
244   myset = get_type_map(tp, d_down);
245   for (i = 0; i < n_subtypes; ++i) {
246     ir_type *stp = get_class_subtype(tp, i);
247     subset = get_type_map(stp, d_down);
248     pset_insert_ptr(myset, stp);
249     pset_insert_pset_ptr(myset, subset);
250   }
251
252   /* entities */
253   n_members = get_class_n_members(tp);
254   for (i = 0; i < n_members; ++i) {
255     entity *mem = get_class_member(tp, i);
256     int j, n_overwrittenby = get_entity_n_overwrittenby(mem);
257
258     myset = get_entity_map(mem, d_down);
259     for (j = 0; j < n_overwrittenby; ++j) {
260       entity *ov = get_entity_overwrittenby(mem, j);
261       subset = get_entity_map(ov, d_down);
262       pset_insert_ptr(myset, ov);
263       pset_insert_pset_ptr(myset, subset);
264     }
265   }
266
267   mark_type_visited(tp);
268
269   /* Walk up. */
270   n_supertypes = get_class_n_supertypes(tp);
271   for (i = 0; i < n_supertypes; ++i) {
272     ir_type *stp = get_class_supertype(tp, i);
273     if (get_type_visited(stp) < master_visited-1) {
274       compute_down_closure(stp);
275     }
276   }
277 }
278
279 static void compute_up_closure(ir_type *tp) {
280   pset *myset, *subset;
281   int i, n_subtypes, n_members, n_supertypes;
282   unsigned long master_visited = get_master_type_visited();
283
284   assert(is_Class_type(tp));
285
286   set_type_visited(tp, master_visited-1);
287
288   /* Recursive descend. */
289   n_supertypes = get_class_n_supertypes(tp);
290   for (i = 0; i < n_supertypes; ++i) {
291     ir_type *stp = get_class_supertype(tp, i);
292     if (get_type_visited(stp) < get_master_type_visited()-1) {
293       compute_up_closure(stp);
294     }
295   }
296
297   /* types */
298   myset = get_type_map(tp, d_up);
299   for (i = 0; i < n_supertypes; ++i) {
300     ir_type *stp = get_class_supertype(tp, i);
301     subset = get_type_map(stp, d_up);
302     pset_insert_ptr(myset, stp);
303     pset_insert_pset_ptr(myset, subset);
304   }
305
306   /* entities */
307   n_members = get_class_n_members(tp);
308   for (i = 0; i < n_members; ++i) {
309     entity *mem = get_class_member(tp, i);
310     int j, n_overwrites = get_entity_n_overwrites(mem);
311
312     myset = get_entity_map(mem, d_up);
313     for (j = 0; j < n_overwrites; ++j) {
314       entity *ov = get_entity_overwrites(mem, j);
315       subset = get_entity_map(ov, d_up);
316       pset_insert_pset_ptr(myset, subset);
317       pset_insert_ptr(myset, ov);
318     }
319   }
320
321   mark_type_visited(tp);
322
323   /* Walk down. */
324   n_subtypes = get_class_n_subtypes(tp);
325   for (i = 0; i < n_subtypes; ++i) {
326     ir_type *stp = get_class_subtype(tp, i);
327     if (get_type_visited(stp) < master_visited-1) {
328       compute_up_closure(stp);
329     }
330   }
331 }
332
333 /** Compute the transitive closure of the subclass/superclass and
334  *  overwrites/overwrittenby relation.
335  *
336  *  This function walks over the ir (O(#types+#entities)) to compute the
337  *  transitive closure.    */
338 void compute_inh_transitive_closure(void) {
339   int i, n_types = get_irp_n_types();
340   free_inh_transitive_closure();
341
342   /* The 'down' relation */
343   inc_master_type_visited();  /* Inc twice: one if on stack, second if values computed. */
344   inc_master_type_visited();
345   for (i = 0; i < n_types; ++i) {
346     ir_type *tp = get_irp_type(i);
347     if (is_Class_type(tp) && type_not_visited(tp)) { /* For others there is nothing to accumulate. */
348       int j, n_subtypes = get_class_n_subtypes(tp);
349       int has_unmarked_subtype = 0;
350
351       assert(get_type_visited(tp) < get_master_type_visited()-1);
352       for (j = 0; j < n_subtypes; ++j) {
353         ir_type *stp = get_class_subtype(tp, j);
354         if (type_not_visited(stp)) {
355           has_unmarked_subtype = 1;
356           break;
357         }
358       }
359
360       /* This is a good starting point. */
361       if (!has_unmarked_subtype)
362         compute_down_closure(tp);
363     }
364   }
365
366   /* The 'up' relation */
367   inc_master_type_visited();
368   inc_master_type_visited();
369   for (i = 0; i < n_types; ++i) {
370     ir_type *tp = get_irp_type(i);
371     if (is_Class_type(tp) && type_not_visited(tp)) { /* For others there is nothing to accumulate. */
372       int j, n_supertypes = get_class_n_supertypes(tp);
373       int has_unmarked_supertype = 0;
374
375       assert(get_type_visited(tp) < get_master_type_visited()-1);
376       for (j = 0; j < n_supertypes; ++j) {
377               ir_type *stp = get_class_supertype(tp, j);
378         if (type_not_visited(stp)) {
379           has_unmarked_supertype = 1;
380           break;
381         }
382       }
383
384       /* This is a good starting point. */
385       if (!has_unmarked_supertype)
386         compute_up_closure(tp);
387     }
388   }
389
390   irp->inh_trans_closure_state = inh_transitive_closure_valid;
391 }
392
393 /** Free memory occupied by the transitive closure information. */
394 void free_inh_transitive_closure(void) {
395   if (tr_inh_trans_set) {
396     tr_inh_trans_tp *elt;
397     for (elt = set_first(tr_inh_trans_set); elt; elt = set_next(tr_inh_trans_set)) {
398       del_pset(elt->directions[d_up]);
399       del_pset(elt->directions[d_down]);
400     }
401     del_set(tr_inh_trans_set);
402     tr_inh_trans_set = NULL;
403   }
404   irp->inh_trans_closure_state = inh_transitive_closure_none;
405 }
406
407 /* - subtype ------------------------------------------------------------- */
408
409 ir_type *get_class_trans_subtype_first(ir_type *tp) {
410   assert_valid_state();
411   return pset_first(get_type_map(tp, d_down));
412 }
413
414 ir_type *get_class_trans_subtype_next (ir_type *tp) {
415   assert_valid_state();
416   return pset_next(get_type_map(tp, d_down));
417 }
418
419 int is_class_trans_subtype (ir_type *tp, ir_type *subtp) {
420   assert_valid_state();
421   return (pset_find_ptr(get_type_map(tp, d_down), subtp) != NULL);
422 }
423
424 /* - supertype ----------------------------------------------------------- */
425
426 ir_type *get_class_trans_supertype_first(ir_type *tp) {
427   assert_valid_state();
428   return pset_first(get_type_map(tp, d_up));
429 }
430
431 ir_type *get_class_trans_supertype_next (ir_type *tp) {
432   assert_valid_state();
433   return pset_next(get_type_map(tp, d_up));
434 }
435
436 /* - overwrittenby ------------------------------------------------------- */
437
438 entity *get_entity_trans_overwrittenby_first(entity *ent) {
439   assert_valid_state();
440   return pset_first(get_entity_map(ent, d_down));
441 }
442
443 entity *get_entity_trans_overwrittenby_next (entity *ent) {
444   assert_valid_state();
445   return pset_next(get_entity_map(ent, d_down));
446 }
447
448 /* - overwrites ---------------------------------------------------------- */
449
450
451 /** Iterate over all transitive overwritten entities. */
452 entity *get_entity_trans_overwrites_first(entity *ent) {
453   assert_valid_state();
454   return pset_first(get_entity_map(ent, d_up));
455 }
456
457 entity *get_entity_trans_overwrites_next (entity *ent) {
458   assert_valid_state();
459   return pset_next(get_entity_map(ent, d_up));
460 }
461
462
463
464
465
466 /* ----------------------------------------------------------------------- */
467 /* Classify pairs of types/entities in the inheritance relations.          */
468 /* ----------------------------------------------------------------------- */
469
470 /* Returns true if low is subclass of high. */
471 int is_SubClass_of(ir_type *low, ir_type *high) {
472   int i, n_subtypes;
473   assert(is_Class_type(low) && is_Class_type(high));
474
475   if (low == high) return 1;
476
477   if (get_irp_inh_transitive_closure_state() == inh_transitive_closure_valid) {
478     pset *m = get_type_map(high, d_down);
479     return pset_find_ptr(m, low) ? 1 : 0;
480   }
481
482   /* depth first search from high downwards. */
483   n_subtypes = get_class_n_subtypes(high);
484   for (i = 0; i < n_subtypes; i++) {
485     ir_type *stp = get_class_subtype(high, i);
486     if (low == stp) return 1;
487     if (is_SubClass_of(low, stp))
488       return 1;
489   }
490   return 0;
491 }
492
493
494 /* Subclass check for pointers to classes.
495  *
496  *  Dereferences at both types the same amount of pointer types (as
497  *  many as possible).  If the remaining types are both class types
498  *  and subclasses, returns true, else false.  Can also be called with
499  *  two class types.  */
500 int is_SubClass_ptr_of(ir_type *low, ir_type *high) {
501   while (is_Pointer_type(low) && is_Pointer_type(high)) {
502     low  = get_pointer_points_to_type(low);
503     high = get_pointer_points_to_type(high);
504   }
505
506   if (is_Class_type(low) && is_Class_type(high))
507     return is_SubClass_of(low, high);
508   return 0;
509 }
510
511 int is_overwritten_by(entity *high, entity *low) {
512   int i, n_overwrittenby;
513   assert(is_entity(low) && is_entity(high));
514
515   if (get_irp_inh_transitive_closure_state() == inh_transitive_closure_valid) {
516     pset *m = get_entity_map(high, d_down);
517     return pset_find_ptr(m, low) ? 1 : 0;
518   }
519
520   /* depth first search from high downwards. */
521   n_overwrittenby = get_entity_n_overwrittenby(high);
522   for (i = 0; i < n_overwrittenby; i++) {
523     entity *ov = get_entity_overwrittenby(high, i);
524     if (low == ov) return 1;
525     if (is_overwritten_by(low, ov))
526       return 1;
527   }
528   return 0;
529 }
530
531
532 /** Need two routines because I want to assert the result. */
533 static entity *resolve_ent_polymorphy2 (ir_type *dynamic_class, entity *static_ent) {
534   int i, n_overwrittenby;
535
536   if (get_entity_owner(static_ent) == dynamic_class) return static_ent;
537
538   n_overwrittenby = get_entity_n_overwrittenby(static_ent);
539   for (i = 0; i < n_overwrittenby; ++i) {
540     entity *ent = get_entity_overwrittenby(static_ent, i);
541     if (get_entity_owner(ent) == dynamic_class) return ent;
542   }
543   return NULL;
544 }
545
546 /* Resolve polymorphy in the inheritance relation.
547  *
548  * Returns the dynamically referenced entity if the static entity and the
549  * dynamic type are given.
550  * Search downwards in overwritten tree. */
551 entity *resolve_ent_polymorphy(ir_type *dynamic_class, entity *static_ent) {
552   entity *res;
553   assert(static_ent && is_entity(static_ent));
554
555   res = resolve_ent_polymorphy2(dynamic_class, static_ent);
556   assert(res);
557
558   return res;
559 }
560
561
562
563 /* ----------------------------------------------------------------------- */
564 /* Class cast state handling.                                              */
565 /* ----------------------------------------------------------------------- */
566
567 /* - State handling. ----------------------------------------- */
568
569 void set_irg_class_cast_state(ir_graph *irg, ir_class_cast_state s) {
570   if (get_irp_class_cast_state() > s) set_irp_class_cast_state(s);
571   irg->class_cast_state = s;
572 }
573
574 ir_class_cast_state get_irg_class_cast_state(ir_graph *irg) {
575   return irg->class_cast_state;
576 }
577
578 void set_irp_class_cast_state(ir_class_cast_state s) {
579   int i;
580   for (i = 0; i < get_irp_n_irgs(); ++i)
581     assert(get_irg_class_cast_state(get_irp_irg(i)) >= s);
582   irp->class_cast_state = s;
583 }
584
585 ir_class_cast_state get_irp_class_cast_state(void) {
586   return irp->class_cast_state;
587 }
588
589 char *get_class_cast_state_string(ir_class_cast_state s) {
590 #define X(a)    case a: return #a
591   switch(s) {
592     X(ir_class_casts_any);
593     X(ir_class_casts_transitive);
594     X(ir_class_casts_normalized);
595     X(ir_class_casts_state_max);
596   default: return "invalid class cast state";
597   }
598 #undef X
599 }
600
601 /* - State verification. ------------------------------------- */
602
603 typedef struct ccs_env {
604   ir_class_cast_state expected_state;
605   ir_class_cast_state worst_situation;
606 } ccs_env;
607
608 void verify_irn_class_cast_state(ir_node *n, void *env) {
609   ccs_env             *ccs = (ccs_env *)env;
610   ir_class_cast_state this_state = ir_class_casts_any;
611   ir_type             *fromtype, *totype;
612   int                 ref_depth = 0;
613
614   if (get_irn_op(n) != op_Cast) return;
615
616   fromtype = get_irn_typeinfo_type(get_Cast_op(n));
617   totype   = get_Cast_type(n);
618
619   while (is_Pointer_type(totype) && is_Pointer_type(fromtype)) {
620     totype   = get_pointer_points_to_type(totype);
621     fromtype = get_pointer_points_to_type(fromtype);
622     ref_depth++;
623   }
624
625   if (!is_Class_type(totype)) return;
626
627   if (is_SubClass_of(totype, fromtype) ||
628       is_SubClass_of(fromtype, totype)   ) {
629     this_state = ir_class_casts_transitive;
630     if ((get_class_supertype_index(totype, fromtype) != -1) ||
631         (get_class_supertype_index(fromtype, totype) != -1) ||
632         fromtype == totype) {
633       /*   Das ist doch alt?  Aus dem cvs aufgetaucht ...
634            if ((get_class_supertype_index(totype, fromtype) == -1) &&
635            (get_class_supertype_index(fromtype, totype) == -1) ) {  */
636       this_state = ir_class_casts_normalized;
637     }
638   }
639
640   if (!(this_state >= ccs->expected_state)) {
641     printf("  Node is "); DDMN(n);
642     printf("    totype   "); DDMT(totype);
643     printf("    fromtype "); DDMT(fromtype);
644     printf("    this_state: %s, exp. state: %s\n",
645            get_class_cast_state_string(this_state),
646            get_class_cast_state_string(ccs->expected_state));
647     assert(this_state >= ccs->expected_state &&
648            "invalid state class cast state setting in graph");
649   }
650
651   if (this_state < ccs->worst_situation)
652     ccs->worst_situation = this_state;
653 }
654
655
656 /** Verify that the graph meets requirements of state set. */
657 void verify_irg_class_cast_state(ir_graph *irg) {
658   ccs_env env;
659
660   env.expected_state  = get_irg_class_cast_state(irg);
661   env.worst_situation = ir_class_casts_normalized;
662
663   irg_walk_graph(irg, NULL, verify_irn_class_cast_state, &env);
664
665   if ((env.worst_situation > env.expected_state) && get_firm_verbosity()) {
666     printf("Note:  class cast state is set lower than reqired in graph\n       ");
667     DDMG(irg);
668     printf("       state is %s, reqired is %s\n",
669            get_class_cast_state_string(env.expected_state),
670            get_class_cast_state_string(env.worst_situation));
671   }
672 }