46 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_SQRT_H10#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_SQRT_H11 12#include "src/__support/common.h"13#include "src/__support/macros/config.h"14#include "src/__support/macros/properties/architectures.h"15#include "src/__support/macros/properties/cpu_features.h"16 17#if !defined(LIBC_TARGET_ARCH_IS_ARM)18#error "Invalid include"19#endif20 21#include "src/__support/FPUtil/generic/sqrt.h"22 23namespace LIBC_NAMESPACE_DECL {24namespace fputil {25 26#ifdef LIBC_TARGET_CPU_HAS_FPU_FLOAT27template <> LIBC_INLINE float sqrt<float>(float x) {28 float y;29 asm("vsqrt %0, %1\n\t" : "=w"(y) : "w"(x));30 return y;31}32#endif // LIBC_TARGET_CPU_HAS_FPU_FLOAT33 34#ifdef LIBC_TARGET_CPU_HAS_FPU_DOUBLE35template <> LIBC_INLINE double sqrt<double>(double x) {36 double y;37 asm("vsqrt %0, %1\n\t" : "=w"(y) : "w"(x));38 return y;39}40#endif // LIBC_TARGET_CPU_HAS_FPU_DOUBLE41 42} // namespace fputil43} // namespace LIBC_NAMESPACE_DECL44 45#endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_SQRT_H46