Commit ecadb91d authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Remove the parameter mode from new_*_Address().

Deduce the mode automatically from the given entity.
parent eb294bb1
......@@ -627,7 +627,7 @@ void be_map_exc_node_to_runtime_call(ir_node *node, ir_mode *res_mode,
ir_graph *irg = get_irn_irg(node);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *addr = new_r_Address(irg, mode_P_code, runtime_entity);
ir_node *addr = new_r_Address(irg, runtime_entity);
ir_node *block = get_nodes_block(node);
ir_node *mem = get_memop_mem(node);
ir_node *call = new_rd_Call(dbgi, block, mem, addr, n_in, in, mtp);
......
......@@ -106,7 +106,7 @@ static void fix_pic_addresses(ir_node *node, void *data)
continue;
ir_entity *const trampoline = get_trampoline(be, entity);
ir_node *const trampoline_const = new_rd_Address(dbgi, irg, mode_P_code, trampoline);
ir_node *const trampoline_const = new_rd_Address(dbgi, irg, trampoline);
set_irn_n(node, i, trampoline_const);
continue;
} else if (get_entity_type(entity) == get_code_type()) {
......@@ -130,7 +130,7 @@ static void fix_pic_addresses(ir_node *node, void *data)
/* get entry from pic symbol segment */
ir_entity *const pic_symbol = get_pic_symbol(be, entity);
ir_node *const pic_address = new_rd_Address(dbgi, irg, mode_P_code, pic_symbol);
ir_node *const pic_address = new_rd_Address(dbgi, irg, pic_symbol);
ir_node *const add = new_r_Add(block, pic_base, pic_address, mode);
mark_irn_visited(add);
......
......@@ -60,7 +60,7 @@ void instrument_initcall(ir_graph *irg, ir_entity *ent)
}
/* place the call */
ir_node *const adr = new_r_Address(irg, mode_P_code, ent);
ir_node *const adr = new_r_Address(irg, ent);
ir_node *const initial_mem = get_irg_initial_mem(irg);
ir_node *const call = new_r_Call(first_block, initial_mem, adr, 0, NULL, get_entity_type(ent));
ir_node *const new_mem = new_r_Proj(call, mode_M, pn_Call_M);
......
......@@ -262,7 +262,7 @@ ir_node *duplicate_subgraph(dbg_info *dbg, ir_node *n, ir_node *block)
ir_mode *mode = get_irn_mode(n);
switch (get_irn_opcode(n)) {
case iro_Address:
return new_rd_Address(dbg, irg, mode, get_Address_entity(n));
return new_rd_Address(dbg, irg, get_Address_entity(n));
case iro_Const:
return new_rd_Const(dbg, irg, get_Const_tarval(n));
case iro_Offset:
......
......@@ -143,7 +143,7 @@ static void add_constructor(ir_entity *method)
ident *ide = id_unique("constructor_ptr.%u");
ir_entity *ptr = new_entity(constructors, ide, ptr_type);
ir_graph *irg = get_const_code_irg();
ir_node *val = new_r_Address(irg, mode_P_code, method);
ir_node *val = new_r_Address(irg, method);
set_entity_ld_ident(ptr, new_id_from_chars("", 0));
set_entity_compiler_generated(ptr, 1);
......@@ -209,10 +209,10 @@ static ir_graph *gen_initializer_irg(ir_entity *ent_filename,
bb = get_r_cur_block(irg);
ir_node *const callee = new_r_Address(irg, mode_P_data, init_ent);
ir_node *const callee = new_r_Address(irg, init_ent);
ins[0] = new_r_Address(irg, mode_P_data, ent_filename);
ins[1] = new_r_Address(irg, mode_P_data, bblock_counts);
ins[0] = new_r_Address(irg, ent_filename);
ins[1] = new_r_Address(irg, bblock_counts);
ins[2] = new_r_Const_long(irg, mode_Iu, n_blocks);
call = new_r_Call(bb, get_irg_initial_mem(irg), callee, 3, ins,
......@@ -341,7 +341,7 @@ static void instrument_irg(ir_graph *irg, ir_entity *counters,
int i;
/* generate a node pointing to the count array */
wd->counters = new_r_Address(irg, mode_P_data, counters);
wd->counters = new_r_Address(irg, counters);
/* instrument each block in the current irg */
irg_block_walk_graph(irg, block_instrument_walker, NULL, wd);
......
......@@ -520,8 +520,9 @@ static int mode_is_datab(const ir_mode *mode)
static int verify_node_Address(const ir_node *n)
{
bool fine = check_mode_func(n, mode_is_reference, "reference");
ir_entity *ent = get_Address_entity(n);
ir_type *type = get_entity_type(ent);
bool fine = check_mode(n, get_type_pointer_mode(type));
if (!(get_entity_owner(ent)->flags & tf_segment) && !is_method_entity(ent)) {
warn(n, "entity of %+F is not in a segment type but %+F", ent, get_entity_owner(ent));
fine = false;
......
......@@ -90,7 +90,7 @@ static void replace_with_call(ir_node *node)
pmap_insert(entities, id, entity);
}
ir_node *const callee = new_r_Address(irg, mode_P, entity);
ir_node *const callee = new_r_Address(irg, entity);
call = new_rd_Call(dbgi, block, mem, callee, n_params, params, mtp);
call_mem = new_r_Proj(call, mode_M, pn_Call_M);
call_ress = new_r_Proj(call, mode_T, pn_Call_T_result);
......
......@@ -117,7 +117,7 @@ static ir_node *get_memcpy_address(ir_graph *irg)
ir_type *mt = get_memcpy_methodtype();
ir_entity *ent = create_compilerlib_entity(id, mt);
return new_r_Address(irg, mode_P_code, ent);
return new_r_Address(irg, ent);
}
/**
......
......@@ -486,7 +486,7 @@ static ir_node *get_intrinsic_address(ir_type *method, ir_op *op,
assert(ent && "Intrinsic creator must return an entity");
entry->ent = ent;
}
return new_r_Address(env->irg, mode_P_code, ent);
return new_r_Address(env->irg, ent);
}
/**
......
......@@ -279,7 +279,7 @@ static ir_node *create_softfloat_address(const ir_node *n, const char *name)
ir_graph *const irg = get_irn_irg(n);
ident *const id = new_id_from_str(buf);
ir_entity *const ent = create_compilerlib_entity(id, method);
return new_r_Address(irg, mode_P_code, ent);
return new_r_Address(irg, ent);
}
static ir_node *make_softfloat_call(ir_node *const n, char const *const name, size_t const arity, ir_node *const *const in)
......
......@@ -3281,7 +3281,7 @@ static void apply_result(ir_node *irn, void *ctx)
} else if (is_entity(node->type.ent)) {
if (!is_Address(irn)) {
/* can be replaced by an Address */
ir_node *entc = new_r_Address(current_ir_graph, get_irn_mode(irn), node->type.ent);
ir_node *entc = new_r_Address(current_ir_graph, node->type.ent);
set_irn_node(entc, node);
node->node = entc;
......
......@@ -421,7 +421,7 @@ static ir_node *new_cl_Call(ir_node *call, ir_entity *new_entity, size_t pos)
ir_graph *irg = get_irn_irg(call);
ir_node *bl = get_nodes_block(call);
ir_node *const callee = new_r_Address(irg, mode_P_code, new_entity);
ir_node *const callee = new_r_Address(irg, new_entity);
n_params = get_Call_n_params(call);
ir_node **in = ALLOCAN(ir_node*, n_params-1);
......
......@@ -65,7 +65,7 @@ ir_entity *new_entity(ir_type *owner, ident *name, ir_type *type)
if (is_Method_type(type)) {
ir_graph *irg = get_const_code_irg();
res = intern_new_entity(owner, IR_ENTITY_METHOD, name, type);
ir_node *const val = new_r_Address(irg, mode_P_code, res);
ir_node *const val = new_r_Address(irg, res);
set_atomic_ent_value(res, val);
res->linkage = IR_LINKAGE_CONSTANT;
res->attr.mtd_attr.properties = get_method_additional_properties(type);
......
......@@ -1259,14 +1259,8 @@ void set_array_size(ir_type *tp, unsigned size)
ir_type *new_type_pointer(ir_type *points_to)
{
ir_mode *mode;
if (is_Method_type(points_to) || is_code_type(points_to)) {
mode = mode_P_code;
} else {
mode = mode_P_data;
}
ir_type *res = new_type(type_pointer, mode);
ir_mode *const mode = get_type_pointer_mode(points_to);
ir_type *const res = new_type(type_pointer, mode);
res->attr.pa.points_to = points_to;
res->size = get_mode_size_bytes(res->mode);
res->flags |= tf_layout_fixed;
......
......@@ -542,4 +542,9 @@ static inline bool is_aggregate_type(const ir_type *type)
ir_type *new_type_segment(ident *name, type_flags flags);
static inline ir_mode *get_type_pointer_mode(ir_type *const type)
{
return is_Method_type(type) || is_code_type(type) ? mode_P_code : mode_P_data;
}
#endif /* FIRM_TR_TYPE_T_H */
......@@ -48,6 +48,7 @@ class Add(Binop):
@op
class Address(EntConst):
"""Symbolic constant that represents the address of an entity (variable or method)"""
mode = "get_type_pointer_mode(get_entity_type(entity))"
@op
class Alloc:
......
Markdown is supported
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