3 * File name: ir/tr/entity.c
4 * Purpose: Representation of all program known entities.
5 * Author: Martin Trapp, Christian Schaefer
6 * Modified by: Goetz Lindenmaier
9 * Copyright: (c) 1998-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
21 # include "entity_t.h"
23 # include "typegmod.h"
25 /* All this is needed to build the constant node for methods: */
26 # include "irprog_t.h"
30 /*******************************************************************/
32 /*******************************************************************/
39 /*-----------------------------------------------------------------*/
41 /*-----------------------------------------------------------------*/
43 void insert_entity_in_owner (entity *ent) {
44 type *owner = ent->owner;
45 switch (get_type_tpop_code(owner)) {
47 add_class_member (owner, ent);
50 add_struct_member (owner, ent);
53 add_union_member (owner, ent);
56 set_array_element_entity(owner, ent);
63 new_entity (type *owner, ident *name, type *type)
68 assert(!id_contains_char(name, ' ') && "entity name should not contain spaces");
70 res = (entity *) xmalloc (sizeof (entity));
72 assert_legal_owner_of_ent(owner);
77 if (get_type_tpop(type) == type_method)
78 res->allocation = allocation_static;
80 res->allocation = allocation_automatic;
82 res->visibility = visibility_local;
84 if (is_method_type(type)) {
85 res->variability = variability_constant;
86 rem = current_ir_graph;
87 current_ir_graph = get_const_code_irg();
88 res->value = new_Const(mode_P_mach, new_tarval_from_entity(res, mode_P_mach));
89 current_ir_graph = rem;
91 res->variability = variability_uninitialized;
94 res->val_paths = NULL;
96 res->peculiarity = peculiarity_existent;
97 res->volatility = volatility_non_volatile;
99 if (is_class_type(owner)) {
100 res->overwrites = NEW_ARR_F(entity *, 0);
101 res->overwrittenby = NEW_ARR_F(entity *, 0);
103 res->overwrites = NULL;
104 res->overwrittenby = NULL;
109 res->nr = get_irp_new_node_nr();
114 /* Remember entity in it's owner. */
115 insert_entity_in_owner (res);
119 new_d_entity (type *owner, ident *name, type *type, dbg_info *db) {
120 entity *res = new_entity(owner, name, type);
121 set_entity_dbg_info(res, db);
125 void free_compound_graph_path (compound_graph_path *gr);
126 int is_compound_graph_path(void *thing);
127 int get_compound_graph_path_length(compound_graph_path *gr);
128 entity *get_compound_graph_path_node(compound_graph_path *gr, int pos);
129 int get_compound_ent_n_values(entity *ent);
131 void free_entity_attrs(entity *ent) {
134 if (get_type_tpop(get_entity_owner(ent)) == type_class) {
135 DEL_ARR_F(ent->overwrites); ent->overwrites = NULL;
136 DEL_ARR_F(ent->overwrittenby); ent->overwrittenby = NULL;
138 assert(ent->overwrites == NULL);
139 assert(ent->overwrittenby == NULL);
141 /* if (ent->values) DEL_ARR_F(ent->values); *//* @@@ warum nich? */
142 if (ent->val_paths) {
143 if (is_compound_entity(ent))
144 for (i = 0; i < get_compound_ent_n_values(ent); i++)
145 if (ent->val_paths[i]) ;
146 /* free_compound_graph_path(ent->val_paths[i]) ; * @@@ warum nich? */
147 /* Geht nich: wird mehrfach verwendet!!! ==> mehrfach frei gegeben. */
148 /* DEL_ARR_F(ent->val_paths); */
150 ent->val_paths = NULL;
155 copy_entity_own (entity *old, type *new_owner) {
158 assert_legal_owner_of_ent(new_owner);
159 if (old->owner == new_owner) return old;
160 new = (entity *) xmalloc (sizeof (entity));
161 memcpy (new, old, sizeof (entity));
162 new->owner = new_owner;
163 if (is_class_type(new_owner)) {
164 new->overwrites = NEW_ARR_F(entity *, 0);
165 new->overwrittenby = NEW_ARR_F(entity *, 0);
168 new->nr = get_irp_new_node_nr();
171 insert_entity_in_owner (new);
177 copy_entity_name (entity *old, ident *new_name) {
180 if (old->name == new_name) return old;
181 new = (entity *) xmalloc (sizeof (entity));
182 memcpy (new, old, sizeof (entity));
183 new->name = new_name;
185 if (is_class_type(new->owner)) {
186 new->overwrites = DUP_ARR_F(entity *, old->overwrites);
187 new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby);
190 new->nr = get_irp_new_node_nr();
193 insert_entity_in_owner (new);
200 free_entity (entity *ent) {
201 free_tarval_entity(ent);
202 free_entity_attrs(ent);
207 /* Outputs a unique number for this node */
209 get_entity_nr(entity *ent) {
219 get_entity_name (entity *ent) {
221 return get_id_str(get_entity_ident(ent));
225 get_entity_ident (entity *ent) {
231 void set_entitye_ld_name (entity *, char *ld_name);
232 void set_entity_ld_ident (entity *, ident *ld_ident);
236 get_entity_owner (entity *ent) {
237 return ent->owner = skip_tid(ent->owner);
241 set_entity_owner (entity *ent, type *owner) {
242 assert_legal_owner_of_ent(owner);
246 void /* should this go into type.c? */
247 assert_legal_owner_of_ent(type *owner) {
248 assert (get_type_tpop_code(owner) == tpo_class ||
249 get_type_tpop_code(owner) == tpo_union ||
250 get_type_tpop_code(owner) == tpo_struct ||
251 get_type_tpop_code(owner) == tpo_array); /* Yes, array has an entity
252 -- to select fields! */
256 get_entity_ld_ident (entity *ent)
258 if (ent->ld_name == NULL)
259 ent->ld_name = mangle_entity (ent);
264 set_entity_ld_ident (entity *ent, ident *ld_ident) {
265 ent->ld_name = ld_ident;
269 get_entity_ld_name (entity *ent) {
270 return get_id_str(get_entity_ld_ident(ent));
274 char *get_entity_ld_name (entity *);
275 void set_entity_ld_name (entity *, char *ld_name);
279 get_entity_type (entity *ent) {
280 return ent->type = skip_tid(ent->type);
284 set_entity_type (entity *ent, type *type) {
290 get_entity_allocation (entity *ent) {
291 return ent->allocation;
295 set_entity_allocation (entity *ent, ent_allocation al) {
296 ent->allocation = al;
299 /* return the name of the visibility */
300 const char *get_allocation_name(ent_allocation all)
302 #define X(a) case a: return #a
304 X(allocation_automatic);
305 X(allocation_parameter);
306 X(allocation_dynamic);
307 X(allocation_static);
308 default: return "BAD VALUE";
315 get_entity_visibility (entity *ent) {
316 return ent->visibility;
320 set_entity_visibility (entity *ent, ent_visibility vis) {
321 if (vis != visibility_local)
322 assert((ent->allocation == allocation_static) ||
323 (ent->allocation == allocation_automatic));
324 /* @@@ Test that the owner type is not local, but how??
325 && get_class_visibility(get_entity_owner(ent)) != local));*/
326 ent->visibility = vis;
329 /* return the name of the visibility */
330 const char *get_visibility_name(ent_visibility vis)
332 #define X(a) case a: return #a
335 X(visibility_external_visible);
336 X(visibility_external_allocated);
337 default: return "BAD VALUE";
343 get_entity_variability (entity *ent) {
344 return ent->variability;
348 set_entity_variability (entity *ent, ent_variability var)
350 if (var == variability_part_constant)
351 assert(is_class_type(ent->type) || is_struct_type(ent->type));
353 if ((is_compound_type(ent->type)) &&
354 (ent->variability == variability_uninitialized) && (var != variability_uninitialized)) {
355 /* Allocate datastructures for constant values */
356 ent->values = NEW_ARR_F(ir_node *, 0);
357 ent->val_paths = NEW_ARR_F(compound_graph_path *, 0);
360 if ((is_compound_type(ent->type)) &&
361 (var == variability_uninitialized) && (ent->variability != variability_uninitialized)) {
362 /* Free datastructures for constant values */
363 DEL_ARR_F(ent->values); ent->values = NULL;
364 DEL_ARR_F(ent->val_paths); ent->val_paths = NULL;
366 ent->variability = var;
369 /* return the name of the variablity */
370 const char *get_variability_name(ent_variability var)
372 #define X(a) case a: return #a
374 X(variability_uninitialized);
375 X(variability_initialized);
376 X(variability_part_constant);
377 X(variability_constant);
378 default: return "BAD VALUE";
384 get_entity_volatility (entity *ent) {
386 return ent->volatility;
390 set_entity_volatility (entity *ent, ent_volatility vol) {
392 ent->volatility = vol;
395 /* return the name of the volatility */
396 const char *get_volatility_name(ent_volatility var)
398 #define X(a) case a: return #a
400 X(volatility_non_volatile);
401 X(volatility_is_volatile);
402 default: return "BAD VALUE";
408 get_entity_peculiarity (entity *ent) {
410 return ent->peculiarity;
414 set_entity_peculiarity (entity *ent, peculiarity pec) {
416 /* @@@ why peculiarity only for methods? */
417 assert (is_method_type(ent->type));
418 ent->peculiarity = pec;
421 /* return the name of the peculiarity */
422 const char *get_peculiarity_name(peculiarity var)
424 #define X(a) case a: return #a
426 X(peculiarity_description);
427 X(peculiarity_inherited);
428 X(peculiarity_existent);
429 default: return "BAD VALUE";
434 /* Set has no effect for existent entities of type method. */
436 get_atomic_ent_value(entity *ent)
439 assert(is_atomic_entity(ent));
440 assert(ent->variability != variability_uninitialized);
445 set_atomic_ent_value(entity *ent, ir_node *val) {
446 assert(ent && is_atomic_entity(ent) && (ent->variability != variability_uninitialized));
447 if (is_method_type(ent->type) && (ent->peculiarity == peculiarity_existent))
452 /* Returns true if the the node is representable as code on
454 int is_irn_const_expression(ir_node *n) {
458 switch(get_irn_opcode(n)) {
464 if (is_irn_const_expression(get_Add_left(n)))
465 return is_irn_const_expression(get_Add_right(n));
468 return is_irn_const_expression(get_irn_n(n, 0));
477 ir_node *copy_const_value(ir_node *n) {
482 switch(get_irn_opcode(n)) {
484 nn = new_Const(m, get_Const_tarval(n)); break;
486 nn = new_SymConst(get_SymConst_type_or_id(n), get_SymConst_kind(n)); break;
488 nn = new_Add(copy_const_value(get_Add_left(n)),
489 copy_const_value(get_Add_right(n)), m); break;
491 nn = new_Cast(copy_const_value(get_Cast_op(n)), get_Cast_type(n)); break;
493 nn = new_Conv(copy_const_value(get_Conv_op(n)), m); break;
495 nn = new_Unknown(m); break;
498 assert(0 && "opdope invalid or not implemented");
505 compound_graph_path *
506 new_compound_graph_path(type *tp, int length) {
507 compound_graph_path *res;
508 assert(is_type(tp) && is_compound_type(tp));
511 res = (compound_graph_path *) malloc (sizeof(compound_graph_path) + (length-1) * sizeof(entity *));
512 res->kind = k_ir_compound_graph_path;
515 memset(res->nodes, 0, sizeof(entity *) * length);
520 free_compound_graph_path (compound_graph_path *gr) {
521 assert(gr && is_compound_graph_path(gr));
527 is_compound_graph_path(void *thing) {
528 return (get_kind(thing) == k_ir_compound_graph_path);
531 /* checks whether nodes 0..pos are correct (all lie on a path.) */
532 /* @@@ not implemented */
533 int is_proper_compound_graph_path(compound_graph_path *gr, int pos) {
536 type *owner = gr->tp;
537 for (i = 0; i <= pos; i++) {
538 node = get_compound_graph_path_node(gr, i);
539 if (get_entity_owner(node) != owner) return false;
540 owner = get_entity_type(node);
542 if (pos == get_compound_graph_path_length(gr))
543 if (!is_atomic_type(owner)) return false;
548 get_compound_graph_path_length(compound_graph_path *gr) {
549 assert(gr && is_compound_graph_path(gr));
554 get_compound_graph_path_node(compound_graph_path *gr, int pos) {
555 assert(gr && is_compound_graph_path(gr));
556 assert(pos >= 0 && pos < gr->len);
557 return gr->nodes[pos];
561 set_compound_graph_path_node(compound_graph_path *gr, int pos, entity *node) {
562 assert(gr && is_compound_graph_path(gr));
563 assert(pos >= 0 && pos < gr->len);
564 assert(is_entity(node));
565 gr->nodes[pos] = node;
566 assert(is_proper_compound_graph_path(gr, pos));
569 /* A value of a compound entity is a pair of value and the corresponding path to a member of
572 add_compound_ent_value_w_path(entity *ent, ir_node *val, compound_graph_path *path) {
573 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
574 ARR_APP1 (ir_node *, ent->values, val);
575 ARR_APP1 (compound_graph_path *, ent->val_paths, path);
579 set_compound_ent_value_w_path(entity *ent, ir_node *val, compound_graph_path *path, int pos) {
580 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
581 ent->values[pos] = val;
582 ent->val_paths[pos] = path;
586 get_compound_ent_n_values(entity *ent) {
587 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
588 return (ARR_LEN (ent->values));
592 get_compound_ent_value(entity *ent, int pos) {
593 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
594 return ent->values[pos];
597 compound_graph_path *
598 get_compound_ent_value_path(entity *ent, int pos) {
599 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
600 return ent->val_paths[pos];
604 remove_compound_ent_value(entity *ent, entity *value_ent) {
606 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
607 for (i = 0; i < (ARR_LEN (ent->val_paths)); i++) {
608 compound_graph_path *path = ent->val_paths[i];
609 if (path->nodes[path->len-1] == value_ent) {
610 for(; i < (ARR_LEN (ent->val_paths))-1; i++) {
611 ent->val_paths[i] = ent->val_paths[i+1];
612 ent->values[i] = ent->values[i+1];
614 ARR_SETLEN(entity*, ent->val_paths, ARR_LEN(ent->val_paths) - 1);
615 ARR_SETLEN(ir_node*, ent->values, ARR_LEN(ent->values) - 1);
622 add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
623 compound_graph_path *path;
624 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
625 path = new_compound_graph_path(get_entity_owner(ent), 1);
626 path->nodes[0] = member;
627 add_compound_ent_value_w_path(ent, val, path);
630 /* Copies the firm subgraph referenced by val to const_code_irg and adds
631 the node as constant initialization to ent.
632 The subgraph may not contain control flow operations.
634 copy_and_add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
635 ir_graph *rem = current_ir_graph;
637 assert(get_entity_variability(ent) != variability_uninitialized);
638 current_ir_graph = get_const_code_irg();
640 val = copy_const_value(val);
641 add_compound_ent_value(ent, val, member);
642 current_ir_graph = rem;
645 /* Copies the value i of the entity to current_block in current_ir_graph.
647 copy_compound_ent_value(entity *ent, int pos) {
648 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
649 return copy_const_value(ent->values[pos+1]);
653 get_compound_ent_value_member(entity *ent, int pos) {
654 compound_graph_path *path;
655 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
656 path = get_compound_ent_value_path(ent, pos);
658 return get_compound_graph_path_node(path, get_compound_graph_path_length(path)-1);
662 set_compound_ent_value(entity *ent, ir_node *val, entity *member, int pos) {
663 compound_graph_path *path;
664 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
665 path = get_compound_ent_value_path(ent, pos);
666 set_compound_graph_path_node(path, 0, member);
667 set_compound_ent_value_w_path(ent, val, path, pos);
671 set_array_entity_values(entity *ent, tarval **values, int num_vals) {
673 ir_graph *rem = current_ir_graph;
674 type *arrtp = get_entity_type(ent);
677 assert(is_array_type(arrtp));
678 assert(get_array_n_dimensions(arrtp) == 1);
679 /* One bound is sufficient, the nunmber of constant fields makes the
681 assert(get_array_lower_bound (arrtp, 0) || get_array_upper_bound (arrtp, 0));
682 assert(get_entity_variability(ent) != variability_uninitialized);
683 current_ir_graph = get_const_code_irg();
685 for (i = 0; i < num_vals; i++) {
686 val = new_Const(get_tarval_mode (values[i]), values[i]);
687 add_compound_ent_value(ent, val, get_array_element_entity(arrtp));
689 current_ir_graph = rem;
693 get_entity_offset (entity *ent) {
698 set_entity_offset (entity *ent, int offset) {
699 ent->offset = offset;
703 add_entity_overwrites (entity *ent, entity *overwritten) {
705 assert(is_class_type(get_entity_owner(ent)));
706 ARR_APP1 (entity *, ent->overwrites, overwritten);
707 ARR_APP1 (entity *, overwritten->overwrittenby, ent);
711 get_entity_n_overwrites (entity *ent) {
713 assert(is_class_type(get_entity_owner(ent)));
714 return (ARR_LEN (ent->overwrites));
718 get_entity_overwrites_index(entity *ent, entity *overwritten) {
720 assert(ent && is_class_type(get_entity_owner(ent)));
721 for (i = 0; i < get_entity_n_overwrites(ent); i++)
722 if (get_entity_overwrites(ent, i) == overwritten)
728 get_entity_overwrites (entity *ent, int pos) {
730 assert(is_class_type(get_entity_owner(ent)));
731 assert(pos < get_entity_n_overwrites(ent));
732 return ent->overwrites[pos];
736 set_entity_overwrites (entity *ent, int pos, entity *overwritten) {
738 assert(is_class_type(get_entity_owner(ent)));
739 assert(pos < get_entity_n_overwrites(ent));
740 ent->overwrites[pos] = overwritten;
744 remove_entity_overwrites(entity *ent, entity *overwritten) {
746 assert(ent && is_class_type(get_entity_owner(ent)));
747 for (i = 0; i < (ARR_LEN (ent->overwrites)); i++)
748 if (ent->overwrites[i] == overwritten) {
749 for(; i < (ARR_LEN (ent->overwrites))-1; i++)
750 ent->overwrites[i] = ent->overwrites[i+1];
751 ARR_SETLEN(entity*, ent->overwrites, ARR_LEN(ent->overwrites) - 1);
757 add_entity_overwrittenby (entity *ent, entity *overwrites) {
759 assert(is_class_type(get_entity_owner(ent)));
760 add_entity_overwrites(overwrites, ent);
764 get_entity_n_overwrittenby (entity *ent) {
766 assert(is_class_type(get_entity_owner(ent)));
767 return (ARR_LEN (ent->overwrittenby));
771 get_entity_overwrittenby_index(entity *ent, entity *overwrites) {
773 assert(ent && is_class_type(get_entity_owner(ent)));
774 for (i = 0; i < get_entity_n_overwrittenby(ent); i++)
775 if (get_entity_overwrittenby(ent, i) == overwrites)
781 get_entity_overwrittenby (entity *ent, int pos) {
783 assert(is_class_type(get_entity_owner(ent)));
784 assert(pos < get_entity_n_overwrittenby(ent));
785 return ent->overwrittenby[pos];
789 set_entity_overwrittenby (entity *ent, int pos, entity *overwrites) {
791 assert(is_class_type(get_entity_owner(ent)));
792 assert(pos < get_entity_n_overwrittenby(ent));
793 ent->overwrittenby[pos] = overwrites;
796 void remove_entity_overwrittenby(entity *ent, entity *overwrites) {
798 assert(ent && is_class_type(get_entity_owner(ent)));
799 for (i = 0; i < (ARR_LEN (ent->overwrittenby)); i++)
800 if (ent->overwrittenby[i] == overwrites) {
801 for(; i < (ARR_LEN (ent->overwrittenby))-1; i++)
802 ent->overwrittenby[i] = ent->overwrittenby[i+1];
803 ARR_SETLEN(entity*, ent->overwrittenby, ARR_LEN(ent->overwrittenby) - 1);
808 /* A link to store intermediate information */
810 get_entity_link(entity *ent) {
816 set_entity_link(entity *ent, void *l) {
822 get_entity_irg(entity *ent) {
824 assert (is_method_type(ent->type));
829 set_entity_irg(entity *ent, ir_graph *irg) {
830 assert (ent && ent->type);
831 /* Wie kann man die Referenz auf einen IRG löschen, z.B. wenn die
832 * Methode selbst nicht mehr aufgerufen werden kann, die Entität
833 * aber erhalten bleiben soll. */
835 assert (is_method_type(ent->type));
836 assert (ent->peculiarity == peculiarity_existent);
840 int is_entity (void *thing) {
842 if (get_kind(thing) == k_entity)
848 int is_atomic_entity(entity *ent) {
849 type* t = get_entity_type(ent);
850 return (is_primitive_type(t) || is_pointer_type(t) ||
851 is_enumeration_type(t) || is_method_type(t));
854 int is_compound_entity(entity *ent) {
855 type* t = get_entity_type(ent);
856 return (is_class_type(t) || is_struct_type(t) ||
857 is_array_type(t) || is_union_type(t));
860 /* @@@ not implemnted!!! */
861 bool equal_entity(entity *ent1, entity *ent2) {
862 printf(" calling unimplemented equal entity!!! \n");
867 unsigned long get_entity_visited(entity *ent) {
871 void set_entity_visited(entity *ent, unsigned long num) {
875 /* Sets visited field in entity to entity_visited. */
876 void mark_entity_visited(entity *ent) {
878 ent->visit = type_visited;
882 bool entity_visited(entity *ent) {
883 return get_entity_visited(ent) >= type_visited;
886 bool entity_not_visited(entity *ent) {
887 return get_entity_visited(ent) < type_visited;
890 /* Need two routines because I want to assert the result. */
891 static entity *resolve_ent_polymorphy2 (type *dynamic_class, entity* static_ent) {
892 int i, n_overwrittenby;
895 if (get_entity_owner(static_ent) == dynamic_class) return static_ent;
897 n_overwrittenby = get_entity_n_overwrittenby(static_ent);
898 for (i = 0; i < n_overwrittenby; ++i) {
899 res = resolve_ent_polymorphy2(dynamic_class, get_entity_overwrittenby(static_ent, i));
906 /* Returns the dynamically referenced entity if the static entity and the
907 * dynamic type are given.
908 * Search downwards in overwritten tree. */
909 entity *resolve_ent_polymorphy(type *dynamic_class, entity* static_ent) {
910 entity *res = resolve_ent_polymorphy2(dynamic_class, static_ent);
912 printf(" Could not find entity "); DDME(static_ent);
913 printf(" in "); DDMT(dynamic_class);
915 dump_entity(static_ent);
916 dump_type(get_entity_owner(static_ent));
917 dump_type(dynamic_class);
926 /*******************************************************************/
928 /*******************************************************************/
931 #if 1 || DEBUG_libfirm
932 int dump_node_opcode(FILE *F, ir_node *n); /* from irdump.c */
934 #define X(a) case a: printf(#a); break
935 void dump_entity (entity *ent) {
937 type *owner = get_entity_owner(ent);
938 type *type = get_entity_type(ent);
939 printf("entity %s (%ld)\n", get_entity_name(ent), get_entity_nr(ent));
940 printf(" type: %s (%ld)\n", get_type_name(type), get_type_nr(type));
941 printf(" owner: %s (%ld)\n", get_type_name(owner), get_type_nr(owner));
943 if (get_entity_n_overwrites(ent) > 0) {
944 printf (" overwrites:\n");
945 for (i = 0; i < get_entity_n_overwrites(ent); ++i) {
946 entity *ov = get_entity_overwrites(ent, i);
947 printf(" %d: %s of class %s\n", i, get_entity_name(ov), get_type_name(get_entity_owner(ov)));
950 printf(" Does not overwrite other entities. \n");
952 if (get_entity_n_overwrittenby(ent) > 0) {
953 printf (" overwritten by:\n");
954 for (i = 0; i < get_entity_n_overwrittenby(ent); ++i) {
955 entity *ov = get_entity_overwrittenby(ent, i);
956 printf(" %d: %s of class %s\n", i, get_entity_name(ov), get_type_name(get_entity_owner(ov)));
959 printf(" Is not overwriten by other entities. \n");
962 printf (" allocation: ");
963 switch (get_entity_allocation(ent)) {
964 X(allocation_dynamic);
965 X(allocation_automatic);
966 X(allocation_static);
967 X(allocation_parameter);
970 printf ("\n visibility: ");
971 switch (get_entity_visibility(ent)) {
973 X(visibility_external_visible);
974 X(visibility_external_allocated);
977 printf ("\n variability: ");
978 switch (get_entity_variability(ent)) {
979 X(variability_uninitialized);
980 X(variability_initialized);
981 X(variability_part_constant);
982 X(variability_constant);
985 if (get_entity_variability(ent) != variability_uninitialized) {
986 if (is_atomic_entity(ent)) {
987 printf("\n atomic value: ");
988 dump_node_opcode(stdout, get_atomic_ent_value(ent));
990 printf("\n compound values:");
991 for (i = 0; i < get_compound_ent_n_values(ent); ++i) {
992 compound_graph_path *path = get_compound_ent_value_path(ent, i);
993 entity *ent0 = get_compound_graph_path_node(path, 0);
994 printf("\n %2d %s", get_entity_offset(ent0), get_entity_name(ent0));
995 for (j = 1; j < get_compound_graph_path_length(path); ++j)
996 printf(".%s", get_entity_name(get_compound_graph_path_node(path, j)));
998 dump_node_opcode(stdout, get_compound_ent_value(ent, i));
1003 printf ("\n volatility: ");
1004 switch (get_entity_volatility(ent)) {
1005 X(volatility_non_volatile);
1006 X(volatility_is_volatile);
1009 printf("\n peculiarity: %s", get_peculiarity_string(get_entity_peculiarity(ent)));
1010 printf("\n ld_name: %s", ent->ld_name ? get_entity_ld_name(ent) : "no yet set");
1011 printf("\n offset: %d", get_entity_offset(ent));
1012 if (is_method_type(get_entity_type(ent))) {
1013 if (get_entity_irg(ent)) /* can be null */
1014 { printf ("\n irg = %ld", get_irg_graph_nr(get_entity_irg(ent))); }
1016 { printf ("\n irg = NULL"); }
1021 #else /* DEBUG_libfirm */
1022 void dump_entity (entity *ent) {}
1023 #endif /* DEBUG_libfirm */