Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
49548b09
Commit
49548b09
authored
Apr 25, 2014
by
Ralf Baechle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MIPS: math-emu: Cleanup definition of structs describe sp/dp floats.
Signed-off-by:
Ralf Baechle
<
ralf@linux-mips.org
>
parent
de2fc342
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
80 deletions
+67
-80
arch/mips/math-emu/dp_sqrt.c
arch/mips/math-emu/dp_sqrt.c
+3
-3
arch/mips/math-emu/ieee754.c
arch/mips/math-emu/ieee754.c
+42
-43
arch/mips/math-emu/ieee754.h
arch/mips/math-emu/ieee754.h
+9
-22
arch/mips/math-emu/ieee754dp.h
arch/mips/math-emu/ieee754dp.h
+7
-6
arch/mips/math-emu/ieee754sp.h
arch/mips/math-emu/ieee754sp.h
+6
-6
No files found.
arch/mips/math-emu/dp_sqrt.c
View file @
49548b09
...
...
@@ -110,13 +110,13 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
/* triple to almost 56 sig. bits: y ~= sqrt(x) to within 1 ulp */
/* t=y*y; z=t; pt[n0]+=0x00100000; t+=z; z=(x-z)*y; */
z
=
t
=
ieee754dp_mul
(
y
,
y
);
t
.
parts
.
bexp
+=
0x001
;
t
.
bexp
+=
0x001
;
t
=
ieee754dp_add
(
t
,
z
);
z
=
ieee754dp_mul
(
ieee754dp_sub
(
x
,
z
),
y
);
/* t=z/(t+x) ; pt[n0]+=0x00100000; y+=t; */
t
=
ieee754dp_div
(
z
,
ieee754dp_add
(
t
,
x
));
t
.
parts
.
bexp
+=
0x001
;
t
.
bexp
+=
0x001
;
y
=
ieee754dp_add
(
y
,
t
);
/* twiddle last bit to force y correctly rounded */
...
...
@@ -155,7 +155,7 @@ union ieee754dp ieee754dp_sqrt(union ieee754dp x)
}
/* py[n0]=py[n0]+scalx; ...scale back y */
y
.
parts
.
bexp
+=
scalx
;
y
.
bexp
+=
scalx
;
/* restore rounding mode, possibly set inexact */
ieee754_csr
=
oldcsr
;
...
...
arch/mips/math-emu/ieee754.c
View file @
49548b09
...
...
@@ -30,64 +30,63 @@
#include <linux/compiler.h>
#include "ieee754
int
.h"
#include "ieee754.h"
#include "ieee754sp.h"
#include "ieee754dp.h"
/* special constants
*/
#define DP
STR(s, b, mh, ml)
\
#define DP
CNST(s, b, m)
\
{ \
.sign = (s), \
.bexp = (b), \
.manthi = (mh), \
.mantlo = (ml) \
.bexp = (b) + DP_EBIAS, \
.mant = (m) \
}
const
struct
ieee754dp_const
__ieee754dp_spcvals
[]
=
{
DP
STR
(
0
,
DP_EMIN
-
1
+
DP_EBIAS
,
0
,
0
),
/* + zero */
DP
STR
(
1
,
DP_EMIN
-
1
+
DP_EBIAS
,
0
,
0
),
/* - zero */
DP
STR
(
0
,
DP_EBIAS
,
0
,
0
),
/* + 1.0 */
DP
STR
(
1
,
DP_EBIAS
,
0
,
0
),
/* - 1.0 */
DP
STR
(
0
,
3
+
DP_EBIAS
,
0x40000
,
0
),
/* + 10.0 */
DP
STR
(
1
,
3
+
DP_EBIAS
,
0x40000
,
0
),
/* - 10.0 */
DP
STR
(
0
,
DP_EMAX
+
1
+
DP_EBIAS
,
0
,
0
),
/* + infinity */
DP
STR
(
1
,
DP_EMAX
+
1
+
DP_EBIAS
,
0
,
0
),
/* - infinity */
DP
STR
(
0
,
DP_EMAX
+
1
+
DP_EBIAS
,
0x7FFFF
,
0xFFFFFFFF
),
/* + indef quiet Nan */
DP
STR
(
0
,
DP_EMAX
+
DP_EBIAS
,
0xFFFFF
,
0xFFFFFFFF
),
/* + max */
DP
STR
(
1
,
DP_EMAX
+
DP_EBIAS
,
0xFFFFF
,
0xFFFFFFFF
),
/* - max */
DP
STR
(
0
,
DP_EMIN
+
DP_EBIAS
,
0
,
0
),
/* + min normal */
DP
STR
(
1
,
DP_EMIN
+
DP_EBIAS
,
0
,
0
),
/* - min normal */
DP
STR
(
0
,
DP_EMIN
-
1
+
DP_EBIAS
,
0
,
1
),
/* + min denormal */
DP
STR
(
1
,
DP_EMIN
-
1
+
DP_EBIAS
,
0
,
1
),
/* - min denormal */
DP
STR
(
0
,
31
+
DP_EBIAS
,
0
,
0
),
/* + 1.0e31 */
DP
STR
(
0
,
63
+
DP_EBIAS
,
0
,
0
),
/* + 1.0e63 */
const
union
ieee754dp
__ieee754dp_spcvals
[]
=
{
DP
CNST
(
0
,
DP_EMIN
-
1
,
0x0000000000000ULL
),
/* + zero */
DP
CNST
(
1
,
DP_EMIN
-
1
,
0x0000000000000ULL
),
/* - zero */
DP
CNST
(
0
,
0
,
0x0000000000000ULL
),
/* + 1.0 */
DP
CNST
(
1
,
0
,
0x0000000000000ULL
),
/* - 1.0 */
DP
CNST
(
0
,
3
,
0x4000000000000ULL
),
/* + 10.0 */
DP
CNST
(
1
,
3
,
0x4000000000000ULL
),
/* - 10.0 */
DP
CNST
(
0
,
DP_EMAX
+
1
,
0x0000000000000ULL
),
/* + infinity */
DP
CNST
(
1
,
DP_EMAX
+
1
,
0x0000000000000ULL
),
/* - infinity */
DP
CNST
(
0
,
DP_EMAX
+
1
,
0x7FFFFFFFFFFFFULL
),
/* + indef quiet Nan */
DP
CNST
(
0
,
DP_EMAX
,
0xFFFFFFFFFFFFFULL
),
/* + max */
DP
CNST
(
1
,
DP_EMAX
,
0xFFFFFFFFFFFFFULL
),
/* - max */
DP
CNST
(
0
,
DP_EMIN
,
0x0000000000000ULL
),
/* + min normal */
DP
CNST
(
1
,
DP_EMIN
,
0x0000000000000ULL
),
/* - min normal */
DP
CNST
(
0
,
DP_EMIN
-
1
,
0x0000000000001ULL
),
/* + min denormal */
DP
CNST
(
1
,
DP_EMIN
-
1
,
0x0000000000001ULL
),
/* - min denormal */
DP
CNST
(
0
,
31
,
0x0000000000000ULL
),
/* + 1.0e31 */
DP
CNST
(
0
,
63
,
0x0000000000000ULL
),
/* + 1.0e63 */
};
#define SP
STR
(s, b, m) \
#define SP
CNST
(s, b, m) \
{ \
.sign = (s), \
.bexp = (b)
,
\
.bexp = (b)
+ SP_EBIAS,
\
.mant = (m) \
}
const
struct
ieee754sp_const
__ieee754sp_spcvals
[]
=
{
SP
STR
(
0
,
SP_EMIN
-
1
+
SP_EBIAS
,
0
),
/* + zero */
SP
STR
(
1
,
SP_EMIN
-
1
+
SP_EBIAS
,
0
),
/* - zero */
SP
STR
(
0
,
SP_EBIAS
,
0
),
/* + 1.0 */
SP
STR
(
1
,
SP_EBIAS
,
0
),
/* - 1.0 */
SP
STR
(
0
,
3
+
SP_EBIAS
,
0x200000
),
/* + 10.0 */
SP
STR
(
1
,
3
+
SP_EBIAS
,
0x200000
),
/* - 10.0 */
SP
STR
(
0
,
SP_EMAX
+
1
+
SP_EBIAS
,
0
),
/* + infinity */
SP
STR
(
1
,
SP_EMAX
+
1
+
SP_EBIAS
,
0
),
/* - infinity */
SP
STR
(
0
,
SP_EMAX
+
1
+
SP_EBIAS
,
0x3FFFFF
),
/* + indef quiet Nan */
SP
STR
(
0
,
SP_EMAX
+
SP_EBIAS
,
0x7FFFFF
),
/* + max normal */
SP
STR
(
1
,
SP_EMAX
+
SP_EBIAS
,
0x7FFFFF
),
/* - max normal */
SP
STR
(
0
,
SP_EMIN
+
SP_EBIAS
,
0
),
/* + min normal */
SP
STR
(
1
,
SP_EMIN
+
SP_EBIAS
,
0
),
/* - min normal */
SP
STR
(
0
,
SP_EMIN
-
1
+
SP_EBIAS
,
1
),
/* + min denormal */
SP
STR
(
1
,
SP_EMIN
-
1
+
SP_EBIAS
,
1
),
/* - min denormal */
SP
STR
(
0
,
31
+
SP_EBIAS
,
0
),
/* + 1.0e31 */
SP
STR
(
0
,
63
+
SP_EBIAS
,
0
),
/* + 1.0e63 */
const
union
ieee754sp
__ieee754sp_spcvals
[]
=
{
SP
CNST
(
0
,
SP_EMIN
-
1
,
0x00000
0
),
/* + zero */
SP
CNST
(
1
,
SP_EMIN
-
1
,
0x00000
0
),
/* - zero */
SP
CNST
(
0
,
0
,
0x00000
0
),
/* + 1.0 */
SP
CNST
(
1
,
0
,
0x00000
0
),
/* - 1.0 */
SP
CNST
(
0
,
3
,
0x200000
),
/* + 10.0 */
SP
CNST
(
1
,
3
,
0x200000
),
/* - 10.0 */
SP
CNST
(
0
,
SP_EMAX
+
1
,
0x00000
0
),
/* + infinity */
SP
CNST
(
1
,
SP_EMAX
+
1
,
0x00000
0
),
/* - infinity */
SP
CNST
(
0
,
SP_EMAX
+
1
,
0x3FFFFF
),
/* + indef quiet Nan */
SP
CNST
(
0
,
SP_EMAX
,
0x7FFFFF
),
/* + max normal */
SP
CNST
(
1
,
SP_EMAX
,
0x7FFFFF
),
/* - max normal */
SP
CNST
(
0
,
SP_EMIN
,
0x00000
0
),
/* + min normal */
SP
CNST
(
1
,
SP_EMIN
,
0x00000
0
),
/* - min normal */
SP
CNST
(
0
,
SP_EMIN
-
1
,
0x00000
1
),
/* + min denormal */
SP
CNST
(
1
,
SP_EMIN
-
1
,
0x00000
1
),
/* - min denormal */
SP
CNST
(
0
,
31
,
0x00000
0
),
/* + 1.0e31 */
SP
CNST
(
0
,
63
,
0x00000
0
),
/* + 1.0e63 */
};
arch/mips/math-emu/ieee754.h
View file @
49548b09
...
...
@@ -31,36 +31,23 @@
#include <linux/sched.h>
#include <asm/bitfield.h>
struct
ieee754dp_const
{
__BITFIELD_FIELD
(
unsigned
sign
:
1
,
__BITFIELD_FIELD
(
unsigned
bexp
:
11
,
__BITFIELD_FIELD
(
unsigned
manthi
:
20
,
__BITFIELD_FIELD
(
unsigned
mantlo
:
32
,
;))))
};
union
ieee754dp
{
struct
ieee754dp_const
oparts
;
struct
{
__BITFIELD_FIELD
(
unsigned
int
sign
:
1
,
__BITFIELD_FIELD
(
unsigned
int
bexp
:
11
,
__BITFIELD_FIELD
(
u64
mant
:
52
,
;)))
}
parts
;
double
d
;
};
u64
bits
;
};
struct
ieee754sp_const
{
union
ieee754sp
{
struct
{
__BITFIELD_FIELD
(
unsigned
sign
:
1
,
__BITFIELD_FIELD
(
unsigned
bexp
:
8
,
__BITFIELD_FIELD
(
unsigned
mant
:
23
,
;)))
};
union
ieee754sp
{
struct
ieee754sp_const
parts
;
float
f
;
};
u32
bits
;
};
...
...
@@ -299,8 +286,8 @@ union ieee754dp ieee754dp_dump(char *s, union ieee754dp x);
#define IEEE754_SPCVAL_P1E31 15
/* + 1.0e31 */
#define IEEE754_SPCVAL_P1E63 16
/* + 1.0e63 */
extern
const
struct
ieee754dp_const
__ieee754dp_spcvals
[];
extern
const
struct
ieee754sp_const
__ieee754sp_spcvals
[];
extern
const
union
ieee754dp
__ieee754dp_spcvals
[];
extern
const
union
ieee754sp
__ieee754sp_spcvals
[];
#define ieee754dp_spcvals ((const union ieee754dp *)__ieee754dp_spcvals)
#define ieee754sp_spcvals ((const union ieee754sp *)__ieee754sp_spcvals)
...
...
arch/mips/math-emu/ieee754dp.h
View file @
49548b09
...
...
@@ -40,9 +40,9 @@
#define DP_HIDDEN_BIT DP_MBIT(DP_FBITS)
#define DP_SIGN_BIT DP_MBIT(63)
#define DPSIGN(dp) (dp.
parts.
sign)
#define DPBEXP(dp) (dp.
parts.
bexp)
#define DPMANT(dp) (dp.
parts.
mant)
#define DPSIGN(dp) (dp.sign)
#define DPBEXP(dp) (dp.bexp)
#define DPMANT(dp) (dp.mant)
static
inline
int
ieee754dp_finite
(
union
ieee754dp
x
)
{
...
...
@@ -74,9 +74,10 @@ static inline union ieee754dp builddp(int s, int bx, u64 m)
&&
(
bx
)
<=
DP_EMAX
+
1
+
DP_EBIAS
);
assert
(((
m
)
>>
DP_FBITS
)
==
0
);
r
.
parts
.
sign
=
s
;
r
.
parts
.
bexp
=
bx
;
r
.
parts
.
mant
=
m
;
r
.
sign
=
s
;
r
.
bexp
=
bx
;
r
.
mant
=
m
;
return
r
;
}
...
...
arch/mips/math-emu/ieee754sp.h
View file @
49548b09
...
...
@@ -40,9 +40,9 @@
#define SP_HIDDEN_BIT SP_MBIT(SP_FBITS)
#define SP_SIGN_BIT SP_MBIT(31)
#define SPSIGN(sp) (sp.
parts.
sign)
#define SPBEXP(sp) (sp.
parts.
bexp)
#define SPMANT(sp) (sp.
parts.
mant)
#define SPSIGN(sp) (sp.sign)
#define SPBEXP(sp) (sp.bexp)
#define SPMANT(sp) (sp.mant)
static
inline
int
ieee754sp_finite
(
union
ieee754sp
x
)
{
...
...
@@ -79,9 +79,9 @@ static inline union ieee754sp buildsp(int s, int bx, unsigned m)
&&
(
bx
)
<=
SP_EMAX
+
1
+
SP_EBIAS
);
assert
(((
m
)
>>
SP_FBITS
)
==
0
);
r
.
parts
.
sign
=
s
;
r
.
parts
.
bexp
=
bx
;
r
.
parts
.
mant
=
m
;
r
.
sign
=
s
;
r
.
bexp
=
bx
;
r
.
mant
=
m
;
return
r
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment