From: Michael Beck Date: Wed, 2 Apr 2008 14:08:02 +0000 (+0000) Subject: used new is_Global() and get_Global_entity() instead of SymConst calls X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=36332e717eebd9b98603a99ea24e390a1d2aa3be;p=libfirm used new is_Global() and get_Global_entity() instead of SymConst calls [r19066] --- diff --git a/include/libfirm/irnode.h b/include/libfirm/irnode.h index 6349de0ff..5bf8bd2f4 100644 --- a/include/libfirm/irnode.h +++ b/include/libfirm/irnode.h @@ -1417,7 +1417,7 @@ void set_Cond_jmp_pred(ir_node *cond, cond_jmp_predicate pred); int is_Global(const ir_node *node); /* Returns the entity of a global address. */ -ir_entity *get_Global_ent(const ir_node *node); +ir_entity *get_Global_entity(const ir_node *node); /** * Access custom node data. diff --git a/ir/ana/cgana.c b/ir/ana/cgana.c index 3e6893850..dd06f0c97 100644 --- a/ir/ana/cgana.c +++ b/ir/ana/cgana.c @@ -487,8 +487,8 @@ static void add_method_address_intitialzer(ir_initializer_t *initializer, ir_node *n = initializer->consti.value; /* let's check if it's the address of a function */ - if (is_SymConst_addr_ent(n)) { - ir_entity *ent = get_SymConst_entity(n); + if (is_Global(n)) { + ir_entity *ent = get_Global_entity(n); if (is_Method_type(get_entity_type(ent))) eset_insert(set, ent); @@ -544,8 +544,8 @@ static void add_method_address(ir_entity *ent, eset *set) /* let's check if it's the address of a function */ n = get_atomic_ent_value(ent); - if (is_SymConst_addr_ent(n)) { - ent = get_SymConst_entity(n); + if (is_Global(n)) { + ent = get_Global_entity(n); if (is_Method_type(get_entity_type(ent))) eset_insert(set, ent); @@ -555,8 +555,8 @@ static void add_method_address(ir_entity *ent, eset *set) n = get_compound_ent_value(ent, i); /* let's check if it's the address of a function */ - if (is_SymConst_addr_ent(n)) { - ir_entity *ent = get_SymConst_entity(n); + if (is_Global(n)) { + ir_entity *ent = get_Global_entity(n); if (is_Method_type(get_entity_type(ent))) eset_insert(set, ent); diff --git a/ir/ana/irmemory.c b/ir/ana/irmemory.c index c01ecdfc7..246090a9f 100644 --- a/ir/ana/irmemory.c +++ b/ir/ana/irmemory.c @@ -339,13 +339,13 @@ static ir_alias_relation different_types(ir_node *adr1, ir_node *adr2) { ir_entity *ent1 = NULL, *ent2 = NULL; - if (is_SymConst_addr_ent(adr1)) - ent1 = get_SymConst_entity(adr1); + if (is_Global(adr1)) + ent1 = get_Global_entity(adr1); else if (is_Sel(adr1)) ent1 = get_Sel_entity(adr1); - if (is_SymConst_addr_ent(adr2)) - ent2 = get_SymConst_entity(adr2); + if (is_Global(adr2)) + ent2 = get_Global_entity(adr2); else if (is_Sel(adr2)) ent2 = get_Sel_entity(adr2); @@ -407,8 +407,8 @@ static int is_malloc_Result(ir_node *node) { if (! is_Call(node)) return 0; node = get_Call_ptr(node); - if (is_SymConst_addr_ent(node)) { - ir_entity *ent = get_SymConst_entity(node); + if (is_Global(node)) { + ir_entity *ent = get_Global_entity(node); if (get_entity_additional_properties(ent) & mtp_property_malloc) return 1; @@ -417,15 +417,6 @@ static int is_malloc_Result(ir_node *node) { return 0; } /* is_malloc_Result */ -/** - * Returns true if an address represents a global variable. - * - * @param irn the node representing the address - */ -static INLINE int is_global_var(ir_node *irn) { - return is_SymConst_addr_ent(irn); -} /* is_global_var */ - /** * classify storage locations. * Except STORAGE_CLASS_POINTER they are all disjoint. @@ -453,8 +444,8 @@ typedef enum { static storage_class_class_t classify_pointer(ir_graph *irg, ir_node *irn, ir_entity *ent) { storage_class_class_t res = STORAGE_CLASS_POINTER; - if (is_SymConst_addr_ent(irn)) { - ir_entity *entity = get_SymConst_entity(irn); + if (is_Global(irn)) { + ir_entity *entity = get_Global_entity(irn); res = STORAGE_CLASS_GLOBALVAR; if (get_entity_address_taken(entity) == ir_address_not_taken) res |= STORAGE_CLASS_MODIFIER_NOTTAKEN; @@ -939,13 +930,13 @@ static void init_taken_flag(ir_type * tp) { static void check_initializer_nodes(ir_initializer_t *initializer) { - switch(initializer->kind) { + switch (initializer->kind) { case IR_INITIALIZER_CONST: { ir_node *n = initializer->consti.value; /* let's check if it's an address */ - if (is_SymConst_addr_ent(n)) { - ir_entity *ent = get_SymConst_entity(n); + if (is_Global(n)) { + ir_entity *ent = get_Global_entity(n); set_entity_address_taken(ent, ir_address_taken); } return; @@ -956,7 +947,7 @@ static void check_initializer_nodes(ir_initializer_t *initializer) case IR_INITIALIZER_COMPOUND: { size_t i; - for(i = 0; i < initializer->compound.n_initializers; ++i) { + for (i = 0; i < initializer->compound.n_initializers; ++i) { ir_initializer_t *sub_initializer = initializer->compound.initializers[i]; check_initializer_nodes(sub_initializer); @@ -988,8 +979,8 @@ static void check_initializer(ir_entity *ent) { } else if (is_atomic_entity(ent)) { /* let's check if it's an address */ n = get_atomic_ent_value(ent); - if (is_SymConst_addr_ent(n)) { - ir_entity *ent = get_SymConst_entity(n); + if (is_Global(n)) { + ir_entity *ent = get_Global_entity(n); set_entity_address_taken(ent, ir_address_taken); } } else { @@ -997,8 +988,8 @@ static void check_initializer(ir_entity *ent) { n = get_compound_ent_value(ent, i); /* let's check if it's an address */ - if (is_SymConst_addr_ent(n)) { - ir_entity *ent = get_SymConst_entity(n); + if (is_Global(n)) { + ir_entity *ent = get_Global_entity(n); set_entity_address_taken(ent, ir_address_taken); } } @@ -1045,9 +1036,9 @@ static void check_global_address(ir_node *irn, void *env) { ir_entity *ent; ir_address_taken_state state; - if (is_SymConst_addr_ent(irn)) { + if (is_Global(irn)) { /* A global. */ - ent = get_SymConst_entity(irn); + ent = get_Global_entity(irn); } else if (is_Sel(irn) && get_Sel_ptr(irn) == tls) { /* A TLS variable. */ ent = get_Sel_entity(irn); diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 081072008..7380e6a88 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -802,8 +802,8 @@ int dump_node_opcode(FILE *F, ir_node *n) ir_entity *ent = NULL; if (get_irn_op(addr) == op_Sel) ent = get_Sel_entity(addr); - else if (is_SymConst_addr_ent(addr)) - ent = get_SymConst_entity(addr); + else if (is_Global(addr)) + ent = get_Global_entity(addr); fprintf(F, "%s", get_irn_opname(n)); if (ent) fprintf(F, " %s", get_entity_name(ent)); break; diff --git a/ir/ir/irgopt.c b/ir/ir/irgopt.c index 8be65852c..f7dff8b93 100644 --- a/ir/ir/irgopt.c +++ b/ir/ir/irgopt.c @@ -88,7 +88,7 @@ static INLINE void do_local_optimize(ir_node *n) { assert(get_irg_phase_state(current_ir_graph) != phase_building); if (get_opt_global_cse()) - set_irg_pinned(current_ir_graph, op_pin_state_floats); + set_irg_pinned(current_ir_graph, op_pin_state_floats); set_irg_outs_inconsistent(current_ir_graph); set_irg_doms_inconsistent(current_ir_graph); set_irg_loopinfo_inconsistent(current_ir_graph); @@ -1359,8 +1359,8 @@ static ir_graph *get_call_called_irg(ir_node *call) { ir_node *addr; addr = get_Call_ptr(call); - if (is_SymConst_addr_ent(addr)) { - ir_entity *ent = get_SymConst_entity(addr); + if (is_Global(addr)) { + ir_entity *ent = get_Global_entity(addr); return get_entity_irg(ent); } @@ -1499,8 +1499,8 @@ static void collect_calls2(ir_node *call, void *ctx) { if (env->ignore_runtime) { ir_node *symc = get_Call_ptr(call); - if (is_SymConst_addr_ent(symc)) { - ir_entity *ent = get_SymConst_entity(symc); + if (is_Global(symc)) { + ir_entity *ent = get_Global_entity(symc); if (get_entity_additional_properties(ent) & mtp_property_runtime) return; diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index b3ebc104b..45f56fdbb 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -3098,7 +3098,7 @@ int is_Global(const ir_node *node) { } /* returns the entity of a global address */ -ir_entity *get_Global_ent(const ir_node *node) { +ir_entity *get_Global_entity(const ir_node *node) { if (is_SymConst(node)) return get_SymConst_entity(node); else diff --git a/ir/lower/lower_hl.c b/ir/lower/lower_hl.c index e243cee87..dcbf9e8c7 100644 --- a/ir/lower/lower_hl.c +++ b/ir/lower/lower_hl.c @@ -52,13 +52,14 @@ static void lower_sel(ir_node *sel) { assert(is_Sel(sel)); + /* Do not lower frame type/global offset table access: must be lowered by the backend. */ + ptr = get_Sel_ptr(sel); + if (ptr == get_irg_frame(current_ir_graph) || ptr == get_irg_globals(current_ir_graph)) + return; + ent = get_Sel_entity(sel); owner = get_entity_owner(ent); - /* Do not lower frame type access: must be lowered by the backend. */ - if (is_frame_type(owner)) - return; - /* * Cannot handle value param entities here. * Must be lowered by the backend. @@ -66,7 +67,6 @@ static void lower_sel(ir_node *sel) { if (is_value_param_type(owner)) return; - ptr = get_Sel_ptr(sel); dbg = get_irn_dbg_info(sel); mode = get_irn_mode(sel); diff --git a/ir/lower/lower_intrinsics.c b/ir/lower/lower_intrinsics.c index 281c9eb8c..78c81054e 100644 --- a/ir/lower/lower_intrinsics.c +++ b/ir/lower/lower_intrinsics.c @@ -64,10 +64,10 @@ static void call_mapper(ir_node *node, void *env) { ir_entity *ent; symconst = get_Call_ptr(node); - if (! is_SymConst_addr_ent(symconst)) + if (! is_Global(symconst)) return; - ent = get_SymConst_entity(symconst); + ent = get_Global_entity(symconst); p = pmap_find(wenv->c_map, ent); if (p) { @@ -484,8 +484,8 @@ int i_mapper_tanh(ir_node *call, void *ctx) { */ static ir_entity *get_const_entity(ir_node *ptr) { /* FIXME: this cannot handle constant strings inside struct initializers yet */ - if (is_SymConst_addr_ent(ptr)) { - ir_entity *ent = get_SymConst_entity(ptr); + if (is_Global(ptr)) { + ir_entity *ent = get_Global_entity(ptr); if (get_entity_variability(ent) == variability_constant) { /* a constant entity */ diff --git a/ir/opt/funccall.c b/ir/opt/funccall.c index 9ec461522..8fb3d0cdf 100644 --- a/ir/opt/funccall.c +++ b/ir/opt/funccall.c @@ -90,8 +90,8 @@ static void collect_const_and_pure_calls(ir_node *node, void *env) { /* set the link to NULL for all non-const/pure calls */ set_irn_link(call, NULL); ptr = get_Call_ptr(call); - if (is_SymConst_addr_ent(ptr)) { - ent = get_SymConst_entity(ptr); + if (is_Global(ptr)) { + ent = get_Global_entity(ptr); prop = get_entity_additional_properties(ent); if ((prop & (mtp_property_const|mtp_property_pure)) == 0) @@ -261,8 +261,8 @@ static void collect_nothrow_calls(ir_node *node, void *env) { /* set the link to NULL for all non-const/pure calls */ set_irn_link(call, NULL); ptr = get_Call_ptr(call); - if (is_SymConst_addr_ent(ptr)) { - ent = get_SymConst_entity(ptr); + if (is_Global(ptr)) { + ent = get_Global_entity(ptr); prop = get_entity_additional_properties(ent); if ((prop & mtp_property_nothrow) == 0) @@ -677,8 +677,8 @@ static int is_malloc_call_result(const ir_node *node) { if (is_alloc_entity != NULL && is_Call(node)) { ir_node *ptr = get_Call_ptr(node); - if (is_SymConst_addr_ent(ptr)) { - ir_entity *ent = get_SymConst_entity(ptr); + if (is_Global(ptr)) { + ir_entity *ent = get_Global_entity(ptr); return is_alloc_entity(ent); } } @@ -723,8 +723,8 @@ static int is_stored(const ir_node *n) { break; case iro_Call: ptr = get_Call_ptr(succ); - if (is_SymConst_addr_ent(ptr)) { - ir_entity *ent = get_SymConst_entity(ptr); + if (is_Global(ptr)) { + ir_entity *ent = get_Global_entity(ptr); int i; /* we know the called entity */ @@ -831,9 +831,9 @@ static unsigned check_nothrow_or_malloc(ir_graph *irg, int top) { } else if (is_Call(res)) { ir_node *ptr = get_Call_ptr(res); - if (is_SymConst_addr_ent(ptr)) { + if (is_Global(ptr)) { /* a direct call */ - ir_entity *ent = get_SymConst_entity(ptr); + ir_entity *ent = get_Global_entity(ptr); ir_graph *callee = get_entity_irg(ent); if (callee == irg) { @@ -887,9 +887,9 @@ static unsigned check_nothrow_or_malloc(ir_graph *irg, int top) { if (is_Call(pred)) { ir_node *ptr = get_Call_ptr(pred); - if (is_SymConst_addr_ent(ptr)) { + if (is_Global(ptr)) { /* a direct call */ - ir_entity *ent = get_SymConst_entity(ptr); + ir_entity *ent = get_Global_entity(ptr); ir_graph *callee = get_entity_irg(ent); if (callee == irg) { diff --git a/ir/opt/ldstopt.c b/ir/opt/ldstopt.c index 07df1e91b..c1f214c08 100644 --- a/ir/opt/ldstopt.c +++ b/ir/opt/ldstopt.c @@ -446,8 +446,8 @@ static unsigned is_Call_pure(ir_node *call) { /* try the called entity */ ir_node *ptr = get_Call_ptr(call); - if (is_SymConst_addr_ent(ptr)) { - ir_entity *ent = get_SymConst_entity(ptr); + if (is_Global(ptr)) { + ir_entity *ent = get_Global_entity(ptr); prop = get_entity_additional_properties(ent); } @@ -1351,10 +1351,10 @@ static void move_loads_out_of_loops(scc *pscc, loop_env *env) { if (info->projs[pn_Load_res] == NULL || info->projs[pn_Load_X_regular] != NULL || info->projs[pn_Load_X_except] != NULL) continue; - /* for now, we can only handle Load(SymConst) */ - if (! is_SymConst_addr_ent(ptr)) + /* for now, we can only handle Load(Global) */ + if (! is_Global(ptr)) continue; - ent = get_SymConst_entity(ptr); + ent = get_Global_entity(ptr); load_mode = get_Load_mode(load); for (other = pscc->head; other != NULL; other = next_other) { node_entry *ne = get_irn_ne(other, env); diff --git a/ir/opt/proc_cloning.c b/ir/opt/proc_cloning.c index 82cbebb0d..70448fbb5 100644 --- a/ir/opt/proc_cloning.c +++ b/ir/opt/proc_cloning.c @@ -187,10 +187,10 @@ static void collect_irg_calls(ir_node *call, void *env) { if (is_Call(call)) { call_ptr = get_Call_ptr(call); - if (! is_SymConst_addr_ent(call_ptr)) + if (! is_Global(call_ptr)) return; - callee = get_SymConst_entity(call_ptr); + callee = get_Global_entity(call_ptr); /* we can only clone calls to existing entities */ if (get_entity_visibility(callee) == visibility_external_allocated) diff --git a/ir/opt/tailrec.c b/ir/opt/tailrec.c index e0e9aa8ec..a5e493884 100644 --- a/ir/opt/tailrec.c +++ b/ir/opt/tailrec.c @@ -632,10 +632,10 @@ int opt_tail_rec_irg(ir_graph *irg) { /* check if it's a recursive call */ call_ptr = get_Call_ptr(call); - if (! is_SymConst_addr_ent(call_ptr)) + if (! is_Global(call_ptr)) continue; - ent = get_SymConst_entity(call_ptr); + ent = get_Global_entity(call_ptr); if (!ent || get_entity_irg(ent) != irg) continue;