> > - In gcc/config/mips/mips.c:mips_compute_frame_info() you do
> >
> >       /* Move above the GPR save area.  */
> >       if (frame->num_gp > 0)
> >         {
> >           offset += MIPS_STACK_ALIGN (frame->num_gp * UNITS_PER_WORD);
> >           frame->gp_sp_offset = offset - UNITS_PER_WORD;
> >         }
> >
> >   So what is "- UNITS_PER_WORD" for?
> 
> Well, the fields are defined as follows:
> 
>   /* The offset of the topmost GPR and FPR save slots from the top of
>      the frame, or zero if no such slots are needed.  */
>   HOST_WIDE_INT gp_save_offset;
>   HOST_WIDE_INT fp_save_offset;
> 
>   /* Likewise, but giving offsets from the bottom of the frame.  */
>   HOST_WIDE_INT gp_sp_offset;
>   HOST_WIDE_INT fp_sp_offset;
> 
> so the "- UNITS_PER_WORD" converts the offset of the end/top of the save
> slot area to the offset of the topmost save slot.

Understood, thanks.

And now I look at the Figure 7-2 in [1], it's clearly explained there.
I should have read carefully.

> > - Why do you put MIPS_STACK_ALIGN in many places?
> 
> TBH, I just blindly kept these when doing the rewrite.  Some of them
> aren't needed, as you say; I'll try to fix that sometime.
> 
> It isn't just the bottom of the stack that needs to be aligned though.
> Addressable regions like the local variables and the varargs save area
> must also be aligned, so that the alignment attributes work correctly.

Understood too.

(If it's the only reason, GPR and FPR save don't need alignment - but
who cares? :)

Masao

Reply via email to