Commit Graph

25 Commits

Author SHA1 Message Date
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
Frits van Bommel
41c738f4da Re-apply [1346], which was reverted in [1348], now that padding should no longer
be a problem.
As noted before, this will break ABI-compatibility on x86-64, so recompile old
code before linking with newly-compiled code if you're on x86-64.
As an added bonus, I actually tested it this time :).
2009-05-14 20:40:56 +02:00
Frits van Bommel
287b1278d3 Remove struct padding when passing or returning in registers on x86-64 (extern(D) only) 2009-05-14 20:36:55 +02:00
Tomas Lindquist Olsen
f5d635dfc7 Adds explicit alignment information for alloca instructions in general, there's a few cases that still needs to be looked at but this should catch the majority. Fixes ticket #293 . 2009-05-14 13:26:40 +02:00
Frits van Bommel
72a546af4a Revert [1346] for now, it breaks because of padding :( 2009-05-12 16:53:43 +02:00
Frits van Bommel
ec476cc5f1 Remove an old workaround that was kept around for ABI-compatibility on x86-64
between different LLVM versions.
This means LLVM r67588 is required if you want to compile for x86-64, otherwise
the backend will assert when you try to return e.g. struct { int i; char c; }
from a function. (In particular, this is no longer compatible with LLVM 2.5)
It also means that any code returning small structs on x86-64 will probably
need to be recompiled in order to be linkable to code compiled with this change.
2009-05-12 15:50:48 +02:00
Frits van Bommel
83dda319ae Add #include "gen/llvm-version.h" to files that use the macro it defines... 2009-04-24 16:47:42 +02:00
Frits van Bommel
058998f1ad Update comments now that LLVM PR3861 has been fixed. However, since
conditionally removing the workaround makes the ABI dependent on LLVM version,
I reconsidered that.
(The same revision of LDC compiling for the same target should probably produce
code that follows the same ABI, right?)
2009-03-24 02:46:57 +01:00
Frits van Bommel
2dcc7be873 Workaround for LLVM PR 3861 (http://llvm.org/PR3861).
(LLVM abort()s in codegen if the second integer in a return value is <= i8 on
x86/x86-64)

This was breaking native compilation of Tango's TempFile module on x86-64.
2009-03-23 01:01:55 +01:00
Frits van Bommel
532cccbd3a Fixed some #includes to be correct for both D1 and D2 2009-03-08 12:13:22 +01:00
Frits van Bommel
941ccdfdc3 Future-proof the code to classify static array members of structs.
I made sure to create a merge conflict with the code attached to ticket #229
(which comments this code out due to changes in the DMD 'Type' type hierarchy)
so that if it gets committed as-is there will be a human looking at it.
2009-03-08 01:26:30 +01:00
Christian Kamm
ed9591d81f Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
same LDC call.
2009-03-07 14:25:30 +01:00
Frits van Bommel
1c6c4bc361 Two small bugfixes:
- See through typedefs and enums in passByVal
 - Don't depend on TypeFunction::parameters->dim being the actual number of
   parameters; it contains unexpanded tuples as single elements.
2009-03-06 19:12:48 +01:00
Frits van Bommel
3e15c659d1 Fix a typo 2009-03-06 17:00:34 +01:00
Frits van Bommel
27d3ab4546 Some calling convention work for x86-64:
- Implement x86-64 extern(C), hopefully correctly.
 - Tried to be a bit smarter about extern(D) while I was there.

Interestingly, this code seems to be generating more efficient code than
gcc and llvm-gcc in some edge cases, like returning a `{ [7 x i8] }` loaded from
a stack slot from an extern(C) function. (gcc generates 7 1-byte loads, while
this code generates a 4-byte, a 2-byte and a 1-byte load)

I also added some changes to make sure structs being returned from functions or
passed in as parameters are stored in memory where the rest of the backend seems
to expect them to be. These should be removed when support for first-class
aggregates improves.
2009-03-06 16:00:47 +01:00