[libc-commits] [libc] 1ad8d9d - [libc][bazel] Add bazel targets and unit tests for math functions.

Tue Ly via libc-commits libc-commits at lists.llvm.org
Fri Feb 3 12:11:32 PST 2023


Author: Tue Ly
Date: 2023-02-03T15:11:20-05:00
New Revision: 1ad8d9d66d11018d4db71e3a7f6a260659ff39b3

URL: https://github.com/llvm/llvm-project/commit/1ad8d9d66d11018d4db71e3a7f6a260659ff39b3
DIFF: https://github.com/llvm/llvm-project/commit/1ad8d9d66d11018d4db71e3a7f6a260659ff39b3.diff

LOG: [libc][bazel] Add bazel targets and unit tests for math functions.

Add bazel targets and unit tests for single precision exponential,
logarithm, trigonometric, inverse trig, hyperbolic, and inverse hyperbolic
functions.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D143275

Added: 
    

Modified: 
    libc/docs/build_and_test.rst
    libc/src/math/generic/explogxf.h
    libc/src/math/generic/inv_trigf_utils.h
    utils/bazel/llvm-project-overlay/libc/BUILD.bazel
    utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel

Removed: 
    


################################################################################
diff  --git a/libc/docs/build_and_test.rst b/libc/docs/build_and_test.rst
index 22557001568b1..1571dded96673 100644
--- a/libc/docs/build_and_test.rst
+++ b/libc/docs/build_and_test.rst
@@ -62,3 +62,20 @@ and put the following in your settings.json file:
          "LIBC_INCLUDE_DOCS" : true
      }
    }
+
+Building with Bazel
+===================
+
+#. To build with Bazel, use the following command:
+
+  .. code-block:: sh
+
+    $> bazel build --config=generic_clang @llvm-project//libc/...
+
+#. To run the unit tests with bazel, use the following command:
+
+  .. code-block:: sh
+
+    $> bazel test --config=generic_clang @llvm-project//libc/...
+
+#. The bazel target layout of `libc` is located at: `utils/bazel/llvm-project-overlay/libc/BUILD.bazel <https://github.com/llvm/llvm-project/tree/main/utils/bazel/llvm-project-overlay/libc/BUILD.bazel>`_.

diff  --git a/libc/src/math/generic/explogxf.h b/libc/src/math/generic/explogxf.h
index 38a63ff3216d9..cb8efc92f28c7 100644
--- a/libc/src/math/generic/explogxf.h
+++ b/libc/src/math/generic/explogxf.h
@@ -16,7 +16,6 @@
 #include "src/__support/FPUtil/PolyEval.h"
 #include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/common.h"
-#include <src/__support/FPUtil/NearestIntegerOperations.h>
 
 #include <errno.h>
 

diff  --git a/libc/src/math/generic/inv_trigf_utils.h b/libc/src/math/generic/inv_trigf_utils.h
index a01db3ab8e7bd..53763d484b853 100644
--- a/libc/src/math/generic/inv_trigf_utils.h
+++ b/libc/src/math/generic/inv_trigf_utils.h
@@ -15,7 +15,6 @@
 #include "src/__support/FPUtil/PolyEval.h"
 #include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/common.h"
-#include <src/__support/FPUtil/NearestIntegerOperations.h>
 
 #include <errno.h>
 

diff  --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index e8d7f8b608d3a..60878396ecaa4 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -726,6 +726,39 @@ libc_support_library(
     ],
 )
 
+libc_support_library(
+    name = "explogxf",
+    hdrs = ["src/math/generic/explogxf.h"],
+    srcs = ["src/math/generic/explogxf.cpp"],
+    deps = [
+        ":__support_common",
+        ":__support_fputil_fp_bits",
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":common_constants",
+        ":math_utils",
+        ":libc_root",
+    ],
+)
+
+libc_support_library(
+    name = "inv_trigf_utils",
+    hdrs = ["src/math/generic/inv_trigf_utils.h"],
+    srcs = ["src/math/generic/inv_trigf_utils.cpp"],
+    deps = [
+        ":__support_common",
+        ":__support_fputil_fp_bits",
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":math_utils",
+        ":libc_root",
+    ],
+)
+
 libc_math_function(
     name = "expm1f",
     additional_deps = [
@@ -737,6 +770,193 @@ libc_math_function(
     ],
 )
 
+libc_math_function(
+    name = "expf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":common_constants",
+    ],
+)
+
+libc_math_function(
+    name = "exp10f",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":common_constants",
+        ":explogxf",
+    ],
+)
+
+libc_math_function(
+    name = "exp2f",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":explogxf",
+    ],
+)
+
+libc_math_function(
+    name = "logf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":common_constants",
+    ],
+)
+
+libc_math_function(
+    name = "log2f",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":common_constants",
+    ],
+)
+
+libc_math_function(
+    name = "log10f",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":common_constants",
+    ],
+)
+
+libc_math_function(
+    name = "log1pf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":common_constants",
+    ],
+)
+
+libc_math_function(
+    name = "sinhf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":common_constants",
+        ":explogxf",
+    ],
+)
+
+libc_math_function(
+    name = "coshf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":common_constants",
+        ":explogxf",
+    ],
+)
+
+libc_math_function(
+    name = "tanhf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":common_constants",
+        ":explogxf",
+    ],
+)
+
+libc_math_function(
+    name = "asinhf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":__support_fputil_sqrt",
+        ":common_constants",
+        ":explogxf",
+    ],
+)
+
+libc_math_function(
+    name = "acoshf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":__support_fputil_sqrt",
+        ":common_constants",
+        ":explogxf",
+    ],
+)
+
+libc_math_function(
+    name = "atanhf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":common_constants",
+        ":explogxf",
+    ],
+)
+
+libc_math_function(
+    name = "asinf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":__support_fputil_sqrt",
+        ":inv_trigf_utils",
+    ],
+)
+
+libc_math_function(
+    name = "acosf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":__support_fputil_sqrt",
+        ":inv_trigf_utils",
+    ],
+)
+
+libc_math_function(
+    name = "atanf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_nearest_integer",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":inv_trigf_utils",
+    ],
+)
+
 libc_math_function(name = "fabs")
 
 libc_math_function(name = "fabsf")
@@ -912,6 +1132,17 @@ libc_math_function(
     ],
 )
 
+libc_math_function(
+    name = "tanf",
+    additional_deps = [
+        ":__support_fputil_fma",
+        ":__support_fputil_multiply_add",
+        ":__support_fputil_polyeval",
+        ":range_reduction",
+        ":sincosf_utils",
+    ],
+)
+
 libc_math_function(
     name = "sqrt",
     additional_deps = [

diff  --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
index 25687c9070d34..01f64f4d8cdf4 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
@@ -572,3 +572,129 @@ math_test(
         "//libc/utils/MPFRWrapper:mpfr_wrapper",
     ],
 )
+
+math_test(
+    name = "tanf",
+    deps = [
+        ":sdcomp26094",
+        "//libc:__support_cpp_array",
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ],
+)
+
+math_test(
+    name = "expf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "exp2f",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+math_test(
+    name = "exp10f",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+math_test(
+    name = "expm1f",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "logf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "log2f",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "log10f",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "log1pf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "sinhf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "coshf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "tanhf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "asinhf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "acoshf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "atanhf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "asinf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "acosf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)
+
+math_test(
+    name = "atanf",
+    deps = [
+        "//libc/utils/MPFRWrapper:mpfr_wrapper",
+    ]
+)


        


More information about the libc-commits mailing list