micropython/lib/libm/thumb_vfp_sqrtf.c
Damien George cd527bb324 lib/libm: Move Thumb-specific sqrtf function to separate file.
This allows it to be used only when the hardware supports VFP
instructions, preventing compile errors.
2016-11-03 12:26:32 +11:00

12 lines
244 B
C

// an implementation of sqrtf for Thumb using hardware VFP instructions
#include <math.h>
float sqrtf(float x) {
asm volatile (
"vsqrt.f32 %[r], %[x]\n"
: [r] "=t" (x)
: [x] "t" (x));
return x;
}