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 /* redeclared to declare INLINE. */
44 INLINE entity *get_entity_overwrites (entity *ent, int pos);
45 INLINE entity *get_entity_overwrittenby (entity *ent, int pos);
46 INLINE type *get_entity_owner (entity *ent);
48 INLINE void insert_entity_in_owner (entity *ent) {
49 type *owner = ent->owner;
50 switch (get_type_tpop_code(owner)) {
52 add_class_member (owner, ent);
55 add_struct_member (owner, ent);
58 add_union_member (owner, ent);
61 set_array_element_entity(owner, ent);
68 new_entity (type *owner, ident *name, type *type)
73 assert(!id_contains_char(name, ' ') && "entity name should not contain spaces");
75 res = (entity *) xmalloc (sizeof (entity));
77 assert_legal_owner_of_ent(owner);
82 if (get_type_tpop(type) == type_method)
83 res->allocation = allocation_static;
85 res->allocation = allocation_automatic;
87 res->visibility = visibility_local;
89 if (is_method_type(type)) {
90 res->variability = variability_constant;
91 rem = current_ir_graph;
92 current_ir_graph = get_const_code_irg();
93 res->value = new_Const(mode_P_mach, new_tarval_from_entity(res, mode_P_mach));
94 current_ir_graph = rem;
96 res->variability = variability_uninitialized;
99 res->val_paths = NULL;
101 res->peculiarity = peculiarity_existent;
102 res->volatility = volatility_non_volatile;
104 res->overwrites = NEW_ARR_F(entity *, 0);
105 res->overwrittenby = NEW_ARR_F(entity *, 0);
110 res->nr = get_irp_new_node_nr();
115 /* Remember entity in it's owner. */
116 insert_entity_in_owner (res);
120 new_d_entity (type *owner, ident *name, type *type, dbg_info *db) {
121 entity *res = new_entity(owner, name, type);
122 set_entity_dbg_info(res, db);
126 INLINE void free_compound_graph_path (compound_graph_path *gr);
127 INLINE int is_compound_graph_path(void *thing);
128 INLINE int get_compound_graph_path_length(compound_graph_path *gr);
129 INLINE entity *get_compound_graph_path_node(compound_graph_path *gr, int pos);
130 INLINE int get_compound_ent_n_values(entity *ent);
132 INLINE void free_entity_attrs(entity *ent) {
135 if (get_type_tpop(get_entity_owner(ent)) == type_class) {
136 DEL_ARR_F(ent->overwrites); ent->overwrites = NULL;
137 DEL_ARR_F(ent->overwrittenby); ent->overwrittenby = NULL;
139 //if (ent->values) DEL_ARR_F(ent->values); /* @@@ warum nich? */
140 if (ent->val_paths) {
141 if (is_compound_entity(ent))
142 for (i = 0; i < get_compound_ent_n_values(ent); i++)
143 if (ent->val_paths[i]) ;
144 /* free_compound_graph_path(ent->val_paths[i]) ; * @@@ warum nich? */
145 /* Geht nich: wird mehrfach verwendet!!! ==> mehrfach frei gegeben. */
146 //DEL_ARR_F(ent->val_paths);
148 ent->val_paths = NULL;
153 copy_entity_own (entity *old, type *new_owner) {
156 assert_legal_owner_of_ent(new_owner);
157 if (old->owner == new_owner) return old;
158 new = (entity *) xmalloc (sizeof (entity));
159 memcpy (new, old, sizeof (entity));
160 new->owner = new_owner;
162 if ((get_type_tpop(get_entity_owner(old)) == type_class) &&
163 (get_type_tpop(new_owner) == type_class)) {
164 new->overwrites = DUP_ARR_F(entity *, old->overwrites);
165 new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby);
166 } else if ((get_type_tpop(get_entity_owner(old)) != type_class) &&
167 (get_type_tpop(new_owner) == type_class)) {
168 new->overwrites = NEW_ARR_F(entity *, 0);
169 new->overwrittenby = NEW_ARR_F(entity *, 0);
172 if (is_class_type(new_owner)) {
173 new->overwrites = NEW_ARR_F(entity *, 0);
174 new->overwrittenby = NEW_ARR_F(entity *, 0);
177 new->nr = get_irp_new_node_nr();
180 insert_entity_in_owner (new);
186 copy_entity_name (entity *old, ident *new_name) {
189 if (old->name == new_name) return old;
190 new = (entity *) xmalloc (sizeof (entity));
191 memcpy (new, old, sizeof (entity));
192 new->name = new_name;
194 if (is_class_type(new->owner)) {
195 new->overwrites = DUP_ARR_F(entity *, old->overwrites);
196 new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby);
199 new->nr = get_irp_new_node_nr();
202 insert_entity_in_owner (new);
209 free_entity (entity *ent) {
210 free_tarval_entity(ent);
211 free_entity_attrs(ent);
216 /* Outputs a unique number for this node */
218 get_entity_nr(entity *ent) {
228 get_entity_name (entity *ent) {
230 return get_id_str(get_entity_ident(ent));
234 get_entity_ident (entity *ent) {
240 void set_entitye_ld_name (entity *, char *ld_name);
241 void set_entity_ld_ident (entity *, ident *ld_ident);
245 get_entity_owner (entity *ent) {
246 return ent->owner = skip_tid(ent->owner);
250 set_entity_owner (entity *ent, type *owner) {
251 assert_legal_owner_of_ent(owner);
255 INLINE void /* should this go into type.c? */
256 assert_legal_owner_of_ent(type *owner) {
257 assert (get_type_tpop_code(owner) == tpo_class ||
258 get_type_tpop_code(owner) == tpo_union ||
259 get_type_tpop_code(owner) == tpo_struct ||
260 get_type_tpop_code(owner) == tpo_array); /* Yes, array has an entity
261 -- to select fields! */
265 get_entity_ld_ident (entity *ent)
267 if (ent->ld_name == NULL)
268 ent->ld_name = mangle_entity (ent);
273 set_entity_ld_ident (entity *ent, ident *ld_ident) {
274 ent->ld_name = ld_ident;
278 get_entity_ld_name (entity *ent) {
279 return get_id_str(get_entity_ld_ident(ent));
283 char *get_entity_ld_name (entity *);
284 void set_entity_ld_name (entity *, char *ld_name);
288 get_entity_type (entity *ent) {
289 return ent->type = skip_tid(ent->type);
293 set_entity_type (entity *ent, type *type) {
298 INLINE ent_allocation
299 get_entity_allocation (entity *ent) {
300 return ent->allocation;
304 set_entity_allocation (entity *ent, ent_allocation al) {
305 ent->allocation = al;
308 /* return the name of the visibility */
309 const char *get_allocation_name(ent_allocation all)
311 #define X(a) case a: return #a
313 X(allocation_automatic);
314 X(allocation_parameter);
315 X(allocation_dynamic);
316 X(allocation_static);
317 default: return "BAD VALUE";
323 INLINE ent_visibility
324 get_entity_visibility (entity *ent) {
325 return ent->visibility;
329 set_entity_visibility (entity *ent, ent_visibility vis) {
330 if (vis != visibility_local)
331 assert((ent->allocation == allocation_static) ||
332 (ent->allocation == allocation_automatic));
333 /* @@@ Test that the owner type is not local, but how??
334 && get_class_visibility(get_entity_owner(ent)) != local));*/
335 ent->visibility = vis;
338 /* return the name of the visibility */
339 const char *get_visibility_name(ent_visibility vis)
341 #define X(a) case a: return #a
344 X(visibility_external_visible);
345 X(visibility_external_allocated);
346 default: return "BAD VALUE";
351 INLINE ent_variability
352 get_entity_variability (entity *ent) {
353 return ent->variability;
357 set_entity_variability (entity *ent, ent_variability var)
359 if (var == variability_part_constant)
360 assert(is_class_type(ent->type) || is_struct_type(ent->type));
362 if ((is_compound_type(ent->type)) &&
363 (ent->variability == variability_uninitialized) && (var != variability_uninitialized)) {
364 /* Allocate datastructures for constant values */
365 ent->values = NEW_ARR_F(ir_node *, 0);
366 ent->val_paths = NEW_ARR_F(compound_graph_path *, 0);
369 if ((is_compound_type(ent->type)) &&
370 (var == variability_uninitialized) && (ent->variability != variability_uninitialized)) {
371 /* Free datastructures for constant values */
372 DEL_ARR_F(ent->values); ent->values = NULL;
373 DEL_ARR_F(ent->val_paths); ent->val_paths = NULL;
375 ent->variability = var;
378 /* return the name of the variablity */
379 const char *get_variability_name(ent_variability var)
381 #define X(a) case a: return #a
383 X(variability_uninitialized);
384 X(variability_initialized);
385 X(variability_part_constant);
386 X(variability_constant);
387 default: return "BAD VALUE";
392 INLINE ent_volatility
393 get_entity_volatility (entity *ent) {
395 return ent->volatility;
399 set_entity_volatility (entity *ent, ent_volatility vol) {
401 ent->volatility = vol;
404 /* return the name of the volatility */
405 const char *get_volatility_name(ent_volatility var)
407 #define X(a) case a: return #a
409 X(volatility_non_volatile);
410 X(volatility_is_volatile);
411 default: return "BAD VALUE";
417 get_entity_peculiarity (entity *ent) {
419 return ent->peculiarity;
423 set_entity_peculiarity (entity *ent, peculiarity pec) {
425 /* @@@ why peculiarity only for methods? */
426 assert (is_method_type(ent->type));
427 ent->peculiarity = pec;
430 /* return the name of the peculiarity */
431 const char *get_peculiarity_name(peculiarity var)
433 #define X(a) case a: return #a
435 X(peculiarity_description);
436 X(peculiarity_inherited);
437 X(peculiarity_existent);
438 default: return "BAD VALUE";
443 /* Set has no effect for existent entities of type method. */
445 get_atomic_ent_value(entity *ent)
448 assert(is_atomic_entity(ent));
449 assert(ent->variability != variability_uninitialized);
454 set_atomic_ent_value(entity *ent, ir_node *val) {
455 assert(ent && is_atomic_entity(ent) && (ent->variability != variability_uninitialized));
456 if (is_method_type(ent->type) && (ent->peculiarity == peculiarity_existent))
461 /* Returns true if the the node is representable as code on
463 int is_irn_const_expression(ir_node *n) {
467 switch(get_irn_opcode(n)) {
473 if (is_irn_const_expression(get_Add_left(n)))
474 return is_irn_const_expression(get_Add_right(n));
477 return is_irn_const_expression(get_irn_n(n, 0));
486 ir_node *copy_const_value(ir_node *n) {
491 switch(get_irn_opcode(n)) {
493 nn = new_Const(m, get_Const_tarval(n)); break;
495 nn = new_SymConst(get_SymConst_type_or_id(n), get_SymConst_kind(n)); break;
497 nn = new_Add(copy_const_value(get_Add_left(n)),
498 copy_const_value(get_Add_right(n)), m); break;
500 nn = new_Cast(copy_const_value(get_Cast_op(n)), get_Cast_type(n)); break;
502 nn = new_Conv(copy_const_value(get_Conv_op(n)), m); break;
504 nn = new_Unknown(m); break;
507 assert(0 && "opdope invalid or not implemented");
514 compound_graph_path *
515 new_compound_graph_path(type *tp, int length) {
516 compound_graph_path *res;
517 assert(is_type(tp) && is_compound_type(tp));
520 res = (compound_graph_path *) malloc (sizeof(compound_graph_path) + (length-1) * sizeof(entity *));
521 res->kind = k_ir_compound_graph_path;
524 memset(res->nodes, 0, sizeof(entity *) * length);
529 free_compound_graph_path (compound_graph_path *gr) {
530 assert(gr && is_compound_graph_path(gr));
536 is_compound_graph_path(void *thing) {
537 return (get_kind(thing) == k_ir_compound_graph_path);
540 /* checks whether nodes 0..pos are correct (all lie on a path.) */
541 /* @@@ not implemented */
542 INLINE int is_proper_compound_graph_path(compound_graph_path *gr, int pos) {
545 type *owner = gr->tp;
546 for (i = 0; i <= pos; i++) {
547 node = get_compound_graph_path_node(gr, i);
548 if (get_entity_owner(node) != owner) return false;
549 owner = get_entity_type(node);
551 if (pos == get_compound_graph_path_length(gr))
552 if (!is_atomic_type(owner)) return false;
557 get_compound_graph_path_length(compound_graph_path *gr) {
558 assert(gr && is_compound_graph_path(gr));
563 get_compound_graph_path_node(compound_graph_path *gr, int pos) {
564 assert(gr && is_compound_graph_path(gr));
565 assert(pos >= 0 && pos < gr->len);
566 return gr->nodes[pos];
570 set_compound_graph_path_node(compound_graph_path *gr, int pos, entity *node) {
571 assert(gr && is_compound_graph_path(gr));
572 assert(pos >= 0 && pos < gr->len);
573 assert(is_entity(node));
574 gr->nodes[pos] = node;
575 assert(is_proper_compound_graph_path(gr, pos));
578 /* A value of a compound entity is a pair of value and the corresponding path to a member of
581 add_compound_ent_value_w_path(entity *ent, ir_node *val, compound_graph_path *path) {
582 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
583 ARR_APP1 (ir_node *, ent->values, val);
584 ARR_APP1 (compound_graph_path *, ent->val_paths, path);
588 set_compound_ent_value_w_path(entity *ent, ir_node *val, compound_graph_path *path, int pos) {
589 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
590 ent->values[pos] = val;
591 ent->val_paths[pos] = path;
595 get_compound_ent_n_values(entity *ent) {
596 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
597 return (ARR_LEN (ent->values));
601 get_compound_ent_value(entity *ent, int pos) {
602 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
603 return ent->values[pos];
606 INLINE compound_graph_path *
607 get_compound_ent_value_path(entity *ent, int pos) {
608 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
609 return ent->val_paths[pos];
613 remove_compound_ent_value(entity *ent, entity *value_ent) {
615 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
616 for (i = 0; i < (ARR_LEN (ent->val_paths)); i++) {
617 compound_graph_path *path = ent->val_paths[i];
618 if (path->nodes[path->len-1] == value_ent) {
619 for(; i < (ARR_LEN (ent->val_paths))-1; i++) {
620 ent->val_paths[i] = ent->val_paths[i+1];
621 ent->values[i] = ent->values[i+1];
623 ARR_SETLEN(entity*, ent->val_paths, ARR_LEN(ent->val_paths) - 1);
624 ARR_SETLEN(ir_node*, ent->values, ARR_LEN(ent->values) - 1);
631 add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
632 compound_graph_path *path;
633 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
634 path = new_compound_graph_path(get_entity_owner(ent), 1);
635 path->nodes[0] = member;
636 add_compound_ent_value_w_path(ent, val, path);
639 /* Copies the firm subgraph referenced by val to const_code_irg and adds
640 the node as constant initialization to ent.
641 The subgraph may not contain control flow operations.
643 copy_and_add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
644 ir_graph *rem = current_ir_graph;
646 assert(get_entity_variability(ent) != variability_uninitialized);
647 current_ir_graph = get_const_code_irg();
649 val = copy_const_value(val);
650 add_compound_ent_value(ent, val, member);
651 current_ir_graph = rem;
654 /* Copies the value i of the entity to current_block in current_ir_graph.
656 copy_compound_ent_value(entity *ent, int pos) {
657 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
658 return copy_const_value(ent->values[pos+1]);
662 get_compound_ent_value_member(entity *ent, 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);
667 return get_compound_graph_path_node(path, get_compound_graph_path_length(path)-1);
671 set_compound_ent_value(entity *ent, ir_node *val, entity *member, int pos) {
672 compound_graph_path *path;
673 assert(ent && is_compound_entity(ent) && (ent->variability != variability_uninitialized));
674 path = get_compound_ent_value_path(ent, pos);
675 set_compound_graph_path_node(path, 0, member);
676 set_compound_ent_value_w_path(ent, val, path, pos);
680 set_array_entity_values(entity *ent, tarval **values, int num_vals) {
682 ir_graph *rem = current_ir_graph;
683 type *arrtp = get_entity_type(ent);
686 assert(is_array_type(arrtp));
687 assert(get_array_n_dimensions(arrtp) == 1);
688 /* One bound is sufficient, the nunmber of constant fields makes the
690 assert(get_array_lower_bound (arrtp, 0) || get_array_upper_bound (arrtp, 0));
691 assert(get_entity_variability(ent) != variability_uninitialized);
692 current_ir_graph = get_const_code_irg();
694 for (i = 0; i < num_vals; i++) {
695 val = new_Const(get_tarval_mode (values[i]), values[i]);
696 add_compound_ent_value(ent, val, get_array_element_entity(arrtp));
698 current_ir_graph = rem;
702 get_entity_offset (entity *ent) {
707 set_entity_offset (entity *ent, int offset) {
708 ent->offset = offset;
712 add_entity_overwrites (entity *ent, entity *overwritten) {
714 assert(is_class_type(get_entity_owner(ent)));
715 ARR_APP1 (entity *, ent->overwrites, overwritten);
716 ARR_APP1 (entity *, overwritten->overwrittenby, ent);
720 get_entity_n_overwrites (entity *ent) {
722 assert(is_class_type(get_entity_owner(ent)));
723 return (ARR_LEN (ent->overwrites));
727 get_entity_overwrites_index(entity *ent, entity *overwritten) {
729 assert(ent && is_class_type(get_entity_owner(ent)));
730 for (i = 0; i < get_entity_n_overwrites(ent); i++)
731 if (get_entity_overwrites(ent, i) == overwritten)
737 get_entity_overwrites (entity *ent, int pos) {
739 assert(is_class_type(get_entity_owner(ent)));
740 assert(pos < get_entity_n_overwrites(ent));
741 return ent->overwrites[pos];
745 set_entity_overwrites (entity *ent, int pos, entity *overwritten) {
747 assert(is_class_type(get_entity_owner(ent)));
748 assert(pos < get_entity_n_overwrites(ent));
749 ent->overwrites[pos] = overwritten;
753 remove_entity_overwrites(entity *ent, entity *overwritten) {
755 assert(ent && is_class_type(get_entity_owner(ent)));
756 for (i = 0; i < (ARR_LEN (ent->overwrites)); i++)
757 if (ent->overwrites[i] == overwritten) {
758 for(; i < (ARR_LEN (ent->overwrites))-1; i++)
759 ent->overwrites[i] = ent->overwrites[i+1];
760 ARR_SETLEN(entity*, ent->overwrites, ARR_LEN(ent->overwrites) - 1);
766 add_entity_overwrittenby (entity *ent, entity *overwrites) {
768 assert(is_class_type(get_entity_owner(ent)));
769 add_entity_overwrites(overwrites, ent);
773 get_entity_n_overwrittenby (entity *ent) {
775 assert(is_class_type(get_entity_owner(ent)));
776 return (ARR_LEN (ent->overwrittenby));
780 get_entity_overwrittenby_index(entity *ent, entity *overwrites) {
782 assert(ent && is_class_type(get_entity_owner(ent)));
783 for (i = 0; i < get_entity_n_overwrittenby(ent); i++)
784 if (get_entity_overwrittenby(ent, i) == overwrites)
790 get_entity_overwrittenby (entity *ent, int pos) {
792 assert(is_class_type(get_entity_owner(ent)));
793 assert(pos < get_entity_n_overwrittenby(ent));
794 return ent->overwrittenby[pos];
798 set_entity_overwrittenby (entity *ent, int pos, entity *overwrites) {
800 assert(is_class_type(get_entity_owner(ent)));
801 assert(pos < get_entity_n_overwrittenby(ent));
802 ent->overwrittenby[pos] = overwrites;
805 void remove_entity_overwrittenby(entity *ent, entity *overwrites) {
807 assert(ent && is_class_type(get_entity_owner(ent)));
808 for (i = 0; i < (ARR_LEN (ent->overwrittenby)); i++)
809 if (ent->overwrittenby[i] == overwrites) {
810 for(; i < (ARR_LEN (ent->overwrittenby))-1; i++)
811 ent->overwrittenby[i] = ent->overwrittenby[i+1];
812 ARR_SETLEN(entity*, ent->overwrittenby, ARR_LEN(ent->overwrittenby) - 1);
817 /* A link to store intermediate information */
819 get_entity_link(entity *ent) {
825 set_entity_link(entity *ent, void *l) {
831 get_entity_irg(entity *ent) {
833 assert (is_method_type(ent->type));
838 set_entity_irg(entity *ent, ir_graph *irg) {
839 assert (ent && ent->type);
840 /* Wie kann man die Referenz auf einen IRG löschen, z.B. wenn die
841 * Methode selbst nicht mehr aufgerufen werden kann, die Entität
842 * aber erhalten bleiben soll. */
844 assert (is_method_type(ent->type));
845 assert (ent->peculiarity == peculiarity_existent);
849 int is_entity (void *thing) {
851 if (get_kind(thing) == k_entity)
857 int is_atomic_entity(entity *ent) {
858 type* t = get_entity_type(ent);
859 return (is_primitive_type(t) || is_pointer_type(t) ||
860 is_enumeration_type(t) || is_method_type(t));
863 int is_compound_entity(entity *ent) {
864 type* t = get_entity_type(ent);
865 return (is_class_type(t) || is_struct_type(t) ||
866 is_array_type(t) || is_union_type(t));
869 /* @@@ not implemnted!!! */
870 bool equal_entity(entity *ent1, entity *ent2) {
871 printf(" calling unimplemented equal entity!!! \n");
876 unsigned long get_entity_visited(entity *ent) {
880 void set_entity_visited(entity *ent, unsigned long num) {
884 /* Sets visited field in entity to entity_visited. */
885 void mark_entity_visited(entity *ent) {
887 ent->visit = type_visited;
891 INLINE bool entity_visited(entity *ent) {
892 return get_entity_visited(ent) >= type_visited;
895 INLINE bool entity_not_visited(entity *ent) {
896 return get_entity_visited(ent) < type_visited;
899 /* Need two routines because I want to assert the result. */
900 static INLINE entity *resolve_ent_polymorphy2 (type *dynamic_class, entity* static_ent) {
901 int i, n_overwrittenby;
904 if (get_entity_owner(static_ent) == dynamic_class) return static_ent;
906 n_overwrittenby = get_entity_n_overwrittenby(static_ent);
907 for (i = 0; i < n_overwrittenby; ++i) {
908 res = resolve_ent_polymorphy2(dynamic_class, get_entity_overwrittenby(static_ent, i));
915 /* Returns the dynamically referenced entity if the static entity and the
916 * dynamic type are given.
917 * Search downwards in overwritten tree. */
918 entity *resolve_ent_polymorphy(type *dynamic_class, entity* static_ent) {
919 entity *res = resolve_ent_polymorphy2(dynamic_class, static_ent);
921 printf(" Could not find entity "); DDME(static_ent);
922 printf(" in class"); DDMT(dynamic_class);
924 dump_entity(static_ent);
925 dump_type(get_entity_owner(static_ent));
926 dump_type(dynamic_class);
935 /*******************************************************************/
937 /*******************************************************************/
940 #if 1 || DEBUG_libfirm
941 INLINE int dump_node_opcode(FILE *F, ir_node *n); /* from irdump.c */
943 #define X(a) case a: printf(#a); break
944 void dump_entity (entity *ent) {
946 type *owner = get_entity_owner(ent);
947 type *type = get_entity_type(ent);
948 printf("entity %s (%ld)\n", get_entity_name(ent), get_entity_nr(ent));
949 printf(" type: %s (%ld)\n", get_type_name(type), get_type_nr(type));
950 printf(" owner: %s (%ld)\n", get_type_name(owner), get_type_nr(owner));
952 printf (" allocation: ");
953 switch (get_entity_allocation(ent)) {
954 X(allocation_dynamic);
955 X(allocation_automatic);
956 X(allocation_static);
957 X(allocation_parameter);
960 printf ("\n visibility: ");
961 switch (get_entity_visibility(ent)) {
963 X(visibility_external_visible);
964 X(visibility_external_allocated);
967 printf ("\n variability: ");
968 switch (get_entity_variability(ent)) {
969 X(variability_uninitialized);
970 X(variability_initialized);
971 X(variability_part_constant);
972 X(variability_constant);
975 if (get_entity_variability(ent) != variability_uninitialized) {
976 if (is_atomic_entity(ent)) {
977 printf("\n atomic value: ");
978 dump_node_opcode(stdout, get_atomic_ent_value(ent));
980 printf("\n compound values:");
981 for (i = 0; i < get_compound_ent_n_values(ent); ++i) {
982 compound_graph_path *path = get_compound_ent_value_path(ent, i);
983 entity *ent0 = get_compound_graph_path_node(path, 0);
984 printf("\n %2d %s", get_entity_offset(ent0), get_entity_name(ent0));
985 for (j = 1; j < get_compound_graph_path_length(path); ++j)
986 printf(".%s", get_entity_name(get_compound_graph_path_node(path, j)));
988 dump_node_opcode(stdout, get_compound_ent_value(ent, i));
993 printf ("\n volatility: ");
994 switch (get_entity_volatility(ent)) {
995 X(volatility_non_volatile);
996 X(volatility_is_volatile);
999 printf("\n peculiarity: %s", get_peculiarity_string(get_entity_peculiarity(ent)));
1000 printf("\n ld_name: %s", ent->ld_name ? get_entity_ld_name(ent) : "no yet set");
1001 printf("\n offset: %d", get_entity_offset(ent));
1002 if (is_method_type(get_entity_type(ent))) {
1003 if (get_entity_irg(ent)) /* can be null */
1004 { printf ("\n irg = %ld", get_irg_graph_nr(get_entity_irg(ent))); }
1006 { printf ("\n irg = NULL"); }
1011 #else /* DEBUG_libfirm */
1012 void dump_entity (entity *ent) {}
1013 #endif /* DEBUG_libfirm */