authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-08-19 01:31:33-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-09-19 09:37:53-07:00
log401de6dd2f3137569bf7a03f596ffe51ce343169
treef1668c6ce2b4cf665c76c460b9250b8179a6ff5d
parent17e3fcc3a5accb31b9ea15f64bd9e968245000c2

compiler_rt: fix arm hard-float f16 abi

Closes #16848

6 files changed, 7 insertions(+), 26 deletions(-)

lib/compiler_rt/common.zig+7
...@@ -84,6 +84,13 @@ pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?...@@ -84,6 +84,13 @@ pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?
84/// here in compiler-rt.84/// here in compiler-rt.
85pub fn F16T(comptime other_type: type) type {85pub fn F16T(comptime other_type: type) type {
86 return switch (builtin.cpu.arch) {86 return switch (builtin.cpu.arch) {
87 .arm, .armeb, .thumb, .thumbeb => if (std.Target.arm.featureSetHas(builtin.cpu.features, .has_v8))
88 switch (builtin.abi.floatAbi()) {
89 .soft => u16,
90 .hard => f16,
91 }
92 else
93 u16,
87 .aarch64, .aarch64_be, .aarch64_32 => f16,94 .aarch64, .aarch64_be, .aarch64_32 => f16,
88 .riscv64 => if (builtin.zig_backend == .stage1) u16 else f16,95 .riscv64 => if (builtin.zig_backend == .stage1) u16 else f16,
89 .x86, .x86_64 => if (builtin.target.isDarwin()) switch (other_type) {96 .x86, .x86_64 => if (builtin.target.isDarwin()) switch (other_type) {
lib/std/target.zig-1
...@@ -1473,7 +1473,6 @@ pub const Target = struct {...@@ -1473,7 +1473,6 @@ pub const Target = struct {
1473 pub const FloatAbi = enum {1473 pub const FloatAbi = enum {
1474 hard,1474 hard,
1475 soft,1475 soft,
1476 soft_fp,
1477 };1476 };
14781477
1479 pub inline fn getFloatAbi(self: Target) FloatAbi {1478 pub inline fn getFloatAbi(self: Target) FloatAbi {
test/behavior/floatop.zig-5
...@@ -722,11 +722,6 @@ test "@floor f128" {...@@ -722,11 +722,6 @@ test "@floor f128" {
722 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;722 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
723 if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest;723 if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest;
724724
725 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isARM()) {
726 // https://github.com/ziglang/zig/issues/16848
727 return error.SkipZigTest;
728 }
729
730 try testFloorLegacy(f128, 12.0);725 try testFloorLegacy(f128, 12.0);
731 try comptime testFloorLegacy(f128, 12.0);726 try comptime testFloorLegacy(f128, 12.0);
732}727}
test/behavior/muladd.zig-10
...@@ -57,11 +57,6 @@ test "@mulAdd f80" {...@@ -57,11 +57,6 @@ test "@mulAdd f80" {
57 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;57 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
58 if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest;58 if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest;
5959
60 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isARM()) {
61 // https://github.com/ziglang/zig/issues/16848
62 return error.SkipZigTest;
63 }
64
65 try comptime testMulAdd80();60 try comptime testMulAdd80();
66 try testMulAdd80();61 try testMulAdd80();
67}62}
...@@ -81,11 +76,6 @@ test "@mulAdd f128" {...@@ -81,11 +76,6 @@ test "@mulAdd f128" {
81 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;76 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
82 if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest;77 if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest;
8378
84 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isARM()) {
85 // https://github.com/ziglang/zig/issues/16848
86 return error.SkipZigTest;
87 }
88
89 try comptime testMulAdd128();79 try comptime testMulAdd128();
90 try testMulAdd128();80 try testMulAdd128();
91}81}
test/behavior/usingnamespace/import_segregation.zig-5
...@@ -12,11 +12,6 @@ test "no clobbering happened" {...@@ -12,11 +12,6 @@ test "no clobbering happened" {
12 return error.SkipZigTest;12 return error.SkipZigTest;
13 }13 }
1414
15 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isARM()) {
16 // https://github.com/ziglang/zig/issues/16848
17 return error.SkipZigTest;
18 }
19
20 @This().foo_function();15 @This().foo_function();
21 @This().bar_function();16 @This().bar_function();
22 try expect(@This().saw_foo_function);17 try expect(@This().saw_foo_function);
test/behavior/widening.zig-5
...@@ -66,11 +66,6 @@ test "float widening f16 to f128" {...@@ -66,11 +66,6 @@ test "float widening f16 to f128" {
66 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO66 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
67 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;67 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
6868
69 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isARM()) {
70 // https://github.com/ziglang/zig/issues/16848
71 return error.SkipZigTest;
72 }
73
74 var x: f16 = 12.34;69 var x: f16 = 12.34;
75 var y: f128 = x;70 var y: f128 = x;
76 try expect(x == y);71 try expect(x == y);