[dmd-internals] x86_64 ABI questions
David Nadlinger
code at klickverbot.at
Thu Jun 7 16:42:03 PDT 2012
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.
By the way, http://dlang.org/abi.html seems to be quite outdated, as it
still mentions static arrays being passed by reference.
Also related to my current LDC pre-release work, name mangling on OS X:
http://d.puremagic.com/issues/show_bug.cgi?id=8207
Thanks,
David
More information about the dmd-internals
mailing list