This is the bulk of the AAPCS (Procedure Call Standard for the ARM
Architecture) used for C interop. This will be used for both arm and
thumb target triples. The extern(D) ABI tries to follows the AAPCS with
a few exceptions.
* x86: Return most POD aggregates <= 8 bytes in registers
* For extern(D), as in official Win32 D ABI specs [previously: sret]
* For all other calling conventions too, except for Linux and NetBSD
[previously: OSX and MSVC only]
* MSVC++ and extern(C++): treat structs with constructors as non-POD,
for both x86 and Win64 ABIs
* Win64: Pass and return magic C++ structs directly as LL aggregates,
rendering MSVCLongDoubleRewrite obsolete
* x86: Fix regression introduced by previous commits wrt. passing the
last struct argument in EAX register
0.15.1 used stdcall convention everywhere. But the ABI change in 0.15.2
requires use of the C calling convention for variadic calls on x86
because the stdcall convention does not support vararg functions.
Solution is to check the llvm::FunctionType if the function has varargs.
This commit also makes the C calling convention the global default
because according to the LLVM documentation the fastcc convention used
for D linkage does not support varargs.
This fixes issue #1000.
See http://llvm.org/bugs/show_bug.cgi?id=21087:
Static arrays were passed as e.g. [2 x i16]. The LLVM lowering uses a register for each entry,
extending it to 64bit. This is not the expected behaviour.
To work around this problem the PPC ABI now uses the byval-workaround from the Win64 ABI:
The struct/array is copied to some private memory and a pointer to this memory is passed to the function.
Structs/arrays of size 1/2/4/8 are cast to an integer and passed as integer.
This fixes all codegen crashes on Linux/PPC64le.
1. Main include corresponding to .cpp file, if any.
2. DMD and LDC includes.
3. LLVM includes.
4. System includes.
Also updated a few include guards to match the default format.
The generic ABI works well with PPC64 except for LLVM PR 14779.
(http://llvm.org/bugs/show_bug.cgi?id=14779)
The new ABI infrastucture is based on the UnknownTargetABI. The
PPC64 specific parts coming soon.
This should eventually be done on x86 and x86_64 as well, but as
discussed in GitHub issue #110/pull request #120, the ABI there needs a
closer look: at least on x86_64, we need to treat static arrays exactly
like if they were a struct containing T.length members of the same type
to be compatible with DMD (as soon as the ABI is correctly implemented
there, that is).
While for this reason I want to avoid a ABI change which could silently
break some code only to change the x86 ABI again shortly after, this
commit only touches the "default" ABI for unknown targets and thus
should be safe (as we give absoultely no ABI guarantees there anyway).