Commit graph

143 commits

Author SHA1 Message Date
Benjamin Kramer
51c02d192a Some minor cleanups
* remove an #ifdef USE_METADATA I accidently left in
* remove now unneeded llvm-version includes
* fix indentation in metadata.h
* prevent the "Found native target" message from interrupting ccmake
2009-07-20 18:16:11 +02:00
Benjamin Kramer
03020aea39 raw_fd_ostream takes a force parameter now
Build fix for LLVM 75801.
2009-07-15 20:04:42 +02:00
Benjamin Kramer
23b83c4d7b Target.addPassesToEmitFile takes a formatted_raw_ostream now
Build fix for LLVM r75670
2009-07-14 23:06:31 +02:00
Benjamin Kramer
0ee2f34611 Don't use llvm::getGlobalContext() anymore 2009-07-13 20:16:15 +02:00
Benjamin Kramer
331319dab1 Build fix for the latest LLVMContext changes (LLVM r75445)
This shouldn't break the build with older LLVM revs. We include
LLVMContext.h in gen/llvm.h now to make the transition a little bit
easier.
2009-07-13 12:17:58 +02:00
Benjamin Kramer
45f7401a5b Remove all of the now unecessary #if LLVM_REV 2009-07-11 14:09:33 +02:00
Christian Kamm
756a2cb2a1 Adjust LDC to work with the LLVMContext LLVM changes.
This means we now require a fairly new LLVM revision. I use 75234.
2009-07-10 21:30:02 +02:00
Benjamin Kramer
22b36384b0 Fix build for LLVM >= r74640
Some LLVM objects now take a 'Context' to make multi-threaded apps easier.
Since we're not multi-threaded it's safe to use llvm::getGlobalContext()
which gives us the same behavior as we had before.
2009-07-03 17:24:35 +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
Christian Kamm
b4f8bd6e52 Fix #318 by making a list of all seen template instances in a module for
singleobj compilation and then making sure they get emitted in their entirety.
2009-06-06 09:47:32 +02:00
Frits van Bommel
060d18b91e Fix a bug in DtoNestedInit and update an unrelated comment. 2009-06-03 12:32:35 +02:00
Tomas Lindquist Olsen
092381577f Some minor changes to handling of variables referenced from nested functions in D2 .
Added generation of new 'void*[4] reserved;' !ModuleInfo member .
2009-06-03 03:04:47 +02:00
Robert Clipsham
435d3069f6 Automated merge with http://hg.dsource.org/projects/ldc 2009-06-02 17:12:37 +01:00
Frits van Bommel
fd037f35e9 Fix a type mismatch in ModuleInfo generation. 2009-06-01 23:17:47 +02:00
Robert Clipsham
91ddf6140a More tweaks. 2009-06-01 18:58:21 +01:00
Tomas Lindquist Olsen
b64ad3299e Use RTTIBuilder to build !ModuleInfo, still needs some work. 2009-05-17 17:04:47 +02:00
Tomas Lindquist Olsen
9be5694168 Added error messages when failed to open files for .bc and .ll output, instead of just trying to write to the stream, pretty similar to the #281 problem. 2009-05-17 14:40:09 +02:00
Tomas Lindquist Olsen
0a77bd9fa6 Add error message when failed to open output stream for native asm output. Fixes ticket #281 . 2009-05-17 14:20:27 +02:00
Tomas Lindquist Olsen
c0f2af5afd Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Added -v-cg switch, which right now just prints "codegen: module.name (module/name.d)" to stdout, this can really help figuring out where, in some complex build command, things go wrong.
2009-05-16 18:19:52 +02:00
Frits van Bommel
57fc3463f6 Run backend without optimizations when no optimization parameters were used,
even when not generating debug info.
2009-05-10 20:22:08 +02:00
Frits van Bommel
cf0b8936ce Factor out the code to find gcc, and add a command-line option to override the
default executable name.
This should help cross-compilation by allowing a cross-gcc to be specified from
the configuration file instead of only through the CC environment variable.
2009-05-04 13:32:16 +02:00
Frits van Bommel
96108f8e7c Now the backend wants an enum value as optimization level.
Hopefully this'll be the last change to that code...
2009-04-30 11:56:03 +02:00
Frits van Bommel
b9849d86b6 Update codegen to (hopefully) work correctly with newer LLVM trunk, where
there's no longer a Fast flag. (It has been replaced by an optimization level)
Untested because I haven't compiled that recent an LLVM yet :).
2009-04-29 10:26:28 +02:00
Tomas Lindquist Olsen
95b94935ee Moved special casing of 'assert(this, "null this");' generated statements from !ThisExp into !AssertExp.
Fixed filenames for array bounds errors and probably others, fixes #271 .
2009-04-27 13:30:48 +02:00
Christian Kamm
17dbddfe41 Force 'fast' compilation when debug info is requested. LLVM trunk seems to
skip debug info for non-fast compilation.
2009-04-26 18:21:07 +02:00
Tomas Lindquist Olsen
134870c873 Disabled resetting types between modules MAO (more at once). Fixes guaranteed MOA compilation segfault. 2009-04-17 17:16:55 +02:00
Tomas Lindquist Olsen
c7936c2ace !ClassInfo instances were not mutable, this is necessary for .classinfo based locking to work. !ModuleInfo generation was commented out as well. 2009-04-17 00:54:20 +02:00
Tomas Lindquist Olsen
37cf5a5789 Added Doxygen file.
Completely seperated type and symbol generation. Should fix a lot of bugs, but is not yet 100% complete.
2009-04-15 20:06:25 +02:00
Tomas Lindquist Olsen
c6e9f7f9e2 Moved ir/irtype.* into ir/irdtype.*.
Renamed IrType to IrDType, analogous to IrDSymbol.
2009-03-31 20:21:28 +02:00
Frits van Bommel
e129494812 Allow specific optimization passes to be requested from the command line.
Now you can run "`ldc test.d -c -mem2reg -simplifycfg`" if you feel the urge.
The -O<N> options are still supported, and are inserted in the passes list in
the position where they appear on the command line.
(so -simplifycfg -O1 -instcombine does the "right thing")

One small change: -inline is renamed to -enable-inlining due to a naming
conflict with the option to add the -inline pass. -inline now inserts the
inlining pass in the position specified, not in the middle of -O<N>.
(ldmd has been updated to translate -inline to -enable-inlining)
2009-03-29 15:46:55 +02:00
Christian Kamm
ca6a07e2e5 Emit function bodies before generating the module info to make sure static
ctors are collected correctly. Fixes run/constructor_03.
2009-03-28 20:45:33 +01:00
Christian Kamm
c5a09c9deb Force initialize the runtime module in Module::genLLVMModule. It is required
for all non-trivial D modules anyway, so why load it lazily? This fixes
run/typeid_83.d (DtoDeclareTypeInfo expects runtime to be initialized)
2009-03-28 20:01:37 +01:00
Tomas Lindquist Olsen
ec986231e5 Eliminated the need for resolve, declare, const-init and define lists to drive code generation. 2009-03-27 21:50:32 +01:00
Tomas Lindquist Olsen
daef67acc3 Changed use of toObjFile to a new codegen method.
More versioning of DMD specific codegen code.
2009-03-27 17:54:27 +01:00
Tomas Lindquist Olsen
c42c90ea80 * Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
* Added #if IN_DMD versioning around DMD backend specific code in the D1 frontend, D2 is currently broken.
* All part of a greater cleanup scheme.
2009-03-26 20:45:53 +01:00
Frits van Bommel
cc12db505e Make error message on assembler failure more informative (hopefully) 2009-03-08 11:46:55 +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
Frits van Bommel
a742c59a67 Pass -m32/-m64 on to gcc when assembling and linking 2009-03-01 22:59:03 +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
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
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
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
Christian Kamm
b3524ef5f4 Now that we're using LLVM 2.5, we can stop always running the
CFGSimplification pass.

The pass was originally added as a workaround for a LLVM 2.4 bug where debug
info would reference labels that have been optimized away.
2009-02-12 18:39:03 +01:00
Christian Kamm
7c93355672 Mostly rewrite debug info generation in terms of llvm/Analysis/DebugInfo.h.
Add getCompilationModule to Dsymbol and fix template compile unit decision code.
Runtime compiles with -g again.
2009-02-08 16:50:22 +01:00
Tomas Lindquist Olsen
fc480b7fd8 SWITCHED TO LLVM 2.5 !
Applied patch from ticket #129 to compile against latest LLVM. Thanks Frits van Bommel.

Fixed implicit return by asm block at the end of a function on x86-32. Other architectures will produce an error at the moment. Adding support for new targets is fairly simple.

Fixed return calling convention for complex numbers, ST and ST(1) were switched around.

Added some testcases.

I've run a dstress test and there are no regressions. However, the runtime does not seem to compile with symbolic debug information. -O3 -release -inline works well and is what I used for the dstress run. Tango does not compile, a small workaround is needed in tango.io.digest.Digest.Digest.hexDigest. See ticket #206 .
2009-02-08 05:26:54 +01:00
Tomas Lindquist Olsen
7d2a0a84a7 Removed some dead code.
Fixed assertion filenames for imported template instances. Fixes #152 .
2009-02-04 02:10:23 +01:00
Tomas Lindquist Olsen
bd4f7ec731 Replace assertion with errormessage for unsupported calling conventions. like Pascal. See dstress/run/e/extern_10_A.d 2009-02-04 00:04:09 +01:00
Tomas Lindquist Olsen
dc5944df99 Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Fixed align N; in asm blocks.

Fixed inreg parameter passing on x86 for ref/out params.

Removed support for lazy initialization of function local static variables, I have no idea why I ever implemented this, it's not in the D spec, and DMD doesn't support it :P

Some of the global variable related changes might cause minor regressions, but they should be easily fixable.
2009-02-03 08:54:57 +01:00
Tomas Lindquist Olsen
8ab98dad49 Fixed assertion failure when object.d is missing the ModuleInfo class 2009-02-02 02:35:44 +01:00