Commit graph

43 commits

Author SHA1 Message Date
Johan Engelen
04b89e642c Windows: Move the prepending of 0x1 to C++ mangled functions from frontend to the backend.
Windows x64 ABI: remove unnecessary \01 from mangled symbol name.

This removes the 0x1 byte from `.mangleof` accessible from user code.
Resolves issue #1519

Also let mangleForLLVM take a std::string, to enable C++11's moves.
2016-05-30 10:18:39 +02:00
Martin
dd21a805ee Trim signature of method ABIRewrite::type() 2016-05-29 11:04:29 +02:00
Dan Olson
cd216538f9 Merge branch 'master' into objc-wip 2016-04-08 22:38:39 -07:00
Dan Olson
462b089492 Move Objective-C runtime choice to TargetABI 2016-03-23 23:54:49 -07:00
Martin
97d6a123f9 Win32: Remove alignment attributes for byval varargs
As for regular args due to LDC issue #1356.
This fixes runnable/ldc_cabi1 and so dmd-testsuite passes again.
2016-03-18 21:23:38 +01:00
Dan Olson
032f2c9342 Add LINKobj and fix compile error on some systems 2016-03-02 00:30:58 -08: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
Kai Nacke
d072bdf7b6 Do not use global.params.is<OS>
This PR replaces the few uses of global.params.is<OS> with
global.params.targetTriple.isOS<OS>(). This avoids adding a new
boolean for each supported OS.
It also defines all xBSD-type OS as using the dso-registry.
2016-01-12 09:15:05 +01:00
Johan Engelen
4399271762 Fix a few compiler warnings. 2015-12-22 12:36:28 +01:00
Martin
16125f04f4 x86 ABI: Fix Solaris regression and work around MSVC byval alignment issue 2015-12-11 01:13:37 +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
e7f26a94b0 Prepare generic x86 TargetABI for proper MSVC support
Based on Rainer's work in
3e36652c2c
2015-12-06 19:09:33 +01:00
Martin
5fce371c91 Streamline generic x86 ABI 2015-12-06 18:07:54 +01:00
David Nadlinger
ca51f514e4 Convert some C-style casts 2015-11-02 11:30:40 +02: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
Martin
90197d6c72 Simplify working with LLVM attributes 2015-11-01 16:19:27 +01:00
David Nadlinger
cc3228351c abi-x86: Handle magic __c_(u)long structs 2015-09-23 13:35:06 +02:00
David Nadlinger
6f83cb2905 x86: Only skip empty structs on OS X 2015-09-16 18:37:48 +02:00
Dan Olson
f713ee56c7 OS X x86 ABI - fix struct return
OS X varies from IA-32 by returning structs of 1 or 2 bytes in EAX and 4
or 8 bytes in EAX:EDX; other structs still use an sret arg.  The return
value also is rewritten as an int type for LLVM to use the correct
return registers (this matches clang).
2015-08-29 11:56:00 -07: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
Martin
dbe801ddff Refactor ABI rewrites. 2015-02-23 22:52:12 +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
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
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
2d3de4a3d4 Fix ABI on Win32.
We can't simply use the C calling convention, as the D(MD)
ABI is callee-pop, and this is hardcoded in naked functions
with stack parameters.

The \1 "trick" is normally used to avoid prefixes added by
LLVM; on the 3.2 release, a patch is needed to make it work
for the @<n> stdcall suffixes as well.
2013-02-26 13:14:32 +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
88b8ba1053 extern(D): Return static arrays via sret parameters.
On x86_64, a proper solution (see GitHub #120) is still needed,
but this will have to wait until the special case for extern(D)
is gone from the implementation.

We need this right now as std.digest.md in 2.061 triggers a
miscompilation issue in the LLVM x86 backend (not the optimizer!)
when returning them directly as LLVM arrays.
2013-02-04 03:26:18 +01:00
kai
f806ec0ed5 Attribute holds no longer multiple values in LLVM 3.3.
The solution is to replace Attribute with AttrBuilder in IrFuncTyArg.
Then the argument attributes can be easily manipulated and transformed
into the final AttributeSet.
2013-02-03 15:09:36 +01:00
kai
5f37ae30cf LLVM 3.3: class Attributes is renamed to Attribute.
Some other renamings took place in "llvm/Attributes.h" but only this causes
compile errors in LDC.
Also uses new location of "llvm/IRBuilder.h".
2012-12-21 17:32:17 +01:00
David Nadlinger
9458911839 Added LLVM-style license headers to all our files. 2012-12-16 17:19:14 +01:00
kai
fde625b33d More changes to the Attributes class in LLVM 3.2. 2012-10-20 17:22:55 +02:00
kai
657fc42221 And still more changes for LLVM 3.2
There were additional changes to the Attributes class.
2012-10-15 18:31:18 +02:00
kai
a7c7b514c0 Add changes for LLVM 3.2
- The Attributes class was changed again
- TargetData was renamed to DataLayout

Compiles again with LLVm 3.0, 3.1 and trunk(3.2).
2012-10-13 18:54:42 +02:00
David Nadlinger
62bfda0259 Fix #113 - promotion of small static array arguments to registers. 2012-06-06 22:55:59 +02:00
David Nadlinger
d5084d9051 Factored out x86 ABI code to separate file. 2012-06-06 20:39:38 +02:00