[Top][All Lists]

[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.


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

I also made the following two fixes: Eliminated
printf error for windows (I64 vs ll) Eliminated
assembly warning on call indirection

The issue I have is this:

./ --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), \
---< 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
       .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

I'm using and my cross
compiled programs that link against glib/gtk/etc do work.

Any thoughts or comments concerning this?


cinvoke-dev mailing list

reply via email to

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