-/**
- * Check if a value parameter is transmitted as a register.
- * This might happen if the address of an parameter is taken which is
- * transmitted in registers.
- *
- * Note that on some architectures this case must be handled specially
- * because the place of the backing store is determined by their ABI.
- *
- * In the default case we move the entity to the frame type and create
- * a backing store into the first block.
- */
-static void fix_address_of_parameter_access(be_abi_irg_t *env, ir_graph *irg,
- ir_entity **value_param_list)
-{
- be_abi_call_t *call = env->call;
- const arch_env_t *arch_env = be_get_irg_arch_env(irg);
- size_t n = ARR_LEN(value_param_list);
- size_t i;
- bool need_fixes = false;
- ir_node *first_store = NULL;
- ir_node *start_bl;
- ir_node *frame;
- ir_node *imem;
- ir_node *mem;
- ir_node *args;
-
- for (i = 0; i < n; ++i) {
- ir_entity *entity = value_param_list[i];
- size_t pos = get_entity_parameter_number(entity);
- be_abi_call_arg_t *arg = get_call_arg(call, 0, pos, 1);
-
- if (arg->in_reg) {
- need_fixes = true;
- DBG((dbg, LEVEL_2, "\targ #%d need backing store\n", pos));
- }
- }
- if (!need_fixes)
- return;
-
- /* ok, change the graph */
- start_bl = get_irg_start_block(irg);
-
- /* now create backing stores */
- frame = get_irg_frame(irg);
- imem = get_irg_initial_mem(irg);
- mem = imem;
- args = get_irg_args(irg);
- for (i = 0; i < n; ++i) {
- ir_entity *entity = value_param_list[i];
- size_t pos = get_entity_parameter_number(entity);
- be_abi_call_arg_t *arg = get_call_arg(call, 0, pos, 1);
- ir_node *addr;
-
- if (!arg->in_reg)
- continue;
-
- /* address for the backing store */
- addr = be_new_FrameAddr(arch_env->sp->reg_class, start_bl, frame, entity);
-
- if (entity->attr.parameter.doubleword_low_mode != NULL) {
- ir_mode *mode = entity->attr.parameter.doubleword_low_mode;
- ir_node *val0 = new_r_Proj(args, mode, pos);
- ir_node *val1 = new_r_Proj(args, mode, pos+1);
- ir_node *store0 = new_r_Store(start_bl, mem, addr, val0, 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 *addr_mode = get_irn_mode(addr);
- ir_node *cnst = new_r_Const_long(irg, addr_mode, offset);
- ir_node *next_addr = new_r_Add(start_bl, addr, cnst, addr_mode);
- ir_node *store1 = new_r_Store(start_bl, mem0, next_addr, val1, 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 = get_type_mode(tp);
-
- /* the backing store itself */
- ir_node *val = new_r_Proj(args, mode, pos);
- ir_node *store = new_r_Store(start_bl, mem, addr, val, cons_none);
- mem = new_r_Proj(store, mode_M, pn_Store_M);
-
- if (first_store == NULL)
- first_store = store;
- }
- }
-
- assert(mem != imem);
- edges_reroute(imem, mem);
- set_Store_mem(first_store, imem);
-}
-