riscv-rv32i: Add sqrtf function
The int_sqrtf() requires this function if we enable FPU. BRANCH=none BUG=none TEST=manual testing on console command: sqrtf(1.23) = 1.10 sqrtf(0.45) = 0.67 sqrtf(0) = 0 Change-Id: I354453674559ff2e1b956c9dba47baa493332871 Signed-off-by: Dino Li <dino.li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1982298 Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Dino Li <Dino.Li@ite.com.tw> Tested-by: Dino Li <Dino.Li@ite.com.tw>
This commit is contained in:
parent
5e2d7361a6
commit
186f3d2dcb
|
@ -14,4 +14,4 @@ $(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_riscv),\
|
||||||
CFLAGS_CPU+=-march=rv32imafc -mabi=ilp32f -Os
|
CFLAGS_CPU+=-march=rv32imafc -mabi=ilp32f -Os
|
||||||
LDFLAGS_EXTRA+=-mrelax
|
LDFLAGS_EXTRA+=-mrelax
|
||||||
|
|
||||||
core-y=cpu.o init.o panic.o task.o switch.o __builtin.o
|
core-y=cpu.o init.o panic.o task.o switch.o __builtin.o math.o
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Math utility functions for RISC-V */
|
||||||
|
|
||||||
|
#ifndef __CROS_EC_MATH_H
|
||||||
|
#define __CROS_EC_MATH_H
|
||||||
|
|
||||||
|
float sqrtf(float x);
|
||||||
|
|
||||||
|
#endif /* __CROS_EC_MATH_H */
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* Copyright 2020 The Chromium OS Authors. All rights reserved.
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_FPU
|
||||||
|
/* Single precision floating point square root. */
|
||||||
|
float sqrtf(float x)
|
||||||
|
{
|
||||||
|
asm volatile (
|
||||||
|
"fsqrt.s %0, %1"
|
||||||
|
: "=f" (x)
|
||||||
|
: "f" (x));
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue