From e153c0201ad4b75fa63cacd746cf6295bde5cbdc Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Sun, 30 Dec 2007 16:35:17 +0000 Subject: [PATCH] is_SymConst_addr_ent() added [r17111] --- include/libfirm/irnode.h | 2 ++ ir/ana/cgana.c | 4 ++-- ir/ana/irmemory.c | 14 ++++++++------ ir/ana/trouts.c | 4 ++-- ir/ir/irdump.c | 2 +- ir/ir/irgopt.c | 2 +- ir/ir/irnode.c | 14 ++++++++++---- ir/ir/irnode_t.h | 6 ++++++ ir/ir/irvrfy.c | 9 +++++++-- ir/lower/lower_intrinsics.c | 5 ++--- ir/opt/ldstopt.c | 4 ++-- ir/opt/proc_cloning.c | 6 +----- ir/opt/tailrec.c | 2 +- 13 files changed, 45 insertions(+), 29 deletions(-) diff --git a/include/libfirm/irnode.h b/include/libfirm/irnode.h index 664832f4d..7535c3fda 100644 --- a/include/libfirm/irnode.h +++ b/include/libfirm/irnode.h @@ -1292,6 +1292,8 @@ int is_Confirm(const ir_node *node); int is_Pin(const ir_node *node); /** Returns true if node is a SymConst node. */ int is_SymConst(const ir_node *node); +/** Returns true if node is a SymConst node with kind symconst_addr_ent. */ +int is_SymConst_addr_ent(const ir_node *node); /** Returns true if node is a Cond node. */ int is_Cond(const ir_node *node); /** Returns true of node is a CopyB node */ diff --git a/ir/ana/cgana.c b/ir/ana/cgana.c index 35cca90c7..1dfa2c5f2 100644 --- a/ir/ana/cgana.c +++ b/ir/ana/cgana.c @@ -510,7 +510,7 @@ 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(n) && get_SymConst_kind(n) == symconst_addr_ent) { + if (is_SymConst_addr_ent(n)) { ent = get_SymConst_entity(n); if (is_Method_type(get_entity_type(ent))) @@ -521,7 +521,7 @@ 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(n) && get_SymConst_kind(n) == symconst_addr_ent) { + if (is_SymConst_addr_ent(n)) { ir_entity *ent = get_SymConst_entity(n); if (is_Method_type(get_entity_type(ent))) diff --git a/ir/ana/irmemory.c b/ir/ana/irmemory.c index 9ef0f7391..7f46e83a8 100644 --- a/ir/ana/irmemory.c +++ b/ir/ana/irmemory.c @@ -335,12 +335,12 @@ static ir_alias_relation different_types(ir_node *adr1, ir_node *adr2) { ir_entity *ent1 = NULL, *ent2 = NULL; - if (is_SymConst(adr1) && get_SymConst_kind(adr1) == symconst_addr_ent) + if (is_SymConst_addr_ent(adr1)) ent1 = get_SymConst_entity(adr1); else if (is_Sel(adr1)) ent1 = get_Sel_entity(adr1); - if (is_SymConst(adr2) && get_SymConst_kind(adr2) == symconst_addr_ent) + if (is_SymConst_addr_ent(adr2)) ent2 = get_SymConst_entity(adr2); else if (is_Sel(adr2)) ent2 = get_Sel_entity(adr2); @@ -468,9 +468,11 @@ static int is_arg_Proj(ir_node *node) { /** * 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(irn) && get_SymConst_kind(irn) == symconst_addr_ent; + return is_SymConst_addr_ent(irn); } /* is_global_var */ /** @@ -967,7 +969,7 @@ static void check_initializer(ir_entity *ent) { if (is_atomic_entity(ent)) { /* let's check if it's an address */ n = get_atomic_ent_value(ent); - if (is_SymConst(n) && get_SymConst_kind(n) == symconst_addr_ent) { + if (is_SymConst_addr_ent(n)) { ir_entity *ent = get_SymConst_entity(n); set_entity_address_taken(ent, ir_address_taken); } @@ -976,7 +978,7 @@ 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(n) && get_SymConst_kind(n) == symconst_addr_ent) { + if (is_SymConst_addr_ent(n)) { ir_entity *ent = get_SymConst_entity(n); set_entity_address_taken(ent, ir_address_taken); } @@ -1024,7 +1026,7 @@ static void check_global_address(ir_node *irn, void *env) { ir_entity *ent; ir_address_taken_state state; - if (is_SymConst(irn) && get_SymConst_kind(irn) == symconst_addr_ent) { + if (is_SymConst_addr_ent(irn)) { /* A global. */ ent = get_SymConst_entity(irn); } else if (is_Sel(irn) && get_Sel_ptr(irn) == tls) { diff --git a/ir/ana/trouts.c b/ir/ana/trouts.c index 73e6f5897..8624cb431 100644 --- a/ir/ana/trouts.c +++ b/ir/ana/trouts.c @@ -553,10 +553,10 @@ static void chain_accesses(ir_node *n, void *env) { return; } else - if (get_irn_op(n) == op_Sel) { + if (is_Sel(n)) { add_entity_reference(get_Sel_entity(n), n); return; - } else if (get_irn_op(n) == op_SymConst && (get_SymConst_kind(n) == symconst_addr_ent)) { + } else if (is_SymConst_addr_ent(n)) { add_entity_reference(get_SymConst_entity(n), n); return; } else diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index de401e300..8757ebcc8 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -802,7 +802,7 @@ 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 ((get_irn_op(addr) == op_SymConst) && (get_SymConst_kind(addr) == symconst_addr_ent)) + else if (is_SymConst_addr_ent(addr)) ent = get_SymConst_entity(addr); fprintf(F, "%s", get_irn_opname(n)); if (ent) fprintf(F, " %s", get_entity_name(ent)); diff --git a/ir/ir/irgopt.c b/ir/ir/irgopt.c index ac02ba8de..cec08921f 100644 --- a/ir/ir/irgopt.c +++ b/ir/ir/irgopt.c @@ -1340,7 +1340,7 @@ static ir_graph *get_call_called_irg(ir_node *call) { ir_graph *called_irg = NULL; addr = get_Call_ptr(call); - if (is_SymConst(addr) && get_SymConst_kind(addr) == symconst_addr_ent) { + if (is_SymConst_addr_ent(addr)) { called_irg = get_entity_irg(get_SymConst_entity(addr)); } diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index c1deaf2e3..b1c00a5a4 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -2780,25 +2780,31 @@ int return _is_Sync(node); } -/* returns true if node is a Confirm node. */ +/* Returns true if node is a Confirm node. */ int (is_Confirm)(const ir_node *node) { return _is_Confirm(node); } -/* returns true if node is a Pin node. */ +/* Returns true if node is a Pin node. */ int (is_Pin)(const ir_node *node) { return _is_Pin(node); } -/* returns true if node is a SymConst node. */ +/* Returns true if node is a SymConst node. */ int (is_SymConst)(const ir_node *node) { return _is_SymConst(node); } -/* returns true if node is a Cond node. */ +/* Returns true if node is a SymConst node with kind symconst_addr_ent. */ +int +(is_SymConst_addr_ent)(const ir_node *node) { + return _is_SymConst_addr_ent(node); +} + +/* Returns true if node is a Cond node. */ int (is_Cond)(const ir_node *node) { return _is_Cond(node); diff --git a/ir/ir/irnode_t.h b/ir/ir/irnode_t.h index 2d6208292..3f040db67 100644 --- a/ir/ir/irnode_t.h +++ b/ir/ir/irnode_t.h @@ -667,6 +667,11 @@ _is_SymConst(const ir_node *node) { return (_get_irn_op(node) == op_SymConst); } +static INLINE int +_is_SymConst_addr_ent(const ir_node *node) { + return is_SymConst(node) && get_SymConst_kind(node) == symconst_addr_ent; +} + static INLINE int _is_Cond(const ir_node *node) { assert(node); @@ -940,6 +945,7 @@ static INLINE void _set_irn_dbg_info(ir_node *n, dbg_info *db) { #define is_Confirm(node) _is_Confirm(node) #define is_Pin(node) _is_Pin(node) #define is_SymConst(node) _is_SymConst(node) +#define is_SymConst_addr_ent(node) _is_SymConst_addr_ent(node) #define is_Cond(node) _is_Cond(node) #define is_CopyB(node) _is_CopyB(node) #define is_Cmp(node) _is_Cmp(node) diff --git a/ir/ir/irvrfy.c b/ir/ir/irvrfy.c index e6cc6321c..62e5e7e35 100644 --- a/ir/ir/irvrfy.c +++ b/ir/ir/irvrfy.c @@ -277,11 +277,15 @@ static void show_phi_inputs(ir_node *phi, ir_node *block) { #endif /* #ifndef NDEBUG */ -/** If the address is Sel or SymConst, return the entity. */ +/** + * If the address is Sel or SymConst, return the entity. + * + * @param ptr the node representing the address + */ static ir_entity *get_ptr_entity(ir_node *ptr) { if (get_irn_op(ptr) == op_Sel) { return get_Sel_entity(ptr); - } else if ((get_irn_op(ptr) == op_SymConst) && (get_SymConst_kind(ptr) == symconst_addr_ent)) { + } else if (is_SymConst_addr_ent(ptr)) { return get_SymConst_entity(ptr); } return NULL; @@ -388,6 +392,7 @@ static int verify_node_Proj_Call(ir_node *n, ir_node *p) { "wrong Proj from Call", 0, show_proj_failure(p); ); + /* if we have exception flow, we must have a real Memory input */ if (proj == pn_Call_X_regular) ASSERT_AND_RET( get_irn_op(get_Call_mem(n)) != op_NoMem, diff --git a/ir/lower/lower_intrinsics.c b/ir/lower/lower_intrinsics.c index 873f27062..34fd9bce8 100644 --- a/ir/lower/lower_intrinsics.c +++ b/ir/lower/lower_intrinsics.c @@ -63,8 +63,7 @@ static void call_mapper(ir_node *node, void *env) { ir_entity *ent; symconst = get_Call_ptr(node); - if (get_irn_op(symconst) != op_SymConst || - get_SymConst_kind(symconst) != symconst_addr_ent) + if (! is_SymConst_addr_ent(symconst)) return; ent = get_SymConst_entity(symconst); @@ -481,7 +480,7 @@ 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(ptr) && get_SymConst_kind(ptr) == symconst_addr_ent) { + if (is_SymConst_addr_ent(ptr)) { ir_entity *ent = get_SymConst_entity(ptr); if (get_entity_variability(ent) == variability_constant) { diff --git a/ir/opt/ldstopt.c b/ir/opt/ldstopt.c index 3af1d8703..7769e6e28 100644 --- a/ir/opt/ldstopt.c +++ b/ir/opt/ldstopt.c @@ -446,7 +446,7 @@ static unsigned is_Call_pure(ir_node *call) { /* try the called entity */ ir_node *ptr = get_Call_ptr(call); - if (is_SymConst(ptr) && get_SymConst_kind(ptr) == symconst_addr_ent) { + if (is_SymConst_addr_ent(ptr)) { ir_entity *ent = get_SymConst_entity(ptr); prop = get_entity_additional_properties(ent); @@ -1352,7 +1352,7 @@ static void move_loads_out_of_loops(scc *pscc, loop_env *env) { continue; /* for now, we can only handle Load(SymConst) */ - if (! is_SymConst(ptr) || get_SymConst_kind(ptr) != symconst_addr_ent) + if (! is_SymConst_addr_ent(ptr)) continue; ent = get_SymConst_entity(ptr); load_mode = get_Load_mode(load); diff --git a/ir/opt/proc_cloning.c b/ir/opt/proc_cloning.c index 591278428..ee8015058 100644 --- a/ir/opt/proc_cloning.c +++ b/ir/opt/proc_cloning.c @@ -187,11 +187,7 @@ static void collect_irg_calls(ir_node *call, void *env) { if (is_Call(call)) { call_ptr = get_Call_ptr(call); - /* Call pointer must be a SymConst*/ - if (op_SymConst != get_irn_op(call_ptr)) - return; - /* Call pointer must be the address of an entity.*/ - if (get_SymConst_kind(call_ptr) != symconst_addr_ent) + if (! is_SymConst_addr_ent(call_ptr)) return; callee = get_SymConst_entity(call_ptr); diff --git a/ir/opt/tailrec.c b/ir/opt/tailrec.c index 0d10cdc9d..43e309315 100644 --- a/ir/opt/tailrec.c +++ b/ir/opt/tailrec.c @@ -342,7 +342,7 @@ int opt_tail_rec_irg(ir_graph *irg) { /* check if it's a recursive call */ call_ptr = get_Call_ptr(call); - if (! is_SymConst(call_ptr) || get_SymConst_kind(call_ptr) != symconst_addr_ent) + if (! is_SymConst_addr_ent(call_ptr)) continue; ent = get_SymConst_entity(call_ptr); -- 2.20.1