- int omit_fp = env->call->flags.bits.try_omit_fp;
- ir_node *irn;
- int wanted_bias = real_bias;
-
- sched_foreach(bl, irn) {
- int ofs;
-
- /*
- Check, if the node relates to an entity on the stack frame.
- If so, set the true offset (including the bias) for that
- node.
- */
- ir_entity *ent = arch_get_frame_entity(irn);
- if (ent != NULL) {
- int bias = omit_fp ? real_bias : 0;
- int offset = get_stack_entity_offset(&env->frame, ent, bias);
- arch_set_frame_offset(irn, offset);
- DBG((dbg, LEVEL_2, "%F has offset %d (including bias %d)\n",
- ent, offset, bias));
- }
-
- /*
- * If the node modifies the stack pointer by a constant offset,
- * record that in the bias.
- */
- ofs = arch_get_sp_bias(irn);
-
- if (be_is_IncSP(irn)) {
- /* fill in real stack frame size */
- if (ofs == BE_STACK_FRAME_SIZE_EXPAND) {
- ir_type *frame_type = get_irg_frame_type(env->birg->irg);
- ofs = (int) get_type_size_bytes(frame_type);
- be_set_IncSP_offset(irn, ofs);
- } else if (ofs == BE_STACK_FRAME_SIZE_SHRINK) {
- ir_type *frame_type = get_irg_frame_type(env->birg->irg);
- ofs = - (int)get_type_size_bytes(frame_type);
- be_set_IncSP_offset(irn, ofs);
- } else {
- if (be_get_IncSP_align(irn)) {
- /* patch IncSP to produce an aligned stack pointer */
- ir_type *between_type = env->frame.between_type;
- int between_size = get_type_size_bytes(between_type);
- int alignment = 1 << env->arch_env->stack_alignment;
- int delta = (real_bias + ofs + between_size) & (alignment - 1);
- assert(ofs >= 0);
- if (delta > 0) {
- be_set_IncSP_offset(irn, ofs + alignment - delta);
- real_bias += alignment - delta;
- }
- } else {
- /* adjust so real_bias corresponds with wanted_bias */
- int delta = wanted_bias - real_bias;
- assert(delta <= 0);
- if (delta != 0) {
- be_set_IncSP_offset(irn, ofs + delta);
- real_bias += delta;
- }
- }
- }
- }
-
- real_bias += ofs;
- wanted_bias += ofs;
- }
-
- assert(real_bias == wanted_bias);
- return real_bias;