[dmd-internals] x86_64 ABI questions

Iain Buclaw ibuclaw at ubuntu.com
Fri Jun 8 01:41:09 PDT 2012


On 8 June 2012 00:42, David Nadlinger <code at klickverbot.at> wrote:
> I'm currently working on a few codegen issues in LDC, where I'm not quite
> sure if I understood the intended ABI for extern(D) on x86_64 correctly:
>
>  - What is the exact specification for returning static arrays by value?
>
>  - What is the ABI for D vararg functions? (extern(D) void foo(…);)
>
>  - What was the reason of explicitly exposing __va_argsave_t instead of
> going for compiler magic in vararg functions? The latter is what we do in
> LDC (LLVM provides va_* intrinsics), and it seems to work fine. We obviously
> try to be compatible to DMD, but I don't quite see why we should move
> towards an (at least subjectively) worse design: With the DMD
> implementation, the API is different from C _and_ requires annoying special
> casing of code for x86_64. Sure, code that relied on directly manipulating
> the argument pointer on x86 obviously can't work, but a program just using
> va_start/va_arg/va_end should compile fine on either platform without
> changes. With DMD, it doesn't.
>

I chose to put a finger to the system and remove __va_argsave_t from
the D frontend completely in gdc (via #ifndef IN_GCC).  Similarly for
the va_list type too (which might be void*, but then again for the
most popular architechtures, it's not), at the end of the day I'm
forced to use the type that the backend defines as the va type, as if
I change it everything gets broken in all aspects of backend code
generation and backend code checking.

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


More information about the dmd-internals mailing list