[llvm] [libc][bazel] Add BUILD rules for fma and fmaf functions. (PR #159502)
    Alexey Samsonov via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Sep 17 21:17:38 PDT 2025
    
    
  
https://github.com/vonosmas created https://github.com/llvm/llvm-project/pull/159502
This change adds the capability to build fma/fmaf with Bazel (fmal, fmaf128 variants are not implemented yet), and run smoke tests.
BUILD rules for regular MPFR-based tests will be added later, since they require support for building rand/srand as well, which is missing in Bazel for now.
>From 5f74f6f262e7b088a2c593bd543184b548ed818c Mon Sep 17 00:00:00 2001
From: Alexey Samsonov <vonosmas at gmail.com>
Date: Wed, 17 Sep 2025 21:13:32 -0700
Subject: [PATCH] [libc][bazel] Add BUILD rules for fma and fmaf functions.
This change adds the capability to build fma/fmaf with Bazel (fmal,
fmaf128 variants are not implemented yet), and run smoke tests.
BUILD rules for regular MPFR-based tests will be added later, since they
require support for building rand/srand as well, which is missing in
Bazel for now.
---
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel  | 14 +++++++++++++-
 .../libc/test/src/math/smoke/BUILD.bazel           | 10 +++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index c491eb11a4601..6850b9c786a23 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -3834,7 +3834,19 @@ libc_math_function(name = "floorf128")
 
 libc_math_function(name = "floorf16")
 
-# TODO: Add fma, fmaf, fmal, fmaf128 functions.
+libc_math_function(
+    name = "fma",
+    additional_deps = [
+        ":__support_fputil_fma",
+    ],
+)
+
+libc_math_function(
+    name = "fmaf",
+    additional_deps = [
+        ":__support_fputil_fma",
+    ],
+)
 
 libc_math_function(
     name = "fmaf16",
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
index 2bffcdea58478..b213c0f53b694 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
@@ -475,7 +475,15 @@ math_test(
     hdrs = ["FloorTest.h"],
 )
 
-# TODO: Add fma, fmaf, fmal, fmaf128 tests.
+math_test(
+    name = "fma",
+    hdrs = ["FmaTest.h"],
+)
+
+math_test(
+    name = "fmaf",
+    hdrs = ["FmaTest.h"],
+)
 
 # TODO: Reenable this test once it passes at Google.
 # math_test(
    
    
More information about the llvm-commits
mailing list