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 res->overwrites = NEW_ARR_F(entity *, 0);
100 res->overwrittenby = NEW_ARR_F(entity *, 0);
105 res->nr = get_irp_new_node_nr();
110 /* Remember entity in it's owner. */
111 insert_entity_in_owner (res);
115 new_d_entity (type *owner, ident *name, type *type, dbg_info *db) {
116 entity *res = new_entity(owner, name, type);
117 set_entity_dbg_info(res, db);
121 void free_compound_graph_path (compound_graph_path *gr);
122 int is_compound_graph_path(void *thing);
123 int get_compound_graph_path_length(compound_graph_path *gr);
124 entity *get_compound_graph_path_node(compound_graph_path *gr, int pos);
125 int get_compound_ent_n_values(entity *ent);
127 void free_entity_attrs(entity *ent) {
130 if (get_type_tpop(get_entity_owner(ent)) == type_class) {
131 DEL_ARR_F(ent->overwrites); ent->overwrites = NULL;
132 DEL_ARR_F(ent->overwrittenby); ent->overwrittenby = NULL;
134 assert(ent->overwrites == NULL);
135 assert(ent->overwrittenby == NULL);
137 /* if (ent->values) DEL_ARR_F(ent->values); *//* @@@ warum nich? */
138 if (ent->val_paths) {
139 if (is_compound_entity(ent))
140 for (i = 0; i < get_compound_ent_n_values(ent); i++)
141 if (ent->val_paths[i]) ;
142 /* free_compound_graph_path(ent->val_paths[i]) ; * @@@ warum nich? */
143 /* Geht nich: wird mehrfach verwendet!!! ==> mehrfach frei gegeben. */
144 /* DEL_ARR_F(ent->val_paths); */
146 ent->val_paths = NULL;
151 copy_entity_own (entity *old, type *new_owner) {
154 assert_legal_owner_of_ent(new_owner);
155 if (old->owner == new_owner) return old;
156 new = (entity *) xmalloc (sizeof (entity));
157 memcpy (new, old, sizeof (entity));
158 new->owner = new_owner;
160 if ((get_type_tpop(get_entity_owner(old)) == type_class) &&
161 (get_type_tpop(new_owner) == type_class)) {
162 new->overwrites = DUP_ARR_F(entity *, old->overwrites);
163 new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby);
164 } else if ((get_type_tpop(get_entity_owner(old)) != type_class) &&
165 (get_type_tpop(new_owner) == type_class)) {
166 new->overwrites = NEW_ARR_F(entity *, 0);
167 new->overwrittenby = NEW_ARR_F(entity *, 0);
170 if (is_class_type(new_owner)) {
171 new->overwrites = NEW_ARR_F(entity *, 0);
172 new->overwrittenby = NEW_ARR_F(entity *, 0);
175 new->nr = get_irp_new_node_nr();
178 insert_entity_in_owner (new);
184 copy_entity_name (entity *old, ident *new_name) {
187 if (old->name == new_name) return old;
188 new = (entity *) xmalloc (sizeof (entity));
189 memcpy (new, old, sizeof (entity));
190 new->name = new_name;
192 if (is_class_type(new->owner)) {
193 new->overwrites = DUP_ARR_F(entity *, old->overwrites);
194 new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby);
197 new->nr = get_irp_new_node_nr();
200 insert_entity_in_owner (new);
207 free_entity (entity *ent) {
208 free_tarval_entity(ent);
209 free_entity_attrs(ent);
214 /* Outputs a unique number for this node */
216 get_entity_nr(entity *ent) {
226 get_entity_name (entity *ent) {
228 return get_id_str(get_entity_ident(ent));
232 get_entity_ident (entity *ent) {
238 void set_entitye_ld_name (entity *, char *ld_name);
239 void set_entity_ld_ident (entity *, ident *ld_ident);
243 get_entity_owner (entity *ent) {
244 return ent->owner = skip_tid(ent->owner);
248 set_entity_owner (entity *ent, type *owner) {
249 assert_legal_owner_of_ent(owner);
253 void /* should this go into type.c? */
254 assert_legal_owner_of_ent(type *owner) {
255 assert (get_type_tpop_code(owner) == tpo_class ||
256 get_type_tpop_code(owner) == tpo_union ||
257 get_type_tpop_code(owner) == tpo_struct ||
258 get_type_tpop_code(owner) == tpo_array); /* Yes, array has an entity
259 -- to select fields! */
263 get_entity_ld_ident (entity *ent)
265 if (ent->ld_name == NULL)
266 ent->ld_name = mangle_entity (ent);
271 set_entity_ld_ident (entity *ent, ident *ld_ident) {
272 ent->ld_name = ld_ident;
276 get_entity_ld_name (entity *ent) {
277 return get_id_str(get_entity_ld_ident(ent));
281 char *get_entity_ld_name (entity *);
282 void set_entity_ld_name (entity *, char *ld_name);
286 get_entity_type (entity *ent) {
287 return ent->type = skip_tid(ent->type);
291 set_entity_type (entity *ent, type *type) {
297 get_entity_allocation (entity *ent) {
298 return ent->allocation;
302 set_entity_allocation (entity *ent, ent_allocation al) {
303 ent->allocation = al;
306 /* return the name of the visibility */
307 const char *get_allocation_name(ent_allocation all)
309 #define X(a) case a: return #a
311 X(allocation_automatic);
312 X(allocation_parameter);
313 X(allocation_dynamic);
314 X(allocation_static);
315 default: return "BAD VALUE";
322 get_entity_visibility (entity *ent) {
323 return ent->visibility;
327 set_entity_visibility (entity *ent, ent_visibility vis) {
328 if (vis != visibility_local)
329 assert((ent->allocation == allocation_static) ||
330 (ent->allocation == allocation_automatic));
331 /* @@@ Test that the owner type is not local, but how??
332 && get_class_visibility(get_entity_owner(ent)) != local));*/
333 ent->visibility = vis;
336 /* return the name of the visibility */
337 const char *get_visibility_name(ent_visibility vis)
339 #define X(a) case a: return #a
342 X(visibility_external_visible);
343 X(visibility_external_allocated);
344 default: return "BAD VALUE";
350 get_entity_variability (entity *ent) {
351 return ent->variability;
355 set_entity_variability (entity *ent, ent_variability var)
357 if (var == variability_part_constant)
358 assert(is_class_type(ent->type) || is_struct_type(ent->type));
360 if ((is_compound_type(ent->type)) &&
361 (ent->variability == variability_uninitialized) && (var != variability_uninitialized)) {
362 /* Allocate datastructures for constant values */
363 ent->values = NEW_ARR_F(ir_node *, 0);
364 ent->val_paths = NEW_ARR_F(compound_graph_path *, 0);
367 if ((is_compound_type(ent->type)) &&
368 (var == variability_uninitialized) && (ent->variability != variability_uninitialized)) {
369 /* Free datastructures for constant values */
370 DEL_ARR_F(ent->values); ent->values = NULL;
371 DEL_ARR_F(ent->val_paths); ent->val_paths = NULL;
373 ent->variability = var;
376 /* return the name of the variablity */
377 const char *get_variability_name(ent_variability var)
379 #define X(a) case a: return #a
381 X(variability_uninitialized);
382 X(variability_initialized);
383 X(variability_part_constant);
384 X(variability_constant);
385 default: return "BAD VALUE";
391 get_entity_volatility (entity *ent) {
393 return ent->volatility;
397 set_entity_volatility (entity *ent, ent_volatility vol) {
399 ent->volatility = vol;
402 /* return the name of the volatility */
403 const char *get_volatility_name(ent_volatility var)
405 #define X(a) case a: return #a
407 X(volatility_non_volatile);
408 X(volatility_is_volatile);
409 default: return "BAD VALUE";
415 get_entity_peculiarity (entity *ent) {
417 return ent->peculiarity;
421 set_entity_peculiarity (entity *ent, peculiarity pec) {
423 /* @@@ why peculiarity only for methods? */
424 assert (is_method_type(ent->type));
425 ent->peculiarity = pec;
428 /* return the name of the peculiarity */
429 const char *get_peculiarity_name(peculiarity var)
431 #define X(a) case a: return #a
433 X(peculiarity_description);
434 X(peculiarity_inherited);
435 X(peculiarity_existent);
436 default: return "BAD VALUE";
441 /* Set has no effect for existent entities of type method. */
443 get_atomic_ent_value(entity *ent)
446 assert(is_atomic_entity(ent));
447 assert(ent->variability != variability_uninitialized);
452 set_atomic_ent_value(entity *ent, ir_node *val) {
453 assert(ent && is_atomic_entity(ent) && (ent->variability != variability_uninitialized));
454 if (is_method_type(ent->type) && (ent->peculiarity == peculiarity_existent))
459 /* Returns true if the the node is representable as code on
461 int is_irn_const_expression(ir_node *n) {
465 switch(get_irn_opcode(n)) {
471 if (is_irn_const_expression(get_Add_left(n)))
472 return is_irn_const_expression(get_Add_right(n));
475 return is_irn_const_expression(get_irn_n(n, 0));
484 ir_node *copy_const_value(ir_node *n) {
489 switch(get_irn_opcode(n)) {
491 nn = new_Const(m, get_Const_tarval(n)); break;
493 nn = new_SymConst(get_SymConst_type_or_id(n), get_SymConst_kind(n)); break;
495 nn = new_Add(copy_const_value(get_Add_left(n)),
496 copy_const_value(get_Add_right(n)), m); break;
498 nn = new_Cast(copy_const_value(get_Cast_op(n)), get_Cast_type(n)); break;
500 nn = new_Conv(copy_const_value(get_Conv_op(n)), m); break;
502 nn = new_Unknown(m); break;
505 assert(0 && "opdope invalid or not implemented");
512 compound_graph_path *
513 new_compound_graph_path(type *tp, int length) {
514 compound_graph_path *res;
515 assert(is_type(tp) && is_compound_type(tp));
518 res = (compound_graph_path *) malloc (sizeof(compound_graph_path) + (length-1) * sizeof(entity *));
519 res->kind = k_ir_compound_graph_path;
522 memset(res->nodes, 0, sizeof(entity *) * length);
527 free_compound_graph_path (compound_graph_path *gr) {
528 assert(gr && is_compound_graph_path(gr));
534 is_compound_graph_path(void *thing) {
535 return (get_kind(thing) == k_ir_compound_graph_path);
538 /* checks whether nodes 0..pos are correct (all lie on a path.) */
539 /* @@@ not implemented */
540 int is_proper_compound_graph_path(compound_graph_path *gr, int pos) {
543 type *owner = gr->tp;
544 for (i = 0; i <= pos; i++) {
545 node = get_compound_graph_path_node(gr, i);
546 if (get_entity_owner(node) != owner) return false;
547 owner = get_entity_type(node);
549 if (pos == get_compound_graph_path_length(gr))
550 if (!is_atomic_type(owner)) return false;
555 get_compound_graph_path_length(compound_graph_path *gr) {
556 assert(gr && is_compound_graph_path(gr));
561 get_compound_graph_path_node(compound_graph_path *gr, int pos) {
562 assert(gr && is_compound_graph_path(gr));
563 assert(pos >= 0 && pos < gr->len);
564 return gr->nodes[pos];
568 set_compound_graph_path_node(compound_graph_path *gr, int pos, entity *node) {
569 assert(gr && is_compound_graph_path(gr));
570 assert(pos >= 0 && pos < gr->len);
571 assert(is_entity(node));
572 gr->nodes[pos] = node;
573 assert(is_proper_compound_graph_path(gr, pos));
576 /* A value of a compound entity is a pair of value and the corresponding path to a member of
579 add_compound_ent_value_w_path(entity *ent, ir_node *val, compound_graph_path *path) {
580 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
581 ARR_APP1 (ir_node *, ent->values, val);
582 ARR_APP1 (compound_graph_path *, ent->val_paths, path);
586 set_compound_ent_value_w_path(entity *ent, ir_node *val, compound_graph_path *path, int pos) {
587 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
588 ent->values[pos] = val;
589 ent->val_paths[pos] = path;
593 get_compound_ent_n_values(entity *ent) {
594 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
595 return (ARR_LEN (ent->values));
599 get_compound_ent_value(entity *ent, int pos) {
600 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
601 return ent->values[pos];
604 compound_graph_path *
605 get_compound_ent_value_path(entity *ent, int pos) {
606 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
607 return ent->val_paths[pos];
611 remove_compound_ent_value(entity *ent, entity *value_ent) {
613 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
614 for (i = 0; i < (ARR_LEN (ent->val_paths)); i++) {
615 compound_graph_path *path = ent->val_paths[i];
616 if (path->nodes[path->len-1] == value_ent) {
617 for(; i < (ARR_LEN (ent->val_paths))-1; i++) {
618 ent->val_paths[i] = ent->val_paths[i+1];
619 ent->values[i] = ent->values[i+1];
621 ARR_SETLEN(entity*, ent->val_paths, ARR_LEN(ent->val_paths) - 1);
622 ARR_SETLEN(ir_node*, ent->values, ARR_LEN(ent->values) - 1);
629 add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
630 compound_graph_path *path;
631 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
632 path = new_compound_graph_path(get_entity_owner(ent), 1);
633 path->nodes[0] = member;
634 add_compound_ent_value_w_path(ent, val, path);
637 /* Copies the firm subgraph referenced by val to const_code_irg and adds
638 the node as constant initialization to ent.
639 The subgraph may not contain control flow operations.
641 copy_and_add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
642 ir_graph *rem = current_ir_graph;
644 assert(get_entity_variability(ent) != variability_uninitialized);
645 current_ir_graph = get_const_code_irg();
647 val = copy_const_value(val);
648 add_compound_ent_value(ent, val, member);
649 current_ir_graph = rem;
652 /* Copies the value i of the entity to current_block in current_ir_graph.
654 copy_compound_ent_value(entity *ent, int pos) {
655 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
656 return copy_const_value(ent->values[pos+1]);
660 get_compound_ent_value_member(entity *ent, int pos) {
661 compound_graph_path *path;
662 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
663 path = get_compound_ent_value_path(ent, pos);
665 return get_compound_graph_path_node(path, get_compound_graph_path_length(path)-1);
669 set_compound_ent_value(entity *ent, ir_node *val, entity *member, int pos) {
670 compound_graph_path *path;
671 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
672 path = get_compound_ent_value_path(ent, pos);
673 set_compound_graph_path_node(path, 0, member);
674 set_compound_ent_value_w_path(ent, val, path, pos);
678 set_array_entity_values(entity *ent, tarval **values, int num_vals) {
680 ir_graph *rem = current_ir_graph;
681 type *arrtp = get_entity_type(ent);
684 assert(is_array_type(arrtp));
685 assert(get_array_n_dimensions(arrtp) == 1);
686 /* One bound is sufficient, the nunmber of constant fields makes the
688 assert(get_array_lower_bound (arrtp, 0) || get_array_upper_bound (arrtp, 0));
689 assert(get_entity_variability(ent) != variability_uninitialized);
690 current_ir_graph = get_const_code_irg();
692 for (i = 0; i < num_vals; i++) {
693 val = new_Const(get_tarval_mode (values[i]), values[i]);
694 add_compound_ent_value(ent, val, get_array_element_entity(arrtp));
696 current_ir_graph = rem;
700 get_entity_offset (entity *ent) {
705 set_entity_offset (entity *ent, int offset) {
706 ent->offset = offset;
710 add_entity_overwrites (entity *ent, entity *overwritten) {
712 assert(is_class_type(get_entity_owner(ent)));
713 ARR_APP1 (entity *, ent->overwrites, overwritten);
714 ARR_APP1 (entity *, overwritten->overwrittenby, ent);
718 get_entity_n_overwrites (entity *ent) {
720 assert(is_class_type(get_entity_owner(ent)));
721 return (ARR_LEN (ent->overwrites));
725 get_entity_overwrites_index(entity *ent, entity *overwritten) {
727 assert(ent && is_class_type(get_entity_owner(ent)));
728 for (i = 0; i < get_entity_n_overwrites(ent); i++)
729 if (get_entity_overwrites(ent, i) == overwritten)
735 get_entity_overwrites (entity *ent, int pos) {
737 assert(is_class_type(get_entity_owner(ent)));
738 assert(pos < get_entity_n_overwrites(ent));
739 return ent->overwrites[pos];
743 set_entity_overwrites (entity *ent, int pos, entity *overwritten) {
745 assert(is_class_type(get_entity_owner(ent)));
746 assert(pos < get_entity_n_overwrites(ent));
747 ent->overwrites[pos] = overwritten;
751 remove_entity_overwrites(entity *ent, entity *overwritten) {
753 assert(ent && is_class_type(get_entity_owner(ent)));
754 for (i = 0; i < (ARR_LEN (ent->overwrites)); i++)
755 if (ent->overwrites[i] == overwritten) {
756 for(; i < (ARR_LEN (ent->overwrites))-1; i++)
757 ent->overwrites[i] = ent->overwrites[i+1];
758 ARR_SETLEN(entity*, ent->overwrites, ARR_LEN(ent->overwrites) - 1);
764 add_entity_overwrittenby (entity *ent, entity *overwrites) {
766 assert(is_class_type(get_entity_owner(ent)));
767 add_entity_overwrites(overwrites, ent);
771 get_entity_n_overwrittenby (entity *ent) {
773 assert(is_class_type(get_entity_owner(ent)));
774 return (ARR_LEN (ent->overwrittenby));
778 get_entity_overwrittenby_index(entity *ent, entity *overwrites) {
780 assert(ent && is_class_type(get_entity_owner(ent)));
781 for (i = 0; i < get_entity_n_overwrittenby(ent); i++)
782 if (get_entity_overwrittenby(ent, i) == overwrites)
788 get_entity_overwrittenby (entity *ent, int pos) {
790 assert(is_class_type(get_entity_owner(ent)));
791 assert(pos < get_entity_n_overwrittenby(ent));
792 return ent->overwrittenby[pos];
796 set_entity_overwrittenby (entity *ent, int pos, entity *overwrites) {
798 assert(is_class_type(get_entity_owner(ent)));
799 assert(pos < get_entity_n_overwrittenby(ent));
800 ent->overwrittenby[pos] = overwrites;
803 void remove_entity_overwrittenby(entity *ent, entity *overwrites) {
805 assert(ent && is_class_type(get_entity_owner(ent)));
806 for (i = 0; i < (ARR_LEN (ent->overwrittenby)); i++)
807 if (ent->overwrittenby[i] == overwrites) {
808 for(; i < (ARR_LEN (ent->overwrittenby))-1; i++)
809 ent->overwrittenby[i] = ent->overwrittenby[i+1];
810 ARR_SETLEN(entity*, ent->overwrittenby, ARR_LEN(ent->overwrittenby) - 1);
815 /* A link to store intermediate information */
817 get_entity_link(entity *ent) {
823 set_entity_link(entity *ent, void *l) {
829 get_entity_irg(entity *ent) {
831 assert (is_method_type(ent->type));
836 set_entity_irg(entity *ent, ir_graph *irg) {
837 assert (ent && ent->type);
838 /* Wie kann man die Referenz auf einen IRG löschen, z.B. wenn die
839 * Methode selbst nicht mehr aufgerufen werden kann, die Entität
840 * aber erhalten bleiben soll. */
842 assert (is_method_type(ent->type));
843 assert (ent->peculiarity == peculiarity_existent);
847 int is_entity (void *thing) {
849 if (get_kind(thing) == k_entity)
855 int is_atomic_entity(entity *ent) {
856 type* t = get_entity_type(ent);
857 return (is_primitive_type(t) || is_pointer_type(t) ||
858 is_enumeration_type(t) || is_method_type(t));
861 int is_compound_entity(entity *ent) {
862 type* t = get_entity_type(ent);
863 return (is_class_type(t) || is_struct_type(t) ||
864 is_array_type(t) || is_union_type(t));
867 /* @@@ not implemnted!!! */
868 bool equal_entity(entity *ent1, entity *ent2) {
869 printf(" calling unimplemented equal entity!!! \n");
874 unsigned long get_entity_visited(entity *ent) {
878 void set_entity_visited(entity *ent, unsigned long num) {
882 /* Sets visited field in entity to entity_visited. */
883 void mark_entity_visited(entity *ent) {
885 ent->visit = type_visited;
889 bool entity_visited(entity *ent) {
890 return get_entity_visited(ent) >= type_visited;
893 bool entity_not_visited(entity *ent) {
894 return get_entity_visited(ent) < type_visited;
897 /* Need two routines because I want to assert the result. */
898 static entity *resolve_ent_polymorphy2 (type *dynamic_class, entity* static_ent) {
899 int i, n_overwrittenby;
902 if (get_entity_owner(static_ent) == dynamic_class) return static_ent;
904 n_overwrittenby = get_entity_n_overwrittenby(static_ent);
905 for (i = 0; i < n_overwrittenby; ++i) {
906 res = resolve_ent_polymorphy2(dynamic_class, get_entity_overwrittenby(static_ent, i));
913 /* Returns the dynamically referenced entity if the static entity and the
914 * dynamic type are given.
915 * Search downwards in overwritten tree. */
916 entity *resolve_ent_polymorphy(type *dynamic_class, entity* static_ent) {
917 entity *res = resolve_ent_polymorphy2(dynamic_class, static_ent);
919 printf(" Could not find entity "); DDME(static_ent);
920 printf(" in "); DDMT(dynamic_class);
922 dump_entity(static_ent);
923 dump_type(get_entity_owner(static_ent));
924 dump_type(dynamic_class);
933 /*******************************************************************/
935 /*******************************************************************/
938 #if 1 || DEBUG_libfirm
939 int dump_node_opcode(FILE *F, ir_node *n); /* from irdump.c */
941 #define X(a) case a: printf(#a); break
942 void dump_entity (entity *ent) {
944 type *owner = get_entity_owner(ent);
945 type *type = get_entity_type(ent);
946 printf("entity %s (%ld)\n", get_entity_name(ent), get_entity_nr(ent));
947 printf(" type: %s (%ld)\n", get_type_name(type), get_type_nr(type));
948 printf(" owner: %s (%ld)\n", get_type_name(owner), get_type_nr(owner));
950 if (get_entity_n_overwrites(ent) > 0) {
951 printf (" overwrites:\n");
952 for (i = 0; i < get_entity_n_overwrites(ent); ++i) {
953 entity *ov = get_entity_overwrites(ent, i);
954 printf(" %d: %s of class %s\n", i, get_entity_name(ov), get_type_name(get_entity_owner(ov)));
957 printf(" Does not overwrite other entities. \n");
959 if (get_entity_n_overwrittenby(ent) > 0) {
960 printf (" overwritten by:\n");
961 for (i = 0; i < get_entity_n_overwrittenby(ent); ++i) {
962 entity *ov = get_entity_overwrittenby(ent, i);
963 printf(" %d: %s of class %s\n", i, get_entity_name(ov), get_type_name(get_entity_owner(ov)));
966 printf(" Is not overwriten by other entities. \n");
969 printf (" allocation: ");
970 switch (get_entity_allocation(ent)) {
971 X(allocation_dynamic);
972 X(allocation_automatic);
973 X(allocation_static);
974 X(allocation_parameter);
977 printf ("\n visibility: ");
978 switch (get_entity_visibility(ent)) {
980 X(visibility_external_visible);
981 X(visibility_external_allocated);
984 printf ("\n variability: ");
985 switch (get_entity_variability(ent)) {
986 X(variability_uninitialized);
987 X(variability_initialized);
988 X(variability_part_constant);
989 X(variability_constant);
992 if (get_entity_variability(ent) != variability_uninitialized) {
993 if (is_atomic_entity(ent)) {
994 printf("\n atomic value: ");
995 dump_node_opcode(stdout, get_atomic_ent_value(ent));
997 printf("\n compound values:");
998 for (i = 0; i < get_compound_ent_n_values(ent); ++i) {
999 compound_graph_path *path = get_compound_ent_value_path(ent, i);
1000 entity *ent0 = get_compound_graph_path_node(path, 0);
1001 printf("\n %2d %s", get_entity_offset(ent0), get_entity_name(ent0));
1002 for (j = 1; j < get_compound_graph_path_length(path); ++j)
1003 printf(".%s", get_entity_name(get_compound_graph_path_node(path, j)));
1005 dump_node_opcode(stdout, get_compound_ent_value(ent, i));
1010 printf ("\n volatility: ");
1011 switch (get_entity_volatility(ent)) {
1012 X(volatility_non_volatile);
1013 X(volatility_is_volatile);
1016 printf("\n peculiarity: %s", get_peculiarity_string(get_entity_peculiarity(ent)));
1017 printf("\n ld_name: %s", ent->ld_name ? get_entity_ld_name(ent) : "no yet set");
1018 printf("\n offset: %d", get_entity_offset(ent));
1019 if (is_method_type(get_entity_type(ent))) {
1020 if (get_entity_irg(ent)) /* can be null */
1021 { printf ("\n irg = %ld", get_irg_graph_nr(get_entity_irg(ent))); }
1023 { printf ("\n irg = NULL"); }
1028 #else /* DEBUG_libfirm */
1029 void dump_entity (entity *ent) {}
1030 #endif /* DEBUG_libfirm */