[NFC][Py Reformat] Added more commits to .git-blame-ignore-revs
[llvm-project.git] / libc / src / __support / FPUtil / aarch64 / nearest_integer.h
blob1726ec056ad50ac10910e5361d2e2c9124728dd6
1 //===--- Round floating point to nearest integer on aarch64 -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_NEAREST_INTEGER_H
10 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_NEAREST_INTEGER_H
12 #include "src/__support/common.h"
13 #include "src/__support/macros/properties/architectures.h"
15 #if !defined(LIBC_TARGET_ARCH_IS_AARCH64)
16 #error "Invalid include"
17 #endif
19 namespace __llvm_libc {
20 namespace fputil {
22 LIBC_INLINE float nearest_integer(float x) {
23 float result;
24 __asm__ __volatile__("frintn %s0, %s1\n\t" : "=w"(result) : "w"(x));
25 return result;
28 LIBC_INLINE double nearest_integer(double x) {
29 double result;
30 __asm__ __volatile__("frintn %d0, %d1\n\t" : "=w"(result) : "w"(x));
31 return result;
34 } // namespace fputil
35 } // namespace __llvm_libc
37 #endif // LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_NEAREST_INTEGER_H