Commit Graph

668 Commits

Author SHA1 Message Date
Kelly Wilson
da7fdb94f7 Fix for asm { jle short Lret; }, used by Tango since dmd accepts the 'short'. We just
throw the 'short/long' away right now.
2009-03-09 20:11:42 -06:00
Frits van Bommel
c1d9694494 Work around llvm bug #3749 better, or not at all if using a fixed llvm revision. 2009-03-09 13:29:25 +01:00
Frits van Bommel
0182641f85 Ignore the ABI some more for intrinsics 2009-03-09 03:44:11 +01:00
Christian Kamm
c49642a08f Make CompileUnit linkage compatible with llvm trunk. 2009-03-08 16:30:39 +01:00
Christian Kamm
fc5f35c410 Automated merge with http://hg.dsource.org/projects/ldc 2009-03-08 16:22:06 +01:00
Christian Kamm
13e83bf1c1 Improved template emission control for singleobj building. 2009-03-08 16:21:56 +01:00
Christian Kamm
520bc229ea Give compile units LinkOnceLinkage to circumvent duplicate symbols with LLVM linking. 2009-03-08 16:21:11 +01:00
Frits van Bommel
622a93a810 Make LDC work with LLVM trunk (s/LinkOnceLinkage/LinkOnceOdrLinkage/)
Also moved the #defines for linkage types into a separate header instead of
mars.h so we can #include revisions.h without having to rebuild the entire
frontend every time we update.
(I'm using revisions.h to get the LLVM revision for use in preprocessor
conditionals. It should work with LLVM release 2.5, old trunk and new trunk)
2009-03-08 16:13:10 +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
cc12db505e Make error message on assembler failure more informative (hopefully) 2009-03-08 11:46:55 +01:00
Tomas Lindquist Olsen
d8c89ce681 really fixed fstp a, b; on x86-64 2009-03-08 04:23:44 +01:00
Tomas Lindquist Olsen
9a5350afb1 Applied rev two operand form fstp fix to x86-64 asm 2009-03-08 02:46:37 +01:00
Tomas Lindquist Olsen
341dfe7a9f Merge 2009-03-08 02:36:45 +01:00
Tomas Lindquist Olsen
16668d1508 Fixed two operand form of X86 fstp instruction. (throw away second operand!) 2009-03-08 02:36:09 +01:00
Frits van Bommel
59f677c7ae Apply [1053] to x86-32 asm as well. 2009-03-08 02:07:53 +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
Frits van Bommel
2687d58198 Always pass an address expression (not a var expression) to asm operands of
type Arg_Memory.

This fixes the following code:
{{{
  void f(real x) { asm { fld x[RBP];      } }
  void g(int x)  { asm { mov EAX, x[RBP]; } }
}}}
2009-03-08 00:57:58 +01:00
Christian Kamm
95f12f04f1 Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
The switch allows the optimizer and inliner to run on all modules at once and opens the door for template instantiation improvements that should lower compile time and executable size.
2009-03-07 19:38:00 +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
5af82ee8d3 Fix a bug in the X86 ABI. The size of a struct is different from the size of a
pointer to that struct...
2009-03-06 21:15:13 +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
Tomas Lindquist Olsen
b8e9d554e5 Fixed lazy arguments again. 2009-03-05 18:33:20 +01:00
Frits van Bommel
cc612c7290 Fix hasUnalignedFields(): take static arrays into account too. 2009-03-04 23:17:32 +01:00
Frits van Bommel
d257890e29 Fix bug in default implementation of ABIRewrite::getL. 2009-03-04 23:06:23 +01:00
Tomas Lindquist Olsen
65ba1d4d88 Updated ABI handling to be more flexible with regard to reusing lvalues and allocating fewer temporaries. 2009-03-04 17:24:25 +01:00
Tomas Lindquist Olsen
f25bbe3d09 Fixed inreg attribute to no longer overwrite sign/zeroext. 2009-03-03 21:20:20 +01:00
Tomas Lindquist Olsen
bb495c6e40 remove memory clobber again ... 2009-03-03 19:27:23 +01:00
Tomas Lindquist Olsen
ae214b18e7 Added ~{memory} clobber when a jump_target is generated in inline asm (branch out of inline asm) 2009-03-03 19:18:47 +01:00
Christian Kamm
a3bc6ce3f9 Switch LLVM_InlineAsm -> D_InlineAsm. It's for real this time, hopefully. 2009-03-03 17:44:56 +01:00
Tomas Lindquist Olsen
8ce5a07fc0 Fixed potential assertion failure in taking address of function as a constant expression. 2009-03-03 17:27:14 +01:00
Tomas Lindquist Olsen
fdecec122a Disabled some extensive LLVM value logging with -vv that dramatically increases -vv output length for little value. 2009-03-03 17:21:35 +01:00
Tomas Lindquist Olsen
c3a53c0128 Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct. 2009-03-03 15:08:26 +01:00
Frits van Bommel
84963b9a03 Oops, merge with mainline and actually push this time... 2009-03-03 09:51:15 +01:00
Tomas Lindquist Olsen
5dbe3ee8e2 Abstracted more (most) ABI details out of the normal codegen. 2009-03-03 02:51:21 +01:00
Frits van Bommel
a742c59a67 Pass -m32/-m64 on to gcc when assembling and linking 2009-03-01 22:59:03 +01:00
Tomas Lindquist Olsen
a71b028a0f Implemented basic -m32 and -m64 options. 2009-03-01 22:27:03 +01:00
Tomas Lindquist Olsen
3d6b0b68d5 Remember to set asm type back to void and n=0 when rewriting to sret asm return. 2009-03-01 20:22:10 +01:00
Tomas Lindquist Olsen
ee1e545a0a Removed some code that wasn't supposed to be in last commit! 2009-03-01 19:06:47 +01:00
Tomas Lindquist Olsen
61dfb11bc5 - Fixed x86-32 C ABI for complex number return values.
- Removed unused code from the ABI class.
2009-03-01 19:01:05 +01:00
Kelly Wilson
093a22d1d2 Just forgot an opcode for x64 2009-02-28 18:17:45 -07:00
Frits van Bommel
dd41366a99 Use llvm::CallSite instead of custom CallOrInvoke class. 2009-02-28 22:16:52 +01:00
Christian Kamm
2f5b7bcd3e Readded indentation that got lost in the dmd/mars.c -> gen/main.cpp move. 2009-02-28 15:06:09 +01:00
Christian Kamm
993a624e3e Don't reset gTargetData after compiling a module. Fixes segfault when
compiling more than one file.
2009-02-28 09:06:25 +01:00
Frits van Bommel
70b97b9d1e Remove initialization of padding of reals, ireals and creals.
According to the spec and C ABIs, the contents of padding is undefined.
This was breaking dstress creal_01,02,03,07,08,09 and 20 on x86-64.

The code was apparently added to fix creal_13,14 and 15, which explicitly
compare padding and assert if it's different. I'd argue those tests are broken.
(Also, on x86-64 they *also* fail)

The tests this fixes, on the other hand, are basic arithmetic.
2009-02-27 19:41:25 +01:00
Frits van Bommel
03ce6604a0 Fix cfloat return on x86_64: only perform ABI transformation for non-extern(D)
functions.
There's no need to waste cycles with extern(D), which we get to define
ourselves. Fixes tests/mini/asm8.d. (Since the asm abiret code already assumed
{xmm0, xmm1} returns)
2009-02-26 23:35:39 +01:00
Frits van Bommel
4f51adc810 Implement support for intrinsics returning struct types
(such as llvm.*.with.overflow)
2009-02-26 22:47:06 +01:00
Tomas Lindquist Olsen
bcd05cf258 Added some missing version identifiers. 2009-02-26 18:28:50 +01:00
Tomas Lindquist Olsen
7ef533b136 Fixed debug info for globals in D2. 2009-02-26 18:02:13 +01:00