1 //===-- Square root of IEEE 754 floating point numbers ----------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_SQRT_H
10 #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_SQRT_H
12 #include "src/__support/common.h"
13 #include "src/__support/macros/config.h"
14 #include "src/__support/macros/properties/architectures.h"
16 #if !defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
17 #error "Invalid include"
20 #include "src/__support/FPUtil/generic/sqrt.h"
22 namespace LIBC_NAMESPACE_DECL
{
26 template <> LIBC_INLINE
float sqrt
<float>(float x
) {
28 __asm__
__volatile__("fsqrt.s %0, %1\n\t" : "=f"(result
) : "f"(x
));
32 #if __riscv_flen >= 64
33 template <> LIBC_INLINE
double sqrt
<double>(double x
) {
35 __asm__
__volatile__("fsqrt.d %0, %1\n\t" : "=f"(result
) : "f"(x
));
38 #endif // __riscv_flen >= 64
39 #endif // __riscv_flen
42 } // namespace LIBC_NAMESPACE_DECL
44 #endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_SQRT_H