Commit Graph

644 Commits

Author SHA1 Message Date
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
Tomas Lindquist Olsen
886a66f4e0 Missing %s error param in main.cpp 2009-02-26 15:51:19 +01:00
Frits van Bommel
001f83a296 Don't crash if we don't know what ABI to use. Assume some defaults instead. 2009-02-26 15:23:52 +01:00
Frits van Bommel
695fc3f5c3 Fix some -vv output 2009-02-26 14:51:05 +01:00
Frits van Bommel
e37c82d1ec Use LLVM OStream wrapper instead of <iostream> in the logger.
llvm::OStream provides all std::ostream functionality (by holding a
std::ostream* internally), but
 * doesn't include <iostream>, avoiding per-file overhead.
 * allows the stream pointer to be null, and the (inlined) operators do nothing
   when that's the case. (This also allows removal of the ofstream("/dev/null")
   hack Logger used when disabled, which presumably wasn't very portable)
2009-02-26 14:51:02 +01:00
Tomas Lindquist Olsen
58a8711bc1 Fixed const/invariant struc/class fields of the form const int i = 4; they don't add a field. 2009-02-26 15:24:20 +01:00
Frits van Bommel
ff31c804a9 Fix x86_64 cfloat support to work on intended target :) 2009-02-26 14:48:47 +01:00
Tomas Lindquist Olsen
024946219a Forgot new files that were supposed to be in last commit. 2009-02-26 14:13:27 +01:00
Tomas Lindquist Olsen
57a69e8177 - Fixed LLVM style CL args for D2.
- Moved main() into its own file gen/main.cpp
- Fixed basic cross compilation
- removed the option for setting OS
- added support for llc's mattr, mcpu and mtriple switches
- added basic ABI abstraction for return value rewrites, it's not perfect and will probably be completely rewritten once I get to handling parameter rewrites as well.
- x86-64 extern(C) abi for cfloat returns now match (llvm-)gcc.
2009-02-26 14:11:49 +01:00
Frits van Bommel
f61733cb57 Call llvm_shutdown when shutting down the backend. 2009-02-25 19:30:06 +01:00
Frits van Bommel
b3d87205ad Use LLVM-style command line (instead of DMD-style)
Note: For a backward compatible interface, use the new bin/ldmd script. It
      supports all old options while passing on anything it doesn't recognize.

Some changes caused by this:
* -debug and -version are now -d-debug and -d-version due to a conflict with
  standard LLVM options.
* All "flag" options now allow an optional =true/=1/=false/=0 suffix.
* Some "hidden debug switches" starting with "--" were renamed because LLVM
  doesn't care about the number of dashes, so they were conflicting with other
  options (such as -c).
  The new versions start with "-hidden-debug-" instead of "--"
* --help works, but has a non-zero exit code. This breaks some Tango scripts
  which use it to test for compiler existence. See tango.patch.

Some changes not (directly) caused by this;
* (-enable/-disable)-FOO options are now available for pre- and postconditions.
* -march is used instead of -m (like other LLVM programs), but -m is an alias
  for it.
* -defaultlib, -debuglib, -d-debug and -d-version allow comma-separated values.
  The effect should be identical to specifying the same option multiple times.
  I decided against allowing these for some other options because paths might
  contain commas on some systems.
* -fPIC is removed in favor of the standard LLVM option -relocation-model=pic

Bug:
* If -run is specified as the last argument in DFLAGS, no error is generated.
  (Not very serious IMHO)
2009-02-25 17:34:51 +01:00
Frits van Bommel
8ce2c9773e Clean up the code generated when jumping out of inline asm and make label names more expressive. 2009-02-18 22:50:22 +01:00
Frits van Bommel
e3d6b1c051 Fix some assembler issues:
The assembler was miscompiling "add" (specifically, the "add reg/mem, imm"
variations).
The change that caused this seems to have been made because without it, some
"add"s didn't compile at all.

This patch reverts the previous change, and makes sure assembler operands are
remapped correctly even though the input operands auto-generated due to
updating operations aren't explicitly used.
2009-02-18 21:46:14 +01:00
Frits van Bommel
3ee7952451 Fix a latent bug in the asm code.
I think that technically, using "*m0" instead of "*0" allows LLVM to pick
between using the same memory as output 0 and using a new memory location.
(So far I haven't been able to construct a testcase that actually breaks
because of this, though)
2009-02-18 03:38:12 +01:00
Christian Kamm
461544fce8 Fix for fix from [974]. 2009-02-17 19:08:38 +01:00
Christian Kamm
f62df176d6 Allow 'return exp;' for void main().
It's unfortunate that for main the llvm type and D type don't match up...
2009-02-17 18:53:15 +01:00
Christian Kamm
d6a264e74b Fix #216 by implementing TypeExp::toElem. It just provides the appropriate
error message.
2009-02-17 18:25:34 +01:00
Frits van Bommel
9cad440d4c Fix the problems exposed by the callingconv1.d test case.
The first was that unless otherwise specified, inputs are assumed to be in
registers even if they specify a "matching output" that's in memory.

While testing that fix, I also ran into a bug causing the generated "matching
output" for any input was always the first one instead of the correct one.
2009-02-17 00:08:20 +01:00
Frits van Bommel
7c7ed26a17 Revert wilsonk's "fix" for the callingconv1.d problem. 2009-02-16 23:56:56 +01:00
Frits van Bommel
f5bd002d80 Add some extra debug output that's useful in diagnosing inline assembler bugs. 2009-02-16 23:56:56 +01:00
Christian Kamm
51385fe325 Reduce size of integer constant make x86-64 asm parsing code compile on x86-32. 2009-02-16 18:27:33 +01:00
Kelly Wilson
b77c44b7dc Fix for tests/mini/callingconv1.d 2009-02-15 22:56:10 -07:00
Kelly Wilson
7ea5df5a26 Fix 32 bit truncation of 'asm { movq RAX, 0xAA_1234_5678; }'...ie. move constant larger than 32 bits 2009-02-15 16:30:15 -07:00
Kelly Wilson
cc02076479 Fix shl/r bad operand size error 2009-02-15 16:26:12 -07:00
Frits van Bommel
2dec6aeb41 Implement implicit return after inline asm on x86_64 2009-02-15 18:04:22 +01:00