Commit e153c020 authored by Michael Beck's avatar Michael Beck
Browse files

is_SymConst_addr_ent() added

[r17111]
parent b76f27ff
......@@ -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 */
......
......@@ -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)))
......
......@@ -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) {
......
......@@ -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
......
......@@ -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));
......
......@@ -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));
}
......
......@@ -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);
......
......@@ -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)
......
......@@ -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,
......
......@@ -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) {
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment