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 //if (ent->values) DEL_ARR_F(ent->values); /* @@@ warum nich? */
135 if (ent->val_paths) {
136 if (is_compound_entity(ent))
137 for (i = 0; i < get_compound_ent_n_values(ent); i++)
138 if (ent->val_paths[i]) ;
139 /* free_compound_graph_path(ent->val_paths[i]) ; * @@@ warum nich? */
140 /* Geht nich: wird mehrfach verwendet!!! ==> mehrfach frei gegeben. */
141 //DEL_ARR_F(ent->val_paths);
143 ent->val_paths = NULL;
148 copy_entity_own (entity *old, type *new_owner) {
151 assert_legal_owner_of_ent(new_owner);
152 if (old->owner == new_owner) return old;
153 new = (entity *) xmalloc (sizeof (entity));
154 memcpy (new, old, sizeof (entity));
155 new->owner = new_owner;
157 if ((get_type_tpop(get_entity_owner(old)) == type_class) &&
158 (get_type_tpop(new_owner) == type_class)) {
159 new->overwrites = DUP_ARR_F(entity *, old->overwrites);
160 new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby);
161 } else if ((get_type_tpop(get_entity_owner(old)) != type_class) &&
162 (get_type_tpop(new_owner) == type_class)) {
163 new->overwrites = NEW_ARR_F(entity *, 0);
164 new->overwrittenby = NEW_ARR_F(entity *, 0);
167 if (is_class_type(new_owner)) {
168 new->overwrites = NEW_ARR_F(entity *, 0);
169 new->overwrittenby = NEW_ARR_F(entity *, 0);
172 new->nr = get_irp_new_node_nr();
175 insert_entity_in_owner (new);
181 copy_entity_name (entity *old, ident *new_name) {
184 if (old->name == new_name) return old;
185 new = (entity *) xmalloc (sizeof (entity));
186 memcpy (new, old, sizeof (entity));
187 new->name = new_name;
189 if (is_class_type(new->owner)) {
190 new->overwrites = DUP_ARR_F(entity *, old->overwrites);
191 new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby);
194 new->nr = get_irp_new_node_nr();
197 insert_entity_in_owner (new);
204 free_entity (entity *ent) {
205 free_tarval_entity(ent);
206 free_entity_attrs(ent);
211 /* Outputs a unique number for this node */
213 get_entity_nr(entity *ent) {
223 get_entity_name (entity *ent) {
225 return get_id_str(get_entity_ident(ent));
229 get_entity_ident (entity *ent) {
235 void set_entitye_ld_name (entity *, char *ld_name);
236 void set_entity_ld_ident (entity *, ident *ld_ident);
240 get_entity_owner (entity *ent) {
241 return ent->owner = skip_tid(ent->owner);
245 set_entity_owner (entity *ent, type *owner) {
246 assert_legal_owner_of_ent(owner);
250 void /* should this go into type.c? */
251 assert_legal_owner_of_ent(type *owner) {
252 assert (get_type_tpop_code(owner) == tpo_class ||
253 get_type_tpop_code(owner) == tpo_union ||
254 get_type_tpop_code(owner) == tpo_struct ||
255 get_type_tpop_code(owner) == tpo_array); /* Yes, array has an entity
256 -- to select fields! */
260 get_entity_ld_ident (entity *ent)
262 if (ent->ld_name == NULL)
263 ent->ld_name = mangle_entity (ent);
268 set_entity_ld_ident (entity *ent, ident *ld_ident) {
269 ent->ld_name = ld_ident;
273 get_entity_ld_name (entity *ent) {
274 return get_id_str(get_entity_ld_ident(ent));
278 char *get_entity_ld_name (entity *);
279 void set_entity_ld_name (entity *, char *ld_name);
283 get_entity_type (entity *ent) {
284 return ent->type = skip_tid(ent->type);
288 set_entity_type (entity *ent, type *type) {
294 get_entity_allocation (entity *ent) {
295 return ent->allocation;
299 set_entity_allocation (entity *ent, ent_allocation al) {
300 ent->allocation = al;
303 /* return the name of the visibility */
304 const char *get_allocation_name(ent_allocation all)
306 #define X(a) case a: return #a
308 X(allocation_automatic);
309 X(allocation_parameter);
310 X(allocation_dynamic);
311 X(allocation_static);
312 default: return "BAD VALUE";
319 get_entity_visibility (entity *ent) {
320 return ent->visibility;
324 set_entity_visibility (entity *ent, ent_visibility vis) {
325 if (vis != visibility_local)
326 assert((ent->allocation == allocation_static) ||
327 (ent->allocation == allocation_automatic));
328 /* @@@ Test that the owner type is not local, but how??
329 && get_class_visibility(get_entity_owner(ent)) != local));*/
330 ent->visibility = vis;
333 /* return the name of the visibility */
334 const char *get_visibility_name(ent_visibility vis)
336 #define X(a) case a: return #a
339 X(visibility_external_visible);
340 X(visibility_external_allocated);
341 default: return "BAD VALUE";
347 get_entity_variability (entity *ent) {
348 return ent->variability;
352 set_entity_variability (entity *ent, ent_variability var)
354 if (var == variability_part_constant)
355 assert(is_class_type(ent->type) || is_struct_type(ent->type));
357 if ((is_compound_type(ent->type)) &&
358 (ent->variability == variability_uninitialized) && (var != variability_uninitialized)) {
359 /* Allocate datastructures for constant values */
360 ent->values = NEW_ARR_F(ir_node *, 0);
361 ent->val_paths = NEW_ARR_F(compound_graph_path *, 0);
364 if ((is_compound_type(ent->type)) &&
365 (var == variability_uninitialized) && (ent->variability != variability_uninitialized)) {
366 /* Free datastructures for constant values */
367 DEL_ARR_F(ent->values); ent->values = NULL;
368 DEL_ARR_F(ent->val_paths); ent->val_paths = NULL;
370 ent->variability = var;
373 /* return the name of the variablity */
374 const char *get_variability_name(ent_variability var)
376 #define X(a) case a: return #a
378 X(variability_uninitialized);
379 X(variability_initialized);
380 X(variability_part_constant);
381 X(variability_constant);
382 default: return "BAD VALUE";
388 get_entity_volatility (entity *ent) {
390 return ent->volatility;
394 set_entity_volatility (entity *ent, ent_volatility vol) {
396 ent->volatility = vol;
399 /* return the name of the volatility */
400 const char *get_volatility_name(ent_volatility var)
402 #define X(a) case a: return #a
404 X(volatility_non_volatile);
405 X(volatility_is_volatile);
406 default: return "BAD VALUE";
412 get_entity_peculiarity (entity *ent) {
414 return ent->peculiarity;
418 set_entity_peculiarity (entity *ent, peculiarity pec) {
420 /* @@@ why peculiarity only for methods? */
421 assert (is_method_type(ent->type));
422 ent->peculiarity = pec;
425 /* return the name of the peculiarity */
426 const char *get_peculiarity_name(peculiarity var)
428 #define X(a) case a: return #a
430 X(peculiarity_description);
431 X(peculiarity_inherited);
432 X(peculiarity_existent);
433 default: return "BAD VALUE";
438 /* Set has no effect for existent entities of type method. */
440 get_atomic_ent_value(entity *ent)
443 assert(is_atomic_entity(ent));
444 assert(ent->variability != variability_uninitialized);
449 set_atomic_ent_value(entity *ent, ir_node *val) {
450 assert(ent && is_atomic_entity(ent) && (ent->variability != variability_uninitialized));
451 if (is_method_type(ent->type) && (ent->peculiarity == peculiarity_existent))
456 /* Returns true if the the node is representable as code on
458 int is_irn_const_expression(ir_node *n) {
462 switch(get_irn_opcode(n)) {
468 if (is_irn_const_expression(get_Add_left(n)))
469 return is_irn_const_expression(get_Add_right(n));
472 return is_irn_const_expression(get_irn_n(n, 0));
481 ir_node *copy_const_value(ir_node *n) {
486 switch(get_irn_opcode(n)) {
488 nn = new_Const(m, get_Const_tarval(n)); break;
490 nn = new_SymConst(get_SymConst_type_or_id(n), get_SymConst_kind(n)); break;
492 nn = new_Add(copy_const_value(get_Add_left(n)),
493 copy_const_value(get_Add_right(n)), m); break;
495 nn = new_Cast(copy_const_value(get_Cast_op(n)), get_Cast_type(n)); break;
497 nn = new_Conv(copy_const_value(get_Conv_op(n)), m); break;
499 nn = new_Unknown(m); break;
502 assert(0 && "opdope invalid or not implemented");
509 compound_graph_path *
510 new_compound_graph_path(type *tp, int length) {
511 compound_graph_path *res;
512 assert(is_type(tp) && is_compound_type(tp));
515 res = (compound_graph_path *) malloc (sizeof(compound_graph_path) + (length-1) * sizeof(entity *));
516 res->kind = k_ir_compound_graph_path;
519 memset(res->nodes, 0, sizeof(entity *) * length);
524 free_compound_graph_path (compound_graph_path *gr) {
525 assert(gr && is_compound_graph_path(gr));
531 is_compound_graph_path(void *thing) {
532 return (get_kind(thing) == k_ir_compound_graph_path);
535 /* checks whether nodes 0..pos are correct (all lie on a path.) */
536 /* @@@ not implemented */
537 int is_proper_compound_graph_path(compound_graph_path *gr, int pos) {
540 type *owner = gr->tp;
541 for (i = 0; i <= pos; i++) {
542 node = get_compound_graph_path_node(gr, i);
543 if (get_entity_owner(node) != owner) return false;
544 owner = get_entity_type(node);
546 if (pos == get_compound_graph_path_length(gr))
547 if (!is_atomic_type(owner)) return false;
552 get_compound_graph_path_length(compound_graph_path *gr) {
553 assert(gr && is_compound_graph_path(gr));
558 get_compound_graph_path_node(compound_graph_path *gr, int pos) {
559 assert(gr && is_compound_graph_path(gr));
560 assert(pos >= 0 && pos < gr->len);
561 return gr->nodes[pos];
565 set_compound_graph_path_node(compound_graph_path *gr, int pos, entity *node) {
566 assert(gr && is_compound_graph_path(gr));
567 assert(pos >= 0 && pos < gr->len);
568 assert(is_entity(node));
569 gr->nodes[pos] = node;
570 assert(is_proper_compound_graph_path(gr, pos));
573 /* A value of a compound entity is a pair of value and the corresponding path to a member of
576 add_compound_ent_value_w_path(entity *ent, ir_node *val, compound_graph_path *path) {
577 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
578 ARR_APP1 (ir_node *, ent->values, val);
579 ARR_APP1 (compound_graph_path *, ent->val_paths, path);
583 set_compound_ent_value_w_path(entity *ent, ir_node *val, compound_graph_path *path, int pos) {
584 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
585 ent->values[pos] = val;
586 ent->val_paths[pos] = path;
590 get_compound_ent_n_values(entity *ent) {
591 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
592 return (ARR_LEN (ent->values));
596 get_compound_ent_value(entity *ent, int pos) {
597 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
598 return ent->values[pos];
601 compound_graph_path *
602 get_compound_ent_value_path(entity *ent, int pos) {
603 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
604 return ent->val_paths[pos];
608 remove_compound_ent_value(entity *ent, entity *value_ent) {
610 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
611 for (i = 0; i < (ARR_LEN (ent->val_paths)); i++) {
612 compound_graph_path *path = ent->val_paths[i];
613 if (path->nodes[path->len-1] == value_ent) {
614 for(; i < (ARR_LEN (ent->val_paths))-1; i++) {
615 ent->val_paths[i] = ent->val_paths[i+1];
616 ent->values[i] = ent->values[i+1];
618 ARR_SETLEN(entity*, ent->val_paths, ARR_LEN(ent->val_paths) - 1);
619 ARR_SETLEN(ir_node*, ent->values, ARR_LEN(ent->values) - 1);
626 add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
627 compound_graph_path *path;
628 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
629 path = new_compound_graph_path(get_entity_owner(ent), 1);
630 path->nodes[0] = member;
631 add_compound_ent_value_w_path(ent, val, path);
634 /* Copies the firm subgraph referenced by val to const_code_irg and adds
635 the node as constant initialization to ent.
636 The subgraph may not contain control flow operations.
638 copy_and_add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
639 ir_graph *rem = current_ir_graph;
641 assert(get_entity_variability(ent) != variability_uninitialized);
642 current_ir_graph = get_const_code_irg();
644 val = copy_const_value(val);
645 add_compound_ent_value(ent, val, member);
646 current_ir_graph = rem;
649 /* Copies the value i of the entity to current_block in current_ir_graph.
651 copy_compound_ent_value(entity *ent, int pos) {
652 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
653 return copy_const_value(ent->values[pos+1]);
657 get_compound_ent_value_member(entity *ent, int pos) {
658 compound_graph_path *path;
659 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
660 path = get_compound_ent_value_path(ent, pos);
662 return get_compound_graph_path_node(path, get_compound_graph_path_length(path)-1);
666 set_compound_ent_value(entity *ent, ir_node *val, entity *member, int pos) {
667 compound_graph_path *path;
668 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
669 path = get_compound_ent_value_path(ent, pos);
670 set_compound_graph_path_node(path, 0, member);
671 set_compound_ent_value_w_path(ent, val, path, pos);
675 set_array_entity_values(entity *ent, tarval **values, int num_vals) {
677 ir_graph *rem = current_ir_graph;
678 type *arrtp = get_entity_type(ent);
681 assert(is_array_type(arrtp));
682 assert(get_array_n_dimensions(arrtp) == 1);
683 /* One bound is sufficient, the nunmber of constant fields makes the
685 assert(get_array_lower_bound (arrtp, 0) || get_array_upper_bound (arrtp, 0));
686 assert(get_entity_variability(ent) != variability_uninitialized);
687 current_ir_graph = get_const_code_irg();
689 for (i = 0; i < num_vals; i++) {
690 val = new_Const(get_tarval_mode (values[i]), values[i]);
691 add_compound_ent_value(ent, val, get_array_element_entity(arrtp));
693 current_ir_graph = rem;
697 get_entity_offset (entity *ent) {
702 set_entity_offset (entity *ent, int offset) {
703 ent->offset = offset;
707 add_entity_overwrites (entity *ent, entity *overwritten) {
709 assert(is_class_type(get_entity_owner(ent)));
710 ARR_APP1 (entity *, ent->overwrites, overwritten);
711 ARR_APP1 (entity *, overwritten->overwrittenby, ent);
715 get_entity_n_overwrites (entity *ent) {
717 assert(is_class_type(get_entity_owner(ent)));
718 return (ARR_LEN (ent->overwrites));
722 get_entity_overwrites_index(entity *ent, entity *overwritten) {
724 assert(ent && is_class_type(get_entity_owner(ent)));
725 for (i = 0; i < get_entity_n_overwrites(ent); i++)
726 if (get_entity_overwrites(ent, i) == overwritten)
732 get_entity_overwrites (entity *ent, int pos) {
734 assert(is_class_type(get_entity_owner(ent)));
735 assert(pos < get_entity_n_overwrites(ent));
736 return ent->overwrites[pos];
740 set_entity_overwrites (entity *ent, int pos, entity *overwritten) {
742 assert(is_class_type(get_entity_owner(ent)));
743 assert(pos < get_entity_n_overwrites(ent));
744 ent->overwrites[pos] = overwritten;
748 remove_entity_overwrites(entity *ent, entity *overwritten) {
750 assert(ent && is_class_type(get_entity_owner(ent)));
751 for (i = 0; i < (ARR_LEN (ent->overwrites)); i++)
752 if (ent->overwrites[i] == overwritten) {
753 for(; i < (ARR_LEN (ent->overwrites))-1; i++)
754 ent->overwrites[i] = ent->overwrites[i+1];
755 ARR_SETLEN(entity*, ent->overwrites, ARR_LEN(ent->overwrites) - 1);
761 add_entity_overwrittenby (entity *ent, entity *overwrites) {
763 assert(is_class_type(get_entity_owner(ent)));
764 add_entity_overwrites(overwrites, ent);
768 get_entity_n_overwrittenby (entity *ent) {
770 assert(is_class_type(get_entity_owner(ent)));
771 return (ARR_LEN (ent->overwrittenby));
775 get_entity_overwrittenby_index(entity *ent, entity *overwrites) {
777 assert(ent && is_class_type(get_entity_owner(ent)));
778 for (i = 0; i < get_entity_n_overwrittenby(ent); i++)
779 if (get_entity_overwrittenby(ent, i) == overwrites)
785 get_entity_overwrittenby (entity *ent, int pos) {
787 assert(is_class_type(get_entity_owner(ent)));
788 assert(pos < get_entity_n_overwrittenby(ent));
789 return ent->overwrittenby[pos];
793 set_entity_overwrittenby (entity *ent, int pos, entity *overwrites) {
795 assert(is_class_type(get_entity_owner(ent)));
796 assert(pos < get_entity_n_overwrittenby(ent));
797 ent->overwrittenby[pos] = overwrites;
800 void remove_entity_overwrittenby(entity *ent, entity *overwrites) {
802 assert(ent && is_class_type(get_entity_owner(ent)));
803 for (i = 0; i < (ARR_LEN (ent->overwrittenby)); i++)
804 if (ent->overwrittenby[i] == overwrites) {
805 for(; i < (ARR_LEN (ent->overwrittenby))-1; i++)
806 ent->overwrittenby[i] = ent->overwrittenby[i+1];
807 ARR_SETLEN(entity*, ent->overwrittenby, ARR_LEN(ent->overwrittenby) - 1);
812 /* A link to store intermediate information */
814 get_entity_link(entity *ent) {
820 set_entity_link(entity *ent, void *l) {
826 get_entity_irg(entity *ent) {
828 assert (is_method_type(ent->type));
833 set_entity_irg(entity *ent, ir_graph *irg) {
834 assert (ent && ent->type);
835 /* Wie kann man die Referenz auf einen IRG löschen, z.B. wenn die
836 * Methode selbst nicht mehr aufgerufen werden kann, die Entität
837 * aber erhalten bleiben soll. */
839 assert (is_method_type(ent->type));
840 assert (ent->peculiarity == peculiarity_existent);
844 int is_entity (void *thing) {
846 if (get_kind(thing) == k_entity)
852 int is_atomic_entity(entity *ent) {
853 type* t = get_entity_type(ent);
854 return (is_primitive_type(t) || is_pointer_type(t) ||
855 is_enumeration_type(t) || is_method_type(t));
858 int is_compound_entity(entity *ent) {
859 type* t = get_entity_type(ent);
860 return (is_class_type(t) || is_struct_type(t) ||
861 is_array_type(t) || is_union_type(t));
864 /* @@@ not implemnted!!! */
865 bool equal_entity(entity *ent1, entity *ent2) {
866 printf(" calling unimplemented equal entity!!! \n");
871 unsigned long get_entity_visited(entity *ent) {
875 void set_entity_visited(entity *ent, unsigned long num) {
879 /* Sets visited field in entity to entity_visited. */
880 void mark_entity_visited(entity *ent) {
882 ent->visit = type_visited;
886 bool entity_visited(entity *ent) {
887 return get_entity_visited(ent) >= type_visited;
890 bool entity_not_visited(entity *ent) {
891 return get_entity_visited(ent) < type_visited;
894 /* Need two routines because I want to assert the result. */
895 static entity *resolve_ent_polymorphy2 (type *dynamic_class, entity* static_ent) {
896 int i, n_overwrittenby;
899 if (get_entity_owner(static_ent) == dynamic_class) return static_ent;
901 n_overwrittenby = get_entity_n_overwrittenby(static_ent);
902 for (i = 0; i < n_overwrittenby; ++i) {
903 res = resolve_ent_polymorphy2(dynamic_class, get_entity_overwrittenby(static_ent, i));
910 /* Returns the dynamically referenced entity if the static entity and the
911 * dynamic type are given.
912 * Search downwards in overwritten tree. */
913 entity *resolve_ent_polymorphy(type *dynamic_class, entity* static_ent) {
914 entity *res = resolve_ent_polymorphy2(dynamic_class, static_ent);
916 printf(" Could not find entity "); DDME(static_ent);
917 printf(" in "); DDMT(dynamic_class);
919 dump_entity(static_ent);
920 dump_type(get_entity_owner(static_ent));
921 dump_type(dynamic_class);
930 /*******************************************************************/
932 /*******************************************************************/
935 #if 1 || DEBUG_libfirm
936 int dump_node_opcode(FILE *F, ir_node *n); /* from irdump.c */
938 #define X(a) case a: printf(#a); break
939 void dump_entity (entity *ent) {
941 type *owner = get_entity_owner(ent);
942 type *type = get_entity_type(ent);
943 printf("entity %s (%ld)\n", get_entity_name(ent), get_entity_nr(ent));
944 printf(" type: %s (%ld)\n", get_type_name(type), get_type_nr(type));
945 printf(" owner: %s (%ld)\n", get_type_name(owner), get_type_nr(owner));
947 printf (" allocation: ");
948 switch (get_entity_allocation(ent)) {
949 X(allocation_dynamic);
950 X(allocation_automatic);
951 X(allocation_static);
952 X(allocation_parameter);
955 printf ("\n visibility: ");
956 switch (get_entity_visibility(ent)) {
958 X(visibility_external_visible);
959 X(visibility_external_allocated);
962 printf ("\n variability: ");
963 switch (get_entity_variability(ent)) {
964 X(variability_uninitialized);
965 X(variability_initialized);
966 X(variability_part_constant);
967 X(variability_constant);
970 if (get_entity_variability(ent) != variability_uninitialized) {
971 if (is_atomic_entity(ent)) {
972 printf("\n atomic value: ");
973 dump_node_opcode(stdout, get_atomic_ent_value(ent));
975 printf("\n compound values:");
976 for (i = 0; i < get_compound_ent_n_values(ent); ++i) {
977 compound_graph_path *path = get_compound_ent_value_path(ent, i);
978 entity *ent0 = get_compound_graph_path_node(path, 0);
979 printf("\n %2d %s", get_entity_offset(ent0), get_entity_name(ent0));
980 for (j = 1; j < get_compound_graph_path_length(path); ++j)
981 printf(".%s", get_entity_name(get_compound_graph_path_node(path, j)));
983 dump_node_opcode(stdout, get_compound_ent_value(ent, i));
988 printf ("\n volatility: ");
989 switch (get_entity_volatility(ent)) {
990 X(volatility_non_volatile);
991 X(volatility_is_volatile);
994 printf("\n peculiarity: %s", get_peculiarity_string(get_entity_peculiarity(ent)));
995 printf("\n ld_name: %s", ent->ld_name ? get_entity_ld_name(ent) : "no yet set");
996 printf("\n offset: %d", get_entity_offset(ent));
997 if (is_method_type(get_entity_type(ent))) {
998 if (get_entity_irg(ent)) /* can be null */
999 { printf ("\n irg = %ld", get_irg_graph_nr(get_entity_irg(ent))); }
1001 { printf ("\n irg = NULL"); }
1006 #else /* DEBUG_libfirm */
1007 void dump_entity (entity *ent) {}
1008 #endif /* DEBUG_libfirm */