Skip to content

Commit

Permalink
Let PowerPC world optionally build with -msoft-float. For FPU-less Po…
Browse files Browse the repository at this point in the history
…werPC

variations (e500 currently), this provides a gcc-level FPU emulation and is an
alternative approach to the recently introduced kernel-level emulation
(FPU_EMU).

Approved by:	cognet (mentor)
MFp4:		e500
  • Loading branch information
Rafal Jaworowski authored and Rafal Jaworowski committed Feb 24, 2008
1 parent 39358b4 commit 56ae1be
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gnu/lib/libgcc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ LIB2ADDEH = unwind-ia64.c unwind-sjlj.c unwind-c.c

.if ${TARGET_ARCH} == "powerpc"
# from config/rs6000/t-ppccomm
LIB2FUNCS_EXTRA = tramp.asm darwin-ldouble.c
LIB2FUNCS_EXTRA = tramp.asm
LIB2FUNCS_STATIC_EXTRA = eabi.asm
.endif

Expand Down
2 changes: 2 additions & 0 deletions lib/libc/powerpc/gen/flt_rounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <machine/float.h>

#ifndef _SOFT_FLOAT
static const int map[] = {
1, /* round to nearest */
0, /* round to zero */
Expand All @@ -52,3 +53,4 @@ __flt_rounds()
__asm__ __volatile("mffs %0" : "=f"(fpscr));
return map[(fpscr & 0x03)];
}
#endif
2 changes: 2 additions & 0 deletions lib/libc/powerpc/gen/fpgetmask.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <ieeefp.h>

#ifndef _SOFT_FLOAT
fp_except_t
fpgetmask()
{
Expand All @@ -51,3 +52,4 @@ fpgetmask()
__asm__("mffs %0" : "=f"(fpscr));
return ((fp_except_t)((fpscr >> 3) & 0x1f));
}
#endif
2 changes: 2 additions & 0 deletions lib/libc/powerpc/gen/fpgetround.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <ieeefp.h>

#ifndef _SOFT_FLOAT
fp_rnd_t
fpgetround()
{
Expand All @@ -51,3 +52,4 @@ fpgetround()
__asm__("mffs %0" : "=f"(fpscr));
return ((fp_rnd_t)(fpscr & 0x3));
}
#endif
2 changes: 2 additions & 0 deletions lib/libc/powerpc/gen/fpgetsticky.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <sys/types.h>
#include <ieeefp.h>

#ifndef _SOFT_FLOAT
#ifdef __weak_alias
__weak_alias(fpgetsticky,_fpgetsticky)
#endif
Expand All @@ -57,3 +58,4 @@ fpgetsticky()
__asm__ __volatile("mffs %0" : "=f"(fpscr));
return ((fp_except_t)((fpscr >> 25) & 0x1f));
}
#endif
2 changes: 2 additions & 0 deletions lib/libc/powerpc/gen/fpsetmask.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <ieeefp.h>

#ifndef _SOFT_FLOAT
fp_except_t
fpsetmask(fp_except_t mask)
{
Expand All @@ -55,3 +56,4 @@ fpsetmask(fp_except_t mask)
__asm__ __volatile("mtfsf 0xff,%0" :: "f"(fpscr));
return (old);
}
#endif
2 changes: 2 additions & 0 deletions lib/libc/powerpc/gen/fpsetround.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <ieeefp.h>

#ifndef _SOFT_FLOAT
fp_rnd_t
fpsetround(fp_rnd_t rnd_dir)
{
Expand All @@ -55,3 +56,4 @@ fpsetround(fp_rnd_t rnd_dir)
__asm__ __volatile("mtfsf 0xff,%0" :: "f"(fpscr));
return (old);
}
#endif
5 changes: 5 additions & 0 deletions lib/msun/powerpc/fenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@ extern const fenv_t __fe_dfl_env;
#define _ENABLE_MASK ((FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \
FE_OVERFLOW | FE_UNDERFLOW) >> _FPUSW_SHIFT)

#ifndef _SOFT_FLOAT
#define __mffs(__env) __asm __volatile("mffs %0" : "=f" (*(__env)))
#define __mtfsf(__env) __asm __volatile("mtfsf 255,%0" : : "f" (__env))
#else
#define __mffs(__env)
#define __mtfsf(__env)
#endif

union __fpscr {
double __d;
Expand Down
6 changes: 5 additions & 1 deletion sys/powerpc/include/float.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@

#include <sys/cdefs.h>

#ifndef _SOFT_FLOAT
__BEGIN_DECLS
extern int __flt_rounds(void);
__END_DECLS
#define FLT_ROUNDS __flt_rounds()
#else
#define FLT_ROUNDS -1
#endif

#define FLT_RADIX 2 /* b */
#define FLT_ROUNDS __flt_rounds()
#if __ISO_C_VISIBLE >= 1999
#define FLT_EVAL_METHOD 1 /* operands promoted to double */
#define DECIMAL_DIG 35 /* max precision in decimal digits */
Expand Down

0 comments on commit 56ae1be

Please sign in to comment.