Commit graph

70 commits

Author SHA1 Message Date
Kai Nacke
c1c7846e74 Introduce new ABI class for PPC64LE.
The ABI for PPC/PPC64 big-endian is quite similar.
But the ABI for PPC64 little-endian is more like the ARM ABI.
2016-03-28 03:14:00 +02:00
Kai Nacke
412aa04ef6 Linux/AArch64: More ABI implementation.
This is still not perfect but already fixes some test failures.
2016-03-12 20:44:19 +00:00
Kai Nacke
96b452b218 Add armeb/thumbeb to abi switch 2016-02-06 16:43:30 +01:00
Dan Olson
b9b4564d22 Implement ARM AAPCS ABI
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.
2016-02-05 09:04:09 -08:00
Martin
b8de3531a8 Fixes and adaptations for generic x86 and Win64 TargetABIs
* 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
2015-12-08 19:15:15 +01:00
Martin
0a758b180f Refactor TargetABI helpers 2015-12-06 17:42:47 +01:00
Martin
ddfaac10b3 Rename DtoAggrCopy/ZeroInit() to DtoMemCpy/SetZero() overloads
And replace some obvious load->store combos by a memcpy.
2015-12-04 22:23:09 +01:00
Martin
740a21eb8f Rename DtoIsPassedByRef() to DtoIsInMemoryOnly()
Motivation: issue #937
2015-12-04 22:23:09 +01:00
Martin
fae3650f40 Fix 2 aesthetic clang-tidy glitches 2015-11-02 19:28:20 +01:00
David Nadlinger
9df487edff gen/ir: clang-tidy the world 2015-11-02 11:30:40 +02:00
David Nadlinger
44b0f7b615 driver/gen/ir: clang-format the world
This uses the LLVM style, which makes sense for sharing code
with other LLVM projects. The DMD code we use will soon all
be in D anyway.
2015-11-02 00:28:01 +02:00
Martin
2d959ea540 Make use of C++11 range-based for
Should be available now that support for LLVM < 3.5 has been dropped.
2015-11-01 14:49:04 +01:00
Martin
60d676e2a1 Drop support for LLVM < 3.5
This allows to clean up the code a little.
2015-10-30 22:24:05 +01:00
Martin
80c677be46 Slightly refactor ABIRewrite interface for clarification
* put(): pass DValue alone, without explicit D type
* get(): pass LLValue instead of a faked DValue
2015-09-26 00:30:24 +02:00
Martin
9e194bfe2c Refactor store-to-new-alloca code occurrences. 2015-09-25 17:12:42 +02:00
Martin
4b6bd7ab52 Merge branch 'master' into merge-2.067 2015-07-18 16:02:51 +02:00
Kai Nacke
4cf4690ab0 Use C calling convention for variadic functions on x86.
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.
2015-07-15 21:34:00 +02:00
David Nadlinger
7af77ab141 Fix va_list mangling for System V AMD64 2015-06-07 19:18:58 +02:00
kai
84b09dc658 Merge branch 'master' into merge-2.067
Conflicts:
	gen/abi.cpp
	runtime/druntime
2015-05-18 07:28:56 +02:00
kai
ca3915edcb Add minimal ABI class for MIPS.
Without this ABI class it is not possible to compile vararg funtions.
2015-05-18 06:53:58 +02:00
Kai Nacke
8aabe36b43 Add ABI class for AArch64.
With this class most compile errors are fixed.
Notable exceptions are std.math and core.stdc.stdarg.
2015-05-04 19:05:28 +02:00
Martin
b45cc2e478 Do not read from undefined bytes when bit-casting.
Apparently required for LLVM 3.2.
2015-02-24 19:37:26 +01:00
Martin
dbe801ddff Refactor ABI rewrites. 2015-02-23 22:52:12 +01:00
Martin
76d65d45b5 Never rewrite varargs passed by value. 2015-02-23 22:52:11 +01:00
Martin
97dfd89127 SysV ABI: prevent varargs from being only partially passed in registers. 2015-02-23 22:52:11 +01:00
Martin
c19550ad39 Fix va_arg intrinsic. 2015-02-23 22:52:11 +01:00
Martin
aa38fe06ec Refactoring: move ABI-specific variadic stuff to TargetABI type. 2015-02-23 22:52:11 +01:00
Martin
f4ee008a02 Implement rewriteArgument() for Intrinsic ABI. 2015-02-23 22:52:11 +01:00
Kai Nacke
0f345a5152 Replace TAB with spaces. 2014-10-10 18:41:37 +02:00
kai
73245393f2 Fix PPC32/64 ABI.
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.
2014-10-10 17:09:46 +02:00
Kai Nacke
58ff4f1807 More support for PPC64le target. 2014-09-27 20:44:07 -04:00
Alexey Prokhin
a6f358c59b Remove LINKintrisic 2014-07-10 18:10:46 +04:00
kai
2b6dbb03f4 Add IF_LOG to more logging statements.
Evaluating arguments which call toChars() or toPrettyChars() are much more expensive then checking Logger::enabled().
2014-06-26 06:54:38 +02:00
Alexey Prokhin
b819975c84 Eliminate the need for TypeFunction::funcdecl 2013-10-05 19:03:03 +04:00
kai
1e4a8fffc2 Remove DMDV1 and DMDV2. 2013-03-06 10:20:24 +01:00
David Nadlinger
3392f70a4e Move calling convention conversion into TargetABI.
The code is tightly coupled to TargetABI (the transformations
there only make sense knowing that the right CC is selected).
2013-02-26 00:20:45 +01:00
Martin
51b45675cc Support for Windows x64 ABI. 2013-02-10 22:08:35 +01:00
David Nadlinger
0a96aea868 Sort includes according to style guidelines:
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.
2013-02-07 21:20:55 +01:00
David Nadlinger
5f3ba41574 Removed redundant global.params.cpu field.
Now that we have global.params.targetTriple, the information
is only duplicated.
2013-02-07 17:36:54 +01:00
kai
9a0df005f3 Add ABI infrastructure for PPC64.
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.
2013-01-28 22:08:25 +01:00
David Nadlinger
9458911839 Added LLVM-style license headers to all our files. 2012-12-16 17:19:14 +01:00
David Nadlinger
c630ab56ff Fix #136 - return static arrays as sret parameters on non-x86.
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).
2012-07-07 23:53:46 +02:00
David Nadlinger
d5084d9051 Factored out x86 ABI code to separate file. 2012-06-06 20:39:38 +02:00
David Nadlinger
260faae6ec Remove inreg attribute from static arrays when enregistering them. 2012-06-06 15:44:54 +02:00
Dan Sanduleac
2748cdaa88 Fix #49: Static arrays that don't fit in a register should be passed using byval 2012-06-05 02:52:25 +01:00
Alexey Prokhin
629f13929e WIP: port to llvm 3.0 2011-10-25 15:43:39 +04:00
Alexey Prokhin
7f0ecdf7b9 More X86_64 ABI 2011-03-26 19:30:17 +03:00
Alexey Prokhin
20e6c65200 To follow D ABI, swap real and imaginary parts of a complex return value on X86_64
TODO: should we disable this transformation for ldc1 in order to keep its ABI unchanged?
2011-02-26 13:04:09 +03:00
Alexey Prokhin
b1e5993873 Started work on phobos 2010-10-27 18:13:46 +04:00
Benjamin Kramer
c220dcac05 IntegerType is now contextifed.
Requires llvm >= 78969. resistor says this will be the last context API change :)
2009-08-14 00:39:18 +02:00