Commit 80f96382 authored by Andreas Fried's avatar Andreas Fried
Browse files

Provide Store nodes with the type of the object stored to.

parent 8eb7b1b9
......@@ -409,7 +409,7 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp)
if (is_atomic_type(param_type)) {
ir_node *nomem = get_irg_no_mem(irg);
ir_node *mem_input = nomem;
ir_node *store = new_rd_Store(dbgi, bl, mem_input, addr, param, cons_none);
ir_node *store = new_rd_Store(dbgi, bl, mem_input, addr, param, param_type, cons_none);
mem = new_r_Proj(store, mode_M, pn_Store_M);
} else {
/* Make a mem copy for compound arguments. */
......
......@@ -327,6 +327,7 @@ static void create_stores_for_type(ir_graph *irg, ir_type *type)
* (The ones passed on the stack have been moved to the arg type) */
for (i = 0; i < n; ++i) {
ir_entity *entity = get_compound_member(type, i);
ir_type *tp = get_entity_type(entity);
ir_node *addr;
size_t arg;
if (!is_parameter_entity(entity))
......@@ -342,7 +343,7 @@ static void create_stores_for_type(ir_graph *irg, ir_type *type)
ir_node *val0 = new_r_Proj(args, mode, arg);
ir_node *val1 = new_r_Proj(args, mode, arg+1);
ir_node *store0 = new_r_Store(start_block, mem, addr, val0,
cons_none);
tp, cons_none);
ir_node *mem0 = new_r_Proj(store0, mode_M, pn_Store_M);
size_t offset = get_mode_size_bits(mode)/8;
ir_mode *mode_ref = get_irn_mode(addr);
......@@ -350,15 +351,14 @@ static void create_stores_for_type(ir_graph *irg, ir_type *type)
ir_node *cnst = new_r_Const_long(irg, mode_offs, offset);
ir_node *next_addr = new_r_Add(start_block, addr, cnst, mode_ref);
ir_node *store1 = new_r_Store(start_block, mem0, next_addr, val1,
cons_none);
tp, cons_none);
mem = new_r_Proj(store1, mode_M, pn_Store_M);
if (first_store == NULL)
first_store = store0;
} else {
ir_type *tp = get_entity_type(entity);
ir_mode *mode = is_compound_type(tp) ? mode_P : get_type_mode(tp);
ir_node *val = new_r_Proj(args, mode, arg);
ir_node *store = new_r_Store(start_block, mem, addr, val, cons_none);
ir_node *store = new_r_Store(start_block, mem, addr, val, tp, cons_none);
mem = new_r_Proj(store, mode_M, pn_Store_M);
if (first_store == NULL)
first_store = store;
......
......@@ -302,6 +302,7 @@ void dump_irnode_to_file(FILE *const F, const ir_node *const n)
fprintf(F, " align: %s\n", get_align_name(get_Load_unaligned(n)));
break;
case iro_Store:
ir_fprintf(F, " type of object stored to: %+F\n", get_Store_type(n));
fprintf(F, " volatility: %s\n", get_volatility_name(get_Store_volatility(n)));
fprintf(F, " align: %s\n", get_align_name(get_Store_unaligned(n)));
break;
......
......@@ -231,7 +231,7 @@ static void instrument_block(ir_node *const bb, ir_node *const address, unsigned
ir_node *const proji = new_r_Proj(load, mode_Iu, pn_Load_res);
ir_node *const one = new_r_Const_one(irg, mode_Iu);
ir_node *const add = new_r_Add(bb, proji, one, mode_Iu);
ir_node *const store = new_r_Store(bb, lmem, offset, add, cons_none);
ir_node *const store = new_r_Store(bb, lmem, offset, add, type_Iu, cons_none);
ir_node *const smem = new_r_Proj(store, mode_M, pn_Store_M);
set_irn_link(bb, smem);
......
......@@ -270,6 +270,7 @@ typedef struct load_attr {
/** Attributes for Store nodes. */
typedef struct store_attr {
except_attr exc; /**< the exception attribute. MUST be the first one. */
ir_type *type; /**< The type of the object stored at the node's address. */
ENUMBF(ir_volatility) volatility:1; /**< The volatility of this Store operation. */
ENUMBF(ir_align) unaligned:1; /**< The align attribute of this Store operation. */
} store_attr;
......
......@@ -637,8 +637,9 @@ static void fix_int_return(const cl_entry *entry, ir_node *base_addr,
addr = new_r_Add(block, addr, offset_cnst, mode_ref);
}
ir_node *const value = new_r_Proj(proj_res, int_return_mode, pn+i);
ir_type *const type = get_method_res_type(get_Call_type(call), 0);
ir_node *const store = new_r_Store(block, proj_mem, addr, value,
cons_none);
type, cons_none);
ir_node *const store_mem = new_r_Proj(store, mode_M, pn_Store_M);
sync_in[i] = store_mem;
}
......
......@@ -88,7 +88,7 @@ static void lower_small_copyb_node(ir_node *irn)
mode_ref);
ir_node *store = new_r_Store(block, load_mem, add2, load_res,
cons_none);
tp, cons_none);
ir_node *store_mem = new_r_Proj(store, mode_M, pn_Store_M);
mem = store_mem;
......
......@@ -417,6 +417,7 @@ static void lower_Store(ir_node *node, ir_mode *mode)
ir_graph *irg = get_irn_irg(node);
ir_node *adr = get_Store_ptr(node);
ir_node *mem = get_Store_mem(node);
ir_type *type = get_Store_type(node);
ir_node *block = get_nodes_block(node);
ir_node *cnst = new_r_Const(irg, env.tv_mode_bytes);
ir_mode *adr_mode = get_irn_mode(adr);
......@@ -435,9 +436,9 @@ static void lower_Store(ir_node *node, ir_mode *mode)
= get_Store_volatility(node) == volatility_is_volatile ? cons_volatile
: cons_none;
dbg_info *dbg = get_irn_dbg_info(node);
low = new_rd_Store(dbg, block, mem, low, entry->low_word, volatility);
low = new_rd_Store(dbg, block, mem, low, entry->low_word, type, volatility);
ir_node *proj_m = new_r_Proj(low, mode_M, pn_Store_M);
high = new_rd_Store(dbg, block, proj_m, high, entry->high_word, volatility);
high = new_rd_Store(dbg, block, proj_m, high, entry->high_word, type, volatility);
foreach_out_edge_safe(node, edge) {
ir_node *proj = get_edge_src_irn(edge);
......@@ -1542,10 +1543,10 @@ transform:
const lower64_entry_t *entry = get_node_entry(op);
ir_node *store0 = new_rd_Store(dbgi, block, nomem, high,
entry->high_word, cons_floats);
entry->high_word, src_type, cons_floats);
ir_node *mem0 = new_r_Proj(store0, mode_M, pn_Store_M);
ir_node *store1 = new_rd_Store(dbgi, block, nomem, low,
entry->low_word, cons_floats);
entry->low_word, src_type, cons_floats);
ir_node *mem1 = new_r_Proj(store1, mode_M, pn_Store_M);
ir_node *in[] = { mem0, mem1 };
ir_node *sync = new_r_Sync(block, ARRAY_SIZE(in), in);
......@@ -1557,7 +1558,7 @@ transform:
} else {
assert(needs_lowering(dst_mode));
ir_node *store = new_rd_Store(dbgi, block, nomem, addr, op,
cons_floats);
src_type, 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, src_type, cons_floats);
......
......@@ -1249,6 +1249,7 @@ static changes_t optimize_phi(ir_node *phi, walk_env_t *wenv)
ir_node **projMs = ALLOCAN(ir_node*, n);
ir_node **inM = ALLOCAN(ir_node*, n);
ir_node **inD = ALLOCAN(ir_node*, n);
ir_type *type = NULL;
int *idx = ALLOCAN(int, n);
/* Prepare: Collect all Store nodes. We must do this
......@@ -1264,6 +1265,12 @@ static changes_t optimize_phi(ir_node *phi, walk_env_t *wenv)
inM[i] = get_Store_mem(store);
inD[i] = get_Store_value(store);
idx[i] = info->exc_idx;
if (i == n-1) {
type = get_Store_type(store);
} else {
assert(type == get_Store_type(store));
}
}
/* second step: remove keep edge from old Phi and create a new memory Phi */
......@@ -1274,7 +1281,7 @@ static changes_t optimize_phi(ir_node *phi, walk_env_t *wenv)
ir_node *phiD = new_r_Phi(phi_block, n, inD, mode);
/* fourth step: create the Store */
store = new_r_Store(phi_block, phiM, ptr, phiD, cons_none);
store = new_r_Store(phi_block, phiM, ptr, phiD, type, cons_none);
projM = new_r_Proj(store, mode_M, pn_Store_M);
/* rewire memory and kill the old nodes */
......@@ -2103,6 +2110,24 @@ again:;
continue;
}
/* Combine types if necessary */
ir_type *type0 = get_Store_type(store0);
ir_type *type1 = get_Store_type(store1);
ir_type *type;
if (type0 != type1) {
/* Construct an anonymous struct type
* for the combined Store.
*/
ident *struct_id = id_unique("__combined_Store_%u");
type = new_type_struct(struct_id);
ident *member0_id = id_unique("__Store_part_%u");
new_entity(type, member0_id, type0);
ident *member1_id = id_unique("__Store_part_%u");
new_entity(type, member1_id, type1);
} else {
type = type0;
}
/* combine values */
dbg_info *dbgi = get_irn_dbg_info(store0);
ir_node *block = get_nodes_block(store0);
......@@ -2121,7 +2146,7 @@ again:;
|| get_irn_pinned(store1) == op_pin_state_floats)
flags |= cons_floats;
ir_node *new_store
= new_rd_Store(dbgi, block, mem, store_ptr0, or, flags);
= new_rd_Store(dbgi, block, mem, store_ptr0, or, type, flags);
exchange(store0, new_store);
exchange(store1, new_store);
new_in[i] = pred0;
......
......@@ -315,7 +315,7 @@ static void copy_parameter_entities(ir_node *call, ir_graph *called_graph)
}
} else {
/* Store the parameter onto the frame */
ir_node *store = new_rd_Store(dbgi, block, call_mem, sel, param, cons_none);
ir_node *store = new_rd_Store(dbgi, block, call_mem, sel, param, old_type, cons_none);
new_mem = new_r_Proj(store, mode_M, pn_Store_M);
ARR_APP1(ir_node*, sync_mem, new_mem);
}
......
......@@ -804,6 +804,8 @@ class Store:
pinned_init = "flags & cons_floats ? op_pin_state_floats : op_pin_state_pinned"
throws_init = "(flags & cons_throws_exception) != 0"
attrs = [
Attribute("type", type="ir_type*",
comment="The type of the object which is stored at ptr (need not match with value's type)"),
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