mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
std.Target: Remove longDoubleIs
This function is redundant with CType.sizeInBits(), and until the previous commit they disagreed about the correct long double type for several targets. Although they're all synced up now, it's much simpler just to have a single source of truth.
This commit is contained in:
parent
ddbdb83c86
commit
f0e66ac4d0
@ -1780,92 +1780,6 @@ pub const Target = struct {
|
||||
};
|
||||
}
|
||||
|
||||
pub inline fn longDoubleIs(target: Target, comptime F: type) bool {
|
||||
switch (target.os.tag) {
|
||||
.windows, .uefi => switch (target.abi) {
|
||||
.gnu, .gnuilp32, .cygnus => switch (target.cpu.arch) {
|
||||
.i386 => return F == f80,
|
||||
.x86_64 => return F == f128,
|
||||
else => return F == f64,
|
||||
},
|
||||
else => return F == f64,
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
if (target.abi == .android and target.cpu.arch == .i386)
|
||||
return F == f64;
|
||||
|
||||
switch (target.cpu.arch) {
|
||||
.aarch64,
|
||||
.aarch64_be,
|
||||
.aarch64_32,
|
||||
=> switch (target.os.tag) {
|
||||
// According to Apple's official guide:
|
||||
// > The long double type is a double precision IEEE754 binary floating-point type,
|
||||
// > which makes it identical to the double type. This behavior contrasts to the
|
||||
// > standard specification, in which a long double is a quad-precision, IEEE754
|
||||
// > binary, floating-point type.
|
||||
// https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
|
||||
.ios, .macos, .watchos, .tvos => return F == f64,
|
||||
.windows, .uefi => return F == f64,
|
||||
else => return F == f128,
|
||||
},
|
||||
|
||||
.i386 => return F == f80,
|
||||
.x86_64 => return F == f80,
|
||||
|
||||
.mips64,
|
||||
.mips64el,
|
||||
=> switch (target.os.tag) {
|
||||
.freebsd => return F == f64,
|
||||
else => return F == f128,
|
||||
},
|
||||
|
||||
.powerpc,
|
||||
.powerpcle,
|
||||
=> switch (target.abi) {
|
||||
.musl,
|
||||
.musleabi,
|
||||
.musleabihf,
|
||||
.muslx32,
|
||||
=> return F == f64,
|
||||
else => switch (target.os.tag) {
|
||||
.freebsd, .netbsd, .openbsd => return F == f64,
|
||||
else => return F == f128,
|
||||
},
|
||||
},
|
||||
|
||||
.powerpc64,
|
||||
.powerpc64le,
|
||||
=> switch (target.abi) {
|
||||
.musl,
|
||||
.musleabi,
|
||||
.musleabihf,
|
||||
.muslx32,
|
||||
=> return F == f64,
|
||||
else => switch (target.os.tag) {
|
||||
.freebsd, .openbsd => return F == f64,
|
||||
else => return F == f128,
|
||||
},
|
||||
},
|
||||
|
||||
.riscv32,
|
||||
.riscv64,
|
||||
.s390x,
|
||||
.sparc,
|
||||
.sparc64,
|
||||
.sparcel,
|
||||
.wasm32,
|
||||
.wasm64,
|
||||
=> return F == f128,
|
||||
|
||||
.avr, .tce, .tcele => return F == f32,
|
||||
|
||||
else => return F == f64,
|
||||
}
|
||||
}
|
||||
|
||||
pub inline fn maxIntAlignment(target: Target) u16 {
|
||||
return switch (target.cpu.arch) {
|
||||
.avr => 1,
|
||||
|
||||
@ -10615,8 +10615,8 @@ fn backendSupportsF128(target: std.Target) bool {
|
||||
fn intrinsicsAllowed(scalar_ty: Type, target: std.Target) bool {
|
||||
return switch (scalar_ty.tag()) {
|
||||
.f16 => backendSupportsF16(target),
|
||||
.f80 => target.longDoubleIs(f80) and backendSupportsF80(target),
|
||||
.f128 => target.longDoubleIs(f128) and backendSupportsF128(target),
|
||||
.f80 => (CType.longdouble.sizeInBits(target) == 80) and backendSupportsF80(target),
|
||||
.f128 => (CType.longdouble.sizeInBits(target) == 128) and backendSupportsF128(target),
|
||||
else => true,
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user