From f043071cdfb956ff16b1441c9d01ce43eea9fb7b Mon Sep 17 00:00:00 2001 From: Jan Philipp Hafer Date: Thu, 15 Jun 2023 23:06:45 +0200 Subject: [PATCH] compiler_rt: add missing PPC routines Adds conditional exports - __fixkfti - __fixunskfti - __floattikf - __negkf2 - __mulkc3 - __divkc3 - __powikf2 and adjusts tools/gen_stubs.zig. From https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html: "When long double transitions to __float128 on PowerPC in the future, __ibm128 will remain for use in conversions between the two types." Hence `__extendkftf2` and `__trunctfkf2` for conversion are superfluous and only using f128 for `kf` routines is justified. Closes #16057. --- lib/compiler_rt/divtc3.zig | 6 +++++- lib/compiler_rt/fixtfti.zig | 2 ++ lib/compiler_rt/fixunstfti.zig | 2 ++ lib/compiler_rt/floattitf.zig | 2 ++ lib/compiler_rt/multc3.zig | 6 +++++- lib/compiler_rt/negtf2.zig | 6 +++++- lib/compiler_rt/powiXf2.zig | 6 +++++- tools/gen_stubs.zig | 5 +++++ 8 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/compiler_rt/divtc3.zig b/lib/compiler_rt/divtc3.zig index d5b1d12059..592681607d 100644 --- a/lib/compiler_rt/divtc3.zig +++ b/lib/compiler_rt/divtc3.zig @@ -4,7 +4,11 @@ const Complex = @import("./mulc3.zig").Complex; comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(__divtc3, .{ .name = "__divtc3", .linkage = common.linkage, .visibility = common.visibility }); + if (common.want_ppc_abi) { + @export(__divtc3, .{ .name = "__divkc3", .linkage = common.linkage, .visibility = common.visibility }); + } else { + @export(__divtc3, .{ .name = "__divtc3", .linkage = common.linkage, .visibility = common.visibility }); + } } } diff --git a/lib/compiler_rt/fixtfti.zig b/lib/compiler_rt/fixtfti.zig index 03d861f92e..957df1dd5e 100644 --- a/lib/compiler_rt/fixtfti.zig +++ b/lib/compiler_rt/fixtfti.zig @@ -7,6 +7,8 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { @export(__fixtfti_windows_x86_64, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility }); + } else if (common.want_ppc_abi) { + @export(__fixtfti, .{ .name = "__fixkfti", .linkage = common.linkage, .visibility = common.visibility }); } else { @export(__fixtfti, .{ .name = "__fixtfti", .linkage = common.linkage, .visibility = common.visibility }); } diff --git a/lib/compiler_rt/fixunstfti.zig b/lib/compiler_rt/fixunstfti.zig index 72b529e0c9..b77bbb6689 100644 --- a/lib/compiler_rt/fixunstfti.zig +++ b/lib/compiler_rt/fixunstfti.zig @@ -7,6 +7,8 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { @export(__fixunstfti_windows_x86_64, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility }); + } else if (common.want_ppc_abi) { + @export(__fixunstfti, .{ .name = "__fixunskfti", .linkage = common.linkage, .visibility = common.visibility }); } else { @export(__fixunstfti, .{ .name = "__fixunstfti", .linkage = common.linkage, .visibility = common.visibility }); } diff --git a/lib/compiler_rt/floattitf.zig b/lib/compiler_rt/floattitf.zig index 62c215c986..32cc8d49b5 100644 --- a/lib/compiler_rt/floattitf.zig +++ b/lib/compiler_rt/floattitf.zig @@ -7,6 +7,8 @@ pub const panic = common.panic; comptime { if (common.want_windows_v2u64_abi) { @export(__floattitf_windows_x86_64, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility }); + } else if (common.want_ppc_abi) { + @export(__floattitf, .{ .name = "__floattikf", .linkage = common.linkage, .visibility = common.visibility }); } else { @export(__floattitf, .{ .name = "__floattitf", .linkage = common.linkage, .visibility = common.visibility }); } diff --git a/lib/compiler_rt/multc3.zig b/lib/compiler_rt/multc3.zig index 89054e4af8..cb2ea8f106 100644 --- a/lib/compiler_rt/multc3.zig +++ b/lib/compiler_rt/multc3.zig @@ -5,7 +5,11 @@ pub const panic = common.panic; comptime { if (@import("builtin").zig_backend != .stage2_c) { - @export(__multc3, .{ .name = "__multc3", .linkage = common.linkage, .visibility = common.visibility }); + if (common.want_ppc_abi) { + @export(__multc3, .{ .name = "__mulkc3", .linkage = common.linkage, .visibility = common.visibility }); + } else { + @export(__multc3, .{ .name = "__multc3", .linkage = common.linkage, .visibility = common.visibility }); + } } } diff --git a/lib/compiler_rt/negtf2.zig b/lib/compiler_rt/negtf2.zig index 46d498ab97..6332d44ccf 100644 --- a/lib/compiler_rt/negtf2.zig +++ b/lib/compiler_rt/negtf2.zig @@ -3,7 +3,11 @@ const common = @import("./common.zig"); pub const panic = common.panic; comptime { - @export(__negtf2, .{ .name = "__negtf2", .linkage = common.linkage, .visibility = common.visibility }); + if (common.want_ppc_abi) { + @export(__negtf2, .{ .name = "__negkf2", .linkage = common.linkage, .visibility = common.visibility }); + } else { + @export(__negtf2, .{ .name = "__negtf2", .linkage = common.linkage, .visibility = common.visibility }); + } } fn __negtf2(a: f128) callconv(.C) f128 { diff --git a/lib/compiler_rt/powiXf2.zig b/lib/compiler_rt/powiXf2.zig index 581dd4a909..6cb80c959e 100644 --- a/lib/compiler_rt/powiXf2.zig +++ b/lib/compiler_rt/powiXf2.zig @@ -13,7 +13,11 @@ comptime { @export(__powihf2, .{ .name = "__powihf2", .linkage = common.linkage, .visibility = common.visibility }); @export(__powisf2, .{ .name = "__powisf2", .linkage = common.linkage, .visibility = common.visibility }); @export(__powidf2, .{ .name = "__powidf2", .linkage = common.linkage, .visibility = common.visibility }); - @export(__powitf2, .{ .name = "__powitf2", .linkage = common.linkage, .visibility = common.visibility }); + if (common.want_ppc_abi) { + @export(__powitf2, .{ .name = "__powikf2", .linkage = common.linkage, .visibility = common.visibility }); + } else { + @export(__powitf2, .{ .name = "__powitf2", .linkage = common.linkage, .visibility = common.visibility }); + } @export(__powixf2, .{ .name = "__powixf2", .linkage = common.linkage, .visibility = common.visibility }); } diff --git a/tools/gen_stubs.zig b/tools/gen_stubs.zig index 95787b719a..5d6b0acbd6 100644 --- a/tools/gen_stubs.zig +++ b/tools/gen_stubs.zig @@ -703,6 +703,7 @@ const blacklisted_symbols = [_][]const u8{ "__fixdfti", "__fixkfdi", "__fixkfsi", + "__fixkfti", "__fixsfdi", "__fixsfsi", "__fixsfti", @@ -714,6 +715,7 @@ const blacklisted_symbols = [_][]const u8{ "__fixunsdfti", "__fixunskfdi", "__fixunskfsi", + "__fixunskfti", "__fixunssfdi", "__fixunssfsi", "__fixunssfti", @@ -737,6 +739,7 @@ const blacklisted_symbols = [_][]const u8{ "__floatsitf", "__floatsixf", "__floattidf", + "__floattikf", "__floattisf", "__floattitf", "__floattixf", @@ -802,6 +805,7 @@ const blacklisted_symbols = [_][]const u8{ "__muldc3", "__muldf3", "__muldi3", + "__mulkc3", "__mulkf3", "__mulodi4", "__mulosi4", @@ -835,6 +839,7 @@ const blacklisted_symbols = [_][]const u8{ "__popcountti2", "__powidf2", "__powihf2", + "__powikf2", "__powisf2", "__powitf2", "__powixf2",