X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftr%2Fentity.c;h=818602338b2911996adff23cf75978de295da1e4;hb=67e3ef5e7088c2254daeb2a72e0950bef6ca0256;hp=85b745275830869e9e56cf3e5e8486685bc2ea41;hpb=9af385ef13d978ce31ec86c4f0c9916c7b196298;p=libfirm diff --git a/ir/tr/entity.c b/ir/tr/entity.c index 85b745275..818602338 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -13,6 +13,8 @@ # include # include +# include + # include "entity_t.h" # include "mangle.h" # include "typegmod_t.h" @@ -147,7 +149,7 @@ get_entity_ident (entity *ent) { } /* -void set_entity_ld_name (entity *, char *ld_name); +void set_entitye_ld_name (entity *, char *ld_name); void set_entity_ld_ident (entity *, ident *ld_ident); */ @@ -291,7 +293,8 @@ set_atomic_ent_value(entity *ent, ir_node *val) { ent->value = val; } -ir_node *copy_value(ir_node *n) { + +ir_node *copy_const_value(ir_node *n) { ir_node *nn; ir_mode *m; @@ -302,7 +305,7 @@ ir_node *copy_value(ir_node *n) { case iro_SymConst: nn = new_SymConst(get_SymConst_type_or_id(n), get_SymConst_kind(n)); break; case iro_Add: - nn = new_Add(copy_value(get_Add_left(n)), copy_value(get_Add_right(n)), m); break; + nn = new_Add(copy_const_value(get_Add_left(n)), copy_const_value(get_Add_right(n)), m); break; default: assert(0 && "opdope invalid or not implemented"); break; } @@ -313,7 +316,7 @@ ir_node *copy_value(ir_node *n) { in current_ir_graph. */ ir_node *copy_atomic_ent_value(entity *ent) { assert(ent && is_atomic_entity(ent) && (ent->variability != uninitialized)); - return copy_value(ent->value); + return copy_const_value(ent->value); } /* A value of a compound entity is a pair of value and the corresponding member of @@ -325,6 +328,21 @@ add_compound_ent_value(entity *ent, ir_node *val, entity *member) { ARR_APP1 (entity *, ent->val_ents, member); } +/* Copies the firm subgraph referenced by val to const_code_irg and adds + the node as constant initialization to ent. + The subgraph may not contain control flow operations. */ +inline void +copy_and_add_compound_ent_value(entity *ent, ir_node *val, entity *member) { + ir_graph *rem = current_ir_graph; + + assert(get_entity_variability(ent) != uninitialized); + current_ir_graph = get_const_code_irg(); + + val = copy_const_value(val); + add_compound_ent_value(ent, val, member); + current_ir_graph = rem; +} + inline int get_compound_ent_n_values(entity *ent) { assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized)); @@ -338,9 +356,10 @@ get_compound_ent_value(entity *ent, int pos) { } /* Copies the value i of the entity to current_block in current_ir_graph. */ -ir_node *copy_compound_ent_value(entity *ent, int pos) { +ir_node * +copy_compound_ent_value(entity *ent, int pos) { assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized)); - return copy_value(ent->values[pos+1]); + return copy_const_value(ent->values[pos+1]); } inline entity * @@ -472,7 +491,10 @@ get_entity_irg(entity *ent) { inline void set_entity_irg(entity *ent, ir_graph *irg) { assert (ent && ent->type); - assert (irg); + /* Wie kann man die Referenz auf einen IRG löschen, z.B. wenn die + * Methode selbst nicht mehr aufgerufen werden kann, die Entität + * aber erhalten bleiben soll. */ + /* assert (irg); */ assert (is_method_type(ent->type)); assert (ent->peculiarity == existent); ent->irg = irg;