125b037bdSOverMighty //===-- Implementation of roundevenf16 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/roundevenf16.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 1825b037bdSOverMighty LLVM_LIBC_FUNCTION(float16, roundevenf16, (float16 x)) { 194531f82cSOverMighty #if defined(__LIBC_USE_BUILTIN_ROUNDEVEN) && \ 2081ce7960SOverMighty defined(LIBC_TARGET_CPU_HAS_FAST_FLOAT16_OPS) 21*127349fcSOverMighty return fputil::cast<float16>(__builtin_roundevenf(x)); 224531f82cSOverMighty #else 2325b037bdSOverMighty return fputil::round_using_specific_rounding_mode(x, FP_INT_TONEAREST); 244531f82cSOverMighty #endif 2525b037bdSOverMighty } 2625b037bdSOverMighty 275ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 28