authorgravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-10-21 19:20:58-07:00
committergravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-10-21 19:20:58-07:00
logf0e66ac4d0e6347bf1b5a00b309fafb5da84191b
tree8d4069daf068c09e1060a38c8d695f2deeb1b210
parentddbdb83c865b1124487b3a00747fc5c1a67e5770

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.

2 files changed, 2 insertions(+), 88 deletions(-)

lib/std/target.zig-86
...@@ -1780,92 +1780,6 @@ pub const Target = struct {...@@ -1780,92 +1780,6 @@ pub const Target = struct {
1780 };1780 };
1781 }1781 }
17821782
1783 pub inline fn longDoubleIs(target: Target, comptime F: type) bool {
1784 switch (target.os.tag) {
1785 .windows, .uefi => switch (target.abi) {
1786 .gnu, .gnuilp32, .cygnus => switch (target.cpu.arch) {
1787 .i386 => return F == f80,
1788 .x86_64 => return F == f128,
1789 else => return F == f64,
1790 },
1791 else => return F == f64,
1792 },
1793 else => {},
1794 }
1795
1796 if (target.abi == .android and target.cpu.arch == .i386)
1797 return F == f64;
1798
1799 switch (target.cpu.arch) {
1800 .aarch64,
1801 .aarch64_be,
1802 .aarch64_32,
1803 => switch (target.os.tag) {
1804 // According to Apple's official guide:
1805 // > The long double type is a double precision IEEE754 binary floating-point type,
1806 // > which makes it identical to the double type. This behavior contrasts to the
1807 // > standard specification, in which a long double is a quad-precision, IEEE754
1808 // > binary, floating-point type.
1809 // https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
1810 .ios, .macos, .watchos, .tvos => return F == f64,
1811 .windows, .uefi => return F == f64,
1812 else => return F == f128,
1813 },
1814
1815 .i386 => return F == f80,
1816 .x86_64 => return F == f80,
1817
1818 .mips64,
1819 .mips64el,
1820 => switch (target.os.tag) {
1821 .freebsd => return F == f64,
1822 else => return F == f128,
1823 },
1824
1825 .powerpc,
1826 .powerpcle,
1827 => switch (target.abi) {
1828 .musl,
1829 .musleabi,
1830 .musleabihf,
1831 .muslx32,
1832 => return F == f64,
1833 else => switch (target.os.tag) {
1834 .freebsd, .netbsd, .openbsd => return F == f64,
1835 else => return F == f128,
1836 },
1837 },
1838
1839 .powerpc64,
1840 .powerpc64le,
1841 => switch (target.abi) {
1842 .musl,
1843 .musleabi,
1844 .musleabihf,
1845 .muslx32,
1846 => return F == f64,
1847 else => switch (target.os.tag) {
1848 .freebsd, .openbsd => return F == f64,
1849 else => return F == f128,
1850 },
1851 },
1852
1853 .riscv32,
1854 .riscv64,
1855 .s390x,
1856 .sparc,
1857 .sparc64,
1858 .sparcel,
1859 .wasm32,
1860 .wasm64,
1861 => return F == f128,
1862
1863 .avr, .tce, .tcele => return F == f32,
1864
1865 else => return F == f64,
1866 }
1867 }
1868
1869 pub inline fn maxIntAlignment(target: Target) u16 {1783 pub inline fn maxIntAlignment(target: Target) u16 {
1870 return switch (target.cpu.arch) {1784 return switch (target.cpu.arch) {
1871 .avr => 1,1785 .avr => 1,
src/codegen/llvm.zig+2-2
...@@ -10615,8 +10615,8 @@ fn backendSupportsF128(target: std.Target) bool {...@@ -10615,8 +10615,8 @@ fn backendSupportsF128(target: std.Target) bool {
10615fn intrinsicsAllowed(scalar_ty: Type, target: std.Target) bool {10615fn intrinsicsAllowed(scalar_ty: Type, target: std.Target) bool {
10616 return switch (scalar_ty.tag()) {10616 return switch (scalar_ty.tag()) {
10617 .f16 => backendSupportsF16(target),10617 .f16 => backendSupportsF16(target),
10618 .f80 => target.longDoubleIs(f80) and backendSupportsF80(target),10618 .f80 => (CType.longdouble.sizeInBits(target) == 80) and backendSupportsF80(target),
10619 .f128 => target.longDoubleIs(f128) and backendSupportsF128(target),10619 .f128 => (CType.longdouble.sizeInBits(target) == 128) and backendSupportsF128(target),
10620 else => true,10620 else => true,
10621 };10621 };
10622}10622}