Commit graph

294 commits

Author SHA1 Message Date
Martin
30b858781b -betterC: Use C assert function
Instead of druntime's _d_assert[_msg], _d_arraybounds and
_d_switch_error.

Tested by dmd-testsuite's runnable/cassert and compilable/betterCarray.
2017-10-25 00:38:05 +02:00
Martin
f63166cf35 Try to fix signalling-ness of {float,double}.init
By letting LLVM narrow compile-time real_t values to float/double IR
constants. We previously relied on the host, which turns signalling
real_t NaNs to quiet float/double NaNs.

Signalling NaNs are characterized by their most-significant mantissa bit
being 0 (and at least for D the 2nd-most-significant mantissa bit being
set to distinguish them from infinity). The host truncation led to the MSB
getting set while keeping the rest of the mantissa (i.e., both MSBs set).

Here's the resulting bitpattern table in hex:

            float:     double:            x87 real:
init old:   7fe00000   7ffc000000000000   7fffa000000000000000
init new:   7fa00000   7ff4000000000000   7fffa000000000000000
qnan:       7fc00000   7ff8000000000000   7fffc000000000000000

DMD 2.074.0 produces wrongly quiet float/double init values.

A Win32 LDC build (with double-precision real_t) still loses the
signalling-ness for {float,double,64-bit real}.init, probably due to the
FPU being used instead of SSE.
2017-07-28 00:58:59 +02:00
Martin
1fb269f940 Drop support for LLVM < 3.7 2017-07-16 02:18:00 +02:00
Luís Marques
7c9874a209 Add support for MSP430 / 16-bit targets (#2194)
Relevant version identifiers PRs:
https://github.com/dlang/dmd/pull/6994
https://github.com/dlang/dlang.org/pull/1822
2017-07-14 16:55:09 +02:00
David Nadlinger
e659db6a11 Merge pull request #2135 from kinke/gh2131
Add range metadata when loading bools
2017-06-03 18:35:01 +01:00
kinke
151e83dc6b Fix C++ warnings (#2140) 2017-05-26 13:45:15 +02:00
Martin
c9b2571a44 Zero-extend Boolean parameters and return values 2017-05-25 04:10:00 +02:00
Nicholas Wilson
6c7f1b616e [NFC] [dcompute] Make LDC somewhat aware of addrspaces. (#2122)
* [NFC] Make LDC somewhat aware of addrspaces.

Required so that we don't generate invalid code when dealing with pointer to addrspaces other than zero.
2017-05-21 08:43:04 +08:00
Martin
0e71a760ae Limited support for arbitrary target reals
While parsing of floating-point literals and CTFE still operate with the
host LDC's real type, compile-time reals can in principle be emitted in
arbitrary precision via LLVM software conversion, therefore paving the way
for cross-compilation to all targets.

The representable constants are still limited by the compile-time real_t
precision. E.g., LDC on Windows with its 64-bit reals can't hold and emit
an 80-bit `real.max` when cross-compiling to a non-Windows x86(_64)
target; the compile-time value will silently overflow to infinity and
later be emitted as 80-bit infinity.

LDC on AArch64 with its 128-bit quad-precision reals on the other hand can
hold and emit reals for all targets, making it a universal cross-compiler
with quad-precision compile-time reals in hardware.

We don't use the strange 2x64-bit PPC double-double format (see
`getRealType()` in `ir/irtype.cpp`), but would more or less support it
(the type properties (max, min_normal...) still need to be determined;
LLVM isn't sure about those either...).
2017-02-11 14:24:46 +01:00
kinke
bb3e16481c Fix alignment and size of target critical section (#1956)
The missing alignment is a front-end bug; this is a combined backport
of dlang/dmd@b9aa6ed and dlang/dmd@a93fa3c.

For POSIX targets, the critical section size was assumed to be identical
to the host compiler's, which generally isn't true when cross-compiling.

DtoMutexType() wasn't used anywhere, so I removed it.
2017-01-13 21:44:28 +01:00
Johan Engelen
5e9914ad29 Fix LLVM trunk build. (#1936) 2016-12-22 17:59:03 +01:00
David Nadlinger
6cc93bc8ba gen/ir: Move function body codegen state into separate class
Previously, the transitory state only needed and valid during
generation of the LLVM IR for the function body was conflated
with the general codegen metadata for the function declaration
in IrFunction.

There is further potential for cleanup regarding the use of
gIR->func() and so on all over the code base, but this is out
of scope of this commit, which is only concerned with those
IrFunction members moved to FuncGenState.

GitHub: Fixes #1661.
2016-08-03 21:07:18 +01:00
Martin
29152f5b94 Refactor DIBuilder
Incl. some subtle changes/fixes.
2016-07-22 22:34:31 +02:00
Rainer Schuetze
f9995b1883 fix build against LLVM trunk svn rev 273030 2016-06-18 10:54:23 +02:00
Johan Engelen
1b4b9a07c9 Fix typo: typeinf.h --> typinf.h [NFC] 2016-06-08 10:40:00 +02:00
David Nadlinger
209b6fc2b0 Merge pull request #1393 from kinke/nullArray
Optimize array comparisons against null
2016-04-09 23:22:53 +01:00
Johan Engelen
823a9efe26 Merge branch 'ltsmaster'
Solved merge conflicts in:
	gen/abi.cpp
	gen/toir.cpp
	runtime/druntime
	tests/d2/dmd-testsuite
	tests/lit.site.cfg.in
2016-03-29 11:40:20 +02:00
Martin
0440bd20db Optimize array comparisons against null
This fixes issue #894 and includes some refactorings.
2016-03-28 15:30:55 +02:00
Johan Engelen
69825a6fb9 Add the @ldc.attributes.weak linkage attributes for global symbols. 2016-03-27 22:08:23 +02:00
Kai Nacke
fc7edf2b90 Fix merge error 2016-03-22 19:20:40 +01:00
Kai Nacke
88f3de8bea Merge branch 'ltsmaster' 2016-03-22 19:05:07 +01:00
Martin
608ce9852e Emit symbols by default as COMDATs
That's apparently what DMD does and what currently happens for all
non-MSVC targets anyway.

For MSVC, we need this to enforce the `any` selection instead of
`no duplicates`, otherwise the linker complains about multiply defined
symbols and refuses to link without an extra command line option
(which in turn outputs a non-suppressable warning).
2016-03-20 18:04:42 +01:00
Martin
88dcb4349a Refactor setting linkage type and COMDAT 2016-03-20 16:37:44 +01:00
Kai Nacke
24adf155ff Revert "Revert "Merge branch 'ltsmaster'""
This reverts commit 1653911600.
2016-03-03 21:12:53 +01:00
Kai Nacke
1653911600 Revert "Merge branch 'ltsmaster'"
This reverts commit dcb781004b, reversing
changes made to 3c6f09faf0.
2016-03-03 13:14:39 +01:00
Kai Nacke
dcb781004b Merge branch 'ltsmaster' 2016-03-03 07:50:17 +01:00
Kai Nacke
2b2438b5b2 Fix IEEE 128-bit reals.
The previous implementation sets all reals to 0.0.
2016-03-02 11:42:09 +00:00
Kai Nacke
4d40ea8fcf AArch64: This platform uses IEEE 128-bit floats.
This adds the missing code paths.
2016-03-01 22:02:29 +01:00
Dan Olson
51074b0ce5 Zero extend char and wchar
Add LLVM zeroext attribute to char and wchar types so they are
compatible with similar sized C ABI unsigned int types.

In particular, this is needed for ARM (fixes runnable/cppa.d at -O3)
and seems like proper behavior for all supported ABIs even though the
x86 ABIs get by without this.
2016-02-25 19:29:14 +00:00
Johan Engelen
acdcc4a8c1 Merge branch 'master' into merge-2.069 2016-02-13 20:12:17 +01:00
David Nadlinger
5a84c2524d DtoType: Handle enum forward references
Note that we don't set t->ctype (we'd need a new IrTypeEnum or something
along the lines). This is okay because we don't do so for enums in either
case, even in the normal code paths. Enums are regarded as being
"transparent" in that sense. We might want to rethink this in the future,
though.

Fixes DMD test case 'ice13792'.
2016-02-06 21:44:53 +01:00
David Nadlinger
10d17e9c92 DtoBitCast: Accept llvm::Twine [nfc] 2016-01-31 00:57:34 +01:00
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
Kai Nacke
8df1f7ec1a Add more support for xBSD type OS.
Use the same code for FreeBSD, NetBSD, OpenBSD and DragonFly BSD.
2016-01-22 22:10:33 +01:00
Martin
956061c3c7 Revise DtoGEP() helpers and mark most GEPs inbounds 2015-12-14 00:18:15 +01:00
Martin
0671e91d6b Remove getTypePaddedSize() and use getTypeAllocSize() instead
The functions were equivalent, only leading to confusion.
2015-12-04 22:23:09 +01:00
Martin
ddfaac10b3 Rename DtoAggrCopy/ZeroInit() to DtoMemCpy/SetZero() overloads
And replace some obvious load->store combos by a memcpy.
2015-12-04 22:23:09 +01:00
Martin
740a21eb8f Rename DtoIsPassedByRef() to DtoIsInMemoryOnly()
Motivation: issue #937
2015-12-04 22:23:09 +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
90197d6c72 Simplify working with LLVM attributes 2015-11-01 16:19:27 +01:00
Martin
60d676e2a1 Drop support for LLVM < 3.5
This allows to clean up the code a little.
2015-10-30 22:24:05 +01:00
Martin
93158caca8 Respect alignments of captured variables when building nested context LL struct 2015-10-18 23:25:37 +02:00
Martin
b13565c17e Refactor common i1ToI8(voidToI8(DtoType(...))) code occurrences 2015-10-03 22:58:00 +02:00
Martin
1a42358cf6 Treat atomic instructions as intrinsics
Whose types aren't rewritten by the regular TargetABI.
2015-09-18 00:02:57 +02:00
Kai Nacke
ab2e8e3646 Refactor new COMDAT code.
Linkage and the COMDAT flag is now returned as std::pair<>.
Also adds more COMDATs.
2015-09-17 21:04:40 +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
4cefa5e8f5 Remove unused DtoInterfaceInfoType and support code 2015-06-14 21:27:21 +02:00