Skip to content

Commit

Permalink
riscv: Support soft float
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelforney committed Oct 18, 2018
1 parent 3d06ad0 commit 988d64a
Show file tree
Hide file tree
Showing 48 changed files with 360 additions and 120 deletions.
15 changes: 15 additions & 0 deletions src/math/riscv32/copysign.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 64

double copysign(double x, double y)
{
__asm__ ("fsgnj.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
return x;
}

#else

#include "../copysign.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/copysign.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv32/copysignf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 32

float copysignf(float x, float y)
{
__asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
return x;
}

#else

#include "../copysignf.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/copysignf.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv32/fabs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 64

double fabs(double x)
{
__asm__ ("fabs.d %0, %1" : "=f"(x) : "f"(x));
return x;
}

#else

#include "../fabs.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/fabs.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv32/fabsf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 32

float fabsf(float x)
{
__asm__ ("fabs.s %0, %1" : "=f"(x) : "f"(x));
return x;
}

#else

#include "../fabsf.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/fabsf.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv32/fma.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 64

double fma(double x, double y, double z)
{
__asm__ ("fmadd.d %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
return x;
}

#else

#include "../fma.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/fma.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv32/fmaf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 32

float fmaf(float x, float y, float z)
{
__asm__ ("fmadd.s %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
return x;
}

#else

#include "../fmaf.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/fmaf.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv32/fmax.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 64

double fmax(double x, double y)
{
__asm__ ("fmax.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
return x;
}

#else

#include "../fmax.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/fmax.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv32/fmaxf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 32

float fmaxf(float x, float y)
{
__asm__ ("fmax.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
return x;
}

#else

#include "../fmaxf.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/fmaxf.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv32/fmin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 64

double fmin(double x, double y)
{
__asm__ ("fmin.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
return x;
}

#else

#include "../fmin.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/fmin.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv32/fminf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 32

float fminf(float x, float y)
{
__asm__ ("fmin.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
return x;
}

#else

#include "../fminf.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/fminf.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv32/sqrt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 64

double sqrt(double x)
{
__asm__ ("sqrt.d %0, %1" : "=f"(x) : "f"(x));
return x;
}

#else

#include "../sqrt.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/sqrt.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv32/sqrtf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 32

float sqrtf(float x)
{
__asm__ ("fsqrt.s %0, %1" : "=f"(x) : "f"(x));
return x;
}

#else

#include "../sqrtf.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv32/sqrtf.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv64/copysign.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 64

double copysign(double x, double y)
{
__asm__ ("fsgnj.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
return x;
}

#else

#include "../copysign.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv64/copysign.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv64/copysignf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 32

float copysignf(float x, float y)
{
__asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
return x;
}

#else

#include "../copysignf.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv64/copysignf.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv64/fabs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 64

double fabs(double x)
{
__asm__ ("fabs.d %0, %1" : "=f"(x) : "f"(x));
return x;
}

#else

#include "../fabs.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv64/fabs.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv64/fabsf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 32

float fabsf(float x)
{
__asm__ ("fabs.s %0, %1" : "=f"(x) : "f"(x));
return x;
}

#else

#include "../fabsf.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv64/fabsf.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv64/fma.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 64

double fma(double x, double y, double z)
{
__asm__ ("fmadd.d %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
return x;
}

#else

#include "../fma.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv64/fma.s

This file was deleted.

15 changes: 15 additions & 0 deletions src/math/riscv64/fmaf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <math.h>

#if __riscv_flen >= 32

float fmaf(float x, float y, float z)
{
__asm__ ("fmadd.s %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
return x;
}

#else

#include "../fmaf.c"

#endif
5 changes: 0 additions & 5 deletions src/math/riscv64/fmaf.s

This file was deleted.

Loading

0 comments on commit 988d64a

Please sign in to comment.