Commit graph

58 commits

Author SHA1 Message Date
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
Dmitri Makarov
5ae8ef92cc Fix linking errors of export(cpp) symbols on OSX. 2015-04-05 21:21:29 +02:00
kai
f61327c149 Replace AsmBlockStatement with CompoundAsmStatement. 2015-03-01 16:40:44 +01:00
Johan Engelen
5ff1e64757 Do not add leading underscore to naked asm functionname for MinGW64 2015-02-22 23:47:29 +01:00
David Nadlinger
e4aa92deb3 Get rid of more superfluous casts with DMD arrays.
There are still a few more left.
2014-11-16 08:00:17 +01:00
kai
e67e472a26 Fix for issue #791.
The ; at the end creates an ExpStatement in the AST with member exp set to
null. Dereferencing exp causes the crash.
IMHO this is a bug in the fontend AST.
2014-11-15 01:27:55 +01: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
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
kai
df0d302d5b Fix MingW build with LLVM 3.5
Starting with LLVM 3.5 it is better/required to use Triple.isWindowsGNUEnvironment().
Reported by Daniel N.
2014-08-26 18:57:12 +02:00
Alexey Prokhin
76dec46df5 WIP: merge dmdfe 2.066 2014-08-22 16:01:28 +04:00
kai
6aebfbdd0a Fix LLVM 3.6 build 2014-08-11 12:37:54 +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
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
92c06dede0 Merge branch 'merge-2.064' into merge-2.065
Conflicts:
	runtime/druntime
2014-05-10 21:38:37 +02:00
Kai Nacke
978912efe6 Change generated inline assembler for naked functions.
This fixes a link error with http://rosettacode.org/wiki/Left_factorials#D
on MinGW32. Reported in news group.
2014-04-12 22:30:42 +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
597be3f8a8 Fix mangled name of naked function on Windows using MSVC.
Do not add an additional underscore (_).
2014-01-26 19:02:06 +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
1242be25d0 Remove unused, empty Ir type.
The codegen parameter was changed to IRState instead of
removing it to set the stage for an eventual eradication
of the gIR global.
2013-10-13 19:44:29 +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
kai
d38448d664 Changed mangling for naked assembler on Win32.
Reported by Temtaime on the newsgroup!
2013-09-08 12:30:04 +02:00
kai
d5744346c6 Change naked asm functions to accept enum declaration.
An enum defines constant values which can be used without trouble in
naked asm functions.
2013-03-06 18:18:56 +01:00
David Nadlinger
6449d5dea2 Fix MinGW names for naked functions. 2013-02-13 00:07:55 +01:00
David Nadlinger
8b71c78571 Minor code cleanup.
No functionality change intended.
2013-02-11 08:25:30 +01:00
David Nadlinger
0a96aea868 Sort includes according to style guidelines:
1. Main include corresponding to .cpp file, if any.
 2. DMD and LDC includes.
 3. LLVM includes.
 4. System includes.

Also updated a few include guards to match the default format.
2013-02-07 21:20:55 +01:00
David Nadlinger
d4b391249d Removed redundant global.params.os field.
I hope I have untangled the checks for "native" Windows (Triple::Win32)
vs. Windows/MinGW/Cygwin (Triple::isOSWindows) correctly.

MinGW needs some default libraries as well, has to be fixed later.
2013-02-07 21:20:54 +01:00
David Nadlinger
5f3ba41574 Removed redundant global.params.cpu field.
Now that we have global.params.targetTriple, the information
is only duplicated.
2013-02-07 17:36:54 +01:00
kai
a11459bc31 "The Great Renaming" continues.
More changes to match the renamed files of LLVM 3.3.
2013-01-06 17:17:30 +01:00
David Nadlinger
9458911839 Added LLVM-style license headers to all our files. 2012-12-16 17:19:14 +01:00
kai
940d6e907f Take advantage of Triple and TargetData.
A lot of system specific knowledge is already present in LLVM. This is used to populate several fields in global.params instead of hard coded values in main(). Ensures that the frontend and LLVM have always the same values.
2012-09-16 19:50:21 +02:00
David Nadlinger
6275c66a89 Fixed segfault on invalid naked functions.
Emitting a frontend error during codegen is somewhat problematic in
any case, but stopping if an error ocurred should work just fine here.
2012-09-07 03:51:33 +02:00
kai
2dbee75523 Prefer C++-style casts.
This is based on Item 2 of "More Effective C++". In general, the C++ cast operators are more expressive and easy to find,
e.g. by grep. Using const_cast also shuts up some compiler warnings.
2012-08-02 19:55:29 +02:00
kai
fcd3ac6a11 Do not add a second underscore to naked functions on Windows.
This leads to missing symbols during linking on Windows x64. If
this changes breaks other Windows platforms then we have to analyze
the triple instead of global.params.os.
2012-07-14 18:25:27 +02:00
David Nadlinger
d0ea856024 Emit all D inline asm labels as local labels.
On OS X, there is an actual significance to the distinction, which before lead e.g. to exception throwing in the below example being broken:

---
import core.exception;

void main() {
  asm {
    jmp Lfoo;
Lfoo:
    ;
  }
  throw cast(OutOfMemoryError)cast(void*)OutOfMemoryError.classinfo.init;
  assert(0);
}
---
2011-12-04 18:13:33 +01:00
David Nadlinger
1afc01df72 Whitespace cleanup. 2011-11-14 21:25:56 +01:00
Alexey Prokhin
629f13929e WIP: port to llvm 3.0 2011-10-25 15:43:39 +04:00
Benjamin Kramer
c220dcac05 IntegerType is now contextifed.
Requires llvm >= 78969. resistor says this will be the last context API change :)
2009-08-14 00:39:18 +02:00
Tomas Lindquist Olsen
f5d635dfc7 Adds explicit alignment information for alloca instructions in general, there's a few cases that still needs to be looked at but this should catch the majority. Fixes ticket #293 . 2009-05-14 13:26:40 +02:00
Kelly Wilson
7a1052a2fc Some more fixups for mingw -- missing underscores 2009-04-02 17:27:53 -06:00
Kelly Wilson
e2d6a94271 Fix one more naked asm output problem for mingw32 and remove some
duplicate code
2009-03-30 18:22:30 -06:00
Kelly Wilson
aae3d56e32 Fix up some naked asm output for mingw32 2009-03-30 18:18:23 -06:00
Tomas Lindquist Olsen
e61562033d Added support for tuple return with __asmtuple!(int,int) etc. 2009-03-28 08:25:58 +01:00
Tomas Lindquist Olsen
1809214995 Added support for single D type register return from __asm. 2009-03-28 07:24:53 +01:00
Tomas Lindquist Olsen
99b863e2b1 Added initial support for raw LLVM inline asm. 2009-03-28 06:32:06 +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
Frits van Bommel
27d3ab4546 Some calling convention work for x86-64:
- Implement x86-64 extern(C), hopefully correctly.
 - Tried to be a bit smarter about extern(D) while I was there.

Interestingly, this code seems to be generating more efficient code than
gcc and llvm-gcc in some edge cases, like returning a `{ [7 x i8] }` loaded from
a stack slot from an extern(C) function. (gcc generates 7 1-byte loads, while
this code generates a 4-byte, a 2-byte and a 1-byte load)

I also added some changes to make sure structs being returned from functions or
passed in as parameters are stored in memory where the rest of the backend seems
to expect them to be. These should be removed when support for first-class
aggregates improves.
2009-03-06 16:00:47 +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