Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #1212 (closed task: fixed)

Opened 4 years ago

Last modified 3 years ago

merging in llvmdc runtime

Reported by: lindquist Assigned to: fawzi
Priority: major Milestone: 0.99.8
Component: Core Functionality Version: trunk
Keywords: llvmdc Cc: dclugston@googlemail.com

Description

As there's been some positive reactions to the idea of merging the llvmdc tango runtime into the main tango tree, here comes the first patch for review.

This only covers the files that need modification. There's a slew of new files for the lib/compiler/llvmdc directory as well, I didn't want to clutter the patch with the whole runtime though...

I'm interested in feedback on making the math.Math changes less intrusive.

Attachments

llvmdc.diff (15.7 kB) - added by lindquist on 08/21/08 09:43:46.
updated patch for rev [3899]
llvmdc.2.diff (16.4 kB) - added by lindquist on 08/24/08 10:56:02.
llvmdc.3.diff (16.4 kB) - added by lindquist on 08/24/08 11:16:36.
made a few mistakes in the patch "revert"
tango-atomic.patch (5.5 kB) - added by ChristianK on 12/08/08 11:19:50.
tango-build.patch (2.3 kB) - added by ChristianK on 12/08/08 11:20:06.
tango-common.patch (8.0 kB) - added by ChristianK on 12/08/08 11:20:17.
tango-gc.patch (349 bytes) - added by ChristianK on 12/08/08 11:20:29.
tango-math.patch (2.9 kB) - added by ChristianK on 12/08/08 11:20:44.
tango-misc.patch (4.3 kB) - added by ChristianK on 12/08/08 11:20:57.
tango-build-posixversion.patch (1.0 kB) - added by ChristianK on 12/15/08 14:44:20.
fix for build-tango.sh

Change History

07/31/08 18:48:26 changed by lindquist

updated patch to reflect changes in the llvmdc repository, I've just removed our local copy and now rely on applying the attached patch to a svn checkout.

08/01/08 12:59:42 changed by lindquist

I've decided to change LLVMDC so that 80bit floats are always used for the 'real' type. This fixes a bunch of issues and complies with the spec. Cleaned up the patch a bit, though more can probably be done with improved (automatic?) intrinsic detection/handling.

Feedback is much appreciated.

08/05/08 04:43:18 changed by larsivi

  • cc set to dclugston@googlemail.com.
  • keywords set to llvmdc.
  • priority changed from normal to major.
  • milestone set to 0.99.8.

Don: Maybe you can look at the Math changes?

08/12/08 11:23:01 changed by Don Clugston

Those math changes look OK to me. Actually, those same functions could use some work in the DMD case! I'm not certain the DMD intrinsics always work properly.

08/21/08 09:43:46 changed by lindquist

  • attachment llvmdc.diff added.

updated patch for rev [3899]

08/21/08 09:50:27 changed by lindquist

llvmdc's inline asm and intrinsic support has improved a bit so patch updated.

This time it includes a reimplementation of core.Atomic using llvm atomic intrinsics. The implementation is probably incorrect, at least the unittest fails, but I'm unsure how it should really look, the casting is because llvm only supports atomics on integers of 8,16,32 and 64 bits.

It will currently fail on architectures that don't implement that intrinics to there types.

Regarding the existing X86 implementation, It doesn't work due to missing 'ret' instructions, I don't see anywhere in the spec stating that falling off the end of a function implicitly add a ret, preserving EAX etc. In LLVM, the inline asm will end, and llvm will take over, inserting its own ret instruction and overriding the return value computed in the inline asm.

We could really use some testing of our inline asm support by someone who knows it well. While work on ABI compiliance has only just begun, it's something I'm very interested in fixing.

08/24/08 03:05:36 changed by Don Clugston

Regarding the existing X86 implementation, It doesn't work due to missing 'ret' instructions, I don't see anywhere in the spec stating that falling off the end of a function implicitly add a ret, preserving EAX etc. In LLVM, the inline asm will end, and llvm will take over, inserting its own ret instruction and overriding the return value computed in the inline asm. 

If the function is 'naked', then the programmer needs to add 'ret'. Otherwise, the compiler is responsible for setting up and ending the stack frame (if any), which includes the ret.

Please don't make GDC's mistake of declaring D_InlineAsmX86 before the D ABI is supported! Is there a LLVM which will work on Win32?

08/24/08 10:56:02 changed by lindquist

  • attachment llvmdc.2.diff added.

08/24/08 11:00:46 changed by lindquist

I've updated the patch again, as some of the changes last time was broken.

Basically, LLVM does not support splitting asm blocks. This means a call can't be wrapped in two asm blocks with pushad/popad. I've been talking to the LLVM developers about this and it's not going to change.

I don't see anywhere in the spec where it says that this is actually allowed either so it's not too bad imho.

We do have a LLVMDC for Win32, but there's problems with inline asm specifically, as well as exception handling not implemented at all... Elrood has been kind enough to make an installer available, if you still want to take a look, however, I'm not sure how up to date it is.

We do currently define D_InlineAsmX86, and I'm not sure I want to remove that, Don, see my comment on the ticket for GDC on this issue.

08/24/08 11:02:08 changed by lindquist

the win32 installer is here: http://incasoftware.de/~elrood/

08/24/08 11:16:36 changed by lindquist

  • attachment llvmdc.3.diff added.

made a few mistakes in the patch "revert"

08/25/08 03:39:38 changed by Don Clugston

We do currently define D_InlineAsmX86, and I'm not sure I want to remove that, Don, see my comment on the ticket for GDC on this issue.

And see my reply. That MUST be changed. It's a misreading of the spec page to believe that the ABI is optional. It is IMPOSSIBLE to write inline asm if you don't know what the calling convention is.

09/02/08 10:08:17 changed by ChristianK

A status update: we have removed D_InlineAsmX86 (replaced by LLVM_InlineAsmX86) and made naked an error. Tomas continues to work on supporting the D ABI.

09/08/08 16:30:40 changed by sean

  • status changed from new to assigned.

Cool. I'll "accept" this ticket and wait for your say-so before applying changes.

10/20/08 04:35:34 changed by larsivi

We're getting closer to the next Tango release - unless work starts now, I don't think there is much point in trying this before the release?

11/19/08 07:36:48 changed by larsivi

  • owner changed from sean to fawzi.
  • status changed from assigned to new.

12/08/08 11:19:50 changed by ChristianK

  • attachment tango-atomic.patch added.

12/08/08 11:20:06 changed by ChristianK

  • attachment tango-build.patch added.

12/08/08 11:20:17 changed by ChristianK

  • attachment tango-common.patch added.

12/08/08 11:20:29 changed by ChristianK

  • attachment tango-gc.patch added.

12/08/08 11:20:44 changed by ChristianK

  • attachment tango-math.patch added.

12/08/08 11:20:57 changed by ChristianK

  • attachment tango-misc.patch added.

12/08/08 11:28:17 changed by ChristianK

I have attached the remaining changes to Tango LDC requires. Some (minor) changes had been filed separately as #1309. The patches are split by topic, though I just noticed part of the gc change slipped into tango-common.patch, instead of being in tango-gc.patch.

Most of them should not require further discussion, however there are also:

  • some of fawzi's darwin changes that are not yet in tango
  • slightly ugly changes to tango.math
  • slightly ugly workarounds for the lack of 'naked' in LDC in Thread.d

12/11/08 14:50:15 changed by Don Clugston

Are the math.IEEE changes still required? I think I fixed them. The other ones mostly look like support for intrinsics, which actually don't even work for DMD! But I think they can be folded in as-is... provided they are still current.

12/11/08 15:57:30 changed by ChristianK

The IEEE changes were part of fawzi's darwin patch. If you think you already fixed it, don't apply them - they're optional.

12/12/08 01:08:34 changed by fawzi

Indeed the IEE changes, atomic changes, and a couple of other changes are not needed. I had a very busy week, but this w.e. I plan to test everything well and see what to check in

12/12/08 08:42:04 changed by lindquist

the atomic stuff already in tango could probably work on x86 for ldc, however, using llvm's atomic intrinsics, we can have one implementation that will eventually work on all llvm targets that support them, also the code generators/optimizers understand theses intrinsics, and can do stuff like inlining, which is impossible when asm is used.

12/15/08 09:21:09 changed by fawzi

tango-build.patch applied (with minor changes) in r4169

tango-atomic.patch, tango-common.patch, tango-gc.patch, tango-misc.patch can be applied as they are

12/15/08 11:00:16 changed by fawzi

(In [4171]) LDC atomic implementation refs #1212

12/15/08 12:06:00 changed by fawzi

(In [4172]) LDC patch refs #1212

12/15/08 12:53:51 changed by fawzi

(In [4173]) LDC patch refs #1212

12/15/08 14:44:20 changed by ChristianK

  • attachment tango-build-posixversion.patch added.

fix for build-tango.sh

12/15/08 14:44:37 changed by ChristianK

Thanks for applying these! The modifications to build-tango.sh don't work though - $LDC is always unset. I attached a fix.

12/15/08 16:56:39 changed by fawzi

(In [4174]) LDC patch fixes refs #1212

12/15/08 18:09:00 changed by fawzi

  • status changed from new to closed.
  • resolution set to fixed.

(In [4175]) LDC patch fix (ChristianK) fix #1212