| author | |
| committer | |
| log | 2be066d057946eae592307f8f16679626b85b31d |
| tree | 9525a0de629ac072a6bb8ec2eeaecd1e8f4001a2 |
| parent | d4434dfb6744b82429060b4118ab71c55dff2141 |
Add AEABI builtin __aeabi_l2d4 files changed, 79 insertions(+), 0 deletions(-)
CMakeLists.txt+1| ... | @@ -677,6 +677,7 @@ set(ZIG_STD_FILES | ... | @@ -677,6 +677,7 @@ set(ZIG_STD_FILES |
| 677 | "special/compiler_rt/fixunstfdi.zig" | 677 | "special/compiler_rt/fixunstfdi.zig" |
| 678 | "special/compiler_rt/fixunstfsi.zig" | 678 | "special/compiler_rt/fixunstfsi.zig" |
| 679 | "special/compiler_rt/fixunstfti.zig" | 679 | "special/compiler_rt/fixunstfti.zig" |
| 680 | "special/compiler_rt/floatdidf.zig" | ||
| 680 | "special/compiler_rt/floatsiXf.zig" | 681 | "special/compiler_rt/floatsiXf.zig" |
| 681 | "special/compiler_rt/floatunsidf.zig" | 682 | "special/compiler_rt/floatunsidf.zig" |
| 682 | "special/compiler_rt/floattidf.zig" | 683 | "special/compiler_rt/floattidf.zig" |
std/special/compiler_rt.zig+3| ... | @@ -66,6 +66,7 @@ comptime { | ... | @@ -66,6 +66,7 @@ comptime { |
| 66 | 66 | ||
| 67 | @export("__floatsidf", @import("compiler_rt/floatsiXf.zig").__floatsidf, linkage); | 67 | @export("__floatsidf", @import("compiler_rt/floatsiXf.zig").__floatsidf, linkage); |
| 68 | @export("__floatsisf", @import("compiler_rt/floatsiXf.zig").__floatsisf, linkage); | 68 | @export("__floatsisf", @import("compiler_rt/floatsiXf.zig").__floatsisf, linkage); |
| 69 | @export("__floatdidf", @import("compiler_rt/floatdidf.zig").__floatdidf, linkage); | ||
| 69 | @export("__floatunsidf", @import("compiler_rt/floatunsidf.zig").__floatunsidf, linkage); | 70 | @export("__floatunsidf", @import("compiler_rt/floatunsidf.zig").__floatunsidf, linkage); |
| 70 | @export("__floatundidf", @import("compiler_rt/floatundidf.zig").__floatundidf, linkage); | 71 | @export("__floatundidf", @import("compiler_rt/floatundidf.zig").__floatundidf, linkage); |
| 71 | 72 | ||
| ... | @@ -161,8 +162,10 @@ comptime { | ... | @@ -161,8 +162,10 @@ comptime { |
| 161 | @export("__aeabi_memcmp8", __aeabi_memcmp, linkage); | 162 | @export("__aeabi_memcmp8", __aeabi_memcmp, linkage); |
| 162 | 163 | ||
| 163 | @export("__aeabi_i2d", @import("compiler_rt/floatsiXf.zig").__floatsidf, linkage); | 164 | @export("__aeabi_i2d", @import("compiler_rt/floatsiXf.zig").__floatsidf, linkage); |
| 165 | @export("__aeabi_l2d", @import("compiler_rt/floatdidf.zig").__floatdidf, linkage); | ||
| 164 | @export("__aeabi_ui2d", @import("compiler_rt/floatunsidf.zig").__floatunsidf, linkage); | 166 | @export("__aeabi_ui2d", @import("compiler_rt/floatunsidf.zig").__floatunsidf, linkage); |
| 165 | @export("__aeabi_ul2d", @import("compiler_rt/floatundidf.zig").__floatundidf, linkage); | 167 | @export("__aeabi_ul2d", @import("compiler_rt/floatundidf.zig").__floatundidf, linkage); |
| 168 | |||
| 166 | @export("__aeabi_fneg", @import("compiler_rt/negXf2.zig").__negsf2, linkage); | 169 | @export("__aeabi_fneg", @import("compiler_rt/negXf2.zig").__negsf2, linkage); |
| 167 | @export("__aeabi_dneg", @import("compiler_rt/negXf2.zig").__negdf2, linkage); | 170 | @export("__aeabi_dneg", @import("compiler_rt/negXf2.zig").__negdf2, linkage); |
| 168 | 171 |
std/special/compiler_rt/floatdidf.zig created+22| ... | @@ -0,0 +1,22 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | const std = @import("std"); | ||
| 3 | |||
| 4 | const twop52: f64 = 0x1.0p52; | ||
| 5 | const twop32: f64 = 0x1.0p32; | ||
| 6 | |||
| 7 | pub extern fn __floatdidf(a: i64) f64 { | ||
| 8 | @setRuntimeSafety(builtin.is_test); | ||
| 9 | |||
| 10 | if (a == 0) return 0; | ||
| 11 | |||
| 12 | var low = @bitCast(i64, twop52); | ||
| 13 | const high = @intToFloat(f64, @truncate(i32, a >> 32)) * twop32; | ||
| 14 | |||
| 15 | low |= @bitCast(i64, a & 0xFFFFFFFF); | ||
| 16 | |||
| 17 | return (high - twop52) + @bitCast(f64, low); | ||
| 18 | } | ||
| 19 | |||
| 20 | test "import floatdidf" { | ||
| 21 | _ = @import("floatdidf_test.zig"); | ||
| 22 | } | ||
std/special/compiler_rt/floatdidf_test.zig created+53| ... | @@ -0,0 +1,53 @@ | ||
| 1 | const __floatdidf = @import("floatdidf.zig").__floatdidf; | ||
| 2 | const testing = @import("std").testing; | ||
| 3 | |||
| 4 | fn test__floatdidf(a: i64, expected: f64) void { | ||
| 5 | const r = __floatdidf(a); | ||
| 6 | testing.expect(r == expected); | ||
| 7 | } | ||
| 8 | |||
| 9 | test "floatdidf" { | ||
| 10 | test__floatdidf(0, 0.0); | ||
| 11 | test__floatdidf(1, 1.0); | ||
| 12 | test__floatdidf(2, 2.0); | ||
| 13 | test__floatdidf(20, 20.0); | ||
| 14 | test__floatdidf(-1, -1.0); | ||
| 15 | test__floatdidf(-2, -2.0); | ||
| 16 | test__floatdidf(-20, -20.0); | ||
| 17 | test__floatdidf(0x7FFFFF8000000000, 0x1.FFFFFEp+62); | ||
| 18 | test__floatdidf(0x7FFFFFFFFFFFF800, 0x1.FFFFFFFFFFFFEp+62); | ||
| 19 | test__floatdidf(0x7FFFFF0000000000, 0x1.FFFFFCp+62); | ||
| 20 | test__floatdidf(0x7FFFFFFFFFFFF000, 0x1.FFFFFFFFFFFFCp+62); | ||
| 21 | test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000008000000000)), -0x1.FFFFFEp+62); | ||
| 22 | test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000000800)), -0x1.FFFFFFFFFFFFEp+62); | ||
| 23 | test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000010000000000)), -0x1.FFFFFCp+62); | ||
| 24 | test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000001000)), -0x1.FFFFFFFFFFFFCp+62); | ||
| 25 | test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000000000)), -0x1.000000p+63); | ||
| 26 | test__floatdidf(@bitCast(i64, @intCast(u64, 0x8000000000000001)), -0x1.000000p+63); | ||
| 27 | test__floatdidf(0x0007FB72E8000000, 0x1.FEDCBAp+50); | ||
| 28 | test__floatdidf(0x0007FB72EA000000, 0x1.FEDCBA8p+50); | ||
| 29 | test__floatdidf(0x0007FB72EB000000, 0x1.FEDCBACp+50); | ||
| 30 | test__floatdidf(0x0007FB72EBFFFFFF, 0x1.FEDCBAFFFFFFCp+50); | ||
| 31 | test__floatdidf(0x0007FB72EC000000, 0x1.FEDCBBp+50); | ||
| 32 | test__floatdidf(0x0007FB72E8000001, 0x1.FEDCBA0000004p+50); | ||
| 33 | test__floatdidf(0x0007FB72E6000000, 0x1.FEDCB98p+50); | ||
| 34 | test__floatdidf(0x0007FB72E7000000, 0x1.FEDCB9Cp+50); | ||
| 35 | test__floatdidf(0x0007FB72E7FFFFFF, 0x1.FEDCB9FFFFFFCp+50); | ||
| 36 | test__floatdidf(0x0007FB72E4000001, 0x1.FEDCB90000004p+50); | ||
| 37 | test__floatdidf(0x0007FB72E4000000, 0x1.FEDCB9p+50); | ||
| 38 | test__floatdidf(0x023479FD0E092DC0, 0x1.1A3CFE870496Ep+57); | ||
| 39 | test__floatdidf(0x023479FD0E092DA1, 0x1.1A3CFE870496Dp+57); | ||
| 40 | test__floatdidf(0x023479FD0E092DB0, 0x1.1A3CFE870496Ep+57); | ||
| 41 | test__floatdidf(0x023479FD0E092DB8, 0x1.1A3CFE870496Ep+57); | ||
| 42 | test__floatdidf(0x023479FD0E092DB6, 0x1.1A3CFE870496Ep+57); | ||
| 43 | test__floatdidf(0x023479FD0E092DBF, 0x1.1A3CFE870496Ep+57); | ||
| 44 | test__floatdidf(0x023479FD0E092DC1, 0x1.1A3CFE870496Ep+57); | ||
| 45 | test__floatdidf(0x023479FD0E092DC7, 0x1.1A3CFE870496Ep+57); | ||
| 46 | test__floatdidf(0x023479FD0E092DC8, 0x1.1A3CFE870496Ep+57); | ||
| 47 | test__floatdidf(0x023479FD0E092DCF, 0x1.1A3CFE870496Ep+57); | ||
| 48 | test__floatdidf(0x023479FD0E092DD0, 0x1.1A3CFE870496Ep+57); | ||
| 49 | test__floatdidf(0x023479FD0E092DD1, 0x1.1A3CFE870496Fp+57); | ||
| 50 | test__floatdidf(0x023479FD0E092DD8, 0x1.1A3CFE870496Fp+57); | ||
| 51 | test__floatdidf(0x023479FD0E092DDF, 0x1.1A3CFE870496Fp+57); | ||
| 52 | test__floatdidf(0x023479FD0E092DE0, 0x1.1A3CFE870496Fp+57); | ||
| 53 | } | ||