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