Commit cf39652500

mlugg <mlugg@mlugg.co.uk>
2024-10-16 18:13:25
compiler_rt: remove bogus tests
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.
1 parent 289b2f8
Changed files (3)
lib/compiler_rt/int.zig
@@ -10,7 +10,6 @@ const is_test = builtin.is_test;
 const common = @import("common.zig");
 const udivmod = @import("udivmod.zig").udivmod;
 const __divti3 = @import("divti3.zig").__divti3;
-const arm = @import("arm.zig");
 
 pub const panic = common.panic;
 
@@ -102,25 +101,6 @@ test "test_divmoddi4" {
     }
 }
 
-fn test_one_aeabi_ldivmod(a: i64, b: i64, expected_q: i64, expected_r: i64) !void {
-    const LdivmodRes = extern struct {
-        q: i64, // r1:r0
-        r: i64, // r3:r2
-    };
-    const actualIdivmod = @as(*const fn (a: i64, b: i64) callconv(.AAPCS) LdivmodRes, @ptrCast(&arm.__aeabi_ldivmod));
-    const arm_res = actualIdivmod(a, b);
-    try testing.expectEqual(expected_q, arm_res.q);
-    try testing.expectEqual(expected_r, arm_res.r);
-}
-
-test "arm.__aeabi_ldivmod" {
-    if (!builtin.cpu.arch.isARM()) return error.SkipZigTest;
-
-    for (cases__divmodsi4) |case| {
-        try test_one_aeabi_ldivmod(case[0], case[1], case[2], case[3]);
-    }
-}
-
 pub fn __udivmoddi4(a: u64, b: u64, maybe_rem: ?*u64) callconv(.C) u64 {
     return udivmod(u64, a, b, maybe_rem);
 }
@@ -261,25 +241,6 @@ test "test_divmodsi4" {
     }
 }
 
-fn test_one_aeabi_idivmod(a: i32, b: i32, expected_q: i32, expected_r: i32) !void {
-    const IdivmodRes = extern struct {
-        q: i32, // r0
-        r: i32, // r1
-    };
-    const actualIdivmod = @as(*const fn (a: i32, b: i32) callconv(.AAPCS) IdivmodRes, @ptrCast(&arm.__aeabi_idivmod));
-    const arm_res = actualIdivmod(a, b);
-    try testing.expectEqual(expected_q, arm_res.q);
-    try testing.expectEqual(expected_r, arm_res.r);
-}
-
-test "arm.__aeabi_idivmod" {
-    if (!builtin.cpu.arch.isARM()) return error.SkipZigTest;
-
-    for (cases__divmodsi4) |case| {
-        try test_one_aeabi_idivmod(case[0], case[1], case[2], case[3]);
-    }
-}
-
 pub fn __udivmodsi4(a: u32, b: u32, rem: *u32) callconv(.C) u32 {
     const d = __udivsi3(a, b);
     rem.* = @bitCast(@as(i32, @bitCast(a)) -% (@as(i32, @bitCast(d)) * @as(i32, @bitCast(b))));
lib/compiler_rt/udivmoddi4_test.zig
@@ -3,7 +3,6 @@
 const testing = @import("std").testing;
 const builtin = @import("builtin");
 const __udivmoddi4 = @import("int.zig").__udivmoddi4;
-const __aeabi_uldivmod = @import("arm.zig").__aeabi_uldivmod;
 
 fn test__udivmoddi4(a: u64, b: u64, expected_q: u64, expected_r: u64) !void {
     var r: u64 = undefined;
@@ -18,26 +17,6 @@ test "udivmoddi4" {
     }
 }
 
-const ARMRes = extern struct {
-    q: u64, // r1:r0
-    r: u64, // r3:r2
-};
-
-fn test__aeabi_uldivmod(a: u64, b: u64, expected_q: u64, expected_r: u64) !void {
-    const actualUldivmod = @as(*const fn (a: u64, b: u64) callconv(.AAPCS) ARMRes, @ptrCast(&__aeabi_uldivmod));
-    const arm_res = actualUldivmod(a, b);
-    try testing.expectEqual(expected_q, arm_res.q);
-    try testing.expectEqual(expected_r, arm_res.r);
-}
-
-test "arm.__aeabi_uldivmod" {
-    if (!builtin.cpu.arch.isARM()) return error.SkipZigTest;
-
-    for (cases) |case| {
-        try test__aeabi_uldivmod(case[0], case[1], case[2], case[3]);
-    }
-}
-
 const cases = [_][4]u64{
     [_]u64{0x0000000000000000, 0x0000000000000001, 0x0000000000000000, 0x0000000000000000},
     [_]u64{0x0000000000000000, 0x0000000000000002, 0x0000000000000000, 0x0000000000000000},
lib/compiler_rt/udivmodsi4_test.zig
@@ -2,27 +2,18 @@
 // zig fmt: off
 const testing = @import("std").testing;
 const builtin = @import("builtin");
-const __aeabi_uidivmod = @import("arm.zig").__aeabi_uidivmod;
+const __udivmodsi4 = @import("int.zig").__udivmodsi4;
 
-const ARMRes = extern struct {
-    q: u32, // r0
-    r: u32, // r1
-};
-
-fn test__aeabi_uidivmod(a: u32, b: u32, expected_q: u32, expected_r: u32) !void {
-    const actualUidivmod = @as(*const fn (a: u32, b: u32) callconv(.AAPCS) ARMRes, @ptrCast(&__aeabi_uidivmod));
-    const arm_res = actualUidivmod(a, b);
-    try testing.expectEqual(expected_q, arm_res.q);
-    try testing.expectEqual(expected_r, arm_res.r);
+fn test__udivmodsi4(a: u32, b: u32, expected_q: u32, expected_r: u32) !void {
+    var r: u32 = undefined;
+    const q = __udivmodsi4(a, b, &r);
+    try testing.expectEqual(expected_q, q);
+    try testing.expectEqual(expected_r, r);
 }
 
-test "arm.__aeabi_uidivmod" {
-    if (!builtin.cpu.arch.isARM()) return error.SkipZigTest;
-
-    var i: i32 = 0;
+test "udivmodsi4" {
     for (cases) |case| {
-        try test__aeabi_uidivmod(case[0], case[1], case[2], case[3]);
-        i+=1;
+        try test__udivmodsi4(case[0], case[1], case[2], case[3]);
     }
 }