+
+ /* Add uses of the callee save registers. */
+ pmap_foreach(env->regs, ent) {
+ const arch_register_t *reg = ent->key;
+ if(arch_register_type_is(reg, callee_save) || arch_register_type_is(reg, ignore))
+ pmap_insert(reg_map, ent->key, ent->value);
+ }
+
+ be_abi_reg_map_set(reg_map, isa->sp, stack);
+
+ /* Make the Epilogue node and call the arch's epilogue maker. */
+ create_barrier(env, bl, &mem, reg_map, 1);
+ call->cb->epilogue(env->cb, bl, &mem, reg_map);
+
+ /*
+ Maximum size of the in array for Return nodes is
+ return args + callee save/ignore registers + memory + stack pointer
+ */
+ in_max = pmap_count(reg_map) + n_res + 2;
+
+ in = obstack_alloc(&env->obst, in_max * sizeof(in[0]));
+ regs = obstack_alloc(&env->obst, in_max * sizeof(regs[0]));
+
+ in[0] = mem;
+ in[1] = be_abi_reg_map_get(reg_map, isa->sp);
+ regs[0] = NULL;
+ regs[1] = isa->sp;
+ n = 2;
+
+ /* clear SP entry, since it has already been grown. */
+ pmap_insert(reg_map, (void *) isa->sp, NULL);
+ for(i = 0; i < n_res; ++i) {
+ ir_node *res = get_Return_res(irn, i);
+ be_abi_call_arg_t *arg = get_call_arg(call, 1, i);
+
+ in[n] = be_abi_reg_map_get(reg_map, arg->reg);
+ regs[n++] = arg->reg;
+
+ /* Clear the map entry to mark the register as processed. */
+ be_abi_reg_map_set(reg_map, arg->reg, NULL);
+ }
+
+ /* grow the rest of the stuff. */
+ pmap_foreach(reg_map, ent) {
+ if(ent->value) {
+ in[n] = ent->value;
+ regs[n++] = ent->key;
+ }
+ }
+
+ /* The in array for the new back end return is now ready. */
+ ret = be_new_Return(irn ? get_irn_dbg_info(irn) : NULL, env->birg->irg, bl, n_res, n, in);
+
+ /* Set the register classes of the return's parameter accordingly. */
+ for(i = 0; i < n; ++i)
+ if(regs[i])
+ be_node_set_reg_class(ret, i, regs[i]->reg_class);
+
+ /* Free the space of the Epilog's in array and the register <-> proj map. */
+ obstack_free(&env->obst, in);
+ pmap_destroy(reg_map);
+
+ return ret;