xref: /aosp_15_r20/external/llvm-libc/src/__support/FPUtil/aarch64/sqrt.h (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===-- Square root of IEEE 754 floating point numbers ----------*- 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 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_AARCH64_SQRT_H
10 #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_AARCH64_SQRT_H
11 
12 #include "src/__support/common.h"
13 #include "src/__support/macros/config.h"
14 #include "src/__support/macros/properties/architectures.h"
15 
16 #if !defined(LIBC_TARGET_ARCH_IS_AARCH64)
17 #error "Invalid include"
18 #endif
19 
20 #include "src/__support/FPUtil/generic/sqrt.h"
21 
22 namespace LIBC_NAMESPACE_DECL {
23 namespace fputil {
24 
25 template <> LIBC_INLINE float sqrt<float>(float x) {
26   float y;
27   __asm__ __volatile__("fsqrt %s0, %s1\n\t" : "=w"(y) : "w"(x));
28   return y;
29 }
30 
31 template <> LIBC_INLINE double sqrt<double>(double x) {
32   double y;
33   __asm__ __volatile__("fsqrt %d0, %d1\n\t" : "=w"(y) : "w"(x));
34   return y;
35 }
36 
37 } // namespace fputil
38 } // namespace LIBC_NAMESPACE_DECL
39 
40 #endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_AARCH64_SQRT_H
41