Hari Sandanagobalane <harihar...@picochip.com> writes:

> Can anyone familiar with backend explain to me when we use
> VIRTUAL_STACK_VARS_REGNUM (or) VIRTUAL_STACK_DYNAMIC_REGNUM in gcc?
> Rather, when does the compiler decide to allocate a variable to
> stack_vars region and when to stack_dynamic?

See calls to allocate_dynamic_stack_space.  It's used for, e.g.,
allocate, variable sized local arrays, etc.


> I encountered some trouble with virtual-stack-vars. Since it gets
> translated to FRAME_POINTER_REGNUM and we don't actually have a
> dedicated frame pointer register in picochip, i got a compiler ICE. I
> have set ELIMINABLE_REGS to eliminate FRAME_POINTER in preference to
> STACK_POINTER, but it doesn't work in this case (presumably
> because FRAME_POINTER is used in a memory reference and elimination
> does not work well with memory)

gcc can not always eliminate the frame pointer.  A frame pointer is
required for functions that allocate stack space dynamically.  You don't
need to have a dedicated frame pointer register, but you do need to have
a register which can serve as the frame pointer in a function which
requires a frame pointer.


> In the attached C code, at expand it saves the result from each call
> to getPort function to the virtual_stack_vars region and then copies
> it from there into virtual_stack_dynamic region. Why can it not copy
> straight into virtual_stack_dynamic region? In the example, if i were
> to write to the "int32_elements" instead of cmplx_elements, it does
> work fine by writing it directly into virtual_stack_dynamic region.
>
> I have attached the compiler dumps from expand, sched and ira for reference.
>
> I tried this on GCC 4.6.0 release compiler. The port has had some
> local changes for vector support, which i will submit into mainline
> after a while.

It looks like the port is requiring the local variables to have a
specific alignment, but that the stack pointer is not guaranteed to be
aligned.  If you do expect the stack pointer to be aligned, make sure
you express that in STACK_BOUNDARY and PREFERRED_STACK_BOUNDARY.  If you
do not expect the stack pointer to be aligned, but the local variables
have to be aligned, then I don't see what else gcc can do.

Ian

Reply via email to