cinvoke-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: [cinvoke-dev] i686-pc-mingw32-gcc calling convention


From: Will Weisser
Subject: Fwd: [cinvoke-dev] i686-pc-mingw32-gcc calling convention
Date: Sat, 15 Jan 2011 10:35:16 -0500


The difference is that ECX and EDX are used to pass parameters in the fastcall calling convention.  If you look at cl_x86_win.c arch_set_register_parms or arch_is_register_parm you can see if the calling convention is not CINV_CC_FASTCALL then the register parameters struct will never get set to anything.   GCC is making the calls using the cdecl convention and so it doesn't need to set those registers, but c/invoke gives up a bit of performance in favor of code simplicity, by having one macro that works in both fastcall and cdecl; in the latter case, the ECX and EDX registers get set to zero but there is no debilitating effect from the called cdecl function's point of view.

   -W.W.


On Sat, Jan 15, 2011 at 10:08 AM, Dwight Schauer <address@hidden> wrote:
I added tool prefix functional to configure.pl and the Makefile
templates so that I can cross compile from Linux.

https://bitbucket.org/bogen/cinvoke/changeset/2e5f387b77aa
https://bitbucket.org/bogen/cinvoke/downloads (tag 1.03c)

I also made the following two fixes:

https://bitbucket.org/bogen/cinvoke/changeset/8cc4a9f17c34 Eliminated
printf error for windows (I64 vs ll)
https://bitbucket.org/bogen/cinvoke/changeset/1c1d36f6a300 Eliminated
assembly warning on call indirection

The issue I have is this:

./configure.pl --tool-prefix=i686-pc-mingw32-
Using platform 'X86_WIN'
...

Ok, that is fine.

However, the macro output from gcc_x86_win.h:

---< start clip >---
#define ARCH_CALL(regparms, ep) \
       __asm__("mov %0, %%ecx; \
                       mov %1, %%edx; \
                       call *%2" : \
                       : \
                               "m"((regparms).first), \
                               "m"((regparms).second), \
                "m"(ep));
---< end clip >---

cl_x86_win.h appears to be the same, just a different assembler syntax.

---< start clip >---
#define ARCH_CALL(regparms, ep) \
       __asm mov ecx, [(regparms).first] \
       __asm mov edx, [(regparms).second] \
       __asm call dword ptr [ep]
---< end clip >---


Neither don't seem to match the calling convention that
i686-pc-mingw32-gcc is laying down:

---< start clip >--- // snippets from cinvoke.s
       .loc 1 41 0
       movl    8(%ebp), %eax
       movl    4(%eax), %eax
       movl    %eax, (%esp)
       call    _arch_free_errstr
L2:
...
       .loc 1 50 0
       movl    $0, 12(%esp)
       movl    $LC0, 8(%esp)
       movl    $0, 4(%esp)
       movl    8(%ebp), %eax
       movl    %eax, (%esp)
       call    _context_set_error
       .loc 1 51 0
...
       .loc 1 54 0
       movl    $12, (%esp)
       call    _malloc
       movl    %eax, -12(%ebp)
---
       .loc 1 66 0
       movl    8(%ebp), %eax
       movl    %eax, (%esp)
       call    _free
       .loc 1 67 0
---< end clip >---

I'm assuming I'll need to make another arch .h/.c file to match that
calling calling convention, as i686-pc-mingw32-gcc is what I'm using
to target 32 bit windows.

i686-pc-mingw32-gcc --version
i686-pc-mingw32-gcc (GCC) 4.5.2

i686-pc-mingw32-gcc -dumpmachine
i686-pc-mingw32

I'm using http://www.gtk.org/download-windows.html and my cross
compiled programs that link against glib/gtk/etc do work.

Any thoughts or comments concerning this?

--DAS

_______________________________________________
cinvoke-dev mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/cinvoke-dev



reply via email to

[Prev in Thread] Current Thread [Next in Thread]