[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC/experimental patch] qemu (x86_64 on x86_64 -no-kqe
From: |
Axel Zeuner |
Subject: |
Re: [Qemu-devel] [RFC/experimental patch] qemu (x86_64 on x86_64 -no-kqemu) compiles with gcc4 and works |
Date: |
Mon, 26 Mar 2007 08:16:00 +0200 |
User-agent: |
KMail/1.9.5 |
Hi Anthony,
On Monday 26 March 2007 01:44, you wrote:
> Axel Zeuner wrote:
> > On Saturday 24 March 2007 21:15, Anthony Liguori wrote:
> >> The tricky thing I still can't figure out is how to get ASM_SOFTMMU
> >> working. The problem is GLUE(st, SUFFIX) function. First GCC cannot
> >> deal with the register pressure. The problem I can't seem to fix though
> >> is that GCC sticks %1 in %esi because we're only using an "r"
> >> constraint, not a "q" constraint. This results in the generation of
> >> %sib which is an invalid register. However, refactoring the code to not
> >> require a "q" constraint doesn't seem to help either.
> >
> > Hi Anthony,
> > could you please try the attached patch for softmmu_header.h? Allows
> > compiling with gcc4 and ASM_SOFTMMU.
>
> That did the trick. Could you explain what your changes did?
QEMU/i386 has only 3 three available registers if TARGET_I386 is selected
because ebx,ebp,esi,edi are used by the environment and T0, T1, T3( AKA A0).
This makes inline assembly really ugly. The called external C functions in
ASM_SOFTMMU are REGPARM(1,2), i.e. require their first arguments in eax, edx.
In the two ld functions three registers (eax, edx, ecx) are required and
destroyed because an external C function may be called. We relax the register
pressure a little bit by forcing the return value (res) into eax , because
the return value is returned in a destroyed register. Furthermore the called
C function returns its value in eax anyway (call %7).
The st functions are a little more tricky: we need three registers and the
assembly code requires a reload of %0 (ptr) after the check if the external
function must be called. In the external function the three remaining
registers are destroyed. After the call a need also to reload of %1 (v) into
register is needed, i.e. we need more registers. Register saving on the stack
does not work, because there exist already 2 "m" constraints: if the code is
compiled with -fomit-frame-pointers these are expressed as offsets relative
to %esp, i.e X(%esp) and would become invalid after pushes onto the stack.
One solution was to force all inputs to the asm block onto the stack, thats
what the replacement of the "r" constraints into "m" constraints do: they
force a memory reference. Because i386 can not do direct memory memory moves
one has to reload "m"(v) into ecx again, otherwise the generated assembler
code is invalid.
It must be mentioned, that the generated code is a little bit slower than the
original one.
Kind Regards
Axel
>
> Regards,
>
> Anthony Liguori
>
> > Kind regards
> > Axel
Re: [Qemu-devel] [RFC/experimental patch] qemu (x86_64 on x86_64 -no-kqemu) compiles with gcc4 and works, Axel Zeuner, 2007/03/25
Re: [Qemu-devel] [RFC/experimental patch] qemu (x86_64 on x86_64 -no-kqemu) compiles with gcc4 and works, Avi Kivity, 2007/03/25