115 changes: 90 additions & 25 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,10 @@ add_entrypoint_object(
lround.cpp
HDRS
../lround.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -387,10 +387,10 @@ add_entrypoint_object(
lroundf.cpp
HDRS
../lroundf.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -399,10 +399,23 @@ add_entrypoint_object(
lroundl.cpp
HDRS
../lroundl.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
)

add_entrypoint_object(
lroundf128
SRCS
lroundf128.cpp
HDRS
../lroundf128.h
COMPILE_OPTIONS
-O2
-O3
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.nearest_integer_operations
)

add_entrypoint_object(
Expand All @@ -411,10 +424,10 @@ add_entrypoint_object(
llround.cpp
HDRS
../llround.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -423,10 +436,10 @@ add_entrypoint_object(
llroundf.cpp
HDRS
../llroundf.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -435,10 +448,23 @@ add_entrypoint_object(
llroundl.cpp
HDRS
../llroundl.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
)

add_entrypoint_object(
llroundf128
SRCS
llroundf128.cpp
HDRS
../llroundf128.h
COMPILE_OPTIONS
-O2
-O3
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.nearest_integer_operations
)

add_entrypoint_object(
Expand All @@ -447,10 +473,10 @@ add_entrypoint_object(
rint.cpp
HDRS
../rint.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -459,10 +485,10 @@ add_entrypoint_object(
rintf.cpp
HDRS
../rintf.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -471,10 +497,23 @@ add_entrypoint_object(
rintl.cpp
HDRS
../rintl.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
)

add_entrypoint_object(
rintf128
SRCS
rintf128.cpp
HDRS
../rintf128.h
COMPILE_OPTIONS
-O2
-O3
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.nearest_integer_operations
)

add_entrypoint_object(
Expand All @@ -483,10 +522,10 @@ add_entrypoint_object(
lrint.cpp
HDRS
../lrint.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -495,10 +534,10 @@ add_entrypoint_object(
lrintf.cpp
HDRS
../lrintf.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -507,10 +546,23 @@ add_entrypoint_object(
lrintl.cpp
HDRS
../lrintl.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
)

add_entrypoint_object(
lrintf128
SRCS
lrintf128.cpp
HDRS
../lrintf128.h
COMPILE_OPTIONS
-O2
-O3
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.nearest_integer_operations
)

add_entrypoint_object(
Expand All @@ -519,10 +571,10 @@ add_entrypoint_object(
llrint.cpp
HDRS
../llrint.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -531,10 +583,10 @@ add_entrypoint_object(
llrintf.cpp
HDRS
../llrintf.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -543,10 +595,23 @@ add_entrypoint_object(
llrintl.cpp
HDRS
../llrintl.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
)

add_entrypoint_object(
llrintf128
SRCS
llrintf128.cpp
HDRS
../llrintf128.h
COMPILE_OPTIONS
-O2
-O3
DEPENDS
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.nearest_integer_operations
)

add_entrypoint_object(
Expand Down
21 changes: 21 additions & 0 deletions libc/src/math/generic/llrintf128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation of llrintf128 function -----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/llrintf128.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(long long, llrintf128, (float128 x)) {
return fputil::round_to_signed_integer_using_current_rounding_mode<float128,
long long>(
x);
}

} // namespace LIBC_NAMESPACE
19 changes: 19 additions & 0 deletions libc/src/math/generic/llroundf128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of llroundf128 function ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/llroundf128.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(long long, llroundf128, (float128 x)) {
return fputil::round_to_signed_integer<float128, long long>(x);
}

} // namespace LIBC_NAMESPACE
20 changes: 20 additions & 0 deletions libc/src/math/generic/lrintf128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation of lrintf128 function ------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/lrintf128.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(long, lrintf128, (float128 x)) {
return fputil::round_to_signed_integer_using_current_rounding_mode<float128,
long>(x);
}

} // namespace LIBC_NAMESPACE
19 changes: 19 additions & 0 deletions libc/src/math/generic/lroundf128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of lroundf128 function -----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/lroundf128.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(long, lroundf128, (float128 x)) {
return fputil::round_to_signed_integer<float128, long>(x);
}

} // namespace LIBC_NAMESPACE
19 changes: 19 additions & 0 deletions libc/src/math/generic/rintf128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of rintf128 function -------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/rintf128.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float128, rintf128, (float128 x)) {
return fputil::round_using_current_rounding_mode(x);
}

} // namespace LIBC_NAMESPACE
20 changes: 20 additions & 0 deletions libc/src/math/llrintf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for llrintf128 --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_MATH_LLRINTF128_H
#define LLVM_LIBC_SRC_MATH_LLRINTF128_H

#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE {

long long llrintf128(float128 x);

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_MATH_LLRINTF128_H
20 changes: 20 additions & 0 deletions libc/src/math/llroundf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for llroundf128 -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_MATH_LLROUNDF128_H
#define LLVM_LIBC_SRC_MATH_LLROUNDF128_H

#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE {

long long llroundf128(float128 x);

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_MATH_LLROUNDF128_H
20 changes: 20 additions & 0 deletions libc/src/math/lrintf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for lrintf128 ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_MATH_LRINTF128_H
#define LLVM_LIBC_SRC_MATH_LRINTF128_H

#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE {

long lrintf128(float128 x);

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_MATH_LRINTF128_H
20 changes: 20 additions & 0 deletions libc/src/math/lroundf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for lroundf128 --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_MATH_LROUNDF128_H
#define LLVM_LIBC_SRC_MATH_LROUNDF128_H

#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE {

long lroundf128(float128 x);

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_MATH_LROUNDF128_H
20 changes: 20 additions & 0 deletions libc/src/math/rintf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for rintf128 ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_MATH_RINTF128_H
#define LLVM_LIBC_SRC_MATH_RINTF128_H

#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE {

float128 rintf128(float128 x);

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_MATH_RINTF128_H
81 changes: 81 additions & 0 deletions libc/test/src/math/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,24 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
lroundf128_test
SUITE
libc-math-smoke-tests
SRCS
lroundf128_test.cpp
HDRS
RoundToIntegerTest.h
DEPENDS
libc.include.math
libc.src.errno.errno
libc.src.fenv.feclearexcept
libc.src.fenv.feraiseexcept
libc.src.fenv.fetestexcept
libc.src.math.lroundf128
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
llround_test
SUITE
Expand Down Expand Up @@ -441,6 +459,24 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
llroundf128_test
SUITE
libc-math-smoke-tests
SRCS
llroundf128_test.cpp
HDRS
RoundToIntegerTest.h
DEPENDS
libc.include.math
libc.src.errno.errno
libc.src.fenv.feclearexcept
libc.src.fenv.feraiseexcept
libc.src.fenv.fetestexcept
libc.src.math.llroundf128
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
rint_test
SUITE
Expand Down Expand Up @@ -486,6 +522,21 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
rintf128_test
SUITE
libc-math-smoke-tests
SRCS
rintf128_test.cpp
HDRS
RIntTest.h
DEPENDS
libc.include.math
libc.src.math.rintf128
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
lrint_test
SUITE
Expand Down Expand Up @@ -531,6 +582,21 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
lrintf128_test
SUITE
libc-math-smoke-tests
SRCS
lrintf128_test.cpp
HDRS
RoundToIntegerTest.h
DEPENDS
libc.include.math
libc.src.math.lrintf128
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
llrint_test
SUITE
Expand Down Expand Up @@ -576,6 +642,21 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
llrintf128_test
SUITE
libc-math-smoke-tests
SRCS
llrintf128_test.cpp
HDRS
RoundToIntegerTest.h
DEPENDS
libc.include.math
libc.src.math.llrintf128
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
expf_test
SUITE
Expand Down
14 changes: 14 additions & 0 deletions libc/test/src/math/smoke/llrintf128_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//===-- Unittests for llrintf128 ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "RoundToIntegerTest.h"

#include "src/math/llrintf128.h"

LIST_ROUND_TO_INTEGER_TESTS_WITH_MODES(float128, long long,
LIBC_NAMESPACE::llrintf128)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/llroundf128_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for llroundf128 -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "RoundToIntegerTest.h"

#include "src/math/llroundf128.h"

LIST_ROUND_TO_INTEGER_TESTS(float128, long long, LIBC_NAMESPACE::llroundf128)
14 changes: 14 additions & 0 deletions libc/test/src/math/smoke/lrintf128_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//===-- Unittests for lrintf128 -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "RoundToIntegerTest.h"

#include "src/math/lrintf128.h"

LIST_ROUND_TO_INTEGER_TESTS_WITH_MODES(float128, long,
LIBC_NAMESPACE::lrintf128)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/lroundf128_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for lroundf128 ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "RoundToIntegerTest.h"

#include "src/math/lroundf128.h"

LIST_ROUND_TO_INTEGER_TESTS(float128, long, LIBC_NAMESPACE::lroundf128)
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/rintf128_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for rintf128 --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "RIntTest.h"

#include "src/math/rintf128.h"

LIST_RINT_TESTS(float128, LIBC_NAMESPACE::rintf128)