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...).
This commit is contained in:
Martin 2017-02-10 23:41:24 +01:00
parent c051d8d829
commit 0e71a760ae
7 changed files with 115 additions and 60 deletions

View file

@ -42,7 +42,7 @@ LLType *DtoComplexBaseType(Type *t) {
////////////////////////////////////////////////////////////////////////////////
LLConstant *DtoConstComplex(Type *_ty, longdouble re, longdouble im) {
LLConstant *DtoConstComplex(Type *_ty, real_t re, real_t im) {
Type *base = nullptr;
switch (_ty->toBasetype()->ty) {
default: