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 @@...@@ -1,5 +1,6 @@
1const udivmod = @import("udivmod.zig").udivmod;1const udivmod = @import("udivmod.zig").udivmod;
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const compiler_rt = @import("index.zig");
34
4pub extern fn __divti3(a: i128, b: i128) i128 {5pub extern fn __divti3(a: i128, b: i128) i128 {
5 @setRuntimeSafety(builtin.is_test);6 @setRuntimeSafety(builtin.is_test);
...@@ -14,3 +15,12 @@ pub extern fn __divti3(a: i128, b: i128) i128 {...@@ -14,3 +15,12 @@ pub extern fn __divti3(a: i128, b: i128) i128 {
14 const s = s_a ^ s_b;15 const s = s_a ^ s_b;
15 return (i128(r) ^ s) -% s;16 return (i128(r) ^ s) -% s;
16}17}
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 {...@@ -38,9 +38,6 @@ comptime {
38 @export("__umoddi3", __umoddi3, linkage);38 @export("__umoddi3", __umoddi3, linkage);
39 @export("__udivmodsi4", __udivmodsi4, linkage);39 @export("__udivmodsi4", __udivmodsi4, linkage);
4040
41 @export("__divti3", @import("divti3.zig").__divti3, linkage);
42 @export("__muloti4", @import("muloti4.zig").__muloti4, linkage);
43
44 if (isArmArch()) {41 if (isArmArch()) {
45 @export("__aeabi_uldivmod", __aeabi_uldivmod, linkage);42 @export("__aeabi_uldivmod", __aeabi_uldivmod, linkage);
46 @export("__aeabi_uidivmod", __aeabi_uidivmod, linkage);43 @export("__aeabi_uidivmod", __aeabi_uidivmod, linkage);
...@@ -61,6 +58,8 @@ comptime {...@@ -61,6 +58,8 @@ comptime {
61 @export("__chkstk", __chkstk, strong_linkage);58 @export("__chkstk", __chkstk, strong_linkage);
62 @export("___chkstk_ms", ___chkstk_ms, linkage);59 @export("___chkstk_ms", ___chkstk_ms, linkage);
63 }60 }
61 @export("__divti3", @import("divti3.zig").__divti3_windows_x86_64, linkage);
62 @export("__muloti4", @import("muloti4.zig").__muloti4_windows_x86_64, linkage);
64 @export("__udivti3", @import("udivti3.zig").__udivti3_windows_x86_64, linkage);63 @export("__udivti3", @import("udivti3.zig").__udivti3_windows_x86_64, linkage);
65 @export("__udivmodti4", @import("udivmodti4.zig").__udivmodti4_windows_x86_64, linkage);64 @export("__udivmodti4", @import("udivmodti4.zig").__udivmodti4_windows_x86_64, linkage);
66 @export("__umodti3", @import("umodti3.zig").__umodti3_windows_x86_64, linkage);65 @export("__umodti3", @import("umodti3.zig").__umodti3_windows_x86_64, linkage);
...@@ -68,6 +67,8 @@ comptime {...@@ -68,6 +67,8 @@ comptime {
68 else => {},67 else => {},
69 }68 }
70 } else {69 } else {
70 @export("__divti3", @import("divti3.zig").__divti3, linkage);
71 @export("__muloti4", @import("muloti4.zig").__muloti4, linkage);
71 @export("__udivti3", @import("udivti3.zig").__udivti3, linkage);72 @export("__udivti3", @import("udivti3.zig").__udivti3, linkage);
72 @export("__udivmodti4", @import("udivmodti4.zig").__udivmodti4, linkage);73 @export("__udivmodti4", @import("udivmodti4.zig").__udivmodti4, linkage);
73 @export("__umodti3", @import("umodti3.zig").__umodti3, linkage);74 @export("__umodti3", @import("umodti3.zig").__umodti3, linkage);
std/special/compiler_rt/muloti4.zig+10
...@@ -1,5 +1,6 @@...@@ -1,5 +1,6 @@
1const udivmod = @import("udivmod.zig").udivmod;1const udivmod = @import("udivmod.zig").udivmod;
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const compiler_rt = @import("index.zig");
34
4pub extern fn __muloti4(a: i128, b: i128, overflow: *c_int) i128 {5pub extern fn __muloti4(a: i128, b: i128, overflow: *c_int) i128 {
5 @setRuntimeSafety(builtin.is_test);6 @setRuntimeSafety(builtin.is_test);
...@@ -43,3 +44,12 @@ pub extern fn __muloti4(a: i128, b: i128, overflow: *c_int) i128 {...@@ -43,3 +44,12 @@ pub extern fn __muloti4(a: i128, b: i128, overflow: *c_int) i128 {
4344
44 return r;45 return r;
45}46}
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;...@@ -4,7 +4,7 @@ const assert = @import("std").debug.assert;
4fn test__muloti4(a: i128, b: i128, expected: i128, expected_overflow: c_int) void {4fn test__muloti4(a: i128, b: i128, expected: i128, expected_overflow: c_int) void {
5 var overflow: c_int = undefined;5 var overflow: c_int = undefined;
6 const x = __muloti4(a, b, &overflow);6 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));
8}8}
99
10test "muloti4" {10test "muloti4" {