Commit graph

42 commits

Author SHA1 Message Date
Martin
dd21a805ee Trim signature of method ABIRewrite::type() 2016-05-29 11:04:29 +02:00
Martin
3e20e4c627 Win64: Fix ICE when passing varargs > 64 bit 2016-03-17 21:46:04 +01:00
Johan Engelen
29ce4012af dmd2 --> ddmd. Merge (almost all of) our changes to dmd source into the new D source of dmd 2.069.2.
Also adds the CMake infrastructure to compile and link the D source files.

The build is partially broken:
- A few files in Phobos and druntime do not build
- MSVC build is broken because of unresolved symbols involving reals
2016-01-28 19:03:58 +01: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
0c5c5fa3ab Win64 ABI: inline-implement methods (aesthetics only) 2015-12-06 17:41:46 +01:00
Martin
386622848f Win64 ABI: Rewrite magic __c_long_double struct as double
__c_long and __c_ulong have already been passed directly as LL structs
containing a single 32-bit value, i.e., as 32-bit scalars in the end.

__c_long_double on the other hand was rewritten to a 64-bit integer as any
other 64-bit POD struct, and so passed in a GP register instead of an XMM
register.
2015-12-06 17:37:48 +01:00
Martin
7c544be9d1 Respect explicit type alignments for LL args passed im- and explicitly by value
And for sret args too, except for MSVC targets.

At least on Win64, the sret align attributes lead to ICEs for std.bitmanip
and std.uni (release only), when computing the known alignment in the LLVM
inliner pass:

Assertion failed: I->getParent()->getParent() ==
Q.CxtI->getParent()->getParent() && "Got assumption for the wrong function!",
file C:\LDC\llvm\lib\Analysis\ValueTracking.cpp, line 711
2015-12-04 23:25:06 +01:00
David Nadlinger
05d45350aa clang-tidy: Add readability-else-after-return 2015-11-02 11:30:40 +02: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
David Nadlinger
0b4bcbc28c Merge pull request #1181 from kinke/attribs
Simplify working with LLVM attributes
2015-11-01 17:52:45 +02:00
Martin
90197d6c72 Simplify working with LLVM attributes 2015-11-01 16:19:27 +01: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
5c68fb25a4 Win64 ABI: pass 'this' before 'sret' for extern (C++) 2015-10-12 22:15:49 +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
Johan Engelen
3931fd7d24 Win64 ABI: do not (yet) return dynamic arrays via sret.
The druntime calling code in gen/arrays.cpp to e.g. `_d_newarrayU` is not yet able to handle sret.
2015-04-15 21:43:30 +02:00
Martin
626875d595 Win64 ABI: Return 80-bit real/ireal on x87 stack.
Just like DMD. Inline assembly in druntime/phobos depends on this.
Only relevant for MinGW-w64 as MSVC uses 64-bit real.
2015-03-16 00:16:16 +01:00
Martin
d24fc71a81 Win64 ABI: Treat dynamic arrays and delegates as structs.
I.e., pass them explicitly ByVal and return them via sret.
2015-03-16 00:10:36 +01:00
Martin
01e3e372fa Win64 ABI fix: return non-POD structs via sret.
And get rid of obsolete integer rewrites on Win64 and PPC.
2015-02-28 22:51:51 +01:00
Martin
dbe801ddff Refactor ABI rewrites. 2015-02-23 22:52:12 +01:00
Martin
97dfd89127 SysV ABI: prevent varargs from being only partially passed in registers. 2015-02-23 22:52:11 +01:00
Martin
e7bfb78632 Refactor attributes system.
By introducing abstractions for attribute builder and set since they differ
greatly between LLVM 3.1-3.3.
2015-02-23 22:52:11 +01:00
Martin
5e3785159f Re-reverse parameter order for extern(D). 2015-02-23 22:52:11 +01:00
Martin
965b97c571 Refactor Win64 ABI.
I've decided to use a consistent scheme here - types are returned the same
way as they are passed as arguments. So cfloat as 64-bit struct in RAX,
cdouble/creal and 80-bit real/ireal as types > 64 bit via sret.

MS allows using the x87 stack, but there are no official guidelines as
they don't use x87 at all.
2015-02-23 22:52:11 +01:00
Martin
42c793d12b Use single ByVal ABI rewrite for both Win64 and PPC. 2015-02-23 22:52:11 +01:00
Martin
d8bdb77e47 Get rid of CfloatToInt ABI rewrite and extend CompositeToInt.
CompositeToInt now also accepts complex number pairs and all other types,
not just pointers to structs/static arrays.
2015-02-23 22:52:10 +01:00
Martin
9c9d0f66c7 Don't swap real and imaginary parts of complex numbers.
Rely on LLVM to select a sane order, don't use DMD as reference anymore.
2015-02-23 22:52:10 +01:00
Martin
c15e1a3e9f Win64 fix: don't attempt to rewrite composites of size 0 to integers 2015-02-23 22:52:10 +01:00
Martin
b8833b3d99 Win64 fix: pass 64-bit reals as doubles 2015-02-23 22:52:10 +01:00
Martin
9839cfb889 Experimental varargs fix 2015-02-23 22:52:10 +01:00
Martin
fc59c34da6 Fix and clean-up Win64 ABI 2015-02-23 22:52:10 +01:00
Martin
c64070c09e Win64 ABI hotfix 2014-10-21 23:02:36 +02:00
Martin
31e2c3eae9 Fix Win64 ABI wrt. passing structs > 64 bit 2014-10-21 21:52:23 +02:00
Alexey Prokhin
a6f358c59b Remove LINKintrisic 2014-07-10 18:10:46 +04:00
Alexey Prokhin
b819975c84 Eliminate the need for TypeFunction::funcdecl 2013-10-05 19:03:03 +04:00
kai
37558273c2 Remove SARRAYVALUE 2013-03-06 10:20:24 +01: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
David Nadlinger
3662b06a88 Remove unused variable. 2013-02-13 00:07:52 +01:00
Martin
51b45675cc Support for Windows x64 ABI. 2013-02-10 22:08:35 +01:00