Commit 8eb7b1b9 authored by Andreas Fried's avatar Andreas Fried
Browse files

Provide Load nodes with the type of the object loaded from.

parent f7defa90
......@@ -1365,7 +1365,7 @@ static void modify_irg(ir_graph *const irg, be_abi_irg_t *const env)
ir_mode *load_mode = arg->load_mode;
ir_node *nomem = get_irg_no_mem(irg);
ir_node *load = new_r_Load(start_bl, nomem, addr, load_mode, cons_floats);
ir_node *load = new_r_Load(start_bl, nomem, addr, load_mode, param_type, cons_floats);
repl = new_r_Proj(load, load_mode, pn_Load_res);
if (mode != load_mode) {
......
......@@ -136,8 +136,9 @@ static void fix_pic_addresses(ir_node *node, void *data)
/* we need an extra indirection for global data outside our current
module. The loads are always safe and can therefore float
and need no memory input */
ir_type *const type = get_entity_type(entity);
ir_node *const load
= new_r_Load(block, get_irg_no_mem(irg), add, mode, cons_floats);
= new_r_Load(block, get_irg_no_mem(irg), add, mode, type, cons_floats);
ir_node *const load_res = new_r_Proj(load, mode, pn_Load_res);
set_irn_n(node, i, load_res);
......
......@@ -297,6 +297,7 @@ void dump_irnode_to_file(FILE *const F, const ir_node *const n)
case iro_Load:
fprintf(F, " mode of loaded value: %s\n", get_mode_name(get_Load_mode(n)));
ir_fprintf(F, " type of object loaded from: %+F\n", get_Load_type(n));
fprintf(F, " volatility: %s\n", get_volatility_name(get_Load_volatility(n)));
fprintf(F, " align: %s\n", get_align_name(get_Load_unaligned(n)));
break;
......
......@@ -222,10 +222,11 @@ static void instrument_block(ir_node *const bb, ir_node *const address, unsigned
if (bb == get_irg_end_block(irg))
return;
ir_type *const type_Iu = get_entity_type(get_irn_entity_attr(address));
ir_node *const unknown = new_r_Unknown(irg, mode_M);
ir_node *const cnst = new_r_Const_long(irg, mode_Iu, get_mode_size_bytes(mode_Iu) * id);
ir_node *const offset = new_r_Add(bb, address, cnst, mode_P);
ir_node *const load = new_r_Load(bb, unknown, offset, mode_Iu, cons_none);
ir_node *const load = new_r_Load(bb, unknown, offset, mode_Iu, type_Iu, cons_none);
ir_node *const lmem = new_r_Proj(load, mode_M, pn_Load_M);
ir_node *const proji = new_r_Proj(load, mode_Iu, pn_Load_res);
ir_node *const one = new_r_Const_one(irg, mode_Iu);
......
......@@ -264,6 +264,7 @@ typedef struct load_attr {
ENUMBF(ir_volatility) volatility:1; /**< The volatility of this Load operation. */
ENUMBF(ir_align) unaligned:1; /**< The align attribute of this Load operation. */
ir_mode *mode; /**< The mode of this Load operation. */
ir_type *type; /**< The type of the object loaded. */
} load_attr;
/** Attributes for Store nodes. */
......
......@@ -803,7 +803,7 @@ static void transform_return(ir_node *ret, size_t n_ret_com, wlk_env *env)
addr = new_r_Add(block, addr, offset_cnst, mode_ref);
}
ir_node *load = new_r_Load(block, mem, addr,
int_return_mode, cons_none);
int_return_mode, type, cons_none);
sync_in[i] = new_r_Proj(load, mode_M, pn_Load_M);
new_in[n_in++] = new_r_Proj(load, int_return_mode,
pn_Load_res);
......
......@@ -79,7 +79,7 @@ static void lower_small_copyb_node(ir_node *irn)
ir_node *add = new_r_Add(block, addr_src, addr_const,
mode_ref);
ir_node *load = new_r_Load(block, mem, add, mode, cons_none);
ir_node *load = new_r_Load(block, mem, add, mode, tp, cons_none);
ir_node *load_res = new_r_Proj(load, mode, pn_Load_res);
ir_node *load_mem = new_r_Proj(load, mode_M, pn_Load_M);
......
......@@ -352,6 +352,7 @@ static void lower_Load(ir_node *node, ir_mode *mode)
ir_graph *irg = get_irn_irg(node);
ir_node *adr = get_Load_ptr(node);
ir_node *mem = get_Load_mem(node);
ir_type *type = get_Load_type(node);
ir_node *cnst = new_r_Const(irg, env.tv_mode_bytes);
ir_mode *adr_mode = get_irn_mode(adr);
ir_node *block = get_nodes_block(node);
......@@ -370,9 +371,9 @@ static void lower_Load(ir_node *node, ir_mode *mode)
= get_Load_volatility(node) == volatility_is_volatile ? cons_volatile
: cons_none;
dbg_info *dbg = get_irn_dbg_info(node);
low = new_rd_Load(dbg, block, mem, low, low_mode, volatility);
low = new_rd_Load(dbg, block, mem, low, low_mode, type, volatility);
ir_node *proj_m = new_r_Proj(low, mode_M, pn_Load_M);
high = new_rd_Load(dbg, block, proj_m, high, mode, volatility);
high = new_rd_Load(dbg, block, proj_m, high, mode, type, volatility);
foreach_out_edge_safe(node, edge) {
ir_node *proj = get_edge_src_irn(edge);
......@@ -1529,6 +1530,7 @@ transform:
ir_node *cnst = new_r_Const(irg, env.tv_mode_bytes);
ir_node *low = addr;
ir_node *high = new_r_Add(block, addr, cnst, addr_mode);
ir_type *src_type = get_type_for_mode(src_mode);
/* big endian requires different order for lower/higher word */
if (env.p.big_endian) {
ir_node *tmp = low;
......@@ -1548,8 +1550,8 @@ transform:
ir_node *in[] = { mem0, mem1 };
ir_node *sync = new_r_Sync(block, ARRAY_SIZE(in), in);
ir_node *load = new_rd_Load(dbgi, block, sync, addr, dst_mode,
cons_floats);
ir_node *load = new_rd_Load(dbgi, block, sync, addr,
dst_mode, src_type, cons_floats);
ir_node *res = new_r_Proj(load, dst_mode, pn_Load_res);
exchange(node, res);
} else {
......@@ -1558,11 +1560,11 @@ transform:
cons_floats);
ir_node *mem = new_r_Proj(store, mode_M, pn_Store_M);
ir_node *load_low = new_rd_Load(dbgi, block, mem, low,
env.p.word_unsigned, cons_floats);
env.p.word_unsigned, src_type, cons_floats);
ir_node *res_low = new_r_Proj(load_low, env.p.word_unsigned,
pn_Load_res);
ir_node *load_high = new_rd_Load(dbgi, block, mem, high, mode,
cons_floats);
ir_node *load_high = new_rd_Load(dbgi, block, mem, high,
mode, src_type, cons_floats);
ir_node *res_high = new_r_Proj(load_high, mode, pn_Load_res);
ir_set_dw_lowered(node, res_low, res_high);
}
......
......@@ -827,7 +827,7 @@ replace_by_call:
mode = get_type_mode(char_tp);
/* replace the strcmp by (*x) */
irn = new_rd_Load(dbg, block, mem, v, mode, cons_none);
irn = new_rd_Load(dbg, block, mem, v, mode, char_tp, cons_none);
mem = new_r_Proj(irn, mode_M, pn_Load_M);
irn = new_r_Proj(irn, mode, pn_Load_res);
if (ir_throws_exception(call)) {
......
......@@ -1621,6 +1621,7 @@ static void move_loads_out_of_loops(scc *pscc, loop_env *env)
if (!is_Address(ptr))
continue;
ir_mode *load_mode = get_Load_mode(load);
ir_type *load_type = get_Load_type(load);
ir_node *other;
ir_node *next_other;
for (other = pscc->head; other != NULL; other = next_other) {
......@@ -1632,7 +1633,6 @@ static void move_loads_out_of_loops(scc *pscc, loop_env *env)
ir_node *store_value = get_Store_value(other);
ir_type *store_type
= get_type_for_mode(get_irn_mode(store_value));
ir_type *load_type = get_type_for_mode(load_mode);
ir_alias_relation rel
= get_alias_relation(store_ptr, store_type, ptr,
load_type);
......@@ -1665,7 +1665,7 @@ static void move_loads_out_of_loops(scc *pscc, loop_env *env)
if (res != NULL) {
irn = res->load;
} else {
irn = new_rd_Load(db, pred, get_Phi_pred(phi, pos), ptr, load_mode, cons_none);
irn = new_rd_Load(db, pred, get_Phi_pred(phi, pos), ptr, load_mode, load_type, cons_none);
entry.load = irn;
(void)set_insert(avail_entry_t, avail, &entry, sizeof(entry), hash_cache_entry(&entry));
DB((dbg, LEVEL_1, " Created %+F in %+F\n", irn, pred));
......
......@@ -57,6 +57,7 @@ struct value_t {
ir_node *address; /**< the address of this value */
ir_node *value; /**< the value itself */
ir_mode *mode; /**< the mode of the value */
ir_type *type; /**< the type of the value */
unsigned id; /**< address id */
};
......@@ -446,6 +447,7 @@ static memop_t *alloc_memop(ir_node *irn)
m->value.address = NULL;
m->value.value = NULL;
m->value.mode = NULL;
m->value.type = NULL;
m->node = irn;
m->mem = NULL;
......@@ -585,6 +587,7 @@ static void update_Load_memop(memop_t *m)
ptr = get_Load_ptr(load);
m->value.address = ptr;
m->value.type = get_Load_type(load);
foreach_irn_out_r(load, i, proj) {
/* beware of keep edges */
......@@ -1170,6 +1173,7 @@ static int backward_antic(block_t *bl)
new_op->value.address = trans_adr;
new_op->value.id = register_address(trans_adr);
new_op->value.mode = op->value.mode;
new_op->value.type = op->value.type;
new_op->node = op->node; /* we need the node to decide if Load/Store */
new_op->flags = op->flags;
......@@ -1630,6 +1634,7 @@ static int insert_Load(block_t *bl)
}
if (have_some && !all_same) {
ir_mode *mode = op->value.mode;
ir_type *type = op->value.type;
ir_node **in = ALLOCAN(ir_node*, n);
ir_node *phi;
memop_t *phi_op;
......@@ -1647,7 +1652,7 @@ static int insert_Load(block_t *bl)
assert(last_mem != NULL);
adr = phi_translate(op->value.address, block, i);
load = new_rd_Load(db, pred, last_mem, adr, mode, cons_none);
load = new_rd_Load(db, pred, last_mem, adr, mode, type, cons_none);
def = new_r_Proj(load, mode, pn_Load_res);
DB((dbg, LEVEL_1, "Created new %+F in %+F for party redundant %+F\n", load, pred, op->node));
......@@ -1656,6 +1661,7 @@ static int insert_Load(block_t *bl)
new_op->value.address = adr;
new_op->value.id = op->value.id;
new_op->value.mode = mode;
new_op->value.type = type;
new_op->value.value = def;
new_op->projs[pn_Load_M] = new_op->mem;
......
......@@ -524,6 +524,8 @@ class Load:
attrs = [
Attribute("mode", type="ir_mode*",
comment="mode of the value to be loaded"),
Attribute("type", type="ir_type*",
comment="The type of the object which is stored at ptr (need not match with mode)"),
Attribute("volatility", type="ir_volatility",
init="flags & cons_volatile ? volatility_is_volatile : volatility_non_volatile",
to_flags="%s == volatility_is_volatile ? cons_volatile : cons_none",
......
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