Commit graph

95 commits

Author SHA1 Message Date
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
Frits van Bommel
03ce6604a0 Fix cfloat return on x86_64: only perform ABI transformation for non-extern(D)
functions.
There's no need to waste cycles with extern(D), which we get to define
ourselves. Fixes tests/mini/asm8.d. (Since the asm abiret code already assumed
{xmm0, xmm1} returns)
2009-02-26 23:35:39 +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
2dec6aeb41 Implement implicit return after inline asm on x86_64 2009-02-15 18:04:22 +01:00
Tomas Lindquist Olsen
4dee095dc3 Added support for using a temporary to implement emulated ABI return from inline asm, could be easier to use, but I think this will do. It's so extremely target dependent in any case that doing a completely generic approach seems hard. 2009-02-14 15:25:48 +01:00
Kelly Wilson
707c7bc29f changes to get the naked asm stuff working for x64 2009-02-10 08:02:25 -07: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
e7125498e2 Added support for naked asm on OSX. (hopefully!) 2009-02-03 18:14:30 +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