Commit graph

212 commits

Author SHA1 Message Date
Johan Engelen
29ce4012af dmd2 --> ddmd. Merge (almost all of) our changes to dmd source into the new D source of dmd 2.069.2.
Also adds the CMake infrastructure to compile and link the D source files.

The build is partially broken:
- A few files in Phobos and druntime do not build
- MSVC build is broken because of unresolved symbols involving reals
2016-01-28 19:03:58 +01:00
Johan Engelen
70a6e73188 Cleanup runtime fwd decls and use ABI functiontype rewriting 2015-11-22 01:27:26 +01:00
Martin
2dfa5e8569 Some more cosmetic fixes
Found by searching for lines > 80 chars.
2015-11-05 19:12:32 +01:00
David Nadlinger
05d45350aa clang-tidy: Add readability-else-after-return 2015-11-02 11:30:40 +02:00
David Nadlinger
9df487edff gen/ir: clang-tidy the world 2015-11-02 11:30:40 +02:00
David Nadlinger
44b0f7b615 driver/gen/ir: clang-format the world
This uses the LLVM style, which makes sense for sharing code
with other LLVM projects. The DMD code we use will soon all
be in D anyway.
2015-11-02 00:28:01 +02:00
Martin
2d959ea540 Make use of C++11 range-based for
Should be available now that support for LLVM < 3.5 has been dropped.
2015-11-01 14:49:04 +01:00
David Nadlinger
f4f55abf27 Use thunks instead of calling _d_toObject for D interfaces
This allows us avoid the problems stemming from the 64 kiB
size limit hack in _d_toObject.

GitHub: Fix #1065.
2015-09-13 20:27:00 +02:00
David Nadlinger
553cc3705c Clarify ClassInfo/ModuleInfo size mismatch error messages
GitHub: Fix #1067.
2015-09-10 10:09:49 +02:00
David Nadlinger
6215acc15a Merge pull request #1030 from klickverbot/cfg-rewrite
EH/cleanup codegen rewrite
2015-08-20 15:30:15 +02:00
David Nadlinger
4bcae9731a The big catch/finally rework, part 2
Now with *almost* working EH codegen. Does not compile Phobos yet
because we run into the "instruction does not dominate all uses"
issue when an r-value result of toElemDtor is used and we need to
run cleanups in between. Should easily be fixed by promoting those
values to allocas.

Most of the changes outside of ir/irfunction.{h, cpp} are just
because CreateCallOrInvoke moved locations. I took the
opportunity to also make use of the different arg count
overloads where possible.
2015-08-19 19:56:39 +02:00
Martin
5d71dc38df Fix issue 1024: allow classes to be cast to typeof(null)
... and always return null in that case.
2015-08-16 21:43:24 +02:00
Martin
2304b52acb First attempt to simplify and fix destruction of temporaries in toElem(). 2015-07-18 13:34:26 +02:00
Martin
2444ae0988 First attempt to fix NewExp::argprefix.
The front-end uses a single bool variable as gate for all destructors
(by replacing each dtor expression by `gate || dtor()`).
This flag is set at the end of the argprefix chain of CommaExp.
So when no exception occurs in argprefix, the dtors aren't invoked in
the inserted finally block.
Right after the finally block we have the call to NewExp's ctor, which
will take care of destructing its parameters.
2015-07-18 13:34:26 +02:00
Martin
9f1e6f1a2e Prepare for more flexible toElemDtor().
We'd like to evaluate expression NewExp::argprefix and only destruct
it if an exception interrupts its evaluation.
2015-07-18 13:34:26 +02:00
David Nadlinger
0922254dd1 Directly emit IR into same llvm::Module instead of using Linker
GitHub: Fixes #970.
2015-06-14 21:36:35 +02:00
David Nadlinger
b10f110066 Do not try to use RTTI for C++ classes
Casts are just bitcasts, and do not try to invoke
class invariants on asserts.

@yebblies mentioned he would extend the DMD test suite
accordingly.
2015-05-31 09:34:14 +02:00
Kai Nacke
70218e1fd2 Revert "Don't initialize a new class instance a 2nd time after _d_newclass()." 2015-04-26 00:53:11 +02:00
Kai Nacke
17dddf7c54 Merge pull request #917 from kinke/disabledctor
Don't set default ctor in ClassInfo if it's @disabled.
2015-04-25 23:50:06 +02:00
Martin
ff3a994e09 Don't set default ctor in ClassInfo if it's @disabled. 2015-04-25 19:59:25 +02:00
Martin
f75dcff6a4 Don't initialize a new class instance a 2nd time after _d_newclass(). 2015-04-25 18:50:05 +02:00
Martin
c7e77f9bde Set flag hasDtor for ClassInfos, if appropriate. 2015-04-22 23:07:31 +02:00
kai
024b14cd7f Fix some warnings.
These are easy to solve and reduce the noise in the Travis build.
2014-12-26 15:59:23 +01:00
Kai Nacke
56713ecea4 Add enum for ClassInfoFlags.
Commit provided by Trass3r.
2014-11-11 00:47:47 +01:00
David Nadlinger
bff766b379 Track member field index in IrTypeAggr, not IrField.
This fixes a regression introduced in caa2f15c8a. The IrDsymbol
metadata is obviously reset in between modules, while IrTypes
are not. Thus, we can never set symbol metadata when resolving
types, as the symbol data will be wrong in all modules following
the one where the type was first resolved.

GitHub: Fixes #739.
2014-10-11 03:28:49 +02:00
David Nadlinger
2071cf4b3d [cleanup] Merge DtoIndex{Struct, Class}. 2014-10-11 03:28:48 +02:00
David Nadlinger
bb1ad7e324 Clean up linkage handling.
Since the change to the symbol emission strategy, a lot of the
previous attempts to derive the linkage for a symbol from its
AST node has been superfluous. This cleans up all the related
code, as it is really not doing much anymore.

The code to opportunistically internalize symbols is now gone
entirely. It was commented out anyway due to problems with
making it work reliably in the face of the not-so-stable
structure of the AST we get from the frontend (regarding the
modules certain symbols end up in). But in any case internal
linkage woudl also be troublesome for cross-module inlining,
so I gave up on making this work for the time being.

The only (minor) change in the emitted code should be in
.offTi generation, which is untested and disabled by default
anyway (GENERATE_OFFTI).
2014-10-08 20:55:19 +02:00
Alexey Prokhin
66a392a5c2 Rename Type::irtype to ctype for consistency with dmd and gdc 2014-10-05 16:55:12 +04:00
Alexey Prokhin
caa2f15c8a Remove VarDeclaration::aggrIndex 2014-10-05 16:08:52 +04:00
Andreas Hollandt
6db62ee8a9 remove all the "tmp" IR names 2014-10-02 14:36:51 +02:00
Kai Nacke
382ad184d8 Merge branch 'master' into merge-2.066
Conflicts:
	dmd2/builtin.c
	gen/classes.cpp
	gen/functions.cpp
	gen/llvmhelpers.cpp
	gen/statements.cpp
	gen/toir.cpp
	runtime/druntime
	runtime/phobos
2014-09-13 23:11:54 +02:00
Alexey Prokhin
32b1d4cc55 Reduce size of IrDsymbol even more
resolved/defined/declared/initialized are turned into flags.
2014-09-12 14:43:54 +04:00
Alexey Prokhin
18f33b1815 Make IrDsymbol to be a typesafe union to reduce memory usage 2014-09-12 14:43:49 +04:00
Alexey Prokhin
d9189acbc4 Move toElem/toConstElem to visitors 2014-08-27 16:22:02 +04:00
Alexey Prokhin
abfb684bb5 Remove additional ldc alignment of structs 2014-08-22 16:01:34 +04:00
David Nadlinger
2c30cdb2d1 [trivial] Adapt whitespace style. 2014-07-14 02:36:32 +02:00
David Nadlinger
ce5750c4b4 Fix initialization of C++ class instances.
Fixes 'runnable/cppa' on x86.
2014-07-14 02:36:27 +02:00
kai
45fca1f3b5 Add line number to error message of -nogc switch.
This was suggested by bearophile in the news group.
It also changes all Loc objects to be passed by reference.
2014-07-04 07:15:05 +02:00
Alexey Prokhin
6e8e466f5f Fix virtual table and type info for c++ classes 2014-06-26 21:34:38 +04:00
kai
2b6dbb03f4 Add IF_LOG to more logging statements.
Evaluating arguments which call toChars() or toPrettyChars() are much more expensive then checking Logger::enabled().
2014-06-26 06:54:38 +02:00
Kai Nacke
fe39da53e3 Merge of 2.065.0-b3.
The new visitor class is used for IR generation. This removes some modifications from DMD source.
2014-02-10 08:47:25 +01:00
kai
6287a4d422 Replace ArrayIter<> with Array<>::iterator.
Just use the new iterator instead of the old Java-like class.
Also removes a dead iterator and replaces an iterator with a
pointer in some place.
2014-01-11 14:48:41 +01:00
Kai Nacke
e1464fe458 CCP classes do not have a monitor.
This fixes a failure in runnable/xtest46.d. I still need to check
the structure of the emitted class for compability with C++.
2013-11-28 07:59:01 +01:00
Kai Nacke
4041855110 Update use of Typeinfo. 2013-10-29 19:21:15 +01:00
David Nadlinger
cb341586e3 First merge of 2.064 beta.
This corresponds to DMD commit a913ce4bc59a94a022a27e390fc841f4aededffb.

Doesn't build Phobos yet.
2013-10-29 19:21:15 +01:00
David Nadlinger
1f59740524 _d_allocclass -> "_d_newclass".
The define is a leftover from the times when we supported
both D1 and D2.
2013-10-24 00:25:36 +02:00
David Nadlinger
4fee629c4d Prefer more specific functions to DtoResolveDsymbol.
The remaining ones should also be easy to remove with a
closer look at the situation.

Ideally, we would get rid of all of them at some point and
use safe wrapper functions for accessing the IrDsymbol
associated with a given declaration (which would emit the
declarations on the fly if not already present).
2013-10-13 19:18:24 +02:00
David Nadlinger
787c147986 Use Module::members -> Dsymbol::codegen to define symbols.
This commit fundamentally changes the way symbol emission in
LDC works: Previously, whenever a declaration was used in some
way, the compiler would check whether it actually needs to be
defined in the currently processed module, based only on the
symbol itself. This lack of contextual information proved to
be a major problem in correctly handling emission of templates
(see e.g. #454).

Now, the DtoResolve…() family of functions and similar only
ever declare the symbols, and definition is handled by doing
a single pass over Module::members for the root module. This
is the same strategy that DMD uses as well, which should
also reduce the maintainance burden down the road (which is
important as during the last few releases, there was pretty
much always a symbol emission related problem slowing us
down).

Our old approach might have been a bit better tuned w.r.t.
avoiding emission of unneeded template instances, but 2.064
will bring improvements here (DMD: FuncDeclaration::toObjFile).
Barring such issues, the change shoud also marginally improve
compile times because of declarations no longer being emitted
when they are not needed.

In the future, we should also consider refactoring the code
so that it no longer directly accesses Dsymbol::ir but uses
wrapper functions that ensure that the appropriate
DtoResolve…() function has been called.

GitHub: Fixes #454.
2013-10-13 19:18:24 +02:00
Alexey Prokhin
b819975c84 Eliminate the need for TypeFunction::funcdecl 2013-10-05 19:03:03 +04:00
Alexey Prokhin
90bb32d2d8 extern(C++) interfaces 2013-06-22 17:33:00 +04:00