| author | |
| committer | |
| log | cf39652500df07d33470d89ba96a97463beff986 |
| tree | 47ba5af734da1fb6889b85adf871f869a696e962 |
| parent | 289b2f82c3026ef17047dbe565693b15e2b84c81 |
| signature |
These only worked before because our lowering of the `AAPCS` calling
convention was incorrect in a way which happened to match the ABI of
these functions. The tests aren't actually very helpful -- there are
already tests for `divmoddi4` etc -- so rather than using inline asm on
the caller side to match the ABI, we just delete these two tests.
We were for some reason missing a direct test for `__udivmodsi4`, so one
has been added.3 files changed, 8 insertions(+), 77 deletions(-)
lib/compiler_rt/int.zig-39| ... | @@ -10,7 +10,6 @@ const is_test = builtin.is_test; | ... | @@ -10,7 +10,6 @@ const is_test = builtin.is_test; |
| 10 | const common = @import("common.zig"); | 10 | const common = @import("common.zig"); |
| 11 | const udivmod = @import("udivmod.zig").udivmod; | 11 | const udivmod = @import("udivmod.zig").udivmod; |
| 12 | const __divti3 = @import("divti3.zig").__divti3; | 12 | const __divti3 = @import("divti3.zig").__divti3; |
| 13 | const arm = @import("arm.zig"); | ||
| 14 | 13 | ||
| 15 | pub const panic = common.panic; | 14 | pub const panic = common.panic; |
| 16 | 15 | ||
| ... | @@ -102,25 +101,6 @@ test "test_divmoddi4" { | ... | @@ -102,25 +101,6 @@ test "test_divmoddi4" { |
| 102 | } | 101 | } |
| 103 | } | 102 | } |
| 104 | 103 | ||
| 105 | fn test_one_aeabi_ldivmod(a: i64, b: i64, expected_q: i64, expected_r: i64) !void { | ||
| 106 | const LdivmodRes = extern struct { | ||
| 107 | q: i64, // r1:r0 | ||
| 108 | r: i64, // r3:r2 | ||
| 109 | }; | ||
| 110 | const actualIdivmod = @as(*const fn (a: i64, b: i64) callconv(.AAPCS) LdivmodRes, @ptrCast(&arm.__aeabi_ldivmod)); | ||
| 111 | const arm_res = actualIdivmod(a, b); | ||
| 112 | try testing.expectEqual(expected_q, arm_res.q); | ||
| 113 | try testing.expectEqual(expected_r, arm_res.r); | ||
| 114 | } | ||
| 115 | |||
| 116 | test "arm.__aeabi_ldivmod" { | ||
| 117 | if (!builtin.cpu.arch.isARM()) return error.SkipZigTest; | ||
| 118 | |||
| 119 | for (cases__divmodsi4) |case| { | ||
| 120 | try test_one_aeabi_ldivmod(case[0], case[1], case[2], case[3]); | ||
| 121 | } | ||
| 122 | } | ||
| 123 | |||
| 124 | pub fn __udivmoddi4(a: u64, b: u64, maybe_rem: ?*u64) callconv(.C) u64 { | 104 | pub fn __udivmoddi4(a: u64, b: u64, maybe_rem: ?*u64) callconv(.C) u64 { |
| 125 | return udivmod(u64, a, b, maybe_rem); | 105 | return udivmod(u64, a, b, maybe_rem); |
| 126 | } | 106 | } |
| ... | @@ -261,25 +241,6 @@ test "test_divmodsi4" { | ... | @@ -261,25 +241,6 @@ test "test_divmodsi4" { |
| 261 | } | 241 | } |
| 262 | } | 242 | } |
| 263 | 243 | ||
| 264 | fn test_one_aeabi_idivmod(a: i32, b: i32, expected_q: i32, expected_r: i32) !void { | ||
| 265 | const IdivmodRes = extern struct { | ||
| 266 | q: i32, // r0 | ||
| 267 | r: i32, // r1 | ||
| 268 | }; | ||
| 269 | const actualIdivmod = @as(*const fn (a: i32, b: i32) callconv(.AAPCS) IdivmodRes, @ptrCast(&arm.__aeabi_idivmod)); | ||
| 270 | const arm_res = actualIdivmod(a, b); | ||
| 271 | try testing.expectEqual(expected_q, arm_res.q); | ||
| 272 | try testing.expectEqual(expected_r, arm_res.r); | ||
| 273 | } | ||
| 274 | |||
| 275 | test "arm.__aeabi_idivmod" { | ||
| 276 | if (!builtin.cpu.arch.isARM()) return error.SkipZigTest; | ||
| 277 | |||
| 278 | for (cases__divmodsi4) |case| { | ||
| 279 | try test_one_aeabi_idivmod(case[0], case[1], case[2], case[3]); | ||
| 280 | } | ||
| 281 | } | ||
| 282 | |||
| 283 | pub fn __udivmodsi4(a: u32, b: u32, rem: *u32) callconv(.C) u32 { | 244 | pub fn __udivmodsi4(a: u32, b: u32, rem: *u32) callconv(.C) u32 { |
| 284 | const d = __udivsi3(a, b); | 245 | const d = __udivsi3(a, b); |
| 285 | rem.* = @bitCast(@as(i32, @bitCast(a)) -% (@as(i32, @bitCast(d)) * @as(i32, @bitCast(b)))); | 246 | rem.* = @bitCast(@as(i32, @bitCast(a)) -% (@as(i32, @bitCast(d)) * @as(i32, @bitCast(b)))); |
lib/compiler_rt/udivmoddi4_test.zig-21| ... | @@ -3,7 +3,6 @@ | ... | @@ -3,7 +3,6 @@ |
| 3 | const testing = @import("std").testing; | 3 | const testing = @import("std").testing; |
| 4 | const builtin = @import("builtin"); | 4 | const builtin = @import("builtin"); |
| 5 | const __udivmoddi4 = @import("int.zig").__udivmoddi4; | 5 | const __udivmoddi4 = @import("int.zig").__udivmoddi4; |
| 6 | const __aeabi_uldivmod = @import("arm.zig").__aeabi_uldivmod; | ||
| 7 | 6 | ||
| 8 | fn test__udivmoddi4(a: u64, b: u64, expected_q: u64, expected_r: u64) !void { | 7 | fn test__udivmoddi4(a: u64, b: u64, expected_q: u64, expected_r: u64) !void { |
| 9 | var r: u64 = undefined; | 8 | var r: u64 = undefined; |
| ... | @@ -18,26 +17,6 @@ test "udivmoddi4" { | ... | @@ -18,26 +17,6 @@ test "udivmoddi4" { |
| 18 | } | 17 | } |
| 19 | } | 18 | } |
| 20 | 19 | ||
| 21 | const ARMRes = extern struct { | ||
| 22 | q: u64, // r1:r0 | ||
| 23 | r: u64, // r3:r2 | ||
| 24 | }; | ||
| 25 | |||
| 26 | fn test__aeabi_uldivmod(a: u64, b: u64, expected_q: u64, expected_r: u64) !void { | ||
| 27 | const actualUldivmod = @as(*const fn (a: u64, b: u64) callconv(.AAPCS) ARMRes, @ptrCast(&__aeabi_uldivmod)); | ||
| 28 | const arm_res = actualUldivmod(a, b); | ||
| 29 | try testing.expectEqual(expected_q, arm_res.q); | ||
| 30 | try testing.expectEqual(expected_r, arm_res.r); | ||
| 31 | } | ||
| 32 | |||
| 33 | test "arm.__aeabi_uldivmod" { | ||
| 34 | if (!builtin.cpu.arch.isARM()) return error.SkipZigTest; | ||
| 35 | |||
| 36 | for (cases) |case| { | ||
| 37 | try test__aeabi_uldivmod(case[0], case[1], case[2], case[3]); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | const cases = [_][4]u64{ | 20 | const cases = [_][4]u64{ |
| 42 | [_]u64{0x0000000000000000, 0x0000000000000001, 0x0000000000000000, 0x0000000000000000}, | 21 | [_]u64{0x0000000000000000, 0x0000000000000001, 0x0000000000000000, 0x0000000000000000}, |
| 43 | [_]u64{0x0000000000000000, 0x0000000000000002, 0x0000000000000000, 0x0000000000000000}, | 22 | [_]u64{0x0000000000000000, 0x0000000000000002, 0x0000000000000000, 0x0000000000000000}, |
lib/compiler_rt/udivmodsi4_test.zig+8-17| ... | @@ -2,27 +2,18 @@ | ... | @@ -2,27 +2,18 @@ |
| 2 | // zig fmt: off | 2 | // zig fmt: off |
| 3 | const testing = @import("std").testing; | 3 | const testing = @import("std").testing; |
| 4 | const builtin = @import("builtin"); | 4 | const builtin = @import("builtin"); |
| 5 | const __aeabi_uidivmod = @import("arm.zig").__aeabi_uidivmod; | 5 | const __udivmodsi4 = @import("int.zig").__udivmodsi4; |
| 6 | 6 | ||
| 7 | const ARMRes = extern struct { | 7 | fn test__udivmodsi4(a: u32, b: u32, expected_q: u32, expected_r: u32) !void { |
| 8 | q: u32, // r0 | 8 | var r: u32 = undefined; |
| 9 | r: u32, // r1 | 9 | const q = __udivmodsi4(a, b, &r); |
| 10 | }; | 10 | try testing.expectEqual(expected_q, q); |
| 11 | 11 | try testing.expectEqual(expected_r, r); | |
| 12 | fn test__aeabi_uidivmod(a: u32, b: u32, expected_q: u32, expected_r: u32) !void { | ||
| 13 | const actualUidivmod = @as(*const fn (a: u32, b: u32) callconv(.AAPCS) ARMRes, @ptrCast(&__aeabi_uidivmod)); | ||
| 14 | const arm_res = actualUidivmod(a, b); | ||
| 15 | try testing.expectEqual(expected_q, arm_res.q); | ||
| 16 | try testing.expectEqual(expected_r, arm_res.r); | ||
| 17 | } | 12 | } |
| 18 | 13 | ||
| 19 | test "arm.__aeabi_uidivmod" { | 14 | test "udivmodsi4" { |
| 20 | if (!builtin.cpu.arch.isARM()) return error.SkipZigTest; | ||
| 21 | |||
| 22 | var i: i32 = 0; | ||
| 23 | for (cases) |case| { | 15 | for (cases) |case| { |
| 24 | try test__aeabi_uidivmod(case[0], case[1], case[2], case[3]); | 16 | try test__udivmodsi4(case[0], case[1], case[2], case[3]); |
| 25 | i+=1; | ||
| 26 | } | 17 | } |
| 27 | } | 18 | } |
| 28 | 19 |