• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/properties/architectures.h"
14 
15 #if !defined(LIBC_TARGET_ARCH_IS_AARCH64)
16 #error "Invalid include"
17 #endif
18 
19 #include "src/__support/FPUtil/generic/sqrt.h"
20 
21 namespace LIBC_NAMESPACE {
22 namespace fputil {
23 
24 template <> LIBC_INLINE float sqrt<float>(float x) {
25   float y;
26   __asm__ __volatile__("fsqrt %s0, %s1\n\t" : "=w"(y) : "w"(x));
27   return y;
28 }
29 
30 template <> LIBC_INLINE double sqrt<double>(double x) {
31   double y;
32   __asm__ __volatile__("fsqrt %d0, %d1\n\t" : "=w"(y) : "w"(x));
33   return y;
34 }
35 
36 } // namespace fputil
37 } // namespace LIBC_NAMESPACE
38 
39 #endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_AARCH64_SQRT_H
40