| author | |
| committer | |
| log | 779137be4111ba60c888ed86f33654e538a7a0ca |
| tree | 9f3a3538f9329bf3523e756b32450b28653ebdd6 |
| parent | 38c2093500dcb7dac7cce6bbe08abe92767f24ba |
3 files changed, 28 insertions(+), 0 deletions(-)
CMakeLists.txt+1| ... | ... | @@ -664,6 +664,7 @@ set(ZIG_STD_FILES |
| 664 | 664 | "special/compiler_rt/muloti4.zig" |
| 665 | 665 | "special/compiler_rt/mulXf3.zig" |
| 666 | 666 | "special/compiler_rt/multi3.zig" |
| 667 | "special/compiler_rt/negXf2.zig" | |
| 667 | 668 | "special/compiler_rt/popcountdi2.zig" |
| 668 | 669 | "special/compiler_rt/truncXfYf2.zig" |
| 669 | 670 | "special/compiler_rt/udivmod.zig" |
std/special/compiler_rt.zig+6| ... | ... | @@ -82,6 +82,9 @@ comptime { |
| 82 | 82 | @export("__umoddi3", __umoddi3, linkage); |
| 83 | 83 | @export("__udivmodsi4", __udivmodsi4, linkage); |
| 84 | 84 | |
| 85 | @export("__negsf2", @import("compiler_rt/negXf2.zig").__negsf2, linkage); | |
| 86 | @export("__negdf2", @import("compiler_rt/negXf2.zig").__negdf2, linkage); | |
| 87 | ||
| 85 | 88 | if (is_arm_arch and !is_arm_64) { |
| 86 | 89 | @export("__aeabi_uldivmod", __aeabi_uldivmod, linkage); |
| 87 | 90 | @export("__aeabi_uidivmod", __aeabi_uidivmod, linkage); |
| ... | ... | @@ -107,6 +110,9 @@ comptime { |
| 107 | 110 | @export("__aeabi_memcmp4", __aeabi_memcmp, linkage); |
| 108 | 111 | @export("__aeabi_memcmp8", __aeabi_memcmp, linkage); |
| 109 | 112 | |
| 113 | @export("__aeabi_fneg", @import("compiler_rt/negXf2.zig").__negsf2, linkage); | |
| 114 | @export("__aeabi_dneg", @import("compiler_rt/negXf2.zig").__negdf2, linkage); | |
| 115 | ||
| 110 | 116 | @export("__aeabi_fadd", @import("compiler_rt/addXf3.zig").__addsf3, linkage); |
| 111 | 117 | @export("__aeabi_dadd", @import("compiler_rt/addXf3.zig").__adddf3, linkage); |
| 112 | 118 | @export("__aeabi_fsub", @import("compiler_rt/addXf3.zig").__subsf3, linkage); |
std/special/compiler_rt/negXf2.zig created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub extern fn __negsf2(a: f32) f32 { | |
| 4 | return negXf2(f32, a); | |
| 5 | } | |
| 6 | ||
| 7 | pub extern fn __negdf2(a: f64) f64 { | |
| 8 | return negXf2(f64, a); | |
| 9 | } | |
| 10 | ||
| 11 | fn negXf2(comptime T: type, a: T) T { | |
| 12 | const Z = @IntType(false, T.bit_count); | |
| 13 | ||
| 14 | const typeWidth = T.bit_count; | |
| 15 | const significandBits = std.math.floatMantissaBits(T); | |
| 16 | const exponentBits = std.math.floatExponentBits(T); | |
| 17 | ||
| 18 | const signBit = (Z(1) << (significandBits + exponentBits)); | |
| 19 | ||
| 20 | return @bitCast(T, @bitCast(Z, a) ^ signBit); | |
| 21 | } |