| author | |
| committer | |
| log | 0556a2ba53b8bbb1a60ff31d8dcdde78a8b16727 |
| tree | c691076f8f43db00ba0c6e58afebb1300ea4093e |
| parent | 3efc229bbf8aaec9de54a702054b091bf890d56e |
Finishes cleanups that I started in other commits in this branch.
* Use common.linkage for all exports instead of redoing the logic in
each file.
* Remove pointless `@setRuntimeSafety` calls.
* Avoid redundantly exporting multiple versions of functions. For
example, if PPC wants `ceilf128` then don't also export `ceilq`;
similarly if ARM wants `__aeabi_ddiv` then don't also export
`__divdf3`.
* Use `inline` for helper functions instead of making inline calls at
callsites.45 files changed, 647 insertions(+), 850 deletions(-)
lib/compiler_rt/arm.zig+23-22| ... | @@ -2,40 +2,41 @@ | ... | @@ -2,40 +2,41 @@ |
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | const builtin = @import("builtin"); | 3 | const builtin = @import("builtin"); |
| 4 | const arch = builtin.cpu.arch; | 4 | const arch = builtin.cpu.arch; |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 5 | const common = @import("common.zig"); |
| 6 | pub const panic = @import("common.zig").panic; | 6 | |
| 7 | pub const panic = common.panic; | ||
| 7 | 8 | ||
| 8 | comptime { | 9 | comptime { |
| 9 | if (!builtin.is_test) { | 10 | if (!builtin.is_test) { |
| 10 | if (arch.isARM() or arch.isThumb()) { | 11 | if (arch.isARM() or arch.isThumb()) { |
| 11 | @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = linkage }); | 12 | @export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = common.linkage }); |
| 12 | @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage }); | 13 | @export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage }); |
| 13 | @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = linkage }); | 14 | @export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage }); |
| 14 | 15 | ||
| 15 | @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = linkage }); | 16 | @export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = common.linkage }); |
| 16 | @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = linkage }); | 17 | @export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = common.linkage }); |
| 17 | 18 | ||
| 18 | @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = linkage }); | 19 | @export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = common.linkage }); |
| 19 | @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = linkage }); | 20 | @export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = common.linkage }); |
| 20 | 21 | ||
| 21 | @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = linkage }); | 22 | @export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage }); |
| 22 | @export(__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = linkage }); | 23 | @export(__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage }); |
| 23 | @export(__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = linkage }); | 24 | @export(__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = common.linkage }); |
| 24 | 25 | ||
| 25 | @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = linkage }); | 26 | @export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = common.linkage }); |
| 26 | @export(__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = linkage }); | 27 | @export(__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = common.linkage }); |
| 27 | @export(__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = linkage }); | 28 | @export(__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = common.linkage }); |
| 28 | 29 | ||
| 29 | @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = linkage }); | 30 | @export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = common.linkage }); |
| 30 | @export(__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = linkage }); | 31 | @export(__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = common.linkage }); |
| 31 | @export(__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = linkage }); | 32 | @export(__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = common.linkage }); |
| 32 | 33 | ||
| 33 | @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = linkage }); | 34 | @export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = common.linkage }); |
| 34 | @export(__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = linkage }); | 35 | @export(__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage }); |
| 35 | @export(__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = linkage }); | 36 | @export(__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage }); |
| 36 | 37 | ||
| 37 | if (builtin.os.tag == .linux) { | 38 | if (builtin.os.tag == .linux) { |
| 38 | @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = linkage }); | 39 | @export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage }); |
| 39 | } | 40 | } |
| 40 | } | 41 | } |
| 41 | } | 42 | } |
lib/compiler_rt/aulldiv.zig+5-5| ... | @@ -2,19 +2,19 @@ const std = @import("std"); | ... | @@ -2,19 +2,19 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | 3 | const arch = builtin.cpu.arch; |
| 4 | const abi = builtin.abi; | 4 | const abi = builtin.abi; |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Strong; | 5 | const common = @import("common.zig"); |
| 6 | pub const panic = @import("common.zig").panic; | 6 | |
| 7 | pub const panic = common.panic; | ||
| 7 | 8 | ||
| 8 | comptime { | 9 | comptime { |
| 9 | if (arch == .i386 and abi == .msvc) { | 10 | if (arch == .i386 and abi == .msvc) { |
| 10 | // Don't let LLVM apply the stdcall name mangling on those MSVC builtins | 11 | // Don't let LLVM apply the stdcall name mangling on those MSVC builtins |
| 11 | @export(_alldiv, .{ .name = "\x01__alldiv", .linkage = linkage }); | 12 | @export(_alldiv, .{ .name = "\x01__alldiv", .linkage = common.linkage }); |
| 12 | @export(_aulldiv, .{ .name = "\x01__aulldiv", .linkage = linkage }); | 13 | @export(_aulldiv, .{ .name = "\x01__aulldiv", .linkage = common.linkage }); |
| 13 | } | 14 | } |
| 14 | } | 15 | } |
| 15 | 16 | ||
| 16 | pub fn _alldiv(a: i64, b: i64) callconv(.Stdcall) i64 { | 17 | pub fn _alldiv(a: i64, b: i64) callconv(.Stdcall) i64 { |
| 17 | @setRuntimeSafety(builtin.is_test); | ||
| 18 | const s_a = a >> (64 - 1); | 18 | const s_a = a >> (64 - 1); |
| 19 | const s_b = b >> (64 - 1); | 19 | const s_b = b >> (64 - 1); |
| 20 | 20 |
lib/compiler_rt/aullrem.zig+5-5| ... | @@ -2,19 +2,19 @@ const std = @import("std"); | ... | @@ -2,19 +2,19 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | 3 | const arch = builtin.cpu.arch; |
| 4 | const abi = builtin.abi; | 4 | const abi = builtin.abi; |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Strong; | 5 | const common = @import("common.zig"); |
| 6 | pub const panic = @import("common.zig").panic; | 6 | |
| 7 | pub const panic = common.panic; | ||
| 7 | 8 | ||
| 8 | comptime { | 9 | comptime { |
| 9 | if (arch == .i386 and abi == .msvc) { | 10 | if (arch == .i386 and abi == .msvc) { |
| 10 | // Don't let LLVM apply the stdcall name mangling on those MSVC builtins | 11 | // Don't let LLVM apply the stdcall name mangling on those MSVC builtins |
| 11 | @export(_allrem, .{ .name = "\x01__allrem", .linkage = linkage }); | 12 | @export(_allrem, .{ .name = "\x01__allrem", .linkage = common.linkage }); |
| 12 | @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = linkage }); | 13 | @export(_aullrem, .{ .name = "\x01__aullrem", .linkage = common.linkage }); |
| 13 | } | 14 | } |
| 14 | } | 15 | } |
| 15 | 16 | ||
| 16 | pub fn _allrem(a: i64, b: i64) callconv(.Stdcall) i64 { | 17 | pub fn _allrem(a: i64, b: i64) callconv(.Stdcall) i64 { |
| 17 | @setRuntimeSafety(builtin.is_test); | ||
| 18 | const s_a = a >> (64 - 1); | 18 | const s_a = a >> (64 - 1); |
| 19 | const s_b = b >> (64 - 1); | 19 | const s_b = b >> (64 - 1); |
| 20 | 20 |
lib/compiler_rt/bswap.zig+6-7| ... | @@ -1,13 +1,13 @@ | ... | @@ -1,13 +1,13 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | 3 | const common = @import("common.zig"); |
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 4 | |
| 5 | pub const panic = @import("common.zig").panic; | 5 | pub const panic = common.panic; |
| 6 | 6 | ||
| 7 | comptime { | 7 | comptime { |
| 8 | @export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = linkage }); | 8 | @export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = common.linkage }); |
| 9 | @export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = linkage }); | 9 | @export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = common.linkage }); |
| 10 | @export(__bswapti2, .{ .name = "__bswapti2", .linkage = linkage }); | 10 | @export(__bswapti2, .{ .name = "__bswapti2", .linkage = common.linkage }); |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | // bswap - byteswap | 13 | // bswap - byteswap |
| ... | @@ -21,7 +21,6 @@ comptime { | ... | @@ -21,7 +21,6 @@ comptime { |
| 21 | // 00 00 00 ff << 3*8 (rightmost byte) | 21 | // 00 00 00 ff << 3*8 (rightmost byte) |
| 22 | 22 | ||
| 23 | inline fn bswapXi2(comptime T: type, a: T) T { | 23 | inline fn bswapXi2(comptime T: type, a: T) T { |
| 24 | @setRuntimeSafety(builtin.is_test); | ||
| 25 | switch (@bitSizeOf(T)) { | 24 | switch (@bitSizeOf(T)) { |
| 26 | 32 => { | 25 | 32 => { |
| 27 | // zig fmt: off | 26 | // zig fmt: off |
lib/compiler_rt/ceil.zig+15-23| ... | @@ -1,30 +1,26 @@ | ... | @@ -1,30 +1,26 @@ |
| 1 | // Ported from musl, which is licensed under the MIT license: | 1 | //! Ported from musl, which is MIT licensed. |
| 2 | // https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT | 2 | //! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT |
| 3 | // | 3 | //! |
| 4 | // https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c | 4 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/ceil.c | 5 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/ceil.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const arch = builtin.cpu.arch; | 9 | const arch = builtin.cpu.arch; |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 12 | const common = @import("common.zig"); |
| 13 | pub const panic = @import("common.zig").panic; | 13 | |
| 14 | pub const panic = common.panic; | ||
| 14 | 15 | ||
| 15 | comptime { | 16 | comptime { |
| 16 | @export(__ceilh, .{ .name = "__ceilh", .linkage = linkage }); | 17 | @export(__ceilh, .{ .name = "__ceilh", .linkage = common.linkage }); |
| 17 | @export(ceilf, .{ .name = "ceilf", .linkage = linkage }); | 18 | @export(ceilf, .{ .name = "ceilf", .linkage = common.linkage }); |
| 18 | @export(ceil, .{ .name = "ceil", .linkage = linkage }); | 19 | @export(ceil, .{ .name = "ceil", .linkage = common.linkage }); |
| 19 | @export(__ceilx, .{ .name = "__ceilx", .linkage = linkage }); | 20 | @export(__ceilx, .{ .name = "__ceilx", .linkage = common.linkage }); |
| 20 | @export(ceilq, .{ .name = "ceilq", .linkage = linkage }); | 21 | const ceilq_sym_name = if (common.want_ppc_abi) "ceilf128" else "ceilq"; |
| 21 | @export(ceill, .{ .name = "ceill", .linkage = linkage }); | 22 | @export(ceilq, .{ .name = ceilq_sym_name, .linkage = common.linkage }); |
| 22 | 23 | @export(ceill, .{ .name = "ceill", .linkage = common.linkage }); | |
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(ceilf128, .{ .name = "ceilf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | 24 | } |
| 29 | 25 | ||
| 30 | pub fn __ceilh(x: f16) callconv(.C) f16 { | 26 | pub fn __ceilh(x: f16) callconv(.C) f16 { |
| ... | @@ -130,10 +126,6 @@ pub fn ceilq(x: f128) callconv(.C) f128 { | ... | @@ -130,10 +126,6 @@ pub fn ceilq(x: f128) callconv(.C) f128 { |
| 130 | } | 126 | } |
| 131 | } | 127 | } |
| 132 | 128 | ||
| 133 | pub fn ceilf128(x: f128) callconv(.C) f128 { | ||
| 134 | return @call(.{ .modifier = .always_inline }, ceilq, .{x}); | ||
| 135 | } | ||
| 136 | |||
| 137 | pub fn ceill(x: c_longdouble) callconv(.C) c_longdouble { | 129 | pub fn ceill(x: c_longdouble) callconv(.C) c_longdouble { |
| 138 | switch (@typeInfo(c_longdouble).Float.bits) { | 130 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 139 | 16 => return __ceilh(x), | 131 | 16 => return __ceilh(x), |
lib/compiler_rt/cmp.zig+9-9| ... | @@ -1,16 +1,17 @@ | ... | @@ -1,16 +1,17 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | 3 | const is_test = builtin.is_test; |
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 4 | const common = @import("common.zig"); |
| 5 | pub const panic = @import("common.zig").panic; | 5 | |
| 6 | pub const panic = common.panic; | ||
| 6 | 7 | ||
| 7 | comptime { | 8 | comptime { |
| 8 | @export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = linkage }); | 9 | @export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = common.linkage }); |
| 9 | @export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = linkage }); | 10 | @export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = common.linkage }); |
| 10 | @export(__cmpti2, .{ .name = "__cmpti2", .linkage = linkage }); | 11 | @export(__cmpti2, .{ .name = "__cmpti2", .linkage = common.linkage }); |
| 11 | @export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = linkage }); | 12 | @export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = common.linkage }); |
| 12 | @export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = linkage }); | 13 | @export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = common.linkage }); |
| 13 | @export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = linkage }); | 14 | @export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = common.linkage }); |
| 14 | } | 15 | } |
| 15 | 16 | ||
| 16 | // cmp - signed compare | 17 | // cmp - signed compare |
| ... | @@ -24,7 +25,6 @@ comptime { | ... | @@ -24,7 +25,6 @@ comptime { |
| 24 | // a > b => 2 | 25 | // a > b => 2 |
| 25 | 26 | ||
| 26 | inline fn XcmpXi2(comptime T: type, a: T, b: T) i32 { | 27 | inline fn XcmpXi2(comptime T: type, a: T, b: T) i32 { |
| 27 | @setRuntimeSafety(builtin.is_test); | ||
| 28 | var cmp1: i32 = 0; | 28 | var cmp1: i32 = 0; |
| 29 | var cmp2: i32 = 0; | 29 | var cmp2: i32 = 0; |
| 30 | if (a > b) | 30 | if (a > b) |
lib/compiler_rt/cos.zig+10-18| ... | @@ -3,26 +3,22 @@ const builtin = @import("builtin"); | ... | @@ -3,26 +3,22 @@ const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | 3 | const arch = builtin.cpu.arch; |
| 4 | const math = std.math; | 4 | const math = std.math; |
| 5 | const expect = std.testing.expect; | 5 | const expect = std.testing.expect; |
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 6 | const common = @import("common.zig"); |
| 7 | pub const panic = @import("common.zig").panic; | 7 | |
| 8 | pub const panic = common.panic; | ||
| 8 | 9 | ||
| 9 | const trig = @import("trig.zig"); | 10 | const trig = @import("trig.zig"); |
| 10 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; | 11 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; |
| 11 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; | 12 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; |
| 12 | 13 | ||
| 13 | comptime { | 14 | comptime { |
| 14 | @export(__cosh, .{ .name = "__cosh", .linkage = linkage }); | 15 | @export(__cosh, .{ .name = "__cosh", .linkage = common.linkage }); |
| 15 | @export(cosf, .{ .name = "cosf", .linkage = linkage }); | 16 | @export(cosf, .{ .name = "cosf", .linkage = common.linkage }); |
| 16 | @export(cos, .{ .name = "cos", .linkage = linkage }); | 17 | @export(cos, .{ .name = "cos", .linkage = common.linkage }); |
| 17 | @export(__cosx, .{ .name = "__cosx", .linkage = linkage }); | 18 | @export(__cosx, .{ .name = "__cosx", .linkage = common.linkage }); |
| 18 | @export(cosq, .{ .name = "cosq", .linkage = linkage }); | 19 | const cosq_sym_name = if (common.want_ppc_abi) "cosf128" else "cosq"; |
| 19 | @export(cosl, .{ .name = "cosl", .linkage = linkage }); | 20 | @export(cosq, .{ .name = cosq_sym_name, .linkage = common.linkage }); |
| 20 | 21 | @export(cosl, .{ .name = "cosl", .linkage = common.linkage }); | |
| 21 | if (!builtin.is_test) { | ||
| 22 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 23 | @export(cosf128, .{ .name = "cosf128", .linkage = linkage }); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | } | 22 | } |
| 27 | 23 | ||
| 28 | pub fn __cosh(a: f16) callconv(.C) f16 { | 24 | pub fn __cosh(a: f16) callconv(.C) f16 { |
| ... | @@ -126,10 +122,6 @@ pub fn cosq(a: f128) callconv(.C) f128 { | ... | @@ -126,10 +122,6 @@ pub fn cosq(a: f128) callconv(.C) f128 { |
| 126 | return cos(@floatCast(f64, a)); | 122 | return cos(@floatCast(f64, a)); |
| 127 | } | 123 | } |
| 128 | 124 | ||
| 129 | pub fn cosf128(a: f128) callconv(.C) f128 { | ||
| 130 | return @call(.{ .modifier = .always_inline }, cosq, .{a}); | ||
| 131 | } | ||
| 132 | |||
| 133 | pub fn cosl(x: c_longdouble) callconv(.C) c_longdouble { | 125 | pub fn cosl(x: c_longdouble) callconv(.C) c_longdouble { |
| 134 | switch (@typeInfo(c_longdouble).Float.bits) { | 126 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 135 | 16 => return __cosh(x), | 127 | 16 => return __cosh(x), |
lib/compiler_rt/count0bits.zig+12-17| ... | @@ -1,19 +1,20 @@ | ... | @@ -1,19 +1,20 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | 3 | const is_test = builtin.is_test; |
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 4 | const common = @import("common.zig"); |
| 5 | pub const panic = @import("common.zig").panic; | 5 | |
| 6 | pub const panic = common.panic; | ||
| 6 | 7 | ||
| 7 | comptime { | 8 | comptime { |
| 8 | @export(__clzsi2, .{ .name = "__clzsi2", .linkage = linkage }); | 9 | @export(__clzsi2, .{ .name = "__clzsi2", .linkage = common.linkage }); |
| 9 | @export(__clzdi2, .{ .name = "__clzdi2", .linkage = linkage }); | 10 | @export(__clzdi2, .{ .name = "__clzdi2", .linkage = common.linkage }); |
| 10 | @export(__clzti2, .{ .name = "__clzti2", .linkage = linkage }); | 11 | @export(__clzti2, .{ .name = "__clzti2", .linkage = common.linkage }); |
| 11 | @export(__ctzsi2, .{ .name = "__ctzsi2", .linkage = linkage }); | 12 | @export(__ctzsi2, .{ .name = "__ctzsi2", .linkage = common.linkage }); |
| 12 | @export(__ctzdi2, .{ .name = "__ctzdi2", .linkage = linkage }); | 13 | @export(__ctzdi2, .{ .name = "__ctzdi2", .linkage = common.linkage }); |
| 13 | @export(__ctzti2, .{ .name = "__ctzti2", .linkage = linkage }); | 14 | @export(__ctzti2, .{ .name = "__ctzti2", .linkage = common.linkage }); |
| 14 | @export(__ffssi2, .{ .name = "__ffssi2", .linkage = linkage }); | 15 | @export(__ffssi2, .{ .name = "__ffssi2", .linkage = common.linkage }); |
| 15 | @export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = linkage }); | 16 | @export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = common.linkage }); |
| 16 | @export(__ffsti2, .{ .name = "__ffsti2", .linkage = linkage }); | 17 | @export(__ffsti2, .{ .name = "__ffsti2", .linkage = common.linkage }); |
| 17 | } | 18 | } |
| 18 | 19 | ||
| 19 | // clz - count leading zeroes | 20 | // clz - count leading zeroes |
| ... | @@ -30,8 +31,6 @@ comptime { | ... | @@ -30,8 +31,6 @@ comptime { |
| 30 | // - ffsXi2 for unoptimized little and big endian | 31 | // - ffsXi2 for unoptimized little and big endian |
| 31 | 32 | ||
| 32 | inline fn clzXi2(comptime T: type, a: T) i32 { | 33 | inline fn clzXi2(comptime T: type, a: T) i32 { |
| 33 | @setRuntimeSafety(builtin.is_test); | ||
| 34 | |||
| 35 | var x = switch (@bitSizeOf(T)) { | 34 | var x = switch (@bitSizeOf(T)) { |
| 36 | 32 => @bitCast(u32, a), | 35 | 32 => @bitCast(u32, a), |
| 37 | 64 => @bitCast(u64, a), | 36 | 64 => @bitCast(u64, a), |
| ... | @@ -169,8 +168,6 @@ pub fn __clzti2(a: i128) callconv(.C) i32 { | ... | @@ -169,8 +168,6 @@ pub fn __clzti2(a: i128) callconv(.C) i32 { |
| 169 | } | 168 | } |
| 170 | 169 | ||
| 171 | inline fn ctzXi2(comptime T: type, a: T) i32 { | 170 | inline fn ctzXi2(comptime T: type, a: T) i32 { |
| 172 | @setRuntimeSafety(builtin.is_test); | ||
| 173 | |||
| 174 | var x = switch (@bitSizeOf(T)) { | 171 | var x = switch (@bitSizeOf(T)) { |
| 175 | 32 => @bitCast(u32, a), | 172 | 32 => @bitCast(u32, a), |
| 176 | 64 => @bitCast(u64, a), | 173 | 64 => @bitCast(u64, a), |
| ... | @@ -206,8 +203,6 @@ pub fn __ctzti2(a: i128) callconv(.C) i32 { | ... | @@ -206,8 +203,6 @@ pub fn __ctzti2(a: i128) callconv(.C) i32 { |
| 206 | } | 203 | } |
| 207 | 204 | ||
| 208 | inline fn ffsXi2(comptime T: type, a: T) i32 { | 205 | inline fn ffsXi2(comptime T: type, a: T) i32 { |
| 209 | @setRuntimeSafety(builtin.is_test); | ||
| 210 | |||
| 211 | var x = switch (@bitSizeOf(T)) { | 206 | var x = switch (@bitSizeOf(T)) { |
| 212 | 32 => @bitCast(u32, a), | 207 | 32 => @bitCast(u32, a), |
| 213 | 64 => @bitCast(u64, a), | 208 | 64 => @bitCast(u64, a), |
lib/compiler_rt/divdf3.zig+17-17| ... | @@ -1,30 +1,35 @@ | ... | @@ -1,30 +1,35 @@ |
| 1 | // Ported from: | 1 | //! Ported from: |
| 2 | // | 2 | //! |
| 3 | // https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/divdf3.c | 3 | //! https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/divdf3.c |
| 4 | 4 | ||
| 5 | const std = @import("std"); | 5 | const std = @import("std"); |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = @import("builtin"); |
| 7 | const arch = builtin.cpu.arch; | 7 | const arch = builtin.cpu.arch; |
| 8 | const is_test = builtin.is_test; | 8 | const is_test = builtin.is_test; |
| 9 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 10 | |||
| 11 | const common = @import("common.zig"); | 9 | const common = @import("common.zig"); |
| 10 | |||
| 12 | const normalize = common.normalize; | 11 | const normalize = common.normalize; |
| 13 | const wideMultiply = common.wideMultiply; | 12 | const wideMultiply = common.wideMultiply; |
| 13 | |||
| 14 | pub const panic = common.panic; | 14 | pub const panic = common.panic; |
| 15 | 15 | ||
| 16 | comptime { | 16 | comptime { |
| 17 | @export(__divdf3, .{ .name = "__divdf3", .linkage = linkage }); | 17 | if (common.want_aeabi) { |
| 18 | 18 | @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = common.linkage }); | |
| 19 | if (!is_test) { | 19 | } else { |
| 20 | if (arch.isARM() or arch.isThumb()) { | 20 | @export(__divdf3, .{ .name = "__divdf3", .linkage = common.linkage }); |
| 21 | @export(__aeabi_ddiv, .{ .name = "__aeabi_ddiv", .linkage = linkage }); | ||
| 22 | } | ||
| 23 | } | 21 | } |
| 24 | } | 22 | } |
| 25 | 23 | ||
| 26 | pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { | 24 | pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { |
| 27 | @setRuntimeSafety(builtin.is_test); | 25 | return div(a, b); |
| 26 | } | ||
| 27 | |||
| 28 | fn __aeabi_ddiv(a: f64, b: f64) callconv(.AAPCS) f64 { | ||
| 29 | return div(a, b); | ||
| 30 | } | ||
| 31 | |||
| 32 | inline fn div(a: f64, b: f64) f64 { | ||
| 28 | const Z = std.meta.Int(.unsigned, 64); | 33 | const Z = std.meta.Int(.unsigned, 64); |
| 29 | const SignedZ = std.meta.Int(.signed, 64); | 34 | const SignedZ = std.meta.Int(.signed, 64); |
| 30 | 35 | ||
| ... | @@ -220,11 +225,6 @@ pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { | ... | @@ -220,11 +225,6 @@ pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { |
| 220 | } | 225 | } |
| 221 | } | 226 | } |
| 222 | 227 | ||
| 223 | pub fn __aeabi_ddiv(a: f64, b: f64) callconv(.AAPCS) f64 { | ||
| 224 | @setRuntimeSafety(false); | ||
| 225 | return @call(.{ .modifier = .always_inline }, __divdf3, .{ a, b }); | ||
| 226 | } | ||
| 227 | |||
| 228 | test { | 228 | test { |
| 229 | _ = @import("divdf3_test.zig"); | 229 | _ = @import("divdf3_test.zig"); |
| 230 | } | 230 | } |
lib/compiler_rt/divsf3.zig+16-17| ... | @@ -1,29 +1,33 @@ | ... | @@ -1,29 +1,33 @@ |
| 1 | // Ported from: | 1 | //! Ported from: |
| 2 | // | 2 | //! |
| 3 | // https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/divsf3.c | 3 | //! https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/divsf3.c |
| 4 | 4 | ||
| 5 | const std = @import("std"); | 5 | const std = @import("std"); |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = @import("builtin"); |
| 7 | const arch = builtin.cpu.arch; | 7 | const arch = builtin.cpu.arch; |
| 8 | const is_test = builtin.is_test; | ||
| 9 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 10 | 8 | ||
| 11 | const common = @import("common.zig"); | 9 | const common = @import("common.zig"); |
| 12 | const normalize = common.normalize; | 10 | const normalize = common.normalize; |
| 11 | |||
| 13 | pub const panic = common.panic; | 12 | pub const panic = common.panic; |
| 14 | 13 | ||
| 15 | comptime { | 14 | comptime { |
| 16 | @export(__divsf3, .{ .name = "__divsf3", .linkage = linkage }); | 15 | if (common.want_aeabi) { |
| 17 | 16 | @export(__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = common.linkage }); | |
| 18 | if (!is_test) { | 17 | } else { |
| 19 | if (arch.isARM() or arch.isThumb()) { | 18 | @export(__divsf3, .{ .name = "__divsf3", .linkage = common.linkage }); |
| 20 | @export(__aeabi_fdiv, .{ .name = "__aeabi_fdiv", .linkage = linkage }); | ||
| 21 | } | ||
| 22 | } | 19 | } |
| 23 | } | 20 | } |
| 24 | 21 | ||
| 25 | pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { | 22 | pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { |
| 26 | @setRuntimeSafety(builtin.is_test); | 23 | return div(a, b); |
| 24 | } | ||
| 25 | |||
| 26 | fn __aeabi_fdiv(a: f32, b: f32) callconv(.AAPCS) f32 { | ||
| 27 | return div(a, b); | ||
| 28 | } | ||
| 29 | |||
| 30 | inline fn div(a: f32, b: f32) f32 { | ||
| 27 | const Z = std.meta.Int(.unsigned, 32); | 31 | const Z = std.meta.Int(.unsigned, 32); |
| 28 | 32 | ||
| 29 | const significandBits = std.math.floatMantissaBits(f32); | 33 | const significandBits = std.math.floatMantissaBits(f32); |
| ... | @@ -201,11 +205,6 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { | ... | @@ -201,11 +205,6 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { |
| 201 | } | 205 | } |
| 202 | } | 206 | } |
| 203 | 207 | ||
| 204 | pub fn __aeabi_fdiv(a: f32, b: f32) callconv(.AAPCS) f32 { | ||
| 205 | @setRuntimeSafety(false); | ||
| 206 | return @call(.{ .modifier = .always_inline }, __divsf3, .{ a, b }); | ||
| 207 | } | ||
| 208 | |||
| 209 | test { | 208 | test { |
| 210 | _ = @import("divsf3_test.zig"); | 209 | _ = @import("divsf3_test.zig"); |
| 211 | } | 210 | } |
lib/compiler_rt/divti3.zig+16-16| ... | @@ -2,34 +2,42 @@ const std = @import("std"); | ... | @@ -2,34 +2,42 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const udivmod = @import("udivmod.zig").udivmod; | 3 | const udivmod = @import("udivmod.zig").udivmod; |
| 4 | const arch = builtin.cpu.arch; | 4 | const arch = builtin.cpu.arch; |
| 5 | const is_test = builtin.is_test; | 5 | const common = @import("common.zig"); |
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 6 | |
| 7 | pub const panic = @import("common.zig").panic; | 7 | pub const panic = common.panic; |
| 8 | 8 | ||
| 9 | comptime { | 9 | comptime { |
| 10 | if (builtin.os.tag == .windows) { | 10 | if (builtin.os.tag == .windows) { |
| 11 | switch (arch) { | 11 | switch (arch) { |
| 12 | .i386 => { | 12 | .i386 => { |
| 13 | @export(__divti3, .{ .name = "__divti3", .linkage = linkage }); | 13 | @export(__divti3, .{ .name = "__divti3", .linkage = common.linkage }); |
| 14 | }, | 14 | }, |
| 15 | .x86_64 => { | 15 | .x86_64 => { |
| 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI |
| 17 | // that LLVM expects compiler-rt to have. | 17 | // that LLVM expects compiler-rt to have. |
| 18 | @export(__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = linkage }); | 18 | @export(__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = common.linkage }); |
| 19 | }, | 19 | }, |
| 20 | else => {}, | 20 | else => {}, |
| 21 | } | 21 | } |
| 22 | if (arch.isAARCH64()) { | 22 | if (arch.isAARCH64()) { |
| 23 | @export(__divti3, .{ .name = "__divti3", .linkage = linkage }); | 23 | @export(__divti3, .{ .name = "__divti3", .linkage = common.linkage }); |
| 24 | } | 24 | } |
| 25 | } else { | 25 | } else { |
| 26 | @export(__divti3, .{ .name = "__divti3", .linkage = linkage }); | 26 | @export(__divti3, .{ .name = "__divti3", .linkage = common.linkage }); |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | pub fn __divti3(a: i128, b: i128) callconv(.C) i128 { | 30 | pub fn __divti3(a: i128, b: i128) callconv(.C) i128 { |
| 31 | @setRuntimeSafety(builtin.is_test); | 31 | return div(a, b); |
| 32 | } | ||
| 32 | 33 | ||
| 34 | const v128 = @import("std").meta.Vector(2, u64); | ||
| 35 | |||
| 36 | fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { | ||
| 37 | return @bitCast(v128, div(@bitCast(i128, a), @bitCast(i128, b))); | ||
| 38 | } | ||
| 39 | |||
| 40 | inline fn div(a: i128, b: i128) i128 { | ||
| 33 | const s_a = a >> (128 - 1); | 41 | const s_a = a >> (128 - 1); |
| 34 | const s_b = b >> (128 - 1); | 42 | const s_b = b >> (128 - 1); |
| 35 | 43 | ||
| ... | @@ -41,14 +49,6 @@ pub fn __divti3(a: i128, b: i128) callconv(.C) i128 { | ... | @@ -41,14 +49,6 @@ pub fn __divti3(a: i128, b: i128) callconv(.C) i128 { |
| 41 | return (@bitCast(i128, r) ^ s) -% s; | 49 | return (@bitCast(i128, r) ^ s) -% s; |
| 42 | } | 50 | } |
| 43 | 51 | ||
| 44 | const v128 = @import("std").meta.Vector(2, u64); | ||
| 45 | pub fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { | ||
| 46 | return @bitCast(v128, @call(.{ .modifier = .always_inline }, __divti3, .{ | ||
| 47 | @bitCast(i128, a), | ||
| 48 | @bitCast(i128, b), | ||
| 49 | })); | ||
| 50 | } | ||
| 51 | |||
| 52 | test { | 52 | test { |
| 53 | _ = @import("divti3_test.zig"); | 53 | _ = @import("divti3_test.zig"); |
| 54 | } | 54 | } |
lib/compiler_rt/divxf3.zig+2-4| ... | @@ -1,20 +1,18 @@ | ... | @@ -1,20 +1,18 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | 3 | const arch = builtin.cpu.arch; |
| 4 | const is_test = builtin.is_test; | ||
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 6 | 4 | ||
| 7 | const common = @import("common.zig"); | 5 | const common = @import("common.zig"); |
| 8 | const normalize = common.normalize; | 6 | const normalize = common.normalize; |
| 9 | const wideMultiply = common.wideMultiply; | 7 | const wideMultiply = common.wideMultiply; |
| 8 | |||
| 10 | pub const panic = common.panic; | 9 | pub const panic = common.panic; |
| 11 | 10 | ||
| 12 | comptime { | 11 | comptime { |
| 13 | @export(__divxf3, .{ .name = "__divxf3", .linkage = linkage }); | 12 | @export(__divxf3, .{ .name = "__divxf3", .linkage = common.linkage }); |
| 14 | } | 13 | } |
| 15 | 14 | ||
| 16 | pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 { | 15 | pub fn __divxf3(a: f80, b: f80) callconv(.C) f80 { |
| 17 | @setRuntimeSafety(builtin.is_test); | ||
| 18 | const T = f80; | 16 | const T = f80; |
| 19 | const Z = std.meta.Int(.unsigned, @bitSizeOf(T)); | 17 | const Z = std.meta.Int(.unsigned, @bitSizeOf(T)); |
| 20 | 18 |
lib/compiler_rt/emutls.zig+10-10| ... | @@ -1,25 +1,25 @@ | ... | @@ -1,25 +1,25 @@ |
| 1 | // __emutls_get_address specific builtin | 1 | //! __emutls_get_address specific builtin |
| 2 | // | 2 | //! |
| 3 | // derived work from LLVM Compiler Infrastructure - release 8.0 (MIT) | 3 | //! derived work from LLVM Compiler Infrastructure - release 8.0 (MIT) |
| 4 | // https://github.com/llvm-mirror/compiler-rt/blob/release_80/lib/builtins/emutls.c | 4 | //! https://github.com/llvm-mirror/compiler-rt/blob/release_80/lib/builtins/emutls.c |
| 5 | // | ||
| 6 | 5 | ||
| 7 | const std = @import("std"); | 6 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 7 | const builtin = @import("builtin"); |
| 9 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 8 | const common = @import("common.zig"); |
| 10 | pub const panic = @import("common.zig").panic; | ||
| 11 | 9 | ||
| 12 | const abort = std.os.abort; | 10 | const abort = std.os.abort; |
| 13 | const assert = std.debug.assert; | 11 | const assert = std.debug.assert; |
| 14 | const expect = std.testing.expect; | 12 | const expect = std.testing.expect; |
| 15 | 13 | ||
| 16 | // defined in C as: | 14 | /// defined in C as: |
| 17 | // typedef unsigned int gcc_word __attribute__((mode(word))); | 15 | /// typedef unsigned int gcc_word __attribute__((mode(word))); |
| 18 | const gcc_word = usize; | 16 | const gcc_word = usize; |
| 19 | 17 | ||
| 18 | pub const panic = common.panic; | ||
| 19 | |||
| 20 | comptime { | 20 | comptime { |
| 21 | if (builtin.link_libc and builtin.os.tag == .openbsd) { | 21 | if (builtin.link_libc and builtin.os.tag == .openbsd) { |
| 22 | @export(__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = linkage }); | 22 | @export(__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = common.linkage }); |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
| 25 | 25 |
lib/compiler_rt/exp.zig+10-18| ... | @@ -9,22 +9,18 @@ const builtin = @import("builtin"); | ... | @@ -9,22 +9,18 @@ const builtin = @import("builtin"); |
| 9 | const arch = builtin.cpu.arch; | 9 | const arch = builtin.cpu.arch; |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 12 | const common = @import("common.zig"); |
| 13 | pub const panic = @import("common.zig").panic; | 13 | |
| 14 | pub const panic = common.panic; | ||
| 14 | 15 | ||
| 15 | comptime { | 16 | comptime { |
| 16 | @export(__exph, .{ .name = "__exph", .linkage = linkage }); | 17 | @export(__exph, .{ .name = "__exph", .linkage = common.linkage }); |
| 17 | @export(expf, .{ .name = "expf", .linkage = linkage }); | 18 | @export(expf, .{ .name = "expf", .linkage = common.linkage }); |
| 18 | @export(exp, .{ .name = "exp", .linkage = linkage }); | 19 | @export(exp, .{ .name = "exp", .linkage = common.linkage }); |
| 19 | @export(__expx, .{ .name = "__expx", .linkage = linkage }); | 20 | @export(__expx, .{ .name = "__expx", .linkage = common.linkage }); |
| 20 | @export(expq, .{ .name = "expq", .linkage = linkage }); | 21 | const expq_sym_name = if (common.want_ppc_abi) "expf128" else "expq"; |
| 21 | @export(expl, .{ .name = "expl", .linkage = linkage }); | 22 | @export(expq, .{ .name = expq_sym_name, .linkage = common.linkage }); |
| 22 | 23 | @export(expl, .{ .name = "expl", .linkage = common.linkage }); | |
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(expf128, .{ .name = "expf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | 24 | } |
| 29 | 25 | ||
| 30 | pub fn __exph(a: f16) callconv(.C) f16 { | 26 | pub fn __exph(a: f16) callconv(.C) f16 { |
| ... | @@ -201,10 +197,6 @@ pub fn expq(a: f128) callconv(.C) f128 { | ... | @@ -201,10 +197,6 @@ pub fn expq(a: f128) callconv(.C) f128 { |
| 201 | return exp(@floatCast(f64, a)); | 197 | return exp(@floatCast(f64, a)); |
| 202 | } | 198 | } |
| 203 | 199 | ||
| 204 | pub fn expf128(a: f128) callconv(.C) f128 { | ||
| 205 | return @call(.{ .modifier = .always_inline }, expq, .{a}); | ||
| 206 | } | ||
| 207 | |||
| 208 | pub fn expl(x: c_longdouble) callconv(.C) c_longdouble { | 200 | pub fn expl(x: c_longdouble) callconv(.C) c_longdouble { |
| 209 | switch (@typeInfo(c_longdouble).Float.bits) { | 201 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 210 | 16 => return __exph(x), | 202 | 16 => return __exph(x), |
lib/compiler_rt/exp2.zig+10-18| ... | @@ -9,22 +9,18 @@ const builtin = @import("builtin"); | ... | @@ -9,22 +9,18 @@ const builtin = @import("builtin"); |
| 9 | const arch = builtin.cpu.arch; | 9 | const arch = builtin.cpu.arch; |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 12 | const common = @import("common.zig"); |
| 13 | pub const panic = @import("common.zig").panic; | ||
| 14 | 13 | ||
| 15 | comptime { | 14 | pub const panic = common.panic; |
| 16 | @export(__exp2h, .{ .name = "__exp2h", .linkage = linkage }); | ||
| 17 | @export(exp2f, .{ .name = "exp2f", .linkage = linkage }); | ||
| 18 | @export(exp2, .{ .name = "exp2", .linkage = linkage }); | ||
| 19 | @export(__exp2x, .{ .name = "__exp2x", .linkage = linkage }); | ||
| 20 | @export(exp2q, .{ .name = "exp2q", .linkage = linkage }); | ||
| 21 | @export(exp2l, .{ .name = "exp2l", .linkage = linkage }); | ||
| 22 | 15 | ||
| 23 | if (!builtin.is_test) { | 16 | comptime { |
| 24 | if (arch.isPPC() or arch.isPPC64()) { | 17 | @export(__exp2h, .{ .name = "__exp2h", .linkage = common.linkage }); |
| 25 | @export(exp2f128, .{ .name = "exp2f128", .linkage = linkage }); | 18 | @export(exp2f, .{ .name = "exp2f", .linkage = common.linkage }); |
| 26 | } | 19 | @export(exp2, .{ .name = "exp2", .linkage = common.linkage }); |
| 27 | } | 20 | @export(__exp2x, .{ .name = "__exp2x", .linkage = common.linkage }); |
| 21 | const exp2q_sym_name = if (common.want_ppc_abi) "exp2f128" else "exp2q"; | ||
| 22 | @export(exp2q, .{ .name = exp2q_sym_name, .linkage = common.linkage }); | ||
| 23 | @export(exp2l, .{ .name = "exp2l", .linkage = common.linkage }); | ||
| 28 | } | 24 | } |
| 29 | 25 | ||
| 30 | pub fn __exp2h(x: f16) callconv(.C) f16 { | 26 | pub fn __exp2h(x: f16) callconv(.C) f16 { |
| ... | @@ -168,10 +164,6 @@ pub fn exp2q(x: f128) callconv(.C) f128 { | ... | @@ -168,10 +164,6 @@ pub fn exp2q(x: f128) callconv(.C) f128 { |
| 168 | return exp2(@floatCast(f64, x)); | 164 | return exp2(@floatCast(f64, x)); |
| 169 | } | 165 | } |
| 170 | 166 | ||
| 171 | pub fn exp2f128(x: f128) callconv(.C) f128 { | ||
| 172 | return @call(.{ .modifier = .always_inline }, exp2q, .{x}); | ||
| 173 | } | ||
| 174 | |||
| 175 | pub fn exp2l(x: c_longdouble) callconv(.C) c_longdouble { | 167 | pub fn exp2l(x: c_longdouble) callconv(.C) c_longdouble { |
| 176 | switch (@typeInfo(c_longdouble).Float.bits) { | 168 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 177 | 16 => return __exp2h(x), | 169 | 16 => return __exp2h(x), |
lib/compiler_rt/fabs.zig+10-18| ... | @@ -1,22 +1,18 @@ | ... | @@ -1,22 +1,18 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | 3 | const arch = builtin.cpu.arch; |
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 4 | const common = @import("common.zig"); |
| 5 | pub const panic = @import("common.zig").panic; | 5 | |
| 6 | pub const panic = common.panic; | ||
| 6 | 7 | ||
| 7 | comptime { | 8 | comptime { |
| 8 | @export(__fabsh, .{ .name = "__fabsh", .linkage = linkage }); | 9 | @export(__fabsh, .{ .name = "__fabsh", .linkage = common.linkage }); |
| 9 | @export(fabsf, .{ .name = "fabsf", .linkage = linkage }); | 10 | @export(fabsf, .{ .name = "fabsf", .linkage = common.linkage }); |
| 10 | @export(fabs, .{ .name = "fabs", .linkage = linkage }); | 11 | @export(fabs, .{ .name = "fabs", .linkage = common.linkage }); |
| 11 | @export(__fabsx, .{ .name = "__fabsx", .linkage = linkage }); | 12 | @export(__fabsx, .{ .name = "__fabsx", .linkage = common.linkage }); |
| 12 | @export(fabsq, .{ .name = "fabsq", .linkage = linkage }); | 13 | const fabsq_sym_name = if (common.want_ppc_abi) "fabsf128" else "fabsq"; |
| 13 | @export(fabsl, .{ .name = "fabsl", .linkage = linkage }); | 14 | @export(fabsq, .{ .name = fabsq_sym_name, .linkage = common.linkage }); |
| 14 | 15 | @export(fabsl, .{ .name = "fabsl", .linkage = common.linkage }); | |
| 15 | if (!builtin.is_test) { | ||
| 16 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 17 | @export(fabsf128, .{ .name = "fabsf128", .linkage = linkage }); | ||
| 18 | } | ||
| 19 | } | ||
| 20 | } | 16 | } |
| 21 | 17 | ||
| 22 | pub fn __fabsh(a: f16) callconv(.C) f16 { | 18 | pub fn __fabsh(a: f16) callconv(.C) f16 { |
| ... | @@ -39,10 +35,6 @@ pub fn fabsq(a: f128) callconv(.C) f128 { | ... | @@ -39,10 +35,6 @@ pub fn fabsq(a: f128) callconv(.C) f128 { |
| 39 | return generic_fabs(a); | 35 | return generic_fabs(a); |
| 40 | } | 36 | } |
| 41 | 37 | ||
| 42 | pub fn fabsf128(a: f128) callconv(.C) f128 { | ||
| 43 | return @call(.{ .modifier = .always_inline }, fabsq, .{a}); | ||
| 44 | } | ||
| 45 | |||
| 46 | pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble { | 38 | pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble { |
| 47 | switch (@typeInfo(c_longdouble).Float.bits) { | 39 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 48 | 16 => return __fabsh(x), | 40 | 16 => return __fabsh(x), |
lib/compiler_rt/floor.zig+15-23| ... | @@ -1,30 +1,26 @@ | ... | @@ -1,30 +1,26 @@ |
| 1 | // Ported from musl, which is licensed under the MIT license: | 1 | //! Ported from musl, which is licensed under the MIT license: |
| 2 | // https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT | 2 | //! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT |
| 3 | // | 3 | //! |
| 4 | // https://git.musl-libc.org/cgit/musl/tree/src/math/floorf.c | 4 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/floorf.c |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/floor.c | 5 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/floor.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const math = std.math; | 9 | const math = std.math; |
| 10 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 11 | const arch = builtin.cpu.arch; | 11 | const arch = builtin.cpu.arch; |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 12 | const common = @import("common.zig"); |
| 13 | pub const panic = @import("common.zig").panic; | 13 | |
| 14 | pub const panic = common.panic; | ||
| 14 | 15 | ||
| 15 | comptime { | 16 | comptime { |
| 16 | @export(__floorh, .{ .name = "__floorh", .linkage = linkage }); | 17 | @export(__floorh, .{ .name = "__floorh", .linkage = common.linkage }); |
| 17 | @export(floorf, .{ .name = "floorf", .linkage = linkage }); | 18 | @export(floorf, .{ .name = "floorf", .linkage = common.linkage }); |
| 18 | @export(floor, .{ .name = "floor", .linkage = linkage }); | 19 | @export(floor, .{ .name = "floor", .linkage = common.linkage }); |
| 19 | @export(__floorx, .{ .name = "__floorx", .linkage = linkage }); | 20 | @export(__floorx, .{ .name = "__floorx", .linkage = common.linkage }); |
| 20 | @export(floorq, .{ .name = "floorq", .linkage = linkage }); | 21 | const floorq_sym_name = if (common.want_ppc_abi) "floorf128" else "floorq"; |
| 21 | @export(floorl, .{ .name = "floorl", .linkage = linkage }); | 22 | @export(floorq, .{ .name = floorq_sym_name, .linkage = common.linkage }); |
| 22 | 23 | @export(floorl, .{ .name = "floorl", .linkage = common.linkage }); | |
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(floorf128, .{ .name = "floorf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | 24 | } |
| 29 | 25 | ||
| 30 | pub fn __floorh(x: f16) callconv(.C) f16 { | 26 | pub fn __floorh(x: f16) callconv(.C) f16 { |
| ... | @@ -160,10 +156,6 @@ pub fn floorq(x: f128) callconv(.C) f128 { | ... | @@ -160,10 +156,6 @@ pub fn floorq(x: f128) callconv(.C) f128 { |
| 160 | } | 156 | } |
| 161 | } | 157 | } |
| 162 | 158 | ||
| 163 | pub fn floorf128(x: f128) callconv(.C) f128 { | ||
| 164 | return @call(.{ .modifier = .always_inline }, floorq, .{x}); | ||
| 165 | } | ||
| 166 | |||
| 167 | pub fn floorl(x: c_longdouble) callconv(.C) c_longdouble { | 159 | pub fn floorl(x: c_longdouble) callconv(.C) c_longdouble { |
| 168 | switch (@typeInfo(c_longdouble).Float.bits) { | 160 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 169 | 16 => return __floorh(x), | 161 | 16 => return __floorh(x), |
lib/compiler_rt/fma.zig+16-24| ... | @@ -1,31 +1,27 @@ | ... | @@ -1,31 +1,27 @@ |
| 1 | // Ported from musl, which is MIT licensed: | 1 | //! Ported from musl, which is MIT licensed: |
| 2 | // https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT | 2 | //! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT |
| 3 | // | 3 | //! |
| 4 | // https://git.musl-libc.org/cgit/musl/tree/src/math/fmal.c | 4 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/fmal.c |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/fmaf.c | 5 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/fmaf.c |
| 6 | // https://git.musl-libc.org/cgit/musl/tree/src/math/fma.c | 6 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/fma.c |
| 7 | 7 | ||
| 8 | const std = @import("std"); | 8 | const std = @import("std"); |
| 9 | const builtin = @import("builtin"); | 9 | const builtin = @import("builtin"); |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 12 | const arch = builtin.cpu.arch; | 12 | const arch = builtin.cpu.arch; |
| 13 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 13 | const common = @import("common.zig"); |
| 14 | pub const panic = @import("common.zig").panic; | 14 | |
| 15 | pub const panic = common.panic; | ||
| 15 | 16 | ||
| 16 | comptime { | 17 | comptime { |
| 17 | @export(__fmah, .{ .name = "__fmah", .linkage = linkage }); | 18 | @export(__fmah, .{ .name = "__fmah", .linkage = common.linkage }); |
| 18 | @export(fmaf, .{ .name = "fmaf", .linkage = linkage }); | 19 | @export(fmaf, .{ .name = "fmaf", .linkage = common.linkage }); |
| 19 | @export(fma, .{ .name = "fma", .linkage = linkage }); | 20 | @export(fma, .{ .name = "fma", .linkage = common.linkage }); |
| 20 | @export(__fmax, .{ .name = "__fmax", .linkage = linkage }); | 21 | @export(__fmax, .{ .name = "__fmax", .linkage = common.linkage }); |
| 21 | @export(fmaq, .{ .name = "fmaq", .linkage = linkage }); | 22 | const fmaq_sym_name = if (common.want_ppc_abi) "fmaf128" else "fmaq"; |
| 22 | @export(fmal, .{ .name = "fmal", .linkage = linkage }); | 23 | @export(fmaq, .{ .name = fmaq_sym_name, .linkage = common.linkage }); |
| 23 | 24 | @export(fmal, .{ .name = "fmal", .linkage = common.linkage }); | |
| 24 | if (!builtin.is_test) { | ||
| 25 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 26 | @export(fmaf128, .{ .name = "fmaf128", .linkage = linkage }); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | } | 25 | } |
| 30 | 26 | ||
| 31 | pub fn __fmah(x: f16, y: f16, z: f16) callconv(.C) f16 { | 27 | pub fn __fmah(x: f16, y: f16, z: f16) callconv(.C) f16 { |
| ... | @@ -154,10 +150,6 @@ pub fn fmaq(x: f128, y: f128, z: f128) callconv(.C) f128 { | ... | @@ -154,10 +150,6 @@ pub fn fmaq(x: f128, y: f128, z: f128) callconv(.C) f128 { |
| 154 | } | 150 | } |
| 155 | } | 151 | } |
| 156 | 152 | ||
| 157 | pub fn fmaf128(x: f128, y: f128, z: f128) callconv(.C) f128 { | ||
| 158 | return @call(.{ .modifier = .always_inline }, fmaq, .{ x, y, z }); | ||
| 159 | } | ||
| 160 | |||
| 161 | pub fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) callconv(.C) c_longdouble { | 153 | pub fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) callconv(.C) c_longdouble { |
| 162 | switch (@typeInfo(c_longdouble).Float.bits) { | 154 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 163 | 16 => return __fmah(x, y, z), | 155 | 16 => return __fmah(x, y, z), |
lib/compiler_rt/fmax.zig+10-18| ... | @@ -2,22 +2,18 @@ const std = @import("std"); | ... | @@ -2,22 +2,18 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const math = std.math; | 3 | const math = std.math; |
| 4 | const arch = builtin.cpu.arch; | 4 | const arch = builtin.cpu.arch; |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 5 | const common = @import("common.zig"); |
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | 6 | ||
| 8 | comptime { | 7 | pub const panic = common.panic; |
| 9 | @export(__fmaxh, .{ .name = "__fmaxh", .linkage = linkage }); | ||
| 10 | @export(fmaxf, .{ .name = "fmaxf", .linkage = linkage }); | ||
| 11 | @export(fmax, .{ .name = "fmax", .linkage = linkage }); | ||
| 12 | @export(__fmaxx, .{ .name = "__fmaxx", .linkage = linkage }); | ||
| 13 | @export(fmaxq, .{ .name = "fmaxq", .linkage = linkage }); | ||
| 14 | @export(fmaxl, .{ .name = "fmaxl", .linkage = linkage }); | ||
| 15 | 8 | ||
| 16 | if (!builtin.is_test) { | 9 | comptime { |
| 17 | if (arch.isPPC() or arch.isPPC64()) { | 10 | @export(__fmaxh, .{ .name = "__fmaxh", .linkage = common.linkage }); |
| 18 | @export(fmaxf128, .{ .name = "fmaxf128", .linkage = linkage }); | 11 | @export(fmaxf, .{ .name = "fmaxf", .linkage = common.linkage }); |
| 19 | } | 12 | @export(fmax, .{ .name = "fmax", .linkage = common.linkage }); |
| 20 | } | 13 | @export(__fmaxx, .{ .name = "__fmaxx", .linkage = common.linkage }); |
| 14 | const fmaxq_sym_name = if (common.want_ppc_abi) "fmaxf128" else "fmaxq"; | ||
| 15 | @export(fmaxq, .{ .name = fmaxq_sym_name, .linkage = common.linkage }); | ||
| 16 | @export(fmaxl, .{ .name = "fmaxl", .linkage = common.linkage }); | ||
| 21 | } | 17 | } |
| 22 | 18 | ||
| 23 | pub fn __fmaxh(x: f16, y: f16) callconv(.C) f16 { | 19 | pub fn __fmaxh(x: f16, y: f16) callconv(.C) f16 { |
| ... | @@ -40,10 +36,6 @@ pub fn fmaxq(x: f128, y: f128) callconv(.C) f128 { | ... | @@ -40,10 +36,6 @@ pub fn fmaxq(x: f128, y: f128) callconv(.C) f128 { |
| 40 | return generic_fmax(f128, x, y); | 36 | return generic_fmax(f128, x, y); |
| 41 | } | 37 | } |
| 42 | 38 | ||
| 43 | pub fn fmaxf128(x: f128, y: f128) callconv(.C) f128 { | ||
| 44 | return @call(.{ .modifier = .always_inline }, fmaxq, .{ x, y }); | ||
| 45 | } | ||
| 46 | |||
| 47 | pub fn fmaxl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { | 39 | pub fn fmaxl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { |
| 48 | switch (@typeInfo(c_longdouble).Float.bits) { | 40 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 49 | 16 => return __fmaxh(x, y), | 41 | 16 => return __fmaxh(x, y), |
lib/compiler_rt/fmin.zig+10-18| ... | @@ -2,22 +2,18 @@ const std = @import("std"); | ... | @@ -2,22 +2,18 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const math = std.math; | 3 | const math = std.math; |
| 4 | const arch = builtin.cpu.arch; | 4 | const arch = builtin.cpu.arch; |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 5 | const common = @import("common.zig"); |
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | 6 | ||
| 8 | comptime { | 7 | pub const panic = common.panic; |
| 9 | @export(__fminh, .{ .name = "__fminh", .linkage = linkage }); | ||
| 10 | @export(fminf, .{ .name = "fminf", .linkage = linkage }); | ||
| 11 | @export(fmin, .{ .name = "fmin", .linkage = linkage }); | ||
| 12 | @export(__fminx, .{ .name = "__fminx", .linkage = linkage }); | ||
| 13 | @export(fminq, .{ .name = "fminq", .linkage = linkage }); | ||
| 14 | @export(fminl, .{ .name = "fminl", .linkage = linkage }); | ||
| 15 | 8 | ||
| 16 | if (!builtin.is_test) { | 9 | comptime { |
| 17 | if (arch.isPPC() or arch.isPPC64()) { | 10 | @export(__fminh, .{ .name = "__fminh", .linkage = common.linkage }); |
| 18 | @export(fminf128, .{ .name = "fminf128", .linkage = linkage }); | 11 | @export(fminf, .{ .name = "fminf", .linkage = common.linkage }); |
| 19 | } | 12 | @export(fmin, .{ .name = "fmin", .linkage = common.linkage }); |
| 20 | } | 13 | @export(__fminx, .{ .name = "__fminx", .linkage = common.linkage }); |
| 14 | const fminq_sym_name = if (common.want_ppc_abi) "fminf128" else "fminq"; | ||
| 15 | @export(fminq, .{ .name = fminq_sym_name, .linkage = common.linkage }); | ||
| 16 | @export(fminl, .{ .name = "fminl", .linkage = common.linkage }); | ||
| 21 | } | 17 | } |
| 22 | 18 | ||
| 23 | pub fn __fminh(x: f16, y: f16) callconv(.C) f16 { | 19 | pub fn __fminh(x: f16, y: f16) callconv(.C) f16 { |
| ... | @@ -40,10 +36,6 @@ pub fn fminq(x: f128, y: f128) callconv(.C) f128 { | ... | @@ -40,10 +36,6 @@ pub fn fminq(x: f128, y: f128) callconv(.C) f128 { |
| 40 | return generic_fmin(f128, x, y); | 36 | return generic_fmin(f128, x, y); |
| 41 | } | 37 | } |
| 42 | 38 | ||
| 43 | pub fn fminf128(x: f128, y: f128) callconv(.C) f128 { | ||
| 44 | return @call(.{ .modifier = .always_inline }, fminq, .{ x, y }); | ||
| 45 | } | ||
| 46 | |||
| 47 | pub fn fminl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { | 39 | pub fn fminl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { |
| 48 | switch (@typeInfo(c_longdouble).Float.bits) { | 40 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 49 | 16 => return __fminh(x, y), | 41 | 16 => return __fminh(x, y), |
lib/compiler_rt/fmod.zig+8-23| ... | @@ -3,25 +3,19 @@ const std = @import("std"); | ... | @@ -3,25 +3,19 @@ const std = @import("std"); |
| 3 | const math = std.math; | 3 | const math = std.math; |
| 4 | const assert = std.debug.assert; | 4 | const assert = std.debug.assert; |
| 5 | const arch = builtin.cpu.arch; | 5 | const arch = builtin.cpu.arch; |
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | |||
| 8 | const common = @import("common.zig"); | 6 | const common = @import("common.zig"); |
| 9 | const normalize = common.normalize; | 7 | const normalize = common.normalize; |
| 8 | |||
| 10 | pub const panic = common.panic; | 9 | pub const panic = common.panic; |
| 11 | 10 | ||
| 12 | comptime { | 11 | comptime { |
| 13 | @export(__fmodh, .{ .name = "__fmodh", .linkage = linkage }); | 12 | @export(__fmodh, .{ .name = "__fmodh", .linkage = common.linkage }); |
| 14 | @export(fmodf, .{ .name = "fmodf", .linkage = linkage }); | 13 | @export(fmodf, .{ .name = "fmodf", .linkage = common.linkage }); |
| 15 | @export(fmod, .{ .name = "fmod", .linkage = linkage }); | 14 | @export(fmod, .{ .name = "fmod", .linkage = common.linkage }); |
| 16 | @export(__fmodx, .{ .name = "__fmodx", .linkage = linkage }); | 15 | @export(__fmodx, .{ .name = "__fmodx", .linkage = common.linkage }); |
| 17 | @export(fmodq, .{ .name = "fmodq", .linkage = linkage }); | 16 | const fmodq_sym_name = if (common.want_ppc_abi) "fmodf128" else "fmodq"; |
| 18 | @export(fmodl, .{ .name = "fmodl", .linkage = linkage }); | 17 | @export(fmodq, .{ .name = fmodq_sym_name, .linkage = common.linkage }); |
| 19 | 18 | @export(fmodl, .{ .name = "fmodl", .linkage = common.linkage }); | |
| 20 | if (!builtin.is_test) { | ||
| 21 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 22 | @export(fmodf128, .{ .name = "fmodf128", .linkage = linkage }); | ||
| 23 | } | ||
| 24 | } | ||
| 25 | } | 19 | } |
| 26 | 20 | ||
| 27 | pub fn __fmodh(x: f16, y: f16) callconv(.C) f16 { | 21 | pub fn __fmodh(x: f16, y: f16) callconv(.C) f16 { |
| ... | @@ -40,8 +34,6 @@ pub fn fmod(x: f64, y: f64) callconv(.C) f64 { | ... | @@ -40,8 +34,6 @@ pub fn fmod(x: f64, y: f64) callconv(.C) f64 { |
| 40 | /// fmodx - floating modulo large, returns the remainder of division for f80 types | 34 | /// fmodx - floating modulo large, returns the remainder of division for f80 types |
| 41 | /// Logic and flow heavily inspired by MUSL fmodl for 113 mantissa digits | 35 | /// Logic and flow heavily inspired by MUSL fmodl for 113 mantissa digits |
| 42 | pub fn __fmodx(a: f80, b: f80) callconv(.C) f80 { | 36 | pub fn __fmodx(a: f80, b: f80) callconv(.C) f80 { |
| 43 | @setRuntimeSafety(builtin.is_test); | ||
| 44 | |||
| 45 | const T = f80; | 37 | const T = f80; |
| 46 | const Z = std.meta.Int(.unsigned, @bitSizeOf(T)); | 38 | const Z = std.meta.Int(.unsigned, @bitSizeOf(T)); |
| 47 | 39 | ||
| ... | @@ -140,7 +132,6 @@ pub fn __fmodx(a: f80, b: f80) callconv(.C) f80 { | ... | @@ -140,7 +132,6 @@ pub fn __fmodx(a: f80, b: f80) callconv(.C) f80 { |
| 140 | /// fmodq - floating modulo large, returns the remainder of division for f128 types | 132 | /// fmodq - floating modulo large, returns the remainder of division for f128 types |
| 141 | /// Logic and flow heavily inspired by MUSL fmodl for 113 mantissa digits | 133 | /// Logic and flow heavily inspired by MUSL fmodl for 113 mantissa digits |
| 142 | pub fn fmodq(a: f128, b: f128) callconv(.C) f128 { | 134 | pub fn fmodq(a: f128, b: f128) callconv(.C) f128 { |
| 143 | @setRuntimeSafety(builtin.is_test); | ||
| 144 | var amod = a; | 135 | var amod = a; |
| 145 | var bmod = b; | 136 | var bmod = b; |
| 146 | const aPtr_u64 = @ptrCast([*]u64, &amod); | 137 | const aPtr_u64 = @ptrCast([*]u64, &amod); |
| ... | @@ -257,10 +248,6 @@ pub fn fmodq(a: f128, b: f128) callconv(.C) f128 { | ... | @@ -257,10 +248,6 @@ pub fn fmodq(a: f128, b: f128) callconv(.C) f128 { |
| 257 | return amod; | 248 | return amod; |
| 258 | } | 249 | } |
| 259 | 250 | ||
| 260 | pub fn fmodf128(a: f128, b: f128) callconv(.C) f128 { | ||
| 261 | return @call(.{ .modifier = .always_inline }, fmodq, .{ a, b }); | ||
| 262 | } | ||
| 263 | |||
| 264 | pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble { | 251 | pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble { |
| 265 | switch (@typeInfo(c_longdouble).Float.bits) { | 252 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 266 | 16 => return __fmodh(a, b), | 253 | 16 => return __fmodh(a, b), |
| ... | @@ -273,8 +260,6 @@ pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble { | ... | @@ -273,8 +260,6 @@ pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble { |
| 273 | } | 260 | } |
| 274 | 261 | ||
| 275 | inline fn generic_fmod(comptime T: type, x: T, y: T) T { | 262 | inline fn generic_fmod(comptime T: type, x: T, y: T) T { |
| 276 | @setRuntimeSafety(false); | ||
| 277 | |||
| 278 | const bits = @typeInfo(T).Float.bits; | 263 | const bits = @typeInfo(T).Float.bits; |
| 279 | const uint = std.meta.Int(.unsigned, bits); | 264 | const uint = std.meta.Int(.unsigned, bits); |
| 280 | const log2uint = math.Log2Int(uint); | 265 | const log2uint = math.Log2Int(uint); |
lib/compiler_rt/int.zig+36-53| ... | @@ -1,4 +1,5 @@ | ... | @@ -1,4 +1,5 @@ |
| 1 | // Builtin functions that operate on integer types | 1 | //! Builtin functions that operate on integer types |
| 2 | |||
| 2 | const builtin = @import("builtin"); | 3 | const builtin = @import("builtin"); |
| 3 | const std = @import("std"); | 4 | const std = @import("std"); |
| 4 | const testing = std.testing; | 5 | const testing = std.testing; |
| ... | @@ -6,44 +7,39 @@ const maxInt = std.math.maxInt; | ... | @@ -6,44 +7,39 @@ const maxInt = std.math.maxInt; |
| 6 | const minInt = std.math.minInt; | 7 | const minInt = std.math.minInt; |
| 7 | const arch = builtin.cpu.arch; | 8 | const arch = builtin.cpu.arch; |
| 8 | const is_test = builtin.is_test; | 9 | const is_test = builtin.is_test; |
| 9 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 10 | const common = @import("common.zig"); |
| 10 | pub const panic = @import("common.zig").panic; | ||
| 11 | |||
| 12 | const udivmod = @import("udivmod.zig").udivmod; | 11 | const udivmod = @import("udivmod.zig").udivmod; |
| 13 | 12 | ||
| 13 | pub const panic = common.panic; | ||
| 14 | |||
| 14 | comptime { | 15 | comptime { |
| 15 | @export(__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = linkage }); | 16 | @export(__udivmoddi4, .{ .name = "__udivmoddi4", .linkage = common.linkage }); |
| 16 | @export(__mulsi3, .{ .name = "__mulsi3", .linkage = linkage }); | 17 | @export(__mulsi3, .{ .name = "__mulsi3", .linkage = common.linkage }); |
| 17 | @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = linkage }); | 18 | @export(__divmoddi4, .{ .name = "__divmoddi4", .linkage = common.linkage }); |
| 18 | @export(__divsi3, .{ .name = "__divsi3", .linkage = linkage }); | 19 | if (common.want_aeabi) { |
| 19 | @export(__divdi3, .{ .name = "__divdi3", .linkage = linkage }); | 20 | @export(__aeabi_idiv, .{ .name = "__aeabi_idiv", .linkage = common.linkage }); |
| 20 | @export(__udivsi3, .{ .name = "__udivsi3", .linkage = linkage }); | 21 | @export(__aeabi_uidiv, .{ .name = "__aeabi_uidiv", .linkage = common.linkage }); |
| 21 | @export(__udivdi3, .{ .name = "__udivdi3", .linkage = linkage }); | 22 | } else { |
| 22 | @export(__modsi3, .{ .name = "__modsi3", .linkage = linkage }); | 23 | @export(__divsi3, .{ .name = "__divsi3", .linkage = common.linkage }); |
| 23 | @export(__moddi3, .{ .name = "__moddi3", .linkage = linkage }); | 24 | @export(__udivsi3, .{ .name = "__udivsi3", .linkage = common.linkage }); |
| 24 | @export(__umodsi3, .{ .name = "__umodsi3", .linkage = linkage }); | ||
| 25 | @export(__umoddi3, .{ .name = "__umoddi3", .linkage = linkage }); | ||
| 26 | @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = linkage }); | ||
| 27 | @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = linkage }); | ||
| 28 | |||
| 29 | if (!is_test) { | ||
| 30 | if (arch.isARM() or arch.isThumb()) { | ||
| 31 | @export(__aeabi_idiv, .{ .name = "__aeabi_idiv", .linkage = linkage }); | ||
| 32 | @export(__aeabi_uidiv, .{ .name = "__aeabi_uidiv", .linkage = linkage }); | ||
| 33 | } | ||
| 34 | } | 25 | } |
| 26 | @export(__divdi3, .{ .name = "__divdi3", .linkage = common.linkage }); | ||
| 27 | @export(__udivdi3, .{ .name = "__udivdi3", .linkage = common.linkage }); | ||
| 28 | @export(__modsi3, .{ .name = "__modsi3", .linkage = common.linkage }); | ||
| 29 | @export(__moddi3, .{ .name = "__moddi3", .linkage = common.linkage }); | ||
| 30 | @export(__umodsi3, .{ .name = "__umodsi3", .linkage = common.linkage }); | ||
| 31 | @export(__umoddi3, .{ .name = "__umoddi3", .linkage = common.linkage }); | ||
| 32 | @export(__divmodsi4, .{ .name = "__divmodsi4", .linkage = common.linkage }); | ||
| 33 | @export(__udivmodsi4, .{ .name = "__udivmodsi4", .linkage = common.linkage }); | ||
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | pub fn __divmoddi4(a: i64, b: i64, rem: *i64) callconv(.C) i64 { | 36 | pub fn __divmoddi4(a: i64, b: i64, rem: *i64) callconv(.C) i64 { |
| 38 | @setRuntimeSafety(builtin.is_test); | ||
| 39 | |||
| 40 | const d = __divdi3(a, b); | 37 | const d = __divdi3(a, b); |
| 41 | rem.* = a -% (d *% b); | 38 | rem.* = a -% (d *% b); |
| 42 | return d; | 39 | return d; |
| 43 | } | 40 | } |
| 44 | 41 | ||
| 45 | pub fn __udivmoddi4(a: u64, b: u64, maybe_rem: ?*u64) callconv(.C) u64 { | 42 | pub fn __udivmoddi4(a: u64, b: u64, maybe_rem: ?*u64) callconv(.C) u64 { |
| 46 | @setRuntimeSafety(builtin.is_test); | ||
| 47 | return udivmod(u64, a, b, maybe_rem); | 43 | return udivmod(u64, a, b, maybe_rem); |
| 48 | } | 44 | } |
| 49 | 45 | ||
| ... | @@ -52,8 +48,6 @@ test "test_udivmoddi4" { | ... | @@ -52,8 +48,6 @@ test "test_udivmoddi4" { |
| 52 | } | 48 | } |
| 53 | 49 | ||
| 54 | pub fn __divdi3(a: i64, b: i64) callconv(.C) i64 { | 50 | pub fn __divdi3(a: i64, b: i64) callconv(.C) i64 { |
| 55 | @setRuntimeSafety(builtin.is_test); | ||
| 56 | |||
| 57 | // Set aside the sign of the quotient. | 51 | // Set aside the sign of the quotient. |
| 58 | const sign = @bitCast(u64, (a ^ b) >> 63); | 52 | const sign = @bitCast(u64, (a ^ b) >> 63); |
| 59 | // Take absolute value of a and b via abs(x) = (x^(x >> 63)) - (x >> 63). | 53 | // Take absolute value of a and b via abs(x) = (x^(x >> 63)) - (x >> 63). |
| ... | @@ -91,8 +85,6 @@ fn test_one_divdi3(a: i64, b: i64, expected_q: i64) !void { | ... | @@ -91,8 +85,6 @@ fn test_one_divdi3(a: i64, b: i64, expected_q: i64) !void { |
| 91 | } | 85 | } |
| 92 | 86 | ||
| 93 | pub fn __moddi3(a: i64, b: i64) callconv(.C) i64 { | 87 | pub fn __moddi3(a: i64, b: i64) callconv(.C) i64 { |
| 94 | @setRuntimeSafety(builtin.is_test); | ||
| 95 | |||
| 96 | // Take absolute value of a and b via abs(x) = (x^(x >> 63)) - (x >> 63). | 88 | // Take absolute value of a and b via abs(x) = (x^(x >> 63)) - (x >> 63). |
| 97 | const abs_a = (a ^ (a >> 63)) -% (a >> 63); | 89 | const abs_a = (a ^ (a >> 63)) -% (a >> 63); |
| 98 | const abs_b = (b ^ (b >> 63)) -% (b >> 63); | 90 | const abs_b = (b ^ (b >> 63)) -% (b >> 63); |
| ... | @@ -131,13 +123,10 @@ fn test_one_moddi3(a: i64, b: i64, expected_r: i64) !void { | ... | @@ -131,13 +123,10 @@ fn test_one_moddi3(a: i64, b: i64, expected_r: i64) !void { |
| 131 | } | 123 | } |
| 132 | 124 | ||
| 133 | pub fn __udivdi3(a: u64, b: u64) callconv(.C) u64 { | 125 | pub fn __udivdi3(a: u64, b: u64) callconv(.C) u64 { |
| 134 | @setRuntimeSafety(builtin.is_test); | ||
| 135 | return __udivmoddi4(a, b, null); | 126 | return __udivmoddi4(a, b, null); |
| 136 | } | 127 | } |
| 137 | 128 | ||
| 138 | pub fn __umoddi3(a: u64, b: u64) callconv(.C) u64 { | 129 | pub fn __umoddi3(a: u64, b: u64) callconv(.C) u64 { |
| 139 | @setRuntimeSafety(builtin.is_test); | ||
| 140 | |||
| 141 | var r: u64 = undefined; | 130 | var r: u64 = undefined; |
| 142 | _ = __udivmoddi4(a, b, &r); | 131 | _ = __udivmoddi4(a, b, &r); |
| 143 | return r; | 132 | return r; |
| ... | @@ -157,8 +146,6 @@ fn test_one_umoddi3(a: u64, b: u64, expected_r: u64) !void { | ... | @@ -157,8 +146,6 @@ fn test_one_umoddi3(a: u64, b: u64, expected_r: u64) !void { |
| 157 | } | 146 | } |
| 158 | 147 | ||
| 159 | pub fn __divmodsi4(a: i32, b: i32, rem: *i32) callconv(.C) i32 { | 148 | pub fn __divmodsi4(a: i32, b: i32, rem: *i32) callconv(.C) i32 { |
| 160 | @setRuntimeSafety(builtin.is_test); | ||
| 161 | |||
| 162 | const d = __divsi3(a, b); | 149 | const d = __divsi3(a, b); |
| 163 | rem.* = a -% (d * b); | 150 | rem.* = a -% (d * b); |
| 164 | return d; | 151 | return d; |
| ... | @@ -193,16 +180,20 @@ fn test_one_divmodsi4(a: i32, b: i32, expected_q: i32, expected_r: i32) !void { | ... | @@ -193,16 +180,20 @@ fn test_one_divmodsi4(a: i32, b: i32, expected_q: i32, expected_r: i32) !void { |
| 193 | } | 180 | } |
| 194 | 181 | ||
| 195 | pub fn __udivmodsi4(a: u32, b: u32, rem: *u32) callconv(.C) u32 { | 182 | pub fn __udivmodsi4(a: u32, b: u32, rem: *u32) callconv(.C) u32 { |
| 196 | @setRuntimeSafety(builtin.is_test); | ||
| 197 | |||
| 198 | const d = __udivsi3(a, b); | 183 | const d = __udivsi3(a, b); |
| 199 | rem.* = @bitCast(u32, @bitCast(i32, a) -% (@bitCast(i32, d) * @bitCast(i32, b))); | 184 | rem.* = @bitCast(u32, @bitCast(i32, a) -% (@bitCast(i32, d) * @bitCast(i32, b))); |
| 200 | return d; | 185 | return d; |
| 201 | } | 186 | } |
| 202 | 187 | ||
| 203 | pub fn __divsi3(n: i32, d: i32) callconv(.C) i32 { | 188 | pub fn __divsi3(n: i32, d: i32) callconv(.C) i32 { |
| 204 | @setRuntimeSafety(builtin.is_test); | 189 | return div_i32(n, d); |
| 190 | } | ||
| 191 | |||
| 192 | fn __aeabi_idiv(n: i32, d: i32) callconv(.AAPCS) i32 { | ||
| 193 | return div_i32(n, d); | ||
| 194 | } | ||
| 205 | 195 | ||
| 196 | inline fn div_i32(n: i32, d: i32) i32 { | ||
| 206 | // Set aside the sign of the quotient. | 197 | // Set aside the sign of the quotient. |
| 207 | const sign = @bitCast(u32, (n ^ d) >> 31); | 198 | const sign = @bitCast(u32, (n ^ d) >> 31); |
| 208 | // Take absolute value of a and b via abs(x) = (x^(x >> 31)) - (x >> 31). | 199 | // Take absolute value of a and b via abs(x) = (x^(x >> 31)) - (x >> 31). |
| ... | @@ -214,10 +205,6 @@ pub fn __divsi3(n: i32, d: i32) callconv(.C) i32 { | ... | @@ -214,10 +205,6 @@ pub fn __divsi3(n: i32, d: i32) callconv(.C) i32 { |
| 214 | return @bitCast(i32, (res ^ sign) -% sign); | 205 | return @bitCast(i32, (res ^ sign) -% sign); |
| 215 | } | 206 | } |
| 216 | 207 | ||
| 217 | pub fn __aeabi_idiv(n: i32, d: i32) callconv(.AAPCS) i32 { | ||
| 218 | return @call(.{ .modifier = .always_inline }, __divsi3, .{ n, d }); | ||
| 219 | } | ||
| 220 | |||
| 221 | test "test_divsi3" { | 208 | test "test_divsi3" { |
| 222 | const cases = [_][3]i32{ | 209 | const cases = [_][3]i32{ |
| 223 | [_]i32{ 0, 1, 0 }, | 210 | [_]i32{ 0, 1, 0 }, |
| ... | @@ -244,8 +231,14 @@ fn test_one_divsi3(a: i32, b: i32, expected_q: i32) !void { | ... | @@ -244,8 +231,14 @@ fn test_one_divsi3(a: i32, b: i32, expected_q: i32) !void { |
| 244 | } | 231 | } |
| 245 | 232 | ||
| 246 | pub fn __udivsi3(n: u32, d: u32) callconv(.C) u32 { | 233 | pub fn __udivsi3(n: u32, d: u32) callconv(.C) u32 { |
| 247 | @setRuntimeSafety(builtin.is_test); | 234 | return div_u32(n, d); |
| 235 | } | ||
| 236 | |||
| 237 | fn __aeabi_uidiv(n: u32, d: u32) callconv(.AAPCS) u32 { | ||
| 238 | return div_u32(n, d); | ||
| 239 | } | ||
| 248 | 240 | ||
| 241 | inline fn div_u32(n: u32, d: u32) u32 { | ||
| 249 | const n_uword_bits: c_uint = 32; | 242 | const n_uword_bits: c_uint = 32; |
| 250 | // special cases | 243 | // special cases |
| 251 | if (d == 0) return 0; // ?! | 244 | if (d == 0) return 0; // ?! |
| ... | @@ -284,10 +277,6 @@ pub fn __udivsi3(n: u32, d: u32) callconv(.C) u32 { | ... | @@ -284,10 +277,6 @@ pub fn __udivsi3(n: u32, d: u32) callconv(.C) u32 { |
| 284 | return q; | 277 | return q; |
| 285 | } | 278 | } |
| 286 | 279 | ||
| 287 | pub fn __aeabi_uidiv(n: u32, d: u32) callconv(.AAPCS) u32 { | ||
| 288 | return @call(.{ .modifier = .always_inline }, __udivsi3, .{ n, d }); | ||
| 289 | } | ||
| 290 | |||
| 291 | test "test_udivsi3" { | 280 | test "test_udivsi3" { |
| 292 | const cases = [_][3]u32{ | 281 | const cases = [_][3]u32{ |
| 293 | [_]u32{ 0x00000000, 0x00000001, 0x00000000 }, | 282 | [_]u32{ 0x00000000, 0x00000001, 0x00000000 }, |
| ... | @@ -435,8 +424,6 @@ fn test_one_udivsi3(a: u32, b: u32, expected_q: u32) !void { | ... | @@ -435,8 +424,6 @@ fn test_one_udivsi3(a: u32, b: u32, expected_q: u32) !void { |
| 435 | } | 424 | } |
| 436 | 425 | ||
| 437 | pub fn __modsi3(n: i32, d: i32) callconv(.C) i32 { | 426 | pub fn __modsi3(n: i32, d: i32) callconv(.C) i32 { |
| 438 | @setRuntimeSafety(builtin.is_test); | ||
| 439 | |||
| 440 | return n -% __divsi3(n, d) *% d; | 427 | return n -% __divsi3(n, d) *% d; |
| 441 | } | 428 | } |
| 442 | 429 | ||
| ... | @@ -466,8 +453,6 @@ fn test_one_modsi3(a: i32, b: i32, expected_r: i32) !void { | ... | @@ -466,8 +453,6 @@ fn test_one_modsi3(a: i32, b: i32, expected_r: i32) !void { |
| 466 | } | 453 | } |
| 467 | 454 | ||
| 468 | pub fn __umodsi3(n: u32, d: u32) callconv(.C) u32 { | 455 | pub fn __umodsi3(n: u32, d: u32) callconv(.C) u32 { |
| 469 | @setRuntimeSafety(builtin.is_test); | ||
| 470 | |||
| 471 | return n -% __udivsi3(n, d) *% d; | 456 | return n -% __udivsi3(n, d) *% d; |
| 472 | } | 457 | } |
| 473 | 458 | ||
| ... | @@ -618,8 +603,6 @@ fn test_one_umodsi3(a: u32, b: u32, expected_r: u32) !void { | ... | @@ -618,8 +603,6 @@ fn test_one_umodsi3(a: u32, b: u32, expected_r: u32) !void { |
| 618 | } | 603 | } |
| 619 | 604 | ||
| 620 | pub fn __mulsi3(a: i32, b: i32) callconv(.C) i32 { | 605 | pub fn __mulsi3(a: i32, b: i32) callconv(.C) i32 { |
| 621 | @setRuntimeSafety(builtin.is_test); | ||
| 622 | |||
| 623 | var ua = @bitCast(u32, a); | 606 | var ua = @bitCast(u32, a); |
| 624 | var ub = @bitCast(u32, b); | 607 | var ub = @bitCast(u32, b); |
| 625 | var r: u32 = 0; | 608 | var r: u32 = 0; |
lib/compiler_rt/log.zig+15-23| ... | @@ -1,30 +1,26 @@ | ... | @@ -1,30 +1,26 @@ |
| 1 | // Ported from musl, which is licensed under the MIT license: | 1 | //! Ported from musl, which is licensed under the MIT license: |
| 2 | // https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT | 2 | //! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT |
| 3 | // | 3 | //! |
| 4 | // https://git.musl-libc.org/cgit/musl/tree/src/math/lnf.c | 4 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/lnf.c |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/ln.c | 5 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/ln.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const math = std.math; | 9 | const math = std.math; |
| 10 | const testing = std.testing; | 10 | const testing = std.testing; |
| 11 | const arch = builtin.cpu.arch; | 11 | const arch = builtin.cpu.arch; |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 12 | const common = @import("common.zig"); |
| 13 | pub const panic = @import("common.zig").panic; | 13 | |
| 14 | pub const panic = common.panic; | ||
| 14 | 15 | ||
| 15 | comptime { | 16 | comptime { |
| 16 | @export(__logh, .{ .name = "__logh", .linkage = linkage }); | 17 | @export(__logh, .{ .name = "__logh", .linkage = common.linkage }); |
| 17 | @export(logf, .{ .name = "logf", .linkage = linkage }); | 18 | @export(logf, .{ .name = "logf", .linkage = common.linkage }); |
| 18 | @export(log, .{ .name = "log", .linkage = linkage }); | 19 | @export(log, .{ .name = "log", .linkage = common.linkage }); |
| 19 | @export(__logx, .{ .name = "__logx", .linkage = linkage }); | 20 | @export(__logx, .{ .name = "__logx", .linkage = common.linkage }); |
| 20 | @export(logq, .{ .name = "logq", .linkage = linkage }); | 21 | const logq_sym_name = if (common.want_ppc_abi) "logf128" else "logq"; |
| 21 | @export(logl, .{ .name = "logl", .linkage = linkage }); | 22 | @export(logq, .{ .name = logq_sym_name, .linkage = common.linkage }); |
| 22 | 23 | @export(logl, .{ .name = "logl", .linkage = common.linkage }); | |
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(logf128, .{ .name = "logf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | 24 | } |
| 29 | 25 | ||
| 30 | pub fn __logh(a: f16) callconv(.C) f16 { | 26 | pub fn __logh(a: f16) callconv(.C) f16 { |
| ... | @@ -150,10 +146,6 @@ pub fn logq(a: f128) callconv(.C) f128 { | ... | @@ -150,10 +146,6 @@ pub fn logq(a: f128) callconv(.C) f128 { |
| 150 | return log(@floatCast(f64, a)); | 146 | return log(@floatCast(f64, a)); |
| 151 | } | 147 | } |
| 152 | 148 | ||
| 153 | pub fn logf128(a: f128) callconv(.C) f128 { | ||
| 154 | return @call(.{ .modifier = .always_inline }, logq, .{a}); | ||
| 155 | } | ||
| 156 | |||
| 157 | pub fn logl(x: c_longdouble) callconv(.C) c_longdouble { | 149 | pub fn logl(x: c_longdouble) callconv(.C) c_longdouble { |
| 158 | switch (@typeInfo(c_longdouble).Float.bits) { | 150 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 159 | 16 => return __logh(x), | 151 | 16 => return __logh(x), |
lib/compiler_rt/log10.zig+15-23| ... | @@ -1,8 +1,8 @@ | ... | @@ -1,8 +1,8 @@ |
| 1 | // Ported from musl, which is licensed under the MIT license: | 1 | //! Ported from musl, which is licensed under the MIT license: |
| 2 | // https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT | 2 | //! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT |
| 3 | // | 3 | //! |
| 4 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log10f.c | 4 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/log10f.c |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log10.c | 5 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/log10.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| ... | @@ -10,22 +10,18 @@ const math = std.math; | ... | @@ -10,22 +10,18 @@ const math = std.math; |
| 10 | const testing = std.testing; | 10 | const testing = std.testing; |
| 11 | const maxInt = std.math.maxInt; | 11 | const maxInt = std.math.maxInt; |
| 12 | const arch = builtin.cpu.arch; | 12 | const arch = builtin.cpu.arch; |
| 13 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 13 | const common = @import("common.zig"); |
| 14 | pub const panic = @import("common.zig").panic; | 14 | |
| 15 | pub const panic = common.panic; | ||
| 15 | 16 | ||
| 16 | comptime { | 17 | comptime { |
| 17 | @export(__log10h, .{ .name = "__log10h", .linkage = linkage }); | 18 | @export(__log10h, .{ .name = "__log10h", .linkage = common.linkage }); |
| 18 | @export(log10f, .{ .name = "log10f", .linkage = linkage }); | 19 | @export(log10f, .{ .name = "log10f", .linkage = common.linkage }); |
| 19 | @export(log10, .{ .name = "log10", .linkage = linkage }); | 20 | @export(log10, .{ .name = "log10", .linkage = common.linkage }); |
| 20 | @export(__log10x, .{ .name = "__log10x", .linkage = linkage }); | 21 | @export(__log10x, .{ .name = "__log10x", .linkage = common.linkage }); |
| 21 | @export(log10q, .{ .name = "log10q", .linkage = linkage }); | 22 | const log10q_sym_name = if (common.want_ppc_abi) "log10f128" else "log10q"; |
| 22 | @export(log10l, .{ .name = "log10l", .linkage = linkage }); | 23 | @export(log10q, .{ .name = log10q_sym_name, .linkage = common.linkage }); |
| 23 | 24 | @export(log10l, .{ .name = "log10l", .linkage = common.linkage }); | |
| 24 | if (!builtin.is_test) { | ||
| 25 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 26 | @export(log10f128, .{ .name = "log10f128", .linkage = linkage }); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | } | 25 | } |
| 30 | 26 | ||
| 31 | pub fn __log10h(a: f16) callconv(.C) f16 { | 27 | pub fn __log10h(a: f16) callconv(.C) f16 { |
| ... | @@ -178,10 +174,6 @@ pub fn log10q(a: f128) callconv(.C) f128 { | ... | @@ -178,10 +174,6 @@ pub fn log10q(a: f128) callconv(.C) f128 { |
| 178 | return log10(@floatCast(f64, a)); | 174 | return log10(@floatCast(f64, a)); |
| 179 | } | 175 | } |
| 180 | 176 | ||
| 181 | pub fn log10f128(a: f128) callconv(.C) f128 { | ||
| 182 | return @call(.{ .modifier = .always_inline }, log10q, .{a}); | ||
| 183 | } | ||
| 184 | |||
| 185 | pub fn log10l(x: c_longdouble) callconv(.C) c_longdouble { | 177 | pub fn log10l(x: c_longdouble) callconv(.C) c_longdouble { |
| 186 | switch (@typeInfo(c_longdouble).Float.bits) { | 178 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 187 | 16 => return __log10h(x), | 179 | 16 => return __log10h(x), |
lib/compiler_rt/log2.zig+15-23| ... | @@ -1,8 +1,8 @@ | ... | @@ -1,8 +1,8 @@ |
| 1 | // Ported from musl, which is licensed under the MIT license: | 1 | //! Ported from musl, which is licensed under the MIT license: |
| 2 | // https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT | 2 | //! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT |
| 3 | // | 3 | //! |
| 4 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log2f.c | 4 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/log2f.c |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/log2.c | 5 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/log2.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| ... | @@ -10,22 +10,18 @@ const math = std.math; | ... | @@ -10,22 +10,18 @@ const math = std.math; |
| 10 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 11 | const maxInt = std.math.maxInt; | 11 | const maxInt = std.math.maxInt; |
| 12 | const arch = builtin.cpu.arch; | 12 | const arch = builtin.cpu.arch; |
| 13 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 13 | const common = @import("common.zig"); |
| 14 | pub const panic = @import("common.zig").panic; | 14 | |
| 15 | pub const panic = common.panic; | ||
| 15 | 16 | ||
| 16 | comptime { | 17 | comptime { |
| 17 | @export(__log2h, .{ .name = "__log2h", .linkage = linkage }); | 18 | @export(__log2h, .{ .name = "__log2h", .linkage = common.linkage }); |
| 18 | @export(log2f, .{ .name = "log2f", .linkage = linkage }); | 19 | @export(log2f, .{ .name = "log2f", .linkage = common.linkage }); |
| 19 | @export(log2, .{ .name = "log2", .linkage = linkage }); | 20 | @export(log2, .{ .name = "log2", .linkage = common.linkage }); |
| 20 | @export(__log2x, .{ .name = "__log2x", .linkage = linkage }); | 21 | @export(__log2x, .{ .name = "__log2x", .linkage = common.linkage }); |
| 21 | @export(log2q, .{ .name = "log2q", .linkage = linkage }); | 22 | const log2q_sym_name = if (common.want_ppc_abi) "log2f128" else "log2q"; |
| 22 | @export(log2l, .{ .name = "log2l", .linkage = linkage }); | 23 | @export(log2q, .{ .name = log2q_sym_name, .linkage = common.linkage }); |
| 23 | 24 | @export(log2l, .{ .name = "log2l", .linkage = common.linkage }); | |
| 24 | if (!builtin.is_test) { | ||
| 25 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 26 | @export(log2f128, .{ .name = "log2f128", .linkage = linkage }); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | } | 25 | } |
| 30 | 26 | ||
| 31 | pub fn __log2h(a: f16) callconv(.C) f16 { | 27 | pub fn __log2h(a: f16) callconv(.C) f16 { |
| ... | @@ -170,10 +166,6 @@ pub fn log2q(a: f128) callconv(.C) f128 { | ... | @@ -170,10 +166,6 @@ pub fn log2q(a: f128) callconv(.C) f128 { |
| 170 | return log2(@floatCast(f64, a)); | 166 | return log2(@floatCast(f64, a)); |
| 171 | } | 167 | } |
| 172 | 168 | ||
| 173 | pub fn log2f128(a: f128) callconv(.C) f128 { | ||
| 174 | return @call(.{ .modifier = .always_inline }, log2q, .{a}); | ||
| 175 | } | ||
| 176 | |||
| 177 | pub fn log2l(x: c_longdouble) callconv(.C) c_longdouble { | 169 | pub fn log2l(x: c_longdouble) callconv(.C) c_longdouble { |
| 178 | switch (@typeInfo(c_longdouble).Float.bits) { | 170 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 179 | 16 => return __log2h(x), | 171 | 16 => return __log2h(x), |
lib/compiler_rt/modti3.zig+19-19| ... | @@ -1,39 +1,47 @@ | ... | @@ -1,39 +1,47 @@ |
| 1 | // Ported from: | 1 | //! Ported from: |
| 2 | // | 2 | //! |
| 3 | // https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/modti3.c | 3 | //! https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/modti3.c |
| 4 | 4 | ||
| 5 | const std = @import("std"); | 5 | const std = @import("std"); |
| 6 | const builtin = @import("builtin"); | 6 | const builtin = @import("builtin"); |
| 7 | const udivmod = @import("udivmod.zig").udivmod; | 7 | const udivmod = @import("udivmod.zig").udivmod; |
| 8 | const arch = builtin.cpu.arch; | 8 | const arch = builtin.cpu.arch; |
| 9 | const is_test = builtin.is_test; | 9 | const common = @import("common.zig"); |
| 10 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 10 | |
| 11 | pub const panic = @import("common.zig").panic; | 11 | pub const panic = common.panic; |
| 12 | 12 | ||
| 13 | comptime { | 13 | comptime { |
| 14 | if (builtin.os.tag == .windows) { | 14 | if (builtin.os.tag == .windows) { |
| 15 | switch (arch) { | 15 | switch (arch) { |
| 16 | .i386 => { | 16 | .i386 => { |
| 17 | @export(__modti3, .{ .name = "__modti3", .linkage = linkage }); | 17 | @export(__modti3, .{ .name = "__modti3", .linkage = common.linkage }); |
| 18 | }, | 18 | }, |
| 19 | .x86_64 => { | 19 | .x86_64 => { |
| 20 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | 20 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI |
| 21 | // that LLVM expects compiler-rt to have. | 21 | // that LLVM expects compiler-rt to have. |
| 22 | @export(__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = linkage }); | 22 | @export(__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = common.linkage }); |
| 23 | }, | 23 | }, |
| 24 | else => {}, | 24 | else => {}, |
| 25 | } | 25 | } |
| 26 | if (arch.isAARCH64()) { | 26 | if (arch.isAARCH64()) { |
| 27 | @export(__modti3, .{ .name = "__modti3", .linkage = linkage }); | 27 | @export(__modti3, .{ .name = "__modti3", .linkage = common.linkage }); |
| 28 | } | 28 | } |
| 29 | } else { | 29 | } else { |
| 30 | @export(__modti3, .{ .name = "__modti3", .linkage = linkage }); | 30 | @export(__modti3, .{ .name = "__modti3", .linkage = common.linkage }); |
| 31 | } | 31 | } |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | pub fn __modti3(a: i128, b: i128) callconv(.C) i128 { | 34 | pub fn __modti3(a: i128, b: i128) callconv(.C) i128 { |
| 35 | @setRuntimeSafety(builtin.is_test); | 35 | return mod(a, b); |
| 36 | } | ||
| 36 | 37 | ||
| 38 | const v128 = @import("std").meta.Vector(2, u64); | ||
| 39 | |||
| 40 | fn __modti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { | ||
| 41 | return @bitCast(v128, mod(@bitCast(i128, a), @bitCast(i128, b))); | ||
| 42 | } | ||
| 43 | |||
| 44 | inline fn mod(a: i128, b: i128) i128 { | ||
| 37 | const s_a = a >> (128 - 1); // s = a < 0 ? -1 : 0 | 45 | const s_a = a >> (128 - 1); // s = a < 0 ? -1 : 0 |
| 38 | const s_b = b >> (128 - 1); // s = b < 0 ? -1 : 0 | 46 | const s_b = b >> (128 - 1); // s = b < 0 ? -1 : 0 |
| 39 | 47 | ||
| ... | @@ -45,14 +53,6 @@ pub fn __modti3(a: i128, b: i128) callconv(.C) i128 { | ... | @@ -45,14 +53,6 @@ pub fn __modti3(a: i128, b: i128) callconv(.C) i128 { |
| 45 | return (@bitCast(i128, r) ^ s_a) -% s_a; // negate if s == -1 | 53 | return (@bitCast(i128, r) ^ s_a) -% s_a; // negate if s == -1 |
| 46 | } | 54 | } |
| 47 | 55 | ||
| 48 | const v128 = @import("std").meta.Vector(2, u64); | ||
| 49 | pub fn __modti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { | ||
| 50 | return @bitCast(v128, @call(.{ .modifier = .always_inline }, __modti3, .{ | ||
| 51 | @bitCast(i128, a), | ||
| 52 | @bitCast(i128, b), | ||
| 53 | })); | ||
| 54 | } | ||
| 55 | |||
| 56 | test { | 56 | test { |
| 57 | _ = @import("modti3_test.zig"); | 57 | _ = @import("modti3_test.zig"); |
| 58 | } | 58 | } |
lib/compiler_rt/muldi3.zig+26-29| ... | @@ -1,23 +1,36 @@ | ... | @@ -1,23 +1,36 @@ |
| 1 | //! Ported from | ||
| 2 | //! https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0/compiler-rt/lib/builtins/muldi3.c | ||
| 3 | |||
| 1 | const std = @import("std"); | 4 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 5 | const builtin = @import("builtin"); |
| 3 | const native_endian = builtin.cpu.arch.endian(); | 6 | const native_endian = builtin.cpu.arch.endian(); |
| 4 | const arch = builtin.cpu.arch; | 7 | const common = @import("common.zig"); |
| 5 | const is_test = builtin.is_test; | ||
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 7 | pub const panic = @import("common.zig").panic; | ||
| 8 | 8 | ||
| 9 | comptime { | 9 | pub const panic = common.panic; |
| 10 | @export(__muldi3, .{ .name = "__muldi3", .linkage = linkage }); | ||
| 11 | 10 | ||
| 12 | if (!is_test) { | 11 | comptime { |
| 13 | if (arch.isARM() or arch.isThumb()) { | 12 | if (common.want_aeabi) { |
| 14 | @export(__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = linkage }); | 13 | @export(__aeabi_lmul, .{ .name = "__aeabi_lmul", .linkage = common.linkage }); |
| 15 | } | 14 | } else { |
| 15 | @export(__muldi3, .{ .name = "__muldi3", .linkage = common.linkage }); | ||
| 16 | } | 16 | } |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | // Ported from | 19 | pub fn __muldi3(a: i64, b: i64) callconv(.C) i64 { |
| 20 | // https://github.com/llvm/llvm-project/blob/llvmorg-9.0.0/compiler-rt/lib/builtins/muldi3.c | 20 | return mul(a, b); |
| 21 | } | ||
| 22 | |||
| 23 | fn __aeabi_lmul(a: i64, b: i64) callconv(.AAPCS) i64 { | ||
| 24 | return mul(a, b); | ||
| 25 | } | ||
| 26 | |||
| 27 | inline fn mul(a: i64, b: i64) i64 { | ||
| 28 | const x = dwords{ .all = a }; | ||
| 29 | const y = dwords{ .all = b }; | ||
| 30 | var r = dwords{ .all = muldsi3(x.s.low, y.s.low) }; | ||
| 31 | r.s.high +%= x.s.high *% y.s.low +% x.s.low *% y.s.high; | ||
| 32 | return r.all; | ||
| 33 | } | ||
| 21 | 34 | ||
| 22 | const dwords = extern union { | 35 | const dwords = extern union { |
| 23 | all: i64, | 36 | all: i64, |
| ... | @@ -33,13 +46,7 @@ const dwords = extern union { | ... | @@ -33,13 +46,7 @@ const dwords = extern union { |
| 33 | }, | 46 | }, |
| 34 | }; | 47 | }; |
| 35 | 48 | ||
| 36 | pub fn __aeabi_lmul(a: i64, b: i64) callconv(.AAPCS) i64 { | 49 | fn muldsi3(a: u32, b: u32) i64 { |
| 37 | return @call(.{ .modifier = .always_inline }, __muldi3, .{ a, b }); | ||
| 38 | } | ||
| 39 | |||
| 40 | pub fn __muldsi3(a: u32, b: u32) i64 { | ||
| 41 | @setRuntimeSafety(is_test); | ||
| 42 | |||
| 43 | const bits_in_word_2 = @sizeOf(i32) * 8 / 2; | 50 | const bits_in_word_2 = @sizeOf(i32) * 8 / 2; |
| 44 | const lower_mask = (~@as(u32, 0)) >> bits_in_word_2; | 51 | const lower_mask = (~@as(u32, 0)) >> bits_in_word_2; |
| 45 | 52 | ||
| ... | @@ -59,16 +66,6 @@ pub fn __muldsi3(a: u32, b: u32) i64 { | ... | @@ -59,16 +66,6 @@ pub fn __muldsi3(a: u32, b: u32) i64 { |
| 59 | return r.all; | 66 | return r.all; |
| 60 | } | 67 | } |
| 61 | 68 | ||
| 62 | pub fn __muldi3(a: i64, b: i64) callconv(.C) i64 { | ||
| 63 | @setRuntimeSafety(is_test); | ||
| 64 | |||
| 65 | const x = dwords{ .all = a }; | ||
| 66 | const y = dwords{ .all = b }; | ||
| 67 | var r = dwords{ .all = __muldsi3(x.s.low, y.s.low) }; | ||
| 68 | r.s.high +%= x.s.high *% y.s.low +% x.s.low *% y.s.high; | ||
| 69 | return r.all; | ||
| 70 | } | ||
| 71 | |||
| 72 | test { | 69 | test { |
| 73 | _ = @import("muldi3_test.zig"); | 70 | _ = @import("muldi3_test.zig"); |
| 74 | } | 71 | } |
lib/compiler_rt/mulo.zig+6-8| ... | @@ -1,14 +1,14 @@ | ... | @@ -1,14 +1,14 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const math = std.math; | 3 | const math = std.math; |
| 4 | const is_test = builtin.is_test; | 4 | const common = @import("common.zig"); |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 5 | |
| 6 | pub const panic = @import("common.zig").panic; | 6 | pub const panic = common.panic; |
| 7 | 7 | ||
| 8 | comptime { | 8 | comptime { |
| 9 | @export(__mulosi4, .{ .name = "__mulosi4", .linkage = linkage }); | 9 | @export(__mulosi4, .{ .name = "__mulosi4", .linkage = common.linkage }); |
| 10 | @export(__mulodi4, .{ .name = "__mulodi4", .linkage = linkage }); | 10 | @export(__mulodi4, .{ .name = "__mulodi4", .linkage = common.linkage }); |
| 11 | @export(__muloti4, .{ .name = "__muloti4", .linkage = linkage }); | 11 | @export(__muloti4, .{ .name = "__muloti4", .linkage = common.linkage }); |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | // mulo - multiplication overflow | 14 | // mulo - multiplication overflow |
| ... | @@ -18,7 +18,6 @@ comptime { | ... | @@ -18,7 +18,6 @@ comptime { |
| 18 | // - muloXi4_genericFast for 2*bitsize <= usize | 18 | // - muloXi4_genericFast for 2*bitsize <= usize |
| 19 | 19 | ||
| 20 | inline fn muloXi4_genericSmall(comptime ST: type, a: ST, b: ST, overflow: *c_int) ST { | 20 | inline fn muloXi4_genericSmall(comptime ST: type, a: ST, b: ST, overflow: *c_int) ST { |
| 21 | @setRuntimeSafety(builtin.is_test); | ||
| 22 | overflow.* = 0; | 21 | overflow.* = 0; |
| 23 | const min = math.minInt(ST); | 22 | const min = math.minInt(ST); |
| 24 | var res: ST = a *% b; | 23 | var res: ST = a *% b; |
| ... | @@ -33,7 +32,6 @@ inline fn muloXi4_genericSmall(comptime ST: type, a: ST, b: ST, overflow: *c_int | ... | @@ -33,7 +32,6 @@ inline fn muloXi4_genericSmall(comptime ST: type, a: ST, b: ST, overflow: *c_int |
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | inline fn muloXi4_genericFast(comptime ST: type, a: ST, b: ST, overflow: *c_int) ST { | 34 | inline fn muloXi4_genericFast(comptime ST: type, a: ST, b: ST, overflow: *c_int) ST { |
| 36 | @setRuntimeSafety(builtin.is_test); | ||
| 37 | overflow.* = 0; | 35 | overflow.* = 0; |
| 38 | const EST = switch (ST) { | 36 | const EST = switch (ST) { |
| 39 | i32 => i64, | 37 | i32 => i64, |
lib/compiler_rt/multi3.zig+21-20| ... | @@ -1,51 +1,52 @@ | ... | @@ -1,51 +1,52 @@ |
| 1 | //! Ported from git@github.com:llvm-project/llvm-project-20170507.git | ||
| 2 | //! ae684fad6d34858c014c94da69c15e7774a633c3 | ||
| 3 | //! 2018-08-13 | ||
| 4 | |||
| 1 | const std = @import("std"); | 5 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 6 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | 7 | const arch = builtin.cpu.arch; |
| 4 | const is_test = builtin.is_test; | ||
| 5 | const native_endian = builtin.cpu.arch.endian(); | 8 | const native_endian = builtin.cpu.arch.endian(); |
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 9 | const common = @import("common.zig"); |
| 7 | pub const panic = @import("common.zig").panic; | ||
| 8 | 10 | ||
| 9 | // Ported from git@github.com:llvm-project/llvm-project-20170507.git | 11 | pub const panic = common.panic; |
| 10 | // ae684fad6d34858c014c94da69c15e7774a633c3 | ||
| 11 | // 2018-08-13 | ||
| 12 | 12 | ||
| 13 | comptime { | 13 | comptime { |
| 14 | if (builtin.os.tag == .windows) { | 14 | if (builtin.os.tag == .windows) { |
| 15 | switch (arch) { | 15 | switch (arch) { |
| 16 | .i386 => { | 16 | .i386 => { |
| 17 | @export(__multi3, .{ .name = "__multi3", .linkage = linkage }); | 17 | @export(__multi3, .{ .name = "__multi3", .linkage = common.linkage }); |
| 18 | }, | 18 | }, |
| 19 | .x86_64 => { | 19 | .x86_64 => { |
| 20 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | 20 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI |
| 21 | // that LLVM expects compiler-rt to have. | 21 | // that LLVM expects compiler-rt to have. |
| 22 | @export(__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = linkage }); | 22 | @export(__multi3_windows_x86_64, .{ .name = "__multi3", .linkage = common.linkage }); |
| 23 | }, | 23 | }, |
| 24 | else => {}, | 24 | else => {}, |
| 25 | } | 25 | } |
| 26 | } else { | 26 | } else { |
| 27 | @export(__multi3, .{ .name = "__multi3", .linkage = linkage }); | 27 | @export(__multi3, .{ .name = "__multi3", .linkage = common.linkage }); |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | pub fn __multi3(a: i128, b: i128) callconv(.C) i128 { | 31 | pub fn __multi3(a: i128, b: i128) callconv(.C) i128 { |
| 32 | @setRuntimeSafety(is_test); | 32 | return mul(a, b); |
| 33 | } | ||
| 34 | |||
| 35 | const v128 = @Vector(2, u64); | ||
| 36 | |||
| 37 | fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { | ||
| 38 | return @bitCast(v128, mul(@bitCast(i128, a), @bitCast(i128, b))); | ||
| 39 | } | ||
| 40 | |||
| 41 | inline fn mul(a: i128, b: i128) i128 { | ||
| 33 | const x = twords{ .all = a }; | 42 | const x = twords{ .all = a }; |
| 34 | const y = twords{ .all = b }; | 43 | const y = twords{ .all = b }; |
| 35 | var r = twords{ .all = __mulddi3(x.s.low, y.s.low) }; | 44 | var r = twords{ .all = mulddi3(x.s.low, y.s.low) }; |
| 36 | r.s.high +%= x.s.high *% y.s.low +% x.s.low *% y.s.high; | 45 | r.s.high +%= x.s.high *% y.s.low +% x.s.low *% y.s.high; |
| 37 | return r.all; | 46 | return r.all; |
| 38 | } | 47 | } |
| 39 | 48 | ||
| 40 | const v128 = @Vector(2, u64); | 49 | fn mulddi3(a: u64, b: u64) i128 { |
| 41 | pub fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { | ||
| 42 | return @bitCast(v128, @call(.{ .modifier = .always_inline }, __multi3, .{ | ||
| 43 | @bitCast(i128, a), | ||
| 44 | @bitCast(i128, b), | ||
| 45 | })); | ||
| 46 | } | ||
| 47 | |||
| 48 | pub fn __mulddi3(a: u64, b: u64) i128 { | ||
| 49 | const bits_in_dword_2 = (@sizeOf(i64) * 8) / 2; | 50 | const bits_in_dword_2 = (@sizeOf(i64) * 8) / 2; |
| 50 | const lower_mask = ~@as(u64, 0) >> bits_in_dword_2; | 51 | const lower_mask = ~@as(u64, 0) >> bits_in_dword_2; |
| 51 | var r: twords = undefined; | 52 | var r: twords = undefined; |
lib/compiler_rt/negXf2.zig+16-21| ... | @@ -1,19 +1,16 @@ | ... | @@ -1,19 +1,16 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | 3 | const common = @import("common.zig"); |
| 4 | const is_test = builtin.is_test; | 4 | |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 5 | pub const panic = common.panic; |
| 6 | pub const panic = @import("common.zig").panic; | ||
| 7 | 6 | ||
| 8 | comptime { | 7 | comptime { |
| 9 | @export(__negsf2, .{ .name = "__negsf2", .linkage = linkage }); | 8 | if (common.want_aeabi) { |
| 10 | @export(__negdf2, .{ .name = "__negdf2", .linkage = linkage }); | 9 | @export(__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = common.linkage }); |
| 11 | 10 | @export(__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = common.linkage }); | |
| 12 | if (!is_test) { | 11 | } else { |
| 13 | if (arch.isARM() or arch.isThumb()) { | 12 | @export(__negsf2, .{ .name = "__negsf2", .linkage = common.linkage }); |
| 14 | @export(__aeabi_fneg, .{ .name = "__aeabi_fneg", .linkage = linkage }); | 13 | @export(__negdf2, .{ .name = "__negdf2", .linkage = common.linkage }); |
| 15 | @export(__aeabi_dneg, .{ .name = "__aeabi_dneg", .linkage = linkage }); | ||
| 16 | } | ||
| 17 | } | 14 | } |
| 18 | } | 15 | } |
| 19 | 16 | ||
| ... | @@ -21,21 +18,19 @@ pub fn __negsf2(a: f32) callconv(.C) f32 { | ... | @@ -21,21 +18,19 @@ pub fn __negsf2(a: f32) callconv(.C) f32 { |
| 21 | return negXf2(f32, a); | 18 | return negXf2(f32, a); |
| 22 | } | 19 | } |
| 23 | 20 | ||
| 24 | pub fn __negdf2(a: f64) callconv(.C) f64 { | 21 | fn __aeabi_fneg(a: f32) callconv(.AAPCS) f32 { |
| 25 | return negXf2(f64, a); | 22 | return negXf2(f32, a); |
| 26 | } | 23 | } |
| 27 | 24 | ||
| 28 | pub fn __aeabi_fneg(arg: f32) callconv(.AAPCS) f32 { | 25 | pub fn __negdf2(a: f64) callconv(.C) f64 { |
| 29 | @setRuntimeSafety(false); | 26 | return negXf2(f64, a); |
| 30 | return @call(.{ .modifier = .always_inline }, __negsf2, .{arg}); | ||
| 31 | } | 27 | } |
| 32 | 28 | ||
| 33 | pub fn __aeabi_dneg(arg: f64) callconv(.AAPCS) f64 { | 29 | fn __aeabi_dneg(a: f64) callconv(.AAPCS) f64 { |
| 34 | @setRuntimeSafety(false); | 30 | return negXf2(f64, a); |
| 35 | return @call(.{ .modifier = .always_inline }, __negdf2, .{arg}); | ||
| 36 | } | 31 | } |
| 37 | 32 | ||
| 38 | fn negXf2(comptime T: type, a: T) T { | 33 | inline fn negXf2(comptime T: type, a: T) T { |
| 39 | const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | 34 | const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); |
| 40 | 35 | ||
| 41 | const significandBits = std.math.floatMantissaBits(T); | 36 | const significandBits = std.math.floatMantissaBits(T); |
lib/compiler_rt/negXi2.zig+18-21| ... | @@ -1,28 +1,21 @@ | ... | @@ -1,28 +1,21 @@ |
| 1 | //! neg - negate (the number) | ||
| 2 | //! - negXi2 for unoptimized little and big endian | ||
| 3 | //! sfffffff = 2^31-1 | ||
| 4 | //! two's complement inverting bits and add 1 would result in -INT_MIN == 0 | ||
| 5 | //! => -INT_MIN = -2^31 forbidden | ||
| 6 | //! * size optimized builds | ||
| 7 | //! * machines that dont support carry operations | ||
| 8 | |||
| 1 | const std = @import("std"); | 9 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 10 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | 11 | const common = @import("common.zig"); |
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | ||
| 5 | pub const panic = @import("common.zig").panic; | ||
| 6 | |||
| 7 | comptime { | ||
| 8 | @export(__negsi2, .{ .name = "__negsi2", .linkage = linkage }); | ||
| 9 | @export(__negdi2, .{ .name = "__negdi2", .linkage = linkage }); | ||
| 10 | @export(__negti2, .{ .name = "__negti2", .linkage = linkage }); | ||
| 11 | } | ||
| 12 | 12 | ||
| 13 | // neg - negate (the number) | 13 | pub const panic = common.panic; |
| 14 | // - negXi2 for unoptimized little and big endian | ||
| 15 | 14 | ||
| 16 | // sfffffff = 2^31-1 | 15 | comptime { |
| 17 | // two's complement inverting bits and add 1 would result in -INT_MIN == 0 | 16 | @export(__negsi2, .{ .name = "__negsi2", .linkage = common.linkage }); |
| 18 | // => -INT_MIN = -2^31 forbidden | 17 | @export(__negdi2, .{ .name = "__negdi2", .linkage = common.linkage }); |
| 19 | 18 | @export(__negti2, .{ .name = "__negti2", .linkage = common.linkage }); | |
| 20 | // * size optimized builds | ||
| 21 | // * machines that dont support carry operations | ||
| 22 | |||
| 23 | inline fn negXi2(comptime T: type, a: T) T { | ||
| 24 | @setRuntimeSafety(builtin.is_test); | ||
| 25 | return -a; | ||
| 26 | } | 19 | } |
| 27 | 20 | ||
| 28 | pub fn __negsi2(a: i32) callconv(.C) i32 { | 21 | pub fn __negsi2(a: i32) callconv(.C) i32 { |
| ... | @@ -37,6 +30,10 @@ pub fn __negti2(a: i128) callconv(.C) i128 { | ... | @@ -37,6 +30,10 @@ pub fn __negti2(a: i128) callconv(.C) i128 { |
| 37 | return negXi2(i128, a); | 30 | return negXi2(i128, a); |
| 38 | } | 31 | } |
| 39 | 32 | ||
| 33 | inline fn negXi2(comptime T: type, a: T) T { | ||
| 34 | return -a; | ||
| 35 | } | ||
| 36 | |||
| 40 | test { | 37 | test { |
| 41 | _ = @import("negsi2_test.zig"); | 38 | _ = @import("negsi2_test.zig"); |
| 42 | _ = @import("negdi2_test.zig"); | 39 | _ = @import("negdi2_test.zig"); |
lib/compiler_rt/negv.zig+21-22| ... | @@ -1,19 +1,30 @@ | ... | @@ -1,19 +1,30 @@ |
| 1 | // negv - negate oVerflow | 1 | //! negv - negate oVerflow |
| 2 | // * @panic, if result can not be represented | 2 | //! * @panic, if result can not be represented |
| 3 | // - negvXi4_generic for unoptimized version | 3 | //! - negvXi4_generic for unoptimized version |
| 4 | const std = @import("std"); | 4 | const std = @import("std"); |
| 5 | const builtin = @import("builtin"); | 5 | const builtin = @import("builtin"); |
| 6 | const is_test = builtin.is_test; | 6 | const common = @import("common.zig"); |
| 7 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 7 | |
| 8 | pub const panic = @import("common.zig").panic; | 8 | pub const panic = common.panic; |
| 9 | 9 | ||
| 10 | comptime { | 10 | comptime { |
| 11 | @export(__negvsi2, .{ .name = "__negvsi2", .linkage = linkage }); | 11 | @export(__negvsi2, .{ .name = "__negvsi2", .linkage = common.linkage }); |
| 12 | @export(__negvdi2, .{ .name = "__negvdi2", .linkage = linkage }); | 12 | @export(__negvdi2, .{ .name = "__negvdi2", .linkage = common.linkage }); |
| 13 | @export(__negvti2, .{ .name = "__negvti2", .linkage = linkage }); | 13 | @export(__negvti2, .{ .name = "__negvti2", .linkage = common.linkage }); |
| 14 | } | ||
| 15 | |||
| 16 | pub fn __negvsi2(a: i32) callconv(.C) i32 { | ||
| 17 | return negvXi(i32, a); | ||
| 18 | } | ||
| 19 | |||
| 20 | pub fn __negvdi2(a: i64) callconv(.C) i64 { | ||
| 21 | return negvXi(i64, a); | ||
| 22 | } | ||
| 23 | |||
| 24 | pub fn __negvti2(a: i128) callconv(.C) i128 { | ||
| 25 | return negvXi(i128, a); | ||
| 14 | } | 26 | } |
| 15 | 27 | ||
| 16 | // assume -0 == 0 is gracefully handled by the hardware | ||
| 17 | inline fn negvXi(comptime ST: type, a: ST) ST { | 28 | inline fn negvXi(comptime ST: type, a: ST) ST { |
| 18 | const UT = switch (ST) { | 29 | const UT = switch (ST) { |
| 19 | i32 => u32, | 30 | i32 => u32, |
| ... | @@ -28,18 +39,6 @@ inline fn negvXi(comptime ST: type, a: ST) ST { | ... | @@ -28,18 +39,6 @@ inline fn negvXi(comptime ST: type, a: ST) ST { |
| 28 | return -a; | 39 | return -a; |
| 29 | } | 40 | } |
| 30 | 41 | ||
| 31 | pub fn __negvsi2(a: i32) callconv(.C) i32 { | ||
| 32 | return negvXi(i32, a); | ||
| 33 | } | ||
| 34 | |||
| 35 | pub fn __negvdi2(a: i64) callconv(.C) i64 { | ||
| 36 | return negvXi(i64, a); | ||
| 37 | } | ||
| 38 | |||
| 39 | pub fn __negvti2(a: i128) callconv(.C) i128 { | ||
| 40 | return negvXi(i128, a); | ||
| 41 | } | ||
| 42 | |||
| 43 | test { | 42 | test { |
| 44 | _ = @import("negvsi2_test.zig"); | 43 | _ = @import("negvsi2_test.zig"); |
| 45 | _ = @import("negvdi2_test.zig"); | 44 | _ = @import("negvdi2_test.zig"); |
lib/compiler_rt/parity.zig+20-22| ... | @@ -1,21 +1,31 @@ | ... | @@ -1,21 +1,31 @@ |
| 1 | //! parity - if number of bits set is even => 0, else => 1 | ||
| 2 | //! - pariytXi2_generic for big and little endian | ||
| 3 | |||
| 1 | const std = @import("std"); | 4 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 5 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | 6 | const common = @import("common.zig"); |
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 7 | |
| 5 | pub const panic = @import("common.zig").panic; | 8 | pub const panic = common.panic; |
| 6 | 9 | ||
| 7 | comptime { | 10 | comptime { |
| 8 | @export(__paritysi2, .{ .name = "__paritysi2", .linkage = linkage }); | 11 | @export(__paritysi2, .{ .name = "__paritysi2", .linkage = common.linkage }); |
| 9 | @export(__paritydi2, .{ .name = "__paritydi2", .linkage = linkage }); | 12 | @export(__paritydi2, .{ .name = "__paritydi2", .linkage = common.linkage }); |
| 10 | @export(__parityti2, .{ .name = "__parityti2", .linkage = linkage }); | 13 | @export(__parityti2, .{ .name = "__parityti2", .linkage = common.linkage }); |
| 11 | } | 14 | } |
| 12 | 15 | ||
| 13 | // parity - if number of bits set is even => 0, else => 1 | 16 | pub fn __paritysi2(a: i32) callconv(.C) i32 { |
| 14 | // - pariytXi2_generic for big and little endian | 17 | return parityXi2(i32, a); |
| 18 | } | ||
| 15 | 19 | ||
| 16 | inline fn parityXi2(comptime T: type, a: T) i32 { | 20 | pub fn __paritydi2(a: i64) callconv(.C) i32 { |
| 17 | @setRuntimeSafety(builtin.is_test); | 21 | return parityXi2(i64, a); |
| 22 | } | ||
| 23 | |||
| 24 | pub fn __parityti2(a: i128) callconv(.C) i32 { | ||
| 25 | return parityXi2(i128, a); | ||
| 26 | } | ||
| 18 | 27 | ||
| 28 | inline fn parityXi2(comptime T: type, a: T) i32 { | ||
| 19 | var x = switch (@bitSizeOf(T)) { | 29 | var x = switch (@bitSizeOf(T)) { |
| 20 | 32 => @bitCast(u32, a), | 30 | 32 => @bitCast(u32, a), |
| 21 | 64 => @bitCast(u64, a), | 31 | 64 => @bitCast(u64, a), |
| ... | @@ -32,18 +42,6 @@ inline fn parityXi2(comptime T: type, a: T) i32 { | ... | @@ -32,18 +42,6 @@ inline fn parityXi2(comptime T: type, a: T) i32 { |
| 32 | return (@intCast(u16, 0x6996) >> @intCast(u4, x)) & 1; // optimization for >>2 and >>1 | 42 | return (@intCast(u16, 0x6996) >> @intCast(u4, x)) & 1; // optimization for >>2 and >>1 |
| 33 | } | 43 | } |
| 34 | 44 | ||
| 35 | pub fn __paritysi2(a: i32) callconv(.C) i32 { | ||
| 36 | return parityXi2(i32, a); | ||
| 37 | } | ||
| 38 | |||
| 39 | pub fn __paritydi2(a: i64) callconv(.C) i32 { | ||
| 40 | return parityXi2(i64, a); | ||
| 41 | } | ||
| 42 | |||
| 43 | pub fn __parityti2(a: i128) callconv(.C) i32 { | ||
| 44 | return parityXi2(i128, a); | ||
| 45 | } | ||
| 46 | |||
| 47 | test { | 45 | test { |
| 48 | _ = @import("paritysi2_test.zig"); | 46 | _ = @import("paritysi2_test.zig"); |
| 49 | _ = @import("paritydi2_test.zig"); | 47 | _ = @import("paritydi2_test.zig"); |
lib/compiler_rt/popcount.zig+24-26| ... | @@ -1,26 +1,36 @@ | ... | @@ -1,26 +1,36 @@ |
| 1 | //! popcount - population count | ||
| 2 | //! counts the number of 1 bits | ||
| 3 | //! SWAR-Popcount: count bits of duos, aggregate to nibbles, and bytes inside | ||
| 4 | //! x-bit register in parallel to sum up all bytes | ||
| 5 | //! SWAR-Masks and factors can be defined as 2-adic fractions | ||
| 6 | //! TAOCP: Combinational Algorithms, Bitwise Tricks And Techniques, | ||
| 7 | //! subsubsection "Working with the rightmost bits" and "Sideways addition". | ||
| 8 | |||
| 1 | const builtin = @import("builtin"); | 9 | const builtin = @import("builtin"); |
| 2 | const std = @import("std"); | 10 | const std = @import("std"); |
| 3 | const is_test = builtin.is_test; | 11 | const common = @import("common.zig"); |
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 12 | |
| 5 | pub const panic = @import("common.zig").panic; | 13 | pub const panic = common.panic; |
| 6 | 14 | ||
| 7 | comptime { | 15 | comptime { |
| 8 | @export(__popcountsi2, .{ .name = "__popcountsi2", .linkage = linkage }); | 16 | @export(__popcountsi2, .{ .name = "__popcountsi2", .linkage = common.linkage }); |
| 9 | @export(__popcountdi2, .{ .name = "__popcountdi2", .linkage = linkage }); | 17 | @export(__popcountdi2, .{ .name = "__popcountdi2", .linkage = common.linkage }); |
| 10 | @export(__popcountti2, .{ .name = "__popcountti2", .linkage = linkage }); | 18 | @export(__popcountti2, .{ .name = "__popcountti2", .linkage = common.linkage }); |
| 19 | } | ||
| 20 | |||
| 21 | pub fn __popcountsi2(a: i32) callconv(.C) i32 { | ||
| 22 | return popcountXi2(i32, a); | ||
| 11 | } | 23 | } |
| 12 | 24 | ||
| 13 | // popcount - population count | 25 | pub fn __popcountdi2(a: i64) callconv(.C) i32 { |
| 14 | // counts the number of 1 bits | 26 | return popcountXi2(i64, a); |
| 27 | } | ||
| 15 | 28 | ||
| 16 | // SWAR-Popcount: count bits of duos, aggregate to nibbles, and bytes inside | 29 | pub fn __popcountti2(a: i128) callconv(.C) i32 { |
| 17 | // x-bit register in parallel to sum up all bytes | 30 | return popcountXi2(i128, a); |
| 18 | // SWAR-Masks and factors can be defined as 2-adic fractions | 31 | } |
| 19 | // TAOCP: Combinational Algorithms, Bitwise Tricks And Techniques, | ||
| 20 | // subsubsection "Working with the rightmost bits" and "Sideways addition". | ||
| 21 | 32 | ||
| 22 | inline fn popcountXi2(comptime ST: type, a: ST) i32 { | 33 | inline fn popcountXi2(comptime ST: type, a: ST) i32 { |
| 23 | @setRuntimeSafety(builtin.is_test); | ||
| 24 | const UT = switch (ST) { | 34 | const UT = switch (ST) { |
| 25 | i32 => u32, | 35 | i32 => u32, |
| 26 | i64 => u64, | 36 | i64 => u64, |
| ... | @@ -39,18 +49,6 @@ inline fn popcountXi2(comptime ST: type, a: ST) i32 { | ... | @@ -39,18 +49,6 @@ inline fn popcountXi2(comptime ST: type, a: ST) i32 { |
| 39 | return @intCast(i32, x); | 49 | return @intCast(i32, x); |
| 40 | } | 50 | } |
| 41 | 51 | ||
| 42 | pub fn __popcountsi2(a: i32) callconv(.C) i32 { | ||
| 43 | return popcountXi2(i32, a); | ||
| 44 | } | ||
| 45 | |||
| 46 | pub fn __popcountdi2(a: i64) callconv(.C) i32 { | ||
| 47 | return popcountXi2(i64, a); | ||
| 48 | } | ||
| 49 | |||
| 50 | pub fn __popcountti2(a: i128) callconv(.C) i32 { | ||
| 51 | return popcountXi2(i128, a); | ||
| 52 | } | ||
| 53 | |||
| 54 | test { | 52 | test { |
| 55 | _ = @import("popcountsi2_test.zig"); | 53 | _ = @import("popcountsi2_test.zig"); |
| 56 | _ = @import("popcountdi2_test.zig"); | 54 | _ = @import("popcountdi2_test.zig"); |
lib/compiler_rt/round.zig+15-23| ... | @@ -1,30 +1,26 @@ | ... | @@ -1,30 +1,26 @@ |
| 1 | // Ported from musl, which is licensed under the MIT license: | 1 | //! Ported from musl, which is licensed under the MIT license: |
| 2 | // https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT | 2 | //! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT |
| 3 | // | 3 | //! |
| 4 | // https://git.musl-libc.org/cgit/musl/tree/src/math/roundf.c | 4 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/roundf.c |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/round.c | 5 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/round.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const math = std.math; | 9 | const math = std.math; |
| 10 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 11 | const arch = builtin.cpu.arch; | 11 | const arch = builtin.cpu.arch; |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 12 | const common = @import("common.zig"); |
| 13 | pub const panic = @import("common.zig").panic; | 13 | |
| 14 | pub const panic = common.panic; | ||
| 14 | 15 | ||
| 15 | comptime { | 16 | comptime { |
| 16 | @export(__roundh, .{ .name = "__roundh", .linkage = linkage }); | 17 | @export(__roundh, .{ .name = "__roundh", .linkage = common.linkage }); |
| 17 | @export(roundf, .{ .name = "roundf", .linkage = linkage }); | 18 | @export(roundf, .{ .name = "roundf", .linkage = common.linkage }); |
| 18 | @export(round, .{ .name = "round", .linkage = linkage }); | 19 | @export(round, .{ .name = "round", .linkage = common.linkage }); |
| 19 | @export(__roundx, .{ .name = "__roundx", .linkage = linkage }); | 20 | @export(__roundx, .{ .name = "__roundx", .linkage = common.linkage }); |
| 20 | @export(roundq, .{ .name = "roundq", .linkage = linkage }); | 21 | const roundq_sym_name = if (common.want_ppc_abi) "roundf128" else "roundq"; |
| 21 | @export(roundl, .{ .name = "roundl", .linkage = linkage }); | 22 | @export(roundq, .{ .name = roundq_sym_name, .linkage = common.linkage }); |
| 22 | 23 | @export(roundl, .{ .name = "roundl", .linkage = common.linkage }); | |
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(roundf128, .{ .name = "roundf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | 24 | } |
| 29 | 25 | ||
| 30 | pub fn __roundh(x: f16) callconv(.C) f16 { | 26 | pub fn __roundh(x: f16) callconv(.C) f16 { |
| ... | @@ -142,10 +138,6 @@ pub fn roundq(x_: f128) callconv(.C) f128 { | ... | @@ -142,10 +138,6 @@ pub fn roundq(x_: f128) callconv(.C) f128 { |
| 142 | } | 138 | } |
| 143 | } | 139 | } |
| 144 | 140 | ||
| 145 | pub fn roundf128(x_: f128) callconv(.C) f128 { | ||
| 146 | return @call(.{ .modifier = .always_inline }, roundq, .{x_}); | ||
| 147 | } | ||
| 148 | |||
| 149 | pub fn roundl(x: c_longdouble) callconv(.C) c_longdouble { | 141 | pub fn roundl(x: c_longdouble) callconv(.C) c_longdouble { |
| 150 | switch (@typeInfo(c_longdouble).Float.bits) { | 142 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 151 | 16 => return __roundh(x), | 143 | 16 => return __roundh(x), |
lib/compiler_rt/shift.zig+29-27| ... | @@ -2,25 +2,23 @@ const std = @import("std"); | ... | @@ -2,25 +2,23 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const Log2Int = std.math.Log2Int; | 3 | const Log2Int = std.math.Log2Int; |
| 4 | const native_endian = builtin.cpu.arch.endian(); | 4 | const native_endian = builtin.cpu.arch.endian(); |
| 5 | const arch = builtin.cpu.arch; | 5 | const common = @import("common.zig"); |
| 6 | const is_test = builtin.is_test; | 6 | |
| 7 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 7 | pub const panic = common.panic; |
| 8 | pub const panic = @import("common.zig").panic; | ||
| 9 | 8 | ||
| 10 | comptime { | 9 | comptime { |
| 11 | @export(__ashldi3, .{ .name = "__ashldi3", .linkage = linkage }); | 10 | @export(__ashlti3, .{ .name = "__ashlti3", .linkage = common.linkage }); |
| 12 | @export(__ashlti3, .{ .name = "__ashlti3", .linkage = linkage }); | 11 | @export(__ashrti3, .{ .name = "__ashrti3", .linkage = common.linkage }); |
| 13 | @export(__ashrdi3, .{ .name = "__ashrdi3", .linkage = linkage }); | 12 | @export(__lshrti3, .{ .name = "__lshrti3", .linkage = common.linkage }); |
| 14 | @export(__ashrti3, .{ .name = "__ashrti3", .linkage = linkage }); | 13 | |
| 15 | @export(__lshrdi3, .{ .name = "__lshrdi3", .linkage = linkage }); | 14 | if (common.want_aeabi) { |
| 16 | @export(__lshrti3, .{ .name = "__lshrti3", .linkage = linkage }); | 15 | @export(__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = common.linkage }); |
| 17 | 16 | @export(__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = common.linkage }); | |
| 18 | if (!is_test) { | 17 | @export(__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = common.linkage }); |
| 19 | if (arch.isARM() or arch.isThumb()) { | 18 | } else { |
| 20 | @export(__aeabi_llsl, .{ .name = "__aeabi_llsl", .linkage = linkage }); | 19 | @export(__ashldi3, .{ .name = "__ashldi3", .linkage = common.linkage }); |
| 21 | @export(__aeabi_lasr, .{ .name = "__aeabi_lasr", .linkage = linkage }); | 20 | @export(__ashrdi3, .{ .name = "__ashrdi3", .linkage = common.linkage }); |
| 22 | @export(__aeabi_llsr, .{ .name = "__aeabi_llsr", .linkage = linkage }); | 21 | @export(__lshrdi3, .{ .name = "__lshrdi3", .linkage = common.linkage }); |
| 23 | } | ||
| 24 | } | 22 | } |
| 25 | } | 23 | } |
| 26 | 24 | ||
| ... | @@ -115,30 +113,34 @@ inline fn lshrXi3(comptime T: type, a: T, b: i32) T { | ... | @@ -115,30 +113,34 @@ inline fn lshrXi3(comptime T: type, a: T, b: i32) T { |
| 115 | pub fn __ashldi3(a: i64, b: i32) callconv(.C) i64 { | 113 | pub fn __ashldi3(a: i64, b: i32) callconv(.C) i64 { |
| 116 | return ashlXi3(i64, a, b); | 114 | return ashlXi3(i64, a, b); |
| 117 | } | 115 | } |
| 116 | fn __aeabi_llsl(a: i64, b: i32) callconv(.AAPCS) i64 { | ||
| 117 | return ashlXi3(i64, a, b); | ||
| 118 | } | ||
| 119 | |||
| 118 | pub fn __ashlti3(a: i128, b: i32) callconv(.C) i128 { | 120 | pub fn __ashlti3(a: i128, b: i32) callconv(.C) i128 { |
| 119 | return ashlXi3(i128, a, b); | 121 | return ashlXi3(i128, a, b); |
| 120 | } | 122 | } |
| 123 | |||
| 121 | pub fn __ashrdi3(a: i64, b: i32) callconv(.C) i64 { | 124 | pub fn __ashrdi3(a: i64, b: i32) callconv(.C) i64 { |
| 122 | return ashrXi3(i64, a, b); | 125 | return ashrXi3(i64, a, b); |
| 123 | } | 126 | } |
| 127 | fn __aeabi_lasr(a: i64, b: i32) callconv(.AAPCS) i64 { | ||
| 128 | return ashrXi3(i64, a, b); | ||
| 129 | } | ||
| 130 | |||
| 124 | pub fn __ashrti3(a: i128, b: i32) callconv(.C) i128 { | 131 | pub fn __ashrti3(a: i128, b: i32) callconv(.C) i128 { |
| 125 | return ashrXi3(i128, a, b); | 132 | return ashrXi3(i128, a, b); |
| 126 | } | 133 | } |
| 134 | |||
| 127 | pub fn __lshrdi3(a: i64, b: i32) callconv(.C) i64 { | 135 | pub fn __lshrdi3(a: i64, b: i32) callconv(.C) i64 { |
| 128 | return lshrXi3(i64, a, b); | 136 | return lshrXi3(i64, a, b); |
| 129 | } | 137 | } |
| 130 | pub fn __lshrti3(a: i128, b: i32) callconv(.C) i128 { | 138 | fn __aeabi_llsr(a: i64, b: i32) callconv(.AAPCS) i64 { |
| 131 | return lshrXi3(i128, a, b); | 139 | return lshrXi3(i64, a, b); |
| 132 | } | 140 | } |
| 133 | 141 | ||
| 134 | pub fn __aeabi_llsl(a: i64, b: i32) callconv(.AAPCS) i64 { | 142 | pub fn __lshrti3(a: i128, b: i32) callconv(.C) i128 { |
| 135 | return ashlXi3(i64, a, b); | 143 | return lshrXi3(i128, a, b); |
| 136 | } | ||
| 137 | pub fn __aeabi_lasr(a: i64, b: i32) callconv(.AAPCS) i64 { | ||
| 138 | return ashrXi3(i64, a, b); | ||
| 139 | } | ||
| 140 | pub fn __aeabi_llsr(a: i64, b: i32) callconv(.AAPCS) i64 { | ||
| 141 | return lshrXi3(i64, a, b); | ||
| 142 | } | 144 | } |
| 143 | 145 | ||
| 144 | test { | 146 | test { |
lib/compiler_rt/sin.zig+15-23| ... | @@ -1,34 +1,30 @@ | ... | @@ -1,34 +1,30 @@ |
| 1 | // Ported from musl, which is licensed under the MIT license: | 1 | //! Ported from musl, which is licensed under the MIT license: |
| 2 | // https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT | 2 | //! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT |
| 3 | // | 3 | //! |
| 4 | // https://git.musl-libc.org/cgit/musl/tree/src/math/sinf.c | 4 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/sinf.c |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/sin.c | 5 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/sin.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const arch = builtin.cpu.arch; | 9 | const arch = builtin.cpu.arch; |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 12 | const common = @import("common.zig"); |
| 13 | pub const panic = @import("common.zig").panic; | ||
| 14 | 13 | ||
| 15 | const trig = @import("trig.zig"); | 14 | const trig = @import("trig.zig"); |
| 16 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; | 15 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; |
| 17 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; | 16 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; |
| 18 | 17 | ||
| 18 | pub const panic = common.panic; | ||
| 19 | |||
| 19 | comptime { | 20 | comptime { |
| 20 | @export(__sinh, .{ .name = "__sinh", .linkage = linkage }); | 21 | @export(__sinh, .{ .name = "__sinh", .linkage = common.linkage }); |
| 21 | @export(sinf, .{ .name = "sinf", .linkage = linkage }); | 22 | @export(sinf, .{ .name = "sinf", .linkage = common.linkage }); |
| 22 | @export(sin, .{ .name = "sin", .linkage = linkage }); | 23 | @export(sin, .{ .name = "sin", .linkage = common.linkage }); |
| 23 | @export(__sinx, .{ .name = "__sinx", .linkage = linkage }); | 24 | @export(__sinx, .{ .name = "__sinx", .linkage = common.linkage }); |
| 24 | @export(sinq, .{ .name = "sinq", .linkage = linkage }); | 25 | const sinq_sym_name = if (common.want_ppc_abi) "sinf128" else "sinq"; |
| 25 | @export(sinl, .{ .name = "sinl", .linkage = linkage }); | 26 | @export(sinq, .{ .name = sinq_sym_name, .linkage = common.linkage }); |
| 26 | 27 | @export(sinl, .{ .name = "sinl", .linkage = common.linkage }); | |
| 27 | if (!builtin.is_test) { | ||
| 28 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 29 | @export(sinf128, .{ .name = "sinf128", .linkage = linkage }); | ||
| 30 | } | ||
| 31 | } | ||
| 32 | } | 28 | } |
| 33 | 29 | ||
| 34 | pub fn __sinh(x: f16) callconv(.C) f16 { | 30 | pub fn __sinh(x: f16) callconv(.C) f16 { |
| ... | @@ -130,10 +126,6 @@ pub fn sinq(x: f128) callconv(.C) f128 { | ... | @@ -130,10 +126,6 @@ pub fn sinq(x: f128) callconv(.C) f128 { |
| 130 | return sin(@floatCast(f64, x)); | 126 | return sin(@floatCast(f64, x)); |
| 131 | } | 127 | } |
| 132 | 128 | ||
| 133 | pub fn sinf128(x: f128) callconv(.C) f128 { | ||
| 134 | return @call(.{ .modifier = .always_inline }, sinq, .{x}); | ||
| 135 | } | ||
| 136 | |||
| 137 | pub fn sinl(x: c_longdouble) callconv(.C) c_longdouble { | 129 | pub fn sinl(x: c_longdouble) callconv(.C) c_longdouble { |
| 138 | switch (@typeInfo(c_longdouble).Float.bits) { | 130 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 139 | 16 => return __sinh(x), | 131 | 16 => return __sinh(x), |
lib/compiler_rt/sincos.zig+10-18| ... | @@ -5,22 +5,18 @@ const math = std.math; | ... | @@ -5,22 +5,18 @@ const math = std.math; |
| 5 | const trig = @import("trig.zig"); | 5 | const trig = @import("trig.zig"); |
| 6 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; | 6 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; |
| 7 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; | 7 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; |
| 8 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 8 | const common = @import("common.zig"); |
| 9 | pub const panic = @import("common.zig").panic; | ||
| 10 | 9 | ||
| 11 | comptime { | 10 | pub const panic = common.panic; |
| 12 | @export(__sincosh, .{ .name = "__sincosh", .linkage = linkage }); | ||
| 13 | @export(sincosf, .{ .name = "sincosf", .linkage = linkage }); | ||
| 14 | @export(sincos, .{ .name = "sincos", .linkage = linkage }); | ||
| 15 | @export(__sincosx, .{ .name = "__sincosx", .linkage = linkage }); | ||
| 16 | @export(sincosq, .{ .name = "sincosq", .linkage = linkage }); | ||
| 17 | @export(sincosl, .{ .name = "sincosl", .linkage = linkage }); | ||
| 18 | 11 | ||
| 19 | if (!builtin.is_test) { | 12 | comptime { |
| 20 | if (arch.isPPC() or arch.isPPC64()) { | 13 | @export(__sincosh, .{ .name = "__sincosh", .linkage = common.linkage }); |
| 21 | @export(sincosf128, .{ .name = "sincosf128", .linkage = linkage }); | 14 | @export(sincosf, .{ .name = "sincosf", .linkage = common.linkage }); |
| 22 | } | 15 | @export(sincos, .{ .name = "sincos", .linkage = common.linkage }); |
| 23 | } | 16 | @export(__sincosx, .{ .name = "__sincosx", .linkage = common.linkage }); |
| 17 | const sincosq_sym_name = if (common.want_ppc_abi) "sincosf128" else "sincosq"; | ||
| 18 | @export(sincosq, .{ .name = sincosq_sym_name, .linkage = common.linkage }); | ||
| 19 | @export(sincosl, .{ .name = "sincosl", .linkage = common.linkage }); | ||
| 24 | } | 20 | } |
| 25 | 21 | ||
| 26 | pub fn __sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.C) void { | 22 | pub fn __sincosh(x: f16, r_sin: *f16, r_cos: *f16) callconv(.C) void { |
| ... | @@ -198,10 +194,6 @@ pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void { | ... | @@ -198,10 +194,6 @@ pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void { |
| 198 | r_cos.* = small_cos; | 194 | r_cos.* = small_cos; |
| 199 | } | 195 | } |
| 200 | 196 | ||
| 201 | pub fn sincosf128(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void { | ||
| 202 | return @call(.{ .modifier = .always_inline }, sincosq, .{ x, r_sin, r_cos }); | ||
| 203 | } | ||
| 204 | |||
| 205 | pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.C) void { | 197 | pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.C) void { |
| 206 | switch (@typeInfo(c_longdouble).Float.bits) { | 198 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 207 | 16 => return __sincosh(x, r_sin, r_cos), | 199 | 16 => return __sincosh(x, r_sin, r_cos), |
lib/compiler_rt/sqrt.zig+10-18| ... | @@ -2,22 +2,18 @@ const std = @import("std"); | ... | @@ -2,22 +2,18 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | 3 | const arch = builtin.cpu.arch; |
| 4 | const math = std.math; | 4 | const math = std.math; |
| 5 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 5 | const common = @import("common.zig"); |
| 6 | pub const panic = @import("common.zig").panic; | 6 | |
| 7 | pub const panic = common.panic; | ||
| 7 | 8 | ||
| 8 | comptime { | 9 | comptime { |
| 9 | @export(__sqrth, .{ .name = "__sqrth", .linkage = linkage }); | 10 | @export(__sqrth, .{ .name = "__sqrth", .linkage = common.linkage }); |
| 10 | @export(sqrtf, .{ .name = "sqrtf", .linkage = linkage }); | 11 | @export(sqrtf, .{ .name = "sqrtf", .linkage = common.linkage }); |
| 11 | @export(sqrt, .{ .name = "sqrt", .linkage = linkage }); | 12 | @export(sqrt, .{ .name = "sqrt", .linkage = common.linkage }); |
| 12 | @export(__sqrtx, .{ .name = "__sqrtx", .linkage = linkage }); | 13 | @export(__sqrtx, .{ .name = "__sqrtx", .linkage = common.linkage }); |
| 13 | @export(sqrtq, .{ .name = "sqrtq", .linkage = linkage }); | 14 | const sqrtq_sym_name = if (common.want_ppc_abi) "sqrtf128" else "sqrtq"; |
| 14 | @export(sqrtl, .{ .name = "sqrtl", .linkage = linkage }); | 15 | @export(sqrtq, .{ .name = sqrtq_sym_name, .linkage = common.linkage }); |
| 15 | 16 | @export(sqrtl, .{ .name = "sqrtl", .linkage = common.linkage }); | |
| 16 | if (!builtin.is_test) { | ||
| 17 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 18 | @export(sqrtf128, .{ .name = "sqrtf128", .linkage = linkage }); | ||
| 19 | } | ||
| 20 | } | ||
| 21 | } | 17 | } |
| 22 | 18 | ||
| 23 | pub fn __sqrth(x: f16) callconv(.C) f16 { | 19 | pub fn __sqrth(x: f16) callconv(.C) f16 { |
| ... | @@ -255,10 +251,6 @@ pub fn sqrtl(x: c_longdouble) callconv(.C) c_longdouble { | ... | @@ -255,10 +251,6 @@ pub fn sqrtl(x: c_longdouble) callconv(.C) c_longdouble { |
| 255 | } | 251 | } |
| 256 | } | 252 | } |
| 257 | 253 | ||
| 258 | pub fn sqrtf128(x: f128) callconv(.C) f128 { | ||
| 259 | return @call(.{ .modifier = .always_inline }, sqrtq, .{x}); | ||
| 260 | } | ||
| 261 | |||
| 262 | test "sqrtf" { | 254 | test "sqrtf" { |
| 263 | const V = [_]f32{ | 255 | const V = [_]f32{ |
| 264 | 0.0, | 256 | 0.0, |
lib/compiler_rt/subo.zig+20-21| ... | @@ -1,22 +1,31 @@ | ... | @@ -1,22 +1,31 @@ |
| 1 | //! subo - subtract overflow | ||
| 2 | //! * return a-%b. | ||
| 3 | //! * return if a-b overflows => 1 else => 0 | ||
| 4 | //! - suboXi4_generic as default | ||
| 5 | |||
| 1 | const std = @import("std"); | 6 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 7 | const builtin = @import("builtin"); |
| 3 | const is_test = builtin.is_test; | 8 | const common = @import("common.zig"); |
| 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 9 | |
| 5 | pub const panic = @import("common.zig").panic; | 10 | pub const panic = common.panic; |
| 6 | 11 | ||
| 7 | comptime { | 12 | comptime { |
| 8 | @export(__subosi4, .{ .name = "__subosi4", .linkage = linkage }); | 13 | @export(__subosi4, .{ .name = "__subosi4", .linkage = common.linkage }); |
| 9 | @export(__subodi4, .{ .name = "__subodi4", .linkage = linkage }); | 14 | @export(__subodi4, .{ .name = "__subodi4", .linkage = common.linkage }); |
| 10 | @export(__suboti4, .{ .name = "__suboti4", .linkage = linkage }); | 15 | @export(__suboti4, .{ .name = "__suboti4", .linkage = common.linkage }); |
| 11 | } | 16 | } |
| 12 | 17 | ||
| 13 | // subo - subtract overflow | 18 | pub fn __subosi4(a: i32, b: i32, overflow: *c_int) callconv(.C) i32 { |
| 14 | // * return a-%b. | 19 | return suboXi4_generic(i32, a, b, overflow); |
| 15 | // * return if a-b overflows => 1 else => 0 | 20 | } |
| 16 | // - suboXi4_generic as default | 21 | pub fn __subodi4(a: i64, b: i64, overflow: *c_int) callconv(.C) i64 { |
| 22 | return suboXi4_generic(i64, a, b, overflow); | ||
| 23 | } | ||
| 24 | pub fn __suboti4(a: i128, b: i128, overflow: *c_int) callconv(.C) i128 { | ||
| 25 | return suboXi4_generic(i128, a, b, overflow); | ||
| 26 | } | ||
| 17 | 27 | ||
| 18 | inline fn suboXi4_generic(comptime ST: type, a: ST, b: ST, overflow: *c_int) ST { | 28 | inline fn suboXi4_generic(comptime ST: type, a: ST, b: ST, overflow: *c_int) ST { |
| 19 | @setRuntimeSafety(builtin.is_test); | ||
| 20 | overflow.* = 0; | 29 | overflow.* = 0; |
| 21 | var sum: ST = a -% b; | 30 | var sum: ST = a -% b; |
| 22 | // Hackers Delight: section Overflow Detection, subsection Signed Add/Subtract | 31 | // Hackers Delight: section Overflow Detection, subsection Signed Add/Subtract |
| ... | @@ -31,16 +40,6 @@ inline fn suboXi4_generic(comptime ST: type, a: ST, b: ST, overflow: *c_int) ST | ... | @@ -31,16 +40,6 @@ inline fn suboXi4_generic(comptime ST: type, a: ST, b: ST, overflow: *c_int) ST |
| 31 | return sum; | 40 | return sum; |
| 32 | } | 41 | } |
| 33 | 42 | ||
| 34 | pub fn __subosi4(a: i32, b: i32, overflow: *c_int) callconv(.C) i32 { | ||
| 35 | return suboXi4_generic(i32, a, b, overflow); | ||
| 36 | } | ||
| 37 | pub fn __subodi4(a: i64, b: i64, overflow: *c_int) callconv(.C) i64 { | ||
| 38 | return suboXi4_generic(i64, a, b, overflow); | ||
| 39 | } | ||
| 40 | pub fn __suboti4(a: i128, b: i128, overflow: *c_int) callconv(.C) i128 { | ||
| 41 | return suboXi4_generic(i128, a, b, overflow); | ||
| 42 | } | ||
| 43 | |||
| 44 | test { | 43 | test { |
| 45 | _ = @import("subosi4_test.zig"); | 44 | _ = @import("subosi4_test.zig"); |
| 46 | _ = @import("subodi4_test.zig"); | 45 | _ = @import("subodi4_test.zig"); |
lib/compiler_rt/tan.zig+16-24| ... | @@ -1,9 +1,9 @@ | ... | @@ -1,9 +1,9 @@ |
| 1 | // Ported from musl, which is licensed under the MIT license: | 1 | //! Ported from musl, which is licensed under the MIT license: |
| 2 | // https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT | 2 | //! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT |
| 3 | // | 3 | //! |
| 4 | // https://git.musl-libc.org/cgit/musl/tree/src/math/tanf.c | 4 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/tanf.c |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/tan.c | 5 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/tan.c |
| 6 | // https://golang.org/src/math/tan.go | 6 | //! https://golang.org/src/math/tan.go |
| 7 | 7 | ||
| 8 | const std = @import("std"); | 8 | const std = @import("std"); |
| 9 | const builtin = @import("builtin"); | 9 | const builtin = @import("builtin"); |
| ... | @@ -15,22 +15,18 @@ const rem_pio2 = @import("rem_pio2.zig").rem_pio2; | ... | @@ -15,22 +15,18 @@ const rem_pio2 = @import("rem_pio2.zig").rem_pio2; |
| 15 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; | 15 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; |
| 16 | 16 | ||
| 17 | const arch = builtin.cpu.arch; | 17 | const arch = builtin.cpu.arch; |
| 18 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 18 | const common = @import("common.zig"); |
| 19 | pub const panic = @import("common.zig").panic; | 19 | |
| 20 | pub const panic = common.panic; | ||
| 20 | 21 | ||
| 21 | comptime { | 22 | comptime { |
| 22 | @export(__tanh, .{ .name = "__tanh", .linkage = linkage }); | 23 | @export(__tanh, .{ .name = "__tanh", .linkage = common.linkage }); |
| 23 | @export(tanf, .{ .name = "tanf", .linkage = linkage }); | 24 | @export(tanf, .{ .name = "tanf", .linkage = common.linkage }); |
| 24 | @export(tan, .{ .name = "tan", .linkage = linkage }); | 25 | @export(tan, .{ .name = "tan", .linkage = common.linkage }); |
| 25 | @export(__tanx, .{ .name = "__tanx", .linkage = linkage }); | 26 | @export(__tanx, .{ .name = "__tanx", .linkage = common.linkage }); |
| 26 | @export(tanq, .{ .name = "tanq", .linkage = linkage }); | 27 | const tanq_sym_name = if (common.want_ppc_abi) "tanf128" else "tanq"; |
| 27 | @export(tanl, .{ .name = "tanl", .linkage = linkage }); | 28 | @export(tanq, .{ .name = tanq_sym_name, .linkage = common.linkage }); |
| 28 | 29 | @export(tanl, .{ .name = "tanl", .linkage = common.linkage }); | |
| 29 | if (!builtin.is_test) { | ||
| 30 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 31 | @export(tanf128, .{ .name = "tanf128", .linkage = linkage }); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | } | 30 | } |
| 35 | 31 | ||
| 36 | pub fn __tanh(x: f16) callconv(.C) f16 { | 32 | pub fn __tanh(x: f16) callconv(.C) f16 { |
| ... | @@ -116,10 +112,6 @@ pub fn tanq(x: f128) callconv(.C) f128 { | ... | @@ -116,10 +112,6 @@ pub fn tanq(x: f128) callconv(.C) f128 { |
| 116 | return tan(@floatCast(f64, x)); | 112 | return tan(@floatCast(f64, x)); |
| 117 | } | 113 | } |
| 118 | 114 | ||
| 119 | pub fn tanf128(x: f128) callconv(.C) f128 { | ||
| 120 | return @call(.{ .modifier = .always_inline }, tanq, .{x}); | ||
| 121 | } | ||
| 122 | |||
| 123 | pub fn tanl(x: c_longdouble) callconv(.C) c_longdouble { | 115 | pub fn tanl(x: c_longdouble) callconv(.C) c_longdouble { |
| 124 | switch (@typeInfo(c_longdouble).Float.bits) { | 116 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 125 | 16 => return __tanh(x), | 117 | 16 => return __tanh(x), |
lib/compiler_rt/trunc.zig+16-24| ... | @@ -1,30 +1,26 @@ | ... | @@ -1,30 +1,26 @@ |
| 1 | // Ported from musl, which is licensed under the MIT license: | 1 | //! Ported from musl, which is MIT licensed. |
| 2 | // https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT | 2 | //! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT |
| 3 | // | 3 | //! |
| 4 | // https://git.musl-libc.org/cgit/musl/tree/src/math/truncf.c | 4 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/truncf.c |
| 5 | // https://git.musl-libc.org/cgit/musl/tree/src/math/trunc.c | 5 | //! https://git.musl-libc.org/cgit/musl/tree/src/math/trunc.c |
| 6 | 6 | ||
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const arch = builtin.cpu.arch; | ||
| 9 | const math = std.math; | 10 | const math = std.math; |
| 10 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 11 | const arch = builtin.cpu.arch; | 12 | const common = @import("common.zig"); |
| 12 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 13 | |
| 13 | pub const panic = @import("common.zig").panic; | 14 | pub const panic = common.panic; |
| 14 | 15 | ||
| 15 | comptime { | 16 | comptime { |
| 16 | @export(__trunch, .{ .name = "__trunch", .linkage = linkage }); | 17 | @export(__trunch, .{ .name = "__trunch", .linkage = common.linkage }); |
| 17 | @export(truncf, .{ .name = "truncf", .linkage = linkage }); | 18 | @export(truncf, .{ .name = "truncf", .linkage = common.linkage }); |
| 18 | @export(trunc, .{ .name = "trunc", .linkage = linkage }); | 19 | @export(trunc, .{ .name = "trunc", .linkage = common.linkage }); |
| 19 | @export(__truncx, .{ .name = "__truncx", .linkage = linkage }); | 20 | @export(__truncx, .{ .name = "__truncx", .linkage = common.linkage }); |
| 20 | @export(truncq, .{ .name = "truncq", .linkage = linkage }); | 21 | const truncq_sym_name = if (common.want_ppc_abi) "truncf128" else "truncq"; |
| 21 | @export(truncl, .{ .name = "truncl", .linkage = linkage }); | 22 | @export(truncq, .{ .name = truncq_sym_name, .linkage = common.linkage }); |
| 22 | 23 | @export(truncl, .{ .name = "truncl", .linkage = common.linkage }); | |
| 23 | if (!builtin.is_test) { | ||
| 24 | if (arch.isPPC() or arch.isPPC64()) { | ||
| 25 | @export(truncf128, .{ .name = "truncf128", .linkage = linkage }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | 24 | } |
| 29 | 25 | ||
| 30 | pub fn __trunch(x: f16) callconv(.C) f16 { | 26 | pub fn __trunch(x: f16) callconv(.C) f16 { |
| ... | @@ -100,10 +96,6 @@ pub fn truncq(x: f128) callconv(.C) f128 { | ... | @@ -100,10 +96,6 @@ pub fn truncq(x: f128) callconv(.C) f128 { |
| 100 | } | 96 | } |
| 101 | } | 97 | } |
| 102 | 98 | ||
| 103 | pub fn truncf128(x: f128) callconv(.C) f128 { | ||
| 104 | return @call(.{ .modifier = .always_inline }, truncq, .{x}); | ||
| 105 | } | ||
| 106 | |||
| 107 | pub fn truncl(x: c_longdouble) callconv(.C) c_longdouble { | 99 | pub fn truncl(x: c_longdouble) callconv(.C) c_longdouble { |
| 108 | switch (@typeInfo(c_longdouble).Float.bits) { | 100 | switch (@typeInfo(c_longdouble).Float.bits) { |
| 109 | 16 => return __trunch(x), | 101 | 16 => return __trunch(x), |
lib/compiler_rt/udivmodti4.zig+8-9| ... | @@ -2,36 +2,35 @@ const std = @import("std"); | ... | @@ -2,36 +2,35 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const udivmod = @import("udivmod.zig").udivmod; | 3 | const udivmod = @import("udivmod.zig").udivmod; |
| 4 | const arch = builtin.cpu.arch; | 4 | const arch = builtin.cpu.arch; |
| 5 | const is_test = builtin.is_test; | 5 | const common = @import("common.zig"); |
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 6 | |
| 7 | pub const panic = @import("common.zig").panic; | 7 | pub const panic = common.panic; |
| 8 | 8 | ||
| 9 | comptime { | 9 | comptime { |
| 10 | if (builtin.os.tag == .windows) { | 10 | if (builtin.os.tag == .windows) { |
| 11 | switch (arch) { | 11 | switch (arch) { |
| 12 | .i386 => { | 12 | .i386 => { |
| 13 | @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage }); | 13 | @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = common.linkage }); |
| 14 | }, | 14 | }, |
| 15 | .x86_64 => { | 15 | .x86_64 => { |
| 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI |
| 17 | // that LLVM expects compiler-rt to have. | 17 | // that LLVM expects compiler-rt to have. |
| 18 | @export(__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = linkage }); | 18 | @export(__udivmodti4_windows_x86_64, .{ .name = "__udivmodti4", .linkage = common.linkage }); |
| 19 | }, | 19 | }, |
| 20 | else => {}, | 20 | else => {}, |
| 21 | } | 21 | } |
| 22 | } else { | 22 | } else { |
| 23 | @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = linkage }); | 23 | @export(__udivmodti4, .{ .name = "__udivmodti4", .linkage = common.linkage }); |
| 24 | } | 24 | } |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.C) u128 { | 27 | pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.C) u128 { |
| 28 | @setRuntimeSafety(builtin.is_test); | ||
| 29 | return udivmod(u128, a, b, maybe_rem); | 28 | return udivmod(u128, a, b, maybe_rem); |
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | const v128 = std.meta.Vector(2, u64); | 31 | const v128 = std.meta.Vector(2, u64); |
| 33 | pub fn __udivmodti4_windows_x86_64(a: v128, b: v128, maybe_rem: ?*u128) callconv(.C) v128 { | 32 | |
| 34 | @setRuntimeSafety(builtin.is_test); | 33 | fn __udivmodti4_windows_x86_64(a: v128, b: v128, maybe_rem: ?*u128) callconv(.C) v128 { |
| 35 | return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), maybe_rem)); | 34 | return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), maybe_rem)); |
| 36 | } | 35 | } |
| 37 | 36 |
lib/compiler_rt/udivti3.zig+9-10| ... | @@ -2,38 +2,37 @@ const std = @import("std"); | ... | @@ -2,38 +2,37 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const udivmod = @import("udivmod.zig").udivmod; | 3 | const udivmod = @import("udivmod.zig").udivmod; |
| 4 | const arch = builtin.cpu.arch; | 4 | const arch = builtin.cpu.arch; |
| 5 | const is_test = builtin.is_test; | 5 | const common = @import("common.zig"); |
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 6 | |
| 7 | pub const panic = @import("common.zig").panic; | 7 | pub const panic = common.panic; |
| 8 | 8 | ||
| 9 | comptime { | 9 | comptime { |
| 10 | if (builtin.os.tag == .windows) { | 10 | if (builtin.os.tag == .windows) { |
| 11 | switch (arch) { | 11 | switch (arch) { |
| 12 | .i386 => { | 12 | .i386 => { |
| 13 | @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage }); | 13 | @export(__udivti3, .{ .name = "__udivti3", .linkage = common.linkage }); |
| 14 | }, | 14 | }, |
| 15 | .x86_64 => { | 15 | .x86_64 => { |
| 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI |
| 17 | // that LLVM expects compiler-rt to have. | 17 | // that LLVM expects compiler-rt to have. |
| 18 | @export(__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = linkage }); | 18 | @export(__udivti3_windows_x86_64, .{ .name = "__udivti3", .linkage = common.linkage }); |
| 19 | }, | 19 | }, |
| 20 | else => {}, | 20 | else => {}, |
| 21 | } | 21 | } |
| 22 | if (arch.isAARCH64()) { | 22 | if (arch.isAARCH64()) { |
| 23 | @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage }); | 23 | @export(__udivti3, .{ .name = "__udivti3", .linkage = common.linkage }); |
| 24 | } | 24 | } |
| 25 | } else { | 25 | } else { |
| 26 | @export(__udivti3, .{ .name = "__udivti3", .linkage = linkage }); | 26 | @export(__udivti3, .{ .name = "__udivti3", .linkage = common.linkage }); |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | pub fn __udivti3(a: u128, b: u128) callconv(.C) u128 { | 30 | pub fn __udivti3(a: u128, b: u128) callconv(.C) u128 { |
| 31 | @setRuntimeSafety(builtin.is_test); | ||
| 32 | return udivmod(u128, a, b, null); | 31 | return udivmod(u128, a, b, null); |
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | const v128 = std.meta.Vector(2, u64); | 34 | const v128 = std.meta.Vector(2, u64); |
| 36 | pub fn __udivti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { | 35 | |
| 37 | @setRuntimeSafety(builtin.is_test); | 36 | fn __udivti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { |
| 38 | return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), null)); | 37 | return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), null)); |
| 39 | } | 38 | } |
lib/compiler_rt/umodti3.zig+12-13| ... | @@ -2,42 +2,41 @@ const std = @import("std"); | ... | @@ -2,42 +2,41 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const udivmod = @import("udivmod.zig").udivmod; | 3 | const udivmod = @import("udivmod.zig").udivmod; |
| 4 | const arch = builtin.cpu.arch; | 4 | const arch = builtin.cpu.arch; |
| 5 | const is_test = builtin.is_test; | 5 | const common = @import("common.zig"); |
| 6 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; | 6 | |
| 7 | pub const panic = @import("common.zig").panic; | 7 | pub const panic = common.panic; |
| 8 | 8 | ||
| 9 | comptime { | 9 | comptime { |
| 10 | if (builtin.os.tag == .windows) { | 10 | if (builtin.os.tag == .windows) { |
| 11 | switch (arch) { | 11 | switch (arch) { |
| 12 | .i386 => { | 12 | .i386 => { |
| 13 | @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage }); | 13 | @export(__umodti3, .{ .name = "__umodti3", .linkage = common.linkage }); |
| 14 | }, | 14 | }, |
| 15 | .x86_64 => { | 15 | .x86_64 => { |
| 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI | 16 | // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI |
| 17 | // that LLVM expects compiler-rt to have. | 17 | // that LLVM expects compiler-rt to have. |
| 18 | @export(__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = linkage }); | 18 | @export(__umodti3_windows_x86_64, .{ .name = "__umodti3", .linkage = common.linkage }); |
| 19 | }, | 19 | }, |
| 20 | else => {}, | 20 | else => {}, |
| 21 | } | 21 | } |
| 22 | if (arch.isAARCH64()) { | 22 | if (arch.isAARCH64()) { |
| 23 | @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage }); | 23 | @export(__umodti3, .{ .name = "__umodti3", .linkage = common.linkage }); |
| 24 | } | 24 | } |
| 25 | } else { | 25 | } else { |
| 26 | @export(__umodti3, .{ .name = "__umodti3", .linkage = linkage }); | 26 | @export(__umodti3, .{ .name = "__umodti3", .linkage = common.linkage }); |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | pub fn __umodti3(a: u128, b: u128) callconv(.C) u128 { | 30 | pub fn __umodti3(a: u128, b: u128) callconv(.C) u128 { |
| 31 | @setRuntimeSafety(builtin.is_test); | ||
| 32 | var r: u128 = undefined; | 31 | var r: u128 = undefined; |
| 33 | _ = udivmod(u128, a, b, &r); | 32 | _ = udivmod(u128, a, b, &r); |
| 34 | return r; | 33 | return r; |
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | const v128 = std.meta.Vector(2, u64); | 36 | const v128 = std.meta.Vector(2, u64); |
| 38 | pub fn __umodti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { | 37 | |
| 39 | return @bitCast(v128, @call(.{ .modifier = .always_inline }, __umodti3, .{ | 38 | fn __umodti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { |
| 40 | @bitCast(u128, a), | 39 | var r: u128 = undefined; |
| 41 | @bitCast(u128, b), | 40 | _ = udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), &r); |
| 42 | })); | 41 | return @bitCast(v128, r); |
| 43 | } | 42 | } |