xref: /llvm-project/libc/src/math/generic/floorf16.cpp (revision 127349fcba81646389e4b8202b35405a5fdbef47)
125b037bdSOverMighty //===-- Implementation of floorf16 function -------------------------------===//
225b037bdSOverMighty //
325b037bdSOverMighty // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
425b037bdSOverMighty // See https://llvm.org/LICENSE.txt for license information.
525b037bdSOverMighty // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
625b037bdSOverMighty //
725b037bdSOverMighty //===----------------------------------------------------------------------===//
825b037bdSOverMighty 
925b037bdSOverMighty #include "src/math/floorf16.h"
1025b037bdSOverMighty #include "src/__support/FPUtil/NearestIntegerOperations.h"
11*127349fcSOverMighty #include "src/__support/FPUtil/cast.h"
1225b037bdSOverMighty #include "src/__support/common.h"
135ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
1481ce7960SOverMighty #include "src/__support/macros/properties/cpu_features.h"
1525b037bdSOverMighty 
165ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
1725b037bdSOverMighty 
184531f82cSOverMighty LLVM_LIBC_FUNCTION(float16, floorf16, (float16 x)) {
194531f82cSOverMighty #if defined(__LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC) &&                       \
2081ce7960SOverMighty     defined(LIBC_TARGET_CPU_HAS_FAST_FLOAT16_OPS)
21*127349fcSOverMighty   return fputil::cast<float16>(__builtin_floorf(x));
224531f82cSOverMighty #else
234531f82cSOverMighty   return fputil::floor(x);
244531f82cSOverMighty #endif
254531f82cSOverMighty }
2625b037bdSOverMighty 
275ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
28