authorgravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2018-06-14 21:18:36+12:00
committergravatar for marc@tiehu.isMarc Tiehuis <marc@tiehu.is> 2018-06-14 21:18:36+12:00
loga369d69c5144c2a4186e4f8d20bfda0c3f86605a
tree22a69c778dbb066c972705ca3153b05eb78f4c7f
parent911014051487e83177689893e57491b86e72589b

Add windows x86_64 i128 abi workaround


4 files changed, 25 insertions(+), 4 deletions(-)

std/special/compiler_rt/divti3.zig+10
......@@ -1,5 +1,6 @@
11const udivmod = @import("udivmod.zig").udivmod;
22const builtin = @import("builtin");
3const compiler_rt = @import("index.zig");
34
45pub extern fn __divti3(a: i128, b: i128) i128 {
56 @setRuntimeSafety(builtin.is_test);
......@@ -14,3 +15,12 @@ pub extern fn __divti3(a: i128, b: i128) i128 {
1415 const s = s_a ^ s_b;
1516 return (i128(r) ^ s) -% s;
1617}
18
19pub extern fn __divti3_windows_x86_64(a: *const i128, b: *const i128) void {
20 @setRuntimeSafety(builtin.is_test);
21 compiler_rt.setXmm0(i128, __divti3(a.*, b.*));
22}
23
24test "import divti3" {
25 _ = @import("divti3_test.zig");
26}
std/special/compiler_rt/index.zig+4-3
......@@ -38,9 +38,6 @@ comptime {
3838 @export("__umoddi3", __umoddi3, linkage);
3939 @export("__udivmodsi4", __udivmodsi4, linkage);
4040
41 @export("__divti3", @import("divti3.zig").__divti3, linkage);
42 @export("__muloti4", @import("muloti4.zig").__muloti4, linkage);
43
4441 if (isArmArch()) {
4542 @export("__aeabi_uldivmod", __aeabi_uldivmod, linkage);
4643 @export("__aeabi_uidivmod", __aeabi_uidivmod, linkage);
......@@ -61,6 +58,8 @@ comptime {
6158 @export("__chkstk", __chkstk, strong_linkage);
6259 @export("___chkstk_ms", ___chkstk_ms, linkage);
6360 }
61 @export("__divti3", @import("divti3.zig").__divti3_windows_x86_64, linkage);
62 @export("__muloti4", @import("muloti4.zig").__muloti4_windows_x86_64, linkage);
6463 @export("__udivti3", @import("udivti3.zig").__udivti3_windows_x86_64, linkage);
6564 @export("__udivmodti4", @import("udivmodti4.zig").__udivmodti4_windows_x86_64, linkage);
6665 @export("__umodti3", @import("umodti3.zig").__umodti3_windows_x86_64, linkage);
......@@ -68,6 +67,8 @@ comptime {
6867 else => {},
6968 }
7069 } else {
70 @export("__divti3", @import("divti3.zig").__divti3, linkage);
71 @export("__muloti4", @import("muloti4.zig").__muloti4, linkage);
7172 @export("__udivti3", @import("udivti3.zig").__udivti3, linkage);
7273 @export("__udivmodti4", @import("udivmodti4.zig").__udivmodti4, linkage);
7374 @export("__umodti3", @import("umodti3.zig").__umodti3, linkage);
std/special/compiler_rt/muloti4.zig+10
......@@ -1,5 +1,6 @@
11const udivmod = @import("udivmod.zig").udivmod;
22const builtin = @import("builtin");
3const compiler_rt = @import("index.zig");
34
45pub extern fn __muloti4(a: i128, b: i128, overflow: *c_int) i128 {
56 @setRuntimeSafety(builtin.is_test);
......@@ -43,3 +44,12 @@ pub extern fn __muloti4(a: i128, b: i128, overflow: *c_int) i128 {
4344
4445 return r;
4546}
47
48pub extern fn __muloti4_windows_x86_64(a: *const i128, b: *const i128, overflow: *c_int) void {
49 @setRuntimeSafety(builtin.is_test);
50 compiler_rt.setXmm0(i128, __muloti4(a.*, b.*, overflow));
51}
52
53test "import muloti4" {
54 _ = @import("muloti4_test.zig");
55}
std/special/compiler_rt/muloti4_test.zig+1-1
......@@ -4,7 +4,7 @@ const assert = @import("std").debug.assert;
44fn test__muloti4(a: i128, b: i128, expected: i128, expected_overflow: c_int) void {
55 var overflow: c_int = undefined;
66 const x = __muloti4(a, b, &overflow);
7 assert(overflow == expected_overflow and (overflow != 0 or x == expected));
7 assert(overflow == expected_overflow and (expected_overflow != 0 or x == expected));
88}
99
1010test "muloti4" {