Commit graph

122 commits

Author SHA1 Message Date
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
Christian Kamm
287fa3446c Add -m64 switch to gcc calls on 64-bit platforms. 2009-01-23 10:12:57 +01:00
Christian Kamm
4042f90800 Apply afb's patch from #168 to use $CC instead of "gcc" for toobj and linker. 2009-01-17 17:52:09 +01:00
Christian Kamm
44c606c409 Missed line when removing env sanitizing. 2008-12-14 16:39:27 +01:00
Christian Kamm
dabe5d3efd Remove unportable env-sanitizing code. If it is really needed, it needs to be
rethought. Closes #131.
2008-12-14 16:30:06 +01:00
Tomas Lindquist Olsen
a012859bae Fixed problem with moduleinfo thinking it imports itself, causing assertion failure, fixes #138 2008-12-04 14:36:11 +01:00
Tomas Lindquist Olsen
649b860d2b Added error when gcc cannot be found. 2008-12-01 15:21:33 +01:00
Tomas Lindquist Olsen
d3ae488730 Added error when invoking gcc fails 2008-12-01 15:18:22 +01:00
Tomas Lindquist Olsen
e0972b0793 Fixed ModuleInfo generation to no longer use the ModuleInfo class' default initializer for types/defaults, it's unsafe as initializers don't necesarily match the "formal" type. There might be explicit padding.
Changed -g switch to emit DW_LANG_D debug info, make demangling work with a patched GDB, still more work to do for full support of D's Dwarf extensions.
Added getNullValue helper method.
2008-12-01 02:10:16 +01:00
Tomas Lindquist Olsen
8553fc9aa0 Fixed ModuleInfo patch check, failed on 64bit 2008-11-30 20:41:17 +01:00
Tomas Lindquist Olsen
f46f865375 Removed KDevelop3 project files, CMake can generate them just fine!
Fixed function literals in static initializers.
Changed alignment of delegates from 2*PTRSIZE to just PTRSIZE.
Changed errors to go to stderr instead of stdout.
Fairly major rewriting of struct/union/class handling, STILL A BIT BUGGY !!!
2008-11-29 21:25:43 +01:00
Tomas Lindquist Olsen
d077bbc5e6 D2: Fixed global constants not initialized until module constructor. 2008-11-12 05:40:31 +01:00
Tomas Lindquist Olsen
582deb9827 D2 changes!
Removed druntime from the repository again.. Sorry :/
Updated the druntime port a bit, now requires druntime from trunk.
Added info in runtime/README on how to get druntime from trunk.
Added patch to add LDC support to druntime.
Removed some debug logging from D2 builds.
Fixed broken typeinfo for const/invariant in D2.
2008-11-12 07:22:05 +01:00
Tomas Lindquist Olsen
c4c1c1d72e Added initial D2 support, D2 frontend and changes to codegen to make things compile. 2008-11-11 01:38:48 +01:00
Christian Kamm
16b38a7fef Fix compile-time warnings. Adjust include in d-asm-i386. 2008-11-03 12:35:29 +01:00
Tomas Lindquist Olsen
6cf5ca6aba Removed warnings on ignored aligns. Only do aligment on packed structs, align(1) struct Packed { ... }
Changed the way struct/class fields are added, first small part of cleaning up these...
Make struct/class/union fields aware of any anonymous struct/union they might be part of, not yet really useful, but part of getting better union support.
2008-10-28 15:41:09 +01:00
Tomas Lindquist Olsen
6b9e85df48 Attempt at getting LLVM to provide a proper target data layout. Should assert now if things are borked.
Added untested support for Thumb target.
2008-10-27 17:37:34 +01:00
Tomas Lindquist Olsen
f89592b354 Nested access to with statement should work now. fixes #105 2008-10-27 01:40:47 +01:00
Tomas Lindquist Olsen
fdc172377e Fixed tuple fields, thanx downs 2008-10-27 01:11:41 +01:00
Tomas Lindquist Olsen
5ed0ab3ab8 Commented that codegen: <modulename> printf ... 2008-10-23 19:42:55 +02:00
Tomas Lindquist Olsen
a52f0330d0 Implemented first class delegates. closes #101 2008-10-22 21:50:08 +02:00
Tomas Lindquist Olsen
f7ea1da010 Removed TypeOpaque from DMD.
Changed runtime functions taking opaque[] to void[].
Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[].
Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86.
Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing.
Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way...
Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8.
Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
2008-10-22 14:55:33 +02:00