This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc using clobbered register as input with inline assembly
On Mon, Mar 26, 2001 at 01:56:31PM -0600, Timur Tabi wrote:
> ** Reply to message from "Zack Weinberg" <zackw@stanford.edu> on Mon, 26 Mar
> 2001 11:39:11 -0800
>
>
> > There is a thing called an early clobber which could help here, but
> > when you can explain to the compiler what rdtsc *really* does,
> > i.e. "write 64-bit value into eax and edx considered as a low/high
> > pair", why not do that instead? With inline assembly, you're almost
> > always better off writing just one machine instruction per asm() and
> > describing as accurately as possible what that instruction does with
> > the constraints.
>
> The reason I ask is because I have another, much larger function. I won't
> paste the code, but here is the parameter info:
>
> : "=m" (BestMatch.Count), "=m" (BestMatch.Index), "=m" (Count)
> : "m" (pInput), "2" (Count), "0" (BestMatch.Count), "m" (cbInput), "m"
> (cbWindow), "m" (cbIn4095)
> : "eax", "ebx", "ecx", "edx", "esi", "edi"
>
> As you can see, I have 9 inputs and outputs, which is gcc's max. I
> don't have any more registers available, so I had to use explicit
> registers for all my code.
>
> Are you saying that this won't work? Currently, all my inputs/outputs are
> specified as memory, not register, so I think that I'm safe.
I cannot say for certain without seeing the code and the context. I
would bet, though, that there is a better way to write that, or else
that you ought to be writing a straight assembly function (i.e. an .s
file).
zw