Commit graph

64 commits

Author SHA1 Message Date
Martin
7dcadc299a SysV AMD64 ABI: don't rewrite to a single bit.
Otherwise std.uni cannot be compiled:
getAbiType(BitPacked!(bool, 1LU)) mismatch: i1 vs. i8
gen/tollvm.cpp:527: void DtoStore(llvm::Value*, llvm::Value*): Assertion `src->getType() != llvm::Type::getInt1Ty(gIR->context()) && "Should store bools as i8 instead of i1."' failed.
2015-02-23 22:52:11 +01:00
Martin
12aa7864d4 System V AMD64 ABI: don't use CompositeToInt rewrite.
Hope for toArgTypes() to get it right and otherwise be compatible with DMD.
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
7388861686 Validate new toArgTypes()-based System V implementation against
previous version.
2015-02-23 22:52:11 +01:00
Martin
e05b5d2691 Fix System V AMD64 ABI and facilitate debugging.
Fix: void type's size isn't 0 and so must be filtered out in returnInArg()
before calling passByVal().
2015-02-23 22:52:11 +01:00
Martin
a00c2b5732 Rewrite suited structs/static arrays as integers for extern(C) too. 2015-02-23 22:52:11 +01:00
Martin
e5deefb1dd Re-implement __va_list struct allocation for System V AMD64 varargs ABI. 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
c6c05f1585 Daring, untested attempt to simplify the System V AMD64 ABI.
Rely on LLVM to assign the registers, for D linkage too.
2015-02-23 22:52:11 +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
kai
dbbbe0092b Fix for issue #637.
In case of a ctor `this` is passed to the function and is also the
return value. This is the perfect case for the `Returned` attribute.
But the x86_64 ABI missed the fact that the return value was a pointer
to a struct and did a struct rewrite, resulting in an bitcast
incompatible type.
2014-11-13 02:06:57 +01: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
David Nadlinger
cb341586e3 First merge of 2.064 beta.
This corresponds to DMD commit a913ce4bc59a94a022a27e390fc841f4aededffb.

Doesn't build Phobos yet.
2013-10-29 19:21:15 +01: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
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
8ff3a8060a Use llvm_unreachable instead of assert(0).
Also removed some unused functions.
2013-02-07 03:38:15 +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
David Nadlinger
2be27279c7 Added x86_64 System V ABI extern(D) TODO note. 2013-02-04 03:26:08 +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
4118cddd1f Cleanup: GCC warning fixes. 2012-12-20 01:21:10 +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
kai
2dbee75523 Prefer C++-style casts.
This is based on Item 2 of "More Effective C++". In general, the C++ cast operators are more expressive and easy to find,
e.g. by grep. Using const_cast also shuts up some compiler warnings.
2012-08-02 19:55:29 +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
ba9fb721ed Removed trailing whitespace. 2012-06-06 20:41:46 +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
f8bf70ff7a Fixed an assert when compiling derelict.
The assert was triggered by a line similar to this:
   extern(C) void func(float[4] a1, float[4] a2, float[4] a3, float[4] a4, float[4] a5);
2011-12-06 13:14:57 +04:00
Alexey Prokhin
629f13929e WIP: port to llvm 3.0 2011-10-25 15:43:39 +04:00
David Nadlinger
7a24e12736 Cleanup: Remove unused code in backend, silence some warnings.
This removed quite some clutter that has presumably piled up because LDC is seldom built with a lot of warnings enabled due to DMDFE.
2011-04-24 12:21:33 +02:00
Alexey Prokhin
7f0ecdf7b9 More X86_64 ABI 2011-03-26 19:30:17 +03:00
Alexey Prokhin
70aee84c70 Fix passing of a padded struct to a function 2011-02-26 20:16:01 +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
53fe662957 Fix a bunch of incorrect assert 2011-02-25 22:29:34 +03:00
Alexey Prokhin
b03babcab6 Fixes in X86_64 ABI 2011-02-25 22:28:45 +03:00
Alexey Prokhin
e921998d75 A few fixes for 64bit 2011-02-23 12:49:57 +03: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
Benjamin Kramer
977fa551ee Push the context through StructType::get.
Requires LLVM >= 78258. Also remove old #if's.
2009-08-06 01:47:39 +02:00
Frits van Bommel
4158fb474a Add an llvm::OStream workalike class for use with Logger::cout(), with the
crucial difference being special handling of `llvm::Type`s so they get printed
by name rather than printing their full representation (which can be positively
*huge*).

This allows re-enabling some logger calls that were disabled due to extreme
verbosity.
2009-06-16 19:31:10 +02:00
Tomas Lindquist Olsen
f6997cb604 D2:
Applied function type from D1 frontend that got removed in D2, it's critical for member function type to be correct.

Fixed a bunch of type discrepancies in druntime object.di vs. genobj.d .

Disabled (#if 0) some potentally very large type dumps for -vv .

Updated classinfo and typeinfo generation for D2, almost complete now.

Added finer grained checks for vtbl type mismatching, aids debugging.
2009-06-03 02:28:48 +02:00
Frits van Bommel
3718bd23fb Add nest attribute to this parameters on x86-64. This is a free extra
parameter register :).
2009-05-31 10:41:20 +02:00
Frits van Bommel
59f9b35cea Count the sret register as well when keeping track of how many integer registers
are available for extern(C) functions on x86-64.
Interestingly, llvm-g++ seems to have a very similar bug: http://llvm.org/pr4242
(So this breaks ABI-compatibility with llvm-gcc for this corner case, but gains
it with gcc...)

To clarify, this is about code like this:
{{{
struct S { void*[3] data; }
struct T { void*[2] data; }

// The T should be passed in memory, and p in the last int register.
extern(C) S fail(int, int, int, int, T t, void* p) {
    S s;
    s.data[0] = t.data[0];
    s.data[1] = t.data[1];
    s.data[2] = p;
    return s;
}
}}}
which should generate code functionally equivalent to this:
{{{
extern(C) S* succeed(S* s, int, int, int, int, T t, void* p) {
    s.data[0] = t.data[0];
    s.data[1] = t.data[1];
    s.data[2] = p;
    return s;
}
}}}
(with the same definitions for S and T)
2009-05-22 13:17:06 +02:00
Frits van Bommel
3164ceba17 Remove some overly verbose logging. 2009-05-19 20:46:33 +02:00
Frits van Bommel
541f3723cd Intrinsics shouldn't see struct padding, so use a special TargetABI for them
that removes it.
This unbreaks the `llvm_*_with_overflow` intrinsics.
2009-05-16 13:06:49 +02:00