make f80 less hacky; lower as u80 on non-x86

Get rid of `std.math.F80Repr`. Instead of trying to match the memory
layout of f80, we treat it as a value, same as the other floating point
types. The functions `make_f80` and `break_f80` are introduced to
compose an f80 value out of its parts, and the inverse operation.

stage2 LLVM backend: fix pointer to zero length array tripping LLVM
assertion. It now checks for when the element type is a zero-bit type
and lowers such thing the same way that pointers to other zero-bit types
are lowered.

Both stage1 and stage2 LLVM backends are adjusted so that f80 is lowered
as x86_fp80 on x86_64 and i386 architectures, and identical to a u80 on
others. LLVM constants are lowered in a less hacky way now that #10860
is fixed, by using the expression `(exp << 64) | fraction` using llvm
constants.

Sema is improved to handle c_longdouble by recursively handling it
correctly for whatever the float bit width is. In both stage1 and
stage2.
This commit is contained in:
Andrew Kelley
2022-02-10 22:06:43 -07:00
committed by Jakub Konka
parent 1c23321d03
commit a024aff932
10 changed files with 200 additions and 110 deletions

View File

@@ -5,7 +5,10 @@ const math = std.math;
const pi = std.math.pi;
const e = std.math.e;
const Vector = std.meta.Vector;
const has_f80_rt = @import("builtin").cpu.arch == .x86_64;
const has_f80_rt = switch (builtin.cpu.arch) {
.x86_64, .i386 => true,
else => false,
};
const epsilon_16 = 0.001;
const epsilon = 0.000001;