Commit 779137be41

vegecode <justin.b.alexander1@gmail.com>
2019-03-23 04:51:25
Add __aeabi_{f,d}neg and __neg{s,d,X}f2 to compiler-rt
1 parent 38c2093
Changed files (3)
std/special/compiler_rt/negXf2.zig
@@ -0,0 +1,21 @@
+const std = @import("std");
+
+pub extern fn __negsf2(a: f32) f32 {
+    return negXf2(f32, a);
+}
+
+pub extern fn __negdf2(a: f64) f64 {
+    return negXf2(f64, a);
+}
+
+fn negXf2(comptime T: type, a: T) T {
+    const Z = @IntType(false, T.bit_count);
+
+    const typeWidth = T.bit_count;
+    const significandBits = std.math.floatMantissaBits(T);
+    const exponentBits = std.math.floatExponentBits(T);
+
+    const signBit = (Z(1) << (significandBits + exponentBits));
+
+    return @bitCast(T, @bitCast(Z, a) ^ signBit);
+}
std/special/compiler_rt.zig
@@ -82,6 +82,9 @@ comptime {
     @export("__umoddi3", __umoddi3, linkage);
     @export("__udivmodsi4", __udivmodsi4, linkage);
 
+    @export("__negsf2", @import("compiler_rt/negXf2.zig").__negsf2, linkage);
+    @export("__negdf2", @import("compiler_rt/negXf2.zig").__negdf2, linkage);
+
     if (is_arm_arch and !is_arm_64) {
         @export("__aeabi_uldivmod", __aeabi_uldivmod, linkage);
         @export("__aeabi_uidivmod", __aeabi_uidivmod, linkage);
@@ -107,6 +110,9 @@ comptime {
         @export("__aeabi_memcmp4", __aeabi_memcmp, linkage);
         @export("__aeabi_memcmp8", __aeabi_memcmp, linkage);
 
+        @export("__aeabi_fneg", @import("compiler_rt/negXf2.zig").__negsf2, linkage);
+        @export("__aeabi_dneg", @import("compiler_rt/negXf2.zig").__negdf2, linkage);
+
         @export("__aeabi_fadd", @import("compiler_rt/addXf3.zig").__addsf3, linkage);
         @export("__aeabi_dadd", @import("compiler_rt/addXf3.zig").__adddf3, linkage);
         @export("__aeabi_fsub", @import("compiler_rt/addXf3.zig").__subsf3, linkage);
CMakeLists.txt
@@ -664,6 +664,7 @@ set(ZIG_STD_FILES
     "special/compiler_rt/muloti4.zig"
     "special/compiler_rt/mulXf3.zig"
     "special/compiler_rt/multi3.zig"
+    "special/compiler_rt/negXf2.zig"
     "special/compiler_rt/popcountdi2.zig"
     "special/compiler_rt/truncXfYf2.zig"
     "special/compiler_rt/udivmod.zig"