On Fri, Mar 18, 2011 at 3:42 PM, Jakub Jelinek <ja...@redhat.com> wrote: > 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 <r...@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.
Because TARGET_MEM_REF only works on ptr_mode: http://gcc.gnu.org/ml/gcc-patches/2011-02/msg00655.html x32 accepts (%eax,%ebx,4). > 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. You can change 32bit registers in memory address to 64bit only if there is no index register. I will try ptr_mode == SImode and report any new problems. Thanks. -- H.J.