authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-03-10 07:00:41+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-04 06:08:10+02:00
log858305385d80f736e3b4b80ecdaaf77f100d21e1
treeed951ffb2e16c9d05e1da5381ecf2682c9aa0aba
parentcf9c6f5298924f95e83f2be0e9efb50fe2f61d92
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

llvm: Update the list of targets that use native f16/f128.

Closes #22003. Closes #22013.

2 files changed, 33 insertions(+), 24 deletions(-)

lib/compiler_rt/common.zig+17-13
...@@ -96,21 +96,25 @@ pub const want_sparc_abi = builtin.cpu.arch.isSPARC();...@@ -96,21 +96,25 @@ pub const want_sparc_abi = builtin.cpu.arch.isSPARC();
96// we're trying to test compiler-rt.96// we're trying to test compiler-rt.
97pub const panic = if (builtin.is_test) std.debug.FullPanic(std.debug.defaultPanic) else std.debug.no_panic;97pub const panic = if (builtin.is_test) std.debug.FullPanic(std.debug.defaultPanic) else std.debug.no_panic;
9898
99/// AArch64 is the only ABI (at the moment) to support f16 arguments without the99/// This seems to mostly correspond to `clang::TargetInfo::HasFloat16`.
100/// need for extending them to wider fp types.
101/// TODO remove this; do this type selection in the language rather than
102/// here in compiler-rt.
103pub fn F16T(comptime OtherType: type) type {100pub fn F16T(comptime OtherType: type) type {
104 return switch (builtin.cpu.arch) {101 return switch (builtin.cpu.arch) {
105 .arm, .armeb, .thumb, .thumbeb => if (std.Target.arm.featureSetHas(builtin.cpu.features, .has_v8))102 .amdgcn,
106 switch (builtin.abi.float()) {103 .arm,
107 .soft => u16,104 .armeb,
108 .hard => f16,105 .thumb,
109 }106 .thumbeb,
110 else107 .aarch64,
111 u16,108 .aarch64_be,
112 .aarch64, .aarch64_be => f16,109 .nvptx,
113 .riscv32, .riscv64 => f16,110 .nvptx64,
111 .riscv32,
112 .riscv64,
113 .spirv,
114 .spirv32,
115 .spirv64,
116 => f16,
117 .hexagon => if (std.Target.hexagon.featureSetHas(builtin.target.cpu.features, .v68)) f16 else u16,
114 .x86, .x86_64 => if (builtin.target.os.tag.isDarwin()) switch (OtherType) {118 .x86, .x86_64 => if (builtin.target.os.tag.isDarwin()) switch (OtherType) {
115 // Starting with LLVM 16, Darwin uses different abi for f16119 // Starting with LLVM 16, Darwin uses different abi for f16
116 // depending on the type of the other return/argument..???120 // depending on the type of the other return/argument..???
src/codegen/llvm.zig+16-11
...@@ -12472,21 +12472,21 @@ fn backendSupportsF80(target: std.Target) bool {...@@ -12472,21 +12472,21 @@ fn backendSupportsF80(target: std.Target) bool {
12472/// or if it produces miscompilations.12472/// or if it produces miscompilations.
12473fn backendSupportsF16(target: std.Target) bool {12473fn backendSupportsF16(target: std.Target) bool {
12474 return switch (target.cpu.arch) {12474 return switch (target.cpu.arch) {
12475 // LoongArch can be removed from this list with LLVM 20.12475 // https://github.com/llvm/llvm-project/issues/97981
12476 .loongarch32,12476 .csky,
12477 .loongarch64,12477 // https://github.com/llvm/llvm-project/issues/97981
12478 .hexagon,12478 .hexagon,
12479 // https://github.com/llvm/llvm-project/issues/97981
12479 .powerpc,12480 .powerpc,
12480 .powerpcle,12481 .powerpcle,
12481 .powerpc64,12482 .powerpc64,
12482 .powerpc64le,12483 .powerpc64le,
12484 // https://github.com/llvm/llvm-project/issues/97981
12483 .wasm32,12485 .wasm32,
12484 .wasm64,12486 .wasm64,
12485 .mips,12487 // https://github.com/llvm/llvm-project/issues/50374
12486 .mipsel,
12487 .mips64,
12488 .mips64el,
12489 .s390x,12488 .s390x,
12489 // https://github.com/llvm/llvm-project/issues/97981
12490 .sparc,12490 .sparc,
12491 .sparc64,12491 .sparc64,
12492 => false,12492 => false,
...@@ -12494,7 +12494,8 @@ fn backendSupportsF16(target: std.Target) bool {...@@ -12494,7 +12494,8 @@ fn backendSupportsF16(target: std.Target) bool {
12494 .armeb,12494 .armeb,
12495 .thumb,12495 .thumb,
12496 .thumbeb,12496 .thumbeb,
12497 => target.abi.float() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8),12497 => target.abi.float() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fullfp16),
12498 // https://github.com/llvm/llvm-project/issues/129394
12498 .aarch64,12499 .aarch64,
12499 .aarch64_be,12500 .aarch64_be,
12500 => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),12501 => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
...@@ -12507,11 +12508,18 @@ fn backendSupportsF16(target: std.Target) bool {...@@ -12507,11 +12508,18 @@ fn backendSupportsF16(target: std.Target) bool {
12507/// or if it produces miscompilations.12508/// or if it produces miscompilations.
12508fn backendSupportsF128(target: std.Target) bool {12509fn backendSupportsF128(target: std.Target) bool {
12509 return switch (target.cpu.arch) {12510 return switch (target.cpu.arch) {
12511 // https://github.com/llvm/llvm-project/issues/121122
12510 .amdgcn,12512 .amdgcn,
12513 // Test failures all over the place.
12511 .mips64,12514 .mips64,
12512 .mips64el,12515 .mips64el,
12516 // https://github.com/llvm/llvm-project/issues/95471
12517 .nvptx,
12518 .nvptx64,
12519 // https://github.com/llvm/llvm-project/issues/41838
12513 .sparc,12520 .sparc,
12514 => false,12521 => false,
12522 // https://github.com/llvm/llvm-project/issues/101545
12515 .powerpc,12523 .powerpc,
12516 .powerpcle,12524 .powerpcle,
12517 .powerpc64,12525 .powerpc64,
...@@ -12522,9 +12530,6 @@ fn backendSupportsF128(target: std.Target) bool {...@@ -12522,9 +12530,6 @@ fn backendSupportsF128(target: std.Target) bool {
12522 .thumb,12530 .thumb,
12523 .thumbeb,12531 .thumbeb,
12524 => target.abi.float() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8),12532 => target.abi.float() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8),
12525 .aarch64,
12526 .aarch64_be,
12527 => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8),
12528 else => true,12533 else => true,
12529 };12534 };
12530}12535}