diff --git a/lib/compiler_rt/divti3.zig b/lib/compiler_rt/divti3.zig index cd38d7a93e..31302aab4d 100644 --- a/lib/compiler_rt/divti3.zig +++ b/lib/compiler_rt/divti3.zig @@ -7,21 +7,8 @@ const common = @import("common.zig"); pub const panic = common.panic; comptime { - if (builtin.os.tag == .windows) { - switch (arch) { - .x86 => { - @export(__divti3, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility }); - }, - .x86_64 => { - // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI - // that LLVM expects compiler-rt to have. - @export(__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility }); - }, - else => {}, - } - if (arch.isAARCH64()) { - @export(__divti3, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility }); - } + if (common.want_windows_v2u64_abi) { + @export(__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility }); } else { @export(__divti3, .{ .name = "__divti3", .linkage = common.linkage, .visibility = common.visibility }); } @@ -31,7 +18,7 @@ pub fn __divti3(a: i128, b: i128) callconv(.C) i128 { return div(a, b); } -const v128 = @import("std").meta.Vector(2, u64); +const v128 = @Vector(2, u64); fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { return @bitCast(v128, div(@bitCast(i128, a), @bitCast(i128, b))); diff --git a/lib/compiler_rt/fixunshfti.zig b/lib/compiler_rt/fixunshfti.zig index f7dcb3f790..0c67d4998a 100644 --- a/lib/compiler_rt/fixunshfti.zig +++ b/lib/compiler_rt/fixunshfti.zig @@ -16,7 +16,7 @@ pub fn __fixunshfti(a: f16) callconv(.C) u128 { return floatToInt(u128, a); } -const v2u64 = @import("std").meta.Vector(2, u64); +const v2u64 = @Vector(2, u64); fn __fixunshfti_windows_x86_64(a: f16) callconv(.C) v2u64 { return @bitCast(v2u64, floatToInt(u128, a)); diff --git a/lib/zig.h b/lib/zig.h index b600e0bfc7..c039f3f52f 100644 --- a/lib/zig.h +++ b/lib/zig.h @@ -1341,30 +1341,26 @@ static inline zig_i128 zig_sub_i128(zig_i128 lhs, zig_i128 rhs) { return res; } -// TODO: Implement -static zig_i128 zig_div_trunc_i128(zig_i128 lhs, zig_i128 rhs) { - -} - -// TODO: Implement -zig_extern zig_u128 __udivmodti4(zig_u128 lhs, zig_u128 rhs, zig_u128* rem); +zig_extern zig_u128 __udivti3(zig_u128 lhs, zig_u128 rhs); static zig_u128 zig_div_trunc_u128(zig_u128 lhs, zig_u128 rhs) { - zig_u128 rem; - return __udivmodti4(lhs, rhs, &rem); + return __udivti3(lhs, rhs); }; -// TODO: Implement -zig_extern zig_i128 __modti3(zig_i128 lhs, zig_i128 rhs); -static zig_i128 zig_rem_i128(zig_i128 lhs, zig_i128 rhs) { - return __modti3(lhs, rhs); -} +zig_extern zig_i128 __divti3(zig_i128 lhs, zig_i128 rhs); +static zig_i128 zig_div_trunc_i128(zig_i128 lhs, zig_i128 rhs) { + return __divti3(lhs, rhs); +}; -// TODO: Implement zig_extern zig_u128 __umodti3(zig_u128 lhs, zig_u128 rhs); static zig_u128 zig_rem_u128(zig_u128 lhs, zig_u128 rhs) { return __umodti3(lhs, rhs); } +zig_extern zig_i128 __modti3(zig_i128 lhs, zig_i128 rhs); +static zig_i128 zig_rem_i128(zig_i128 lhs, zig_i128 rhs) { + return __modti3(lhs, rhs); +} + static inline zig_i128 zig_mod_i128(zig_i128 lhs, zig_i128 rhs) { zig_i128 rem = zig_rem_i128(lhs, rhs); return zig_add_i128(rem, (((lhs.hi ^ rhs.hi) & rem.hi) < zig_as_i64(0) ? rhs : zig_as_i128(0, 0))); @@ -1669,6 +1665,8 @@ static inline zig_i128 zig_bit_reverse_i128(zig_i128 val, zig_u8 bits) { #define __builtin_nanf(str) nanf(str) #define __builtin_nanl(str) nanl(str) #define __builtin_inf() zig_msvc_flt_inf +#define __builtin_inff() zig_msvc_flt_inff +#define __builtin_infl() zig_msvc_flt_infl #endif #define zig_has_f16 1