Commit f80cc08d authored by Ralf Baechle's avatar Ralf Baechle

MIPS: math-emu: Use __BITFIELD_FIELD to eleminate redundant definitions.

Union _ieee754sp was even duplicated even though there are no endian
dependencies in it all.
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 64a17a0f
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <asm/bitfield.h>
/* /*
* Not very pretty, but the Linux kernel's normal va_list definition * Not very pretty, but the Linux kernel's normal va_list definition
...@@ -36,60 +37,31 @@ ...@@ -36,60 +37,31 @@
#include <stdarg.h> #include <stdarg.h>
#endif #endif
#ifdef __LITTLE_ENDIAN
struct ieee754dp_konst { struct ieee754dp_konst {
unsigned mantlo:32; __BITFIELD_FIELD(unsigned sign:1,
unsigned manthi:20; __BITFIELD_FIELD(unsigned bexp:11,
unsigned bexp:11; __BITFIELD_FIELD(unsigned manthi:20,
unsigned sign:1; __BITFIELD_FIELD(unsigned mantlo:32,
}; ;))))
struct ieee754sp_konst {
unsigned mant:23;
unsigned bexp:8;
unsigned sign:1;
}; };
typedef union _ieee754dp { typedef union _ieee754dp {
struct ieee754dp_konst oparts; struct ieee754dp_konst oparts;
struct { struct {
u64 mant:52; __BITFIELD_FIELD(unsigned int sign:1,
unsigned int bexp:11; __BITFIELD_FIELD(unsigned int bexp:11,
unsigned int sign:1; __BITFIELD_FIELD(u64 mant:52,
} parts; ;)))
u64 bits;
double d;
} ieee754dp;
typedef union _ieee754sp {
struct ieee754sp_konst parts;
float f;
u32 bits;
} ieee754sp;
#endif
#ifdef __BIG_ENDIAN
struct ieee754dp_konst {
unsigned sign:1;
unsigned bexp:11;
unsigned manthi:20;
unsigned mantlo:32;
};
typedef union _ieee754dp {
struct ieee754dp_konst oparts;
struct {
unsigned int sign:1;
unsigned int bexp:11;
u64 mant:52;
} parts; } parts;
double d; double d;
u64 bits; u64 bits;
} ieee754dp; } ieee754dp;
struct ieee754sp_konst { struct ieee754sp_konst {
unsigned sign:1; __BITFIELD_FIELD(unsigned sign:1,
unsigned bexp:8; __BITFIELD_FIELD(unsigned bexp:8,
unsigned mant:23; __BITFIELD_FIELD(unsigned mant:23,
;)))
}; };
typedef union _ieee754sp { typedef union _ieee754sp {
...@@ -97,7 +69,6 @@ typedef union _ieee754sp { ...@@ -97,7 +69,6 @@ typedef union _ieee754sp {
float f; float f;
u32 bits; u32 bits;
} ieee754sp; } ieee754sp;
#endif
/* /*
* single precision (often aka float) * single precision (often aka float)
...@@ -307,26 +278,15 @@ char *ieee754dp_tstr(ieee754dp x, int prec, int fmt, int af); ...@@ -307,26 +278,15 @@ char *ieee754dp_tstr(ieee754dp x, int prec, int fmt, int af);
* The control status register * The control status register
*/ */
struct _ieee754_csr { struct _ieee754_csr {
#ifdef __BIG_ENDIAN __BITFIELD_FIELD(unsigned pad0:7,
unsigned pad0:7; __BITFIELD_FIELD(unsigned nod:1, /* set 1 for no denormalised numbers */
unsigned nod:1; /* set 1 for no denormalised numbers */ __BITFIELD_FIELD(unsigned c:1, /* condition */
unsigned c:1; /* condition */ __BITFIELD_FIELD(unsigned pad1:5,
unsigned pad1:5; __BITFIELD_FIELD(unsigned cx:6, /* exceptions this operation */
unsigned cx:6; /* exceptions this operation */ __BITFIELD_FIELD(unsigned mx:5, /* exception enable mask */
unsigned mx:5; /* exception enable mask */ __BITFIELD_FIELD(unsigned sx:5, /* exceptions total */
unsigned sx:5; /* exceptions total */ __BITFIELD_FIELD(unsigned rm:2, /* current rounding mode */
unsigned rm:2; /* current rounding mode */ ;))))))))
#endif
#ifdef __LITTLE_ENDIAN
unsigned rm:2; /* current rounding mode */
unsigned sx:5; /* exceptions total */
unsigned mx:5; /* exception enable mask */
unsigned cx:6; /* exceptions this operation */
unsigned pad1:5;
unsigned c:1; /* condition */
unsigned nod:1; /* set 1 for no denormalised numbers */
unsigned pad0:7;
#endif
}; };
#define ieee754_csr (*(struct _ieee754_csr *)(&current->thread.fpu.fcr31)) #define ieee754_csr (*(struct _ieee754_csr *)(&current->thread.fpu.fcr31))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment