+ *mem = new_r_Proj(irg, bl, irn, mode_M, n);
+ }
+
+ obstack_free(&env->obst, rm);
+ return irn;
+}
+
+/**
+ * Creates a be_Return for a Return node.
+ *
+ * @param @env the abi environment
+ * @param irn the Return node or NULL if there was none
+ * @param bl the block where the be_Retun should be placed
+ * @param mem the current memory
+ * @param n_res number of return results
+ */
+static ir_node *create_be_return(be_abi_irg_t *env, ir_node *irn, ir_node *bl, ir_node *mem, int n_res) {
+ be_abi_call_t *call = env->call;
+ const arch_isa_t *isa = env->birg->main_env->arch_env->isa;
+
+ pmap *reg_map = pmap_create();
+ ir_node *keep = pmap_get(env->keep_map, bl);
+ int in_max;
+ ir_node *ret;
+ int i, n;
+ ir_node **in;
+ ir_node *stack;
+ const arch_register_t **regs;
+ pmap_entry *ent ;
+
+ /*
+ get the valid stack node in this block.
+ If we had a call in that block there is a Keep constructed by process_calls()
+ which points to the last stack modification in that block. we'll use
+ it then. Else we use the stack from the start block and let
+ the ssa construction fix the usage.
+ */
+ stack = be_abi_reg_map_get(env->regs, isa->sp);
+ if (keep) {
+ ir_node *bad = new_r_Bad(env->birg->irg);
+ stack = get_irn_n(keep, 0);
+ set_nodes_block(keep, bad);
+ set_irn_n(keep, 0, bad);
+ // exchange(keep, new_r_Bad(env->birg->irg));
+ }
+
+ /* Insert results for Return into the register map. */
+ 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);
+ assert(arg->in_reg && "return value must be passed in register");
+ pmap_insert(reg_map, (void *) arg->reg, res);
+ }
+
+ /* 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);