[llvm] [libc][bazel] Add BUILD rules for float16 math functions. (PR #114187)
Alexey Samsonov via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 23:26:57 PDT 2024
https://github.com/vonosmas created https://github.com/llvm/llvm-project/pull/114187
Adds libc_math_function rules for various f16* and *f16 functions. Closes #114140
>From 6e8ddc7eff2a1e6e02a1c26d3a882fb6d02aa79a Mon Sep 17 00:00:00 2001
From: Alexey Samsonov <vonosmas at gmail.com>
Date: Tue, 29 Oct 2024 23:09:55 -0700
Subject: [PATCH] [libc][bazel] Add BUILD rules for float16 math functions.
---
.../llvm-project-overlay/libc/BUILD.bazel | 310 ++++++++++++++++++
1 file changed, 310 insertions(+)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index d4aeaea6fac845..6d37b79300c44c 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -1773,6 +1773,18 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "expxf16",
+ hdrs = ["src/math/generic/expxf16.h"],
+ deps = [
+ ":__support_cpp_array",
+ ":__support_fputil_cast",
+ ":__support_fputil_fp_bits",
+ ":__support_fputil_nearest_integer",
+ ":__support_fputil_polyeval",
+ ],
+)
+
################################ math targets ##################################
libc_math_function(
@@ -1882,6 +1894,8 @@ libc_math_function(name = "canonicalizel")
libc_math_function(name = "canonicalizef128")
+libc_math_function(name = "canonicalizef16")
+
libc_math_function(
name = "cbrt",
additional_deps = [
@@ -1906,6 +1920,8 @@ libc_math_function(name = "ceill")
libc_math_function(name = "ceilf128")
+libc_math_function(name = "ceilf16")
+
libc_math_function(name = "copysign")
libc_math_function(name = "copysignf")
@@ -1914,6 +1930,8 @@ libc_math_function(name = "copysignl")
libc_math_function(name = "copysignf128")
+libc_math_function(name = "copysignf16")
+
libc_math_function(
name = "cos",
additional_deps = [
@@ -1950,6 +1968,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "coshf16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
libc_math_function(
name = "cospif",
additional_deps = [
@@ -2048,6 +2073,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "expf16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
libc_math_function(
name = "exp10",
additional_deps = [
@@ -2072,6 +2104,20 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "exp10f16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
+libc_math_function(
+ name = "exp10m1f16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
libc_math_function(
name = "exp2",
additional_deps = [
@@ -2096,6 +2142,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "exp2f16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
libc_math_function(
name = "exp2m1f",
additional_deps = [
@@ -2104,6 +2157,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "exp2m1f16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
libc_math_function(
name = "expm1",
additional_deps = [
@@ -2135,6 +2195,101 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "expm1f16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
+libc_math_function(name = "f16add")
+
+libc_math_function(name = "f16addf")
+
+libc_math_function(name = "f16addf128")
+
+libc_math_function(name = "f16addl")
+
+libc_math_function(name = "f16div")
+
+libc_math_function(name = "f16divf")
+
+libc_math_function(name = "f16divf128")
+
+libc_math_function(name = "f16divl")
+
+libc_math_function(
+ name = "f16fma",
+ additional_deps = [
+ ":__support_fputil_fma",
+ ],
+)
+
+libc_math_function(
+ name = "f16fmaf",
+ additional_deps = [
+ ":__support_fputil_fma",
+ ],
+)
+
+libc_math_function(
+ name = "f16fmaf128",
+ additional_deps = [
+ ":__support_fputil_fma",
+ ],
+)
+
+libc_math_function(
+ name = "f16fmal",
+ additional_deps = [
+ ":__support_fputil_fma",
+ ],
+)
+
+libc_math_function(name = "f16mul")
+
+libc_math_function(name = "f16mulf")
+
+libc_math_function(name = "f16mulf128")
+
+libc_math_function(name = "f16mull")
+
+libc_math_function(
+ name = "f16sqrt",
+ additional_deps = [
+ ":__support_fputil_sqrt",
+ ],
+)
+
+libc_math_function(
+ name = "f16sqrtf",
+ additional_deps = [
+ ":__support_fputil_sqrt",
+ ],
+)
+
+libc_math_function(
+ name = "f16sqrtf128",
+ additional_deps = [
+ ":__support_fputil_sqrt",
+ ],
+)
+
+libc_math_function(
+ name = "f16sqrtl",
+ additional_deps = [
+ ":__support_fputil_sqrt",
+ ],
+)
+
+libc_math_function(name = "f16sub")
+
+libc_math_function(name = "f16subf")
+
+libc_math_function(name = "f16subf128")
+
+libc_math_function(name = "f16subl")
+
libc_math_function(name = "fabs")
libc_math_function(name = "fabsf")
@@ -2143,6 +2298,8 @@ libc_math_function(name = "fabsl")
libc_math_function(name = "fabsf128")
+libc_math_function(name = "fabsf16")
+
libc_math_function(name = "fadd")
libc_math_function(name = "faddl")
@@ -2157,6 +2314,8 @@ libc_math_function(name = "fdiml")
libc_math_function(name = "fdimf128")
+libc_math_function(name = "fdimf16")
+
libc_math_function(name = "fdiv")
libc_math_function(name = "fdivl")
@@ -2192,6 +2351,8 @@ libc_math_function(name = "floorl")
libc_math_function(name = "floorf128")
+libc_math_function(name = "floorf16")
+
# TODO: Add fma, fmaf, fmal, fmaf128 functions.
libc_math_function(name = "fmax")
@@ -2202,6 +2363,8 @@ libc_math_function(name = "fmaxl")
libc_math_function(name = "fmaxf128")
+libc_math_function(name = "fmaxf16")
+
libc_math_function(name = "fmaximum")
libc_math_function(name = "fmaximumf")
@@ -2210,6 +2373,8 @@ libc_math_function(name = "fmaximuml")
libc_math_function(name = "fmaximumf128")
+libc_math_function(name = "fmaximumf16")
+
libc_math_function(name = "fmaximum_mag")
libc_math_function(name = "fmaximum_magf")
@@ -2218,6 +2383,8 @@ libc_math_function(name = "fmaximum_magl")
libc_math_function(name = "fmaximum_magf128")
+libc_math_function(name = "fmaximum_magf16")
+
libc_math_function(name = "fmaximum_mag_num")
libc_math_function(name = "fmaximum_mag_numf")
@@ -2226,6 +2393,8 @@ libc_math_function(name = "fmaximum_mag_numl")
libc_math_function(name = "fmaximum_mag_numf128")
+libc_math_function(name = "fmaximum_mag_numf16")
+
libc_math_function(name = "fmaximum_num")
libc_math_function(name = "fmaximum_numf")
@@ -2234,6 +2403,8 @@ libc_math_function(name = "fmaximum_numl")
libc_math_function(name = "fmaximum_numf128")
+libc_math_function(name = "fmaximum_numf16")
+
libc_math_function(name = "fmin")
libc_math_function(name = "fminf")
@@ -2242,6 +2413,8 @@ libc_math_function(name = "fminl")
libc_math_function(name = "fminf128")
+libc_math_function(name = "fminf16")
+
libc_math_function(name = "fminimum")
libc_math_function(name = "fminimumf")
@@ -2250,6 +2423,8 @@ libc_math_function(name = "fminimuml")
libc_math_function(name = "fminimumf128")
+libc_math_function(name = "fminimumf16")
+
libc_math_function(name = "fminimum_mag")
libc_math_function(name = "fminimum_magf")
@@ -2258,6 +2433,8 @@ libc_math_function(name = "fminimum_magl")
libc_math_function(name = "fminimum_magf128")
+libc_math_function(name = "fminimum_magf16")
+
libc_math_function(name = "fminimum_mag_num")
libc_math_function(name = "fminimum_mag_numf")
@@ -2266,6 +2443,8 @@ libc_math_function(name = "fminimum_mag_numl")
libc_math_function(name = "fminimum_mag_numf128")
+libc_math_function(name = "fminimum_mag_numf16")
+
libc_math_function(name = "fminimum_num")
libc_math_function(name = "fminimum_numf")
@@ -2274,6 +2453,8 @@ libc_math_function(name = "fminimum_numl")
libc_math_function(name = "fminimum_numf128")
+libc_math_function(name = "fminimum_numf16")
+
libc_math_function(
name = "fmod",
additional_deps = [
@@ -2302,6 +2483,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "fmodf16",
+ additional_deps = [
+ ":__support_fputil_generic_fmod",
+ ],
+)
+
libc_math_function(
name = "fmul",
additional_deps = [
@@ -2321,6 +2509,8 @@ libc_math_function(name = "frexpl")
libc_math_function(name = "frexpf128")
+libc_math_function(name = "frexpf16")
+
libc_math_function(name = "fromfp")
libc_math_function(name = "fromfpf")
@@ -2329,6 +2519,8 @@ libc_math_function(name = "fromfpl")
libc_math_function(name = "fromfpf128")
+libc_math_function(name = "fromfpf16")
+
libc_math_function(name = "fromfpx")
libc_math_function(name = "fromfpxf")
@@ -2337,6 +2529,8 @@ libc_math_function(name = "fromfpxl")
libc_math_function(name = "fromfpxf128")
+libc_math_function(name = "fromfpxf16")
+
libc_math_function(
name = "fsqrt",
additional_deps = [
@@ -2372,6 +2566,8 @@ libc_math_function(name = "getpayloadl")
libc_math_function(name = "getpayloadf128")
+libc_math_function(name = "getpayloadf16")
+
libc_math_function(name = "hypot")
libc_math_function(
@@ -2390,6 +2586,8 @@ libc_math_function(name = "ilogbl")
libc_math_function(name = "ilogbf128")
+libc_math_function(name = "ilogbf16")
+
libc_math_function(name = "ldexp")
libc_math_function(name = "ldexpf")
@@ -2398,6 +2596,8 @@ libc_math_function(name = "ldexpl")
libc_math_function(name = "ldexpf128")
+libc_math_function(name = "ldexpf16")
+
libc_math_function(name = "llogb")
libc_math_function(name = "llogbf")
@@ -2406,6 +2606,8 @@ libc_math_function(name = "llogbl")
libc_math_function(name = "llogbf128")
+libc_math_function(name = "llogbf16")
+
libc_math_function(name = "llrint")
libc_math_function(name = "llrintf")
@@ -2414,6 +2616,8 @@ libc_math_function(name = "llrintl")
libc_math_function(name = "llrintf128")
+libc_math_function(name = "llrintf16")
+
libc_math_function(name = "llround")
libc_math_function(name = "llroundf")
@@ -2422,6 +2626,8 @@ libc_math_function(name = "llroundl")
libc_math_function(name = "llroundf128")
+libc_math_function(name = "llroundf16")
+
libc_math_function(
name = "log",
additional_deps = [
@@ -2450,6 +2656,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "logf16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
libc_math_function(
name = "log10",
additional_deps = [
@@ -2478,6 +2691,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "log10f16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
libc_math_function(
name = "log1p",
additional_deps = [
@@ -2532,6 +2752,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "log2f16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
libc_math_function(name = "logb")
libc_math_function(name = "logbf")
@@ -2540,6 +2767,8 @@ libc_math_function(name = "logbl")
libc_math_function(name = "logbf128")
+libc_math_function(name = "logbf16")
+
libc_math_function(name = "lrint")
libc_math_function(name = "lrintf")
@@ -2548,6 +2777,8 @@ libc_math_function(name = "lrintl")
libc_math_function(name = "lrintf128")
+libc_math_function(name = "lrintf16")
+
libc_math_function(name = "lround")
libc_math_function(name = "lroundf")
@@ -2556,6 +2787,8 @@ libc_math_function(name = "lroundl")
libc_math_function(name = "lroundf128")
+libc_math_function(name = "lroundf16")
+
libc_math_function(name = "modf")
libc_math_function(name = "modff")
@@ -2564,6 +2797,8 @@ libc_math_function(name = "modfl")
libc_math_function(name = "modff128")
+libc_math_function(name = "modff16")
+
libc_math_function(
name = "nan",
additional_deps = [
@@ -2596,6 +2831,14 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "nanf16",
+ additional_deps = [
+ ":__support_str_to_float",
+ ":errno",
+ ],
+)
+
libc_math_function(name = "nearbyint")
libc_math_function(name = "nearbyintf")
@@ -2604,6 +2847,8 @@ libc_math_function(name = "nearbyintl")
libc_math_function(name = "nearbyintf128")
+libc_math_function(name = "nearbyintf16")
+
libc_math_function(name = "nextafter")
libc_math_function(name = "nextafterf")
@@ -2612,6 +2857,8 @@ libc_math_function(name = "nextafterl")
libc_math_function(name = "nextafterf128")
+libc_math_function(name = "nextafterf16")
+
libc_math_function(name = "nextdown")
libc_math_function(name = "nextdownf")
@@ -2620,10 +2867,14 @@ libc_math_function(name = "nextdownl")
libc_math_function(name = "nextdownf128")
+libc_math_function(name = "nextdownf16")
+
libc_math_function(name = "nexttoward")
libc_math_function(name = "nexttowardf")
+libc_math_function(name = "nexttowardf16")
+
libc_math_function(name = "nexttowardl")
libc_math_function(name = "nextup")
@@ -2634,6 +2885,8 @@ libc_math_function(name = "nextupl")
libc_math_function(name = "nextupf128")
+libc_math_function(name = "nextupf16")
+
libc_math_function(
name = "pow",
additional_deps = [
@@ -2671,6 +2924,8 @@ libc_math_function(name = "remainderl")
libc_math_function(name = "remainderf128")
+libc_math_function(name = "remainderf16")
+
libc_math_function(name = "remquo")
libc_math_function(name = "remquof")
@@ -2679,6 +2934,8 @@ libc_math_function(name = "remquol")
libc_math_function(name = "remquof128")
+libc_math_function(name = "remquof16")
+
libc_math_function(name = "rint")
libc_math_function(name = "rintf")
@@ -2687,6 +2944,8 @@ libc_math_function(name = "rintl")
libc_math_function(name = "rintf128")
+libc_math_function(name = "rintf16")
+
libc_math_function(name = "round")
libc_math_function(name = "roundf")
@@ -2695,6 +2954,8 @@ libc_math_function(name = "roundl")
libc_math_function(name = "roundf128")
+libc_math_function(name = "roundf16")
+
libc_math_function(name = "roundeven")
libc_math_function(name = "roundevenf")
@@ -2703,6 +2964,8 @@ libc_math_function(name = "roundevenl")
libc_math_function(name = "roundevenf128")
+libc_math_function(name = "roundevenf16")
+
libc_math_function(name = "scalbln")
libc_math_function(name = "scalblnf")
@@ -2711,6 +2974,8 @@ libc_math_function(name = "scalblnl")
libc_math_function(name = "scalblnf128")
+libc_math_function(name = "scalblnf16")
+
libc_math_function(name = "scalbn")
libc_math_function(name = "scalbnf")
@@ -2719,6 +2984,8 @@ libc_math_function(name = "scalbnl")
libc_math_function(name = "scalbnf128")
+libc_math_function(name = "scalbnf16")
+
libc_math_function(name = "setpayload")
libc_math_function(name = "setpayloadf")
@@ -2727,6 +2994,8 @@ libc_math_function(name = "setpayloadl")
libc_math_function(name = "setpayloadf128")
+libc_math_function(name = "setpayloadf16")
+
libc_math_function(name = "setpayloadsig")
libc_math_function(name = "setpayloadsigf")
@@ -2735,6 +3004,8 @@ libc_math_function(name = "setpayloadsigl")
libc_math_function(name = "setpayloadsigf128")
+libc_math_function(name = "setpayloadsigf16")
+
libc_math_function(
name = "sin",
additional_deps = [
@@ -2797,6 +3068,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "sinhf16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
libc_math_function(
name = "sinpif",
additional_deps = [
@@ -2804,6 +3082,14 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "sinpif16",
+ additional_deps = [
+ ":__support_fputil_nearest_integer",
+ ":__support_fputil_polyeval",
+ ],
+)
+
libc_math_function(
name = "sqrt",
additional_deps = [
@@ -2832,6 +3118,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "sqrtf16",
+ additional_deps = [
+ ":__support_fputil_sqrt",
+ ],
+)
+
libc_math_function(
name = "tan",
additional_deps = [
@@ -2872,6 +3165,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "tanhf16",
+ additional_deps = [
+ ":expxf16",
+ ],
+)
+
libc_math_function(name = "totalorder")
libc_math_function(name = "totalorderf")
@@ -2880,6 +3180,8 @@ libc_math_function(name = "totalorderl")
libc_math_function(name = "totalorderf128")
+libc_math_function(name = "totalorderf16")
+
libc_math_function(name = "totalordermag")
libc_math_function(name = "totalordermagf")
@@ -2888,6 +3190,8 @@ libc_math_function(name = "totalordermagl")
libc_math_function(name = "totalordermagf128")
+libc_math_function(name = "totalordermagf16")
+
libc_math_function(name = "trunc")
libc_math_function(name = "truncf")
@@ -2896,6 +3200,8 @@ libc_math_function(name = "truncl")
libc_math_function(name = "truncf128")
+libc_math_function(name = "truncf16")
+
libc_math_function(name = "ufromfp")
libc_math_function(name = "ufromfpf")
@@ -2904,6 +3210,8 @@ libc_math_function(name = "ufromfpl")
libc_math_function(name = "ufromfpf128")
+libc_math_function(name = "ufromfpf16")
+
libc_math_function(name = "ufromfpx")
libc_math_function(name = "ufromfpxf")
@@ -2912,6 +3220,8 @@ libc_math_function(name = "ufromfpxl")
libc_math_function(name = "ufromfpxf128")
+libc_math_function(name = "ufromfpxf16")
+
############################## inttypes targets ##############################
libc_function(
More information about the llvm-commits
mailing list