Can't use SImode as Pmode for x32

Jakub Jelinek jakub@redhat.com
Fri Mar 18 22:42:00 GMT 2011


On Fri, Mar 18, 2011 at 03:32:45PM -0700, H.J. Lu wrote:
> On Fri, Mar 18, 2011 at 3:18 PM, Richard Henderson <rth@redhat.com> wrote:
> > On 03/18/2011 02:56 PM, H.J. Lu wrote:
> >> X86 backend uses Pmode for hardware pointer size. Changes
> >> it to 32bit for x32, which is really 64bit process, breaks many
> >> assumptions of x86 backend. push/pop/call is just the tip of
> >> the iceberg.
> >
> > Please enumerate "many assumptions".  I can't think of any off
> > the top of my head.
> >
> 
> I don't have a complete list.  gen_push is one of them:
> 
> static rtx
> gen_push (rtx arg)
> {
>   struct machine_function *m = cfun->machine;
> 
>   if (m->fs.cfa_reg == stack_pointer_rtx)
>     m->fs.cfa_offset += UNITS_PER_WORD;
>   m->fs.sp_offset += UNITS_PER_WORD;
> 
>   return gen_rtx_SET (VOIDmode,
>                       gen_rtx_MEM (Pmode,
>                                    gen_rtx_PRE_DEC (Pmode,
>                                                     stack_pointer_rtx)),
>                       arg);
> }
> 
> You can only push/pup 64bit in hardware 64bit mode.

That's still push/pop/call.  And you can certainly use a Pmode (== SImode)
stack_pointer_rtx to describe it too, push/pop reference %rsp just
implicitly.  For the MEM you would just use DImode for x32 in that case,
or for <= 32 bit pushes you could describe it as a SImode MEM with
PRE_MODIFY inside of it.

For addresses, you could use 32-bit regs (i.e. addr32 prefix) by default,
perhaps with machine reorg optimizing away some of the addr32 prefixes when
it can prove the base register is already zero extended, and if there is no
added or very small one.

	Jakub



More information about the Gcc-patches mailing list