Commit 401de6dd2f

Jacob Young <jacobly0@users.noreply.github.com>
2023-08-19 07:31:33
compiler_rt: fix arm hard-float f16 abi
Closes #16848
1 parent 17e3fcc
Changed files (6)
lib/compiler_rt/common.zig
@@ -84,6 +84,13 @@ pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?
 /// here in compiler-rt.
 pub fn F16T(comptime other_type: type) type {
     return switch (builtin.cpu.arch) {
+        .arm, .armeb, .thumb, .thumbeb => if (std.Target.arm.featureSetHas(builtin.cpu.features, .has_v8))
+            switch (builtin.abi.floatAbi()) {
+                .soft => u16,
+                .hard => f16,
+            }
+        else
+            u16,
         .aarch64, .aarch64_be, .aarch64_32 => f16,
         .riscv64 => if (builtin.zig_backend == .stage1) u16 else f16,
         .x86, .x86_64 => if (builtin.target.isDarwin()) switch (other_type) {
lib/std/target.zig
@@ -1473,7 +1473,6 @@ pub const Target = struct {
     pub const FloatAbi = enum {
         hard,
         soft,
-        soft_fp,
     };
 
     pub inline fn getFloatAbi(self: Target) FloatAbi {
test/behavior/usingnamespace/import_segregation.zig
@@ -12,11 +12,6 @@ test "no clobbering happened" {
         return error.SkipZigTest;
     }
 
-    if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isARM()) {
-        // https://github.com/ziglang/zig/issues/16848
-        return error.SkipZigTest;
-    }
-
     @This().foo_function();
     @This().bar_function();
     try expect(@This().saw_foo_function);
test/behavior/floatop.zig
@@ -722,11 +722,6 @@ test "@floor f128" {
     if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
     if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest;
 
-    if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isARM()) {
-        // https://github.com/ziglang/zig/issues/16848
-        return error.SkipZigTest;
-    }
-
     try testFloorLegacy(f128, 12.0);
     try comptime testFloorLegacy(f128, 12.0);
 }
test/behavior/muladd.zig
@@ -57,11 +57,6 @@ test "@mulAdd f80" {
     if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
     if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest;
 
-    if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isARM()) {
-        // https://github.com/ziglang/zig/issues/16848
-        return error.SkipZigTest;
-    }
-
     try comptime testMulAdd80();
     try testMulAdd80();
 }
@@ -81,11 +76,6 @@ test "@mulAdd f128" {
     if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
     if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest;
 
-    if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isARM()) {
-        // https://github.com/ziglang/zig/issues/16848
-        return error.SkipZigTest;
-    }
-
     try comptime testMulAdd128();
     try testMulAdd128();
 }
test/behavior/widening.zig
@@ -66,11 +66,6 @@ test "float widening f16 to f128" {
     if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
     if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
 
-    if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isARM()) {
-        // https://github.com/ziglang/zig/issues/16848
-        return error.SkipZigTest;
-    }
-
     var x: f16 = 12.34;
     var y: f128 = x;
     try expect(x == y);