Add support for the FPA floating-point format on ARM. The

FPA floating-point format is identical to the VFP format,
but is always stored in big-endian.
Introduce _IEEE_WORD_ORDER to describe the byte-order of
the FP representation.

Obtained from:	Juniper Networks, Inc
This commit is contained in:
Marcel Moolenaar 2008-12-23 22:20:59 +00:00
parent 4769218f4b
commit 74aed9855d
5 changed files with 46 additions and 5 deletions

View File

@ -26,15 +26,26 @@
* $FreeBSD$ * $FreeBSD$
*/ */
#if defined(__VFP_FP__)
#define _IEEE_WORD_ORDER _BYTE_ORDER
#else
#define _IEEE_WORD_ORDER _BIG_ENDIAN
#endif
union IEEEl2bits { union IEEEl2bits {
long double e; long double e;
struct { struct {
#ifndef __ARMEB__ #if _BYTE_ORDER == _LITTLE_ENDIAN
#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN
unsigned int manl :32; unsigned int manl :32;
#endif
unsigned int manh :20; unsigned int manh :20;
unsigned int exp :11; unsigned int exp :11;
unsigned int sign :1; unsigned int sign :1;
#else #if _IEEE_WORD_ORDER == _BIG_ENDIAN
unsigned int manl :32;
#endif
#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
unsigned int sign :1; unsigned int sign :1;
unsigned int exp :11; unsigned int exp :11;
unsigned int manh :20; unsigned int manh :20;

View File

@ -11,7 +11,7 @@
* architecture. See contrib/gdtoa/gdtoaimp.h for details. * architecture. See contrib/gdtoa/gdtoaimp.h for details.
*/ */
#ifndef __ARMEB__ #if !defined(__ARMEB__) && defined(__VFP_FP__)
#define IEEE_8087 #define IEEE_8087
#define Arith_Kind_ASL 1 #define Arith_Kind_ASL 1
#define Sudden_Underflow #define Sudden_Underflow

View File

@ -30,6 +30,10 @@
#include <sys/endian.h> #include <sys/endian.h>
#include "_fpmath.h" #include "_fpmath.h"
#ifndef _IEEE_WORD_ORDER
#define _IEEE_WORD_ORDER _BYTE_ORDER
#endif
union IEEEf2bits { union IEEEf2bits {
float f; float f;
struct { struct {
@ -52,10 +56,15 @@ union IEEEd2bits {
double d; double d;
struct { struct {
#if _BYTE_ORDER == _LITTLE_ENDIAN #if _BYTE_ORDER == _LITTLE_ENDIAN
#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN
unsigned int manl :32; unsigned int manl :32;
#endif
unsigned int manh :20; unsigned int manh :20;
unsigned int exp :11; unsigned int exp :11;
unsigned int sign :1; unsigned int sign :1;
#if _IEEE_WORD_ORDER == _BIG_ENDIAN
unsigned int manl :32;
#endif
#else /* _BIG_ENDIAN */ #else /* _BIG_ENDIAN */
unsigned int sign :1; unsigned int sign :1;
unsigned int exp :11; unsigned int exp :11;

View File

@ -38,7 +38,17 @@
* ints. * ints.
*/ */
#if BYTE_ORDER == BIG_ENDIAN #ifdef __arm__
#if defined(__VFP_FP__)
#define IEEE_WORD_ORDER BYTE_ORDER
#else
#define IEEE_WORD_ORDER BIG_ENDIAN
#endif
#else /* __arm__ */
#define IEEE_WORD_ORDER BYTE_ORDER
#endif
#if IEEE_WORD_ORDER == BIG_ENDIAN
typedef union typedef union
{ {
@ -52,7 +62,7 @@ typedef union
#endif #endif
#if BYTE_ORDER == LITTLE_ENDIAN #if IEEE_WORD_ORDER == LITTLE_ENDIAN
typedef union typedef union
{ {

View File

@ -91,6 +91,12 @@
#define DBL_EXPBITS 11 #define DBL_EXPBITS 11
#define DBL_FRACBITS 52 #define DBL_FRACBITS 52
#if defined(__VFP_FP__)
#define _IEEE_WORD_ORDER _BYTE_ORDER
#else
#define _IEEE_WORD_ORDER _BIG_ENDIAN
#endif
struct ieee_single { struct ieee_single {
#if _BYTE_ORDER == _BIG_ENDIAN #if _BYTE_ORDER == _BIG_ENDIAN
u_int sng_sign:1; u_int sng_sign:1;
@ -110,10 +116,15 @@ struct ieee_double {
u_int dbl_frach:20; u_int dbl_frach:20;
u_int dbl_fracl; u_int dbl_fracl;
#else #else
#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN
u_int dbl_fracl; u_int dbl_fracl;
#endif
u_int dbl_frach:20; u_int dbl_frach:20;
u_int dbl_exp:11; u_int dbl_exp:11;
u_int dbl_sign:1; u_int dbl_sign:1;
#if _IEEE_WORD_ORDER == _BIG_ENDIAN
u_int dbl_fracl;
#endif
#endif #endif
}; };