[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pcc-list
Subject:    Re: xasm "=g" constraint
From:       Anders Magnusson <ragge () ludd ! ltu ! se>
Date:       2008-07-30 15:45:38
Message-ID: 48908CA2.4080305 () ludd ! ltu ! se
[Download RAW message or body]

Gregory McGarry wrote:
> The following code exceeds the number of registers.  While the compiler
> doesn't mind putting variables eax, ecx and edx on the stack without
> -xtemps, it doesn't bother to spill onto the stack with -xtemps.  So I
> am not sure whether it's a problem with the "=g" constraint (actually
> "=r"), or that extended assembler is generated too late for register
> spills to happen.
> 
> 
> void
> mcount(void)
> {
>         int             selfpc, frompcindex;
>         int             eax, ecx, edx;
>         __asm           volatile("movl %%eax,%0":"=g"(eax));
>         __asm           volatile("movl %%ecx,%0":"=g"(ecx));
>         __asm           volatile("movl %%edx,%0":"=g"(edx));
>         __asm           volatile("movl 4(%%ebp),%0":"=r"(selfpc));
>         __asm           volatile("movl (%%ebp),%0;movl
> 4(%0),%0":"=r"(frompcindex));
>         _mcount((unsigned long) frompcindex, (unsigned long) selfpc);
>         __asm           volatile("movl %0,%%edx"::"g"(edx));
>         __asm           volatile("movl %0,%%ecx"::"g"(ecx));
>         __asm           volatile("movl %0,%%eax"::"g"(eax));
> }
> 
> 
> $ /usr/local/libexec/i386-netbsdelf-ccom -k -xtemps m2.c
>         .text
>         .align 4
>         .globl mcount
> mcount:
> <stdin>, line 20: couldn't find available register
> <stdin>, line 20: bad xasm node type
> cannot recover from earlier errors: goodbye!
> 
So, fixed by allowing "g" arg types to be spilled in the register allocator.

-- Ragge

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic