MIPS: math-emu: Reformat code according to coding style.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
Ralf Baechle 2014-04-16 11:00:12 +02:00
parent 85c51c511d
commit 47fa0c0251
7 changed files with 138 additions and 131 deletions

View File

@ -869,14 +869,16 @@ static inline int cop1_64bit(struct pt_regs *xcp)
#endif
}
#define SIFROMREG(si, x) do { \
#define SIFROMREG(si, x) \
do { \
if (cop1_64bit(xcp)) \
(si) = get_fpr32(&ctx->fpr[x], 0); \
else \
(si) = get_fpr32(&ctx->fpr[(x) & ~1], (x) & 1); \
} while (0)
#define SITOREG(si, x) do { \
#define SITOREG(si, x) \
do { \
if (cop1_64bit(xcp)) { \
unsigned i; \
set_fpr32(&ctx->fpr[x], 0, si); \
@ -889,17 +891,19 @@ static inline int cop1_64bit(struct pt_regs *xcp)
#define SIFROMHREG(si, x) ((si) = get_fpr32(&ctx->fpr[x], 1))
#define SITOHREG(si, x) do { \
#define SITOHREG(si, x) \
do { \
unsigned i; \
set_fpr32(&ctx->fpr[x], 1, si); \
for (i = 2; i < ARRAY_SIZE(ctx->fpr[x].val32); i++) \
set_fpr32(&ctx->fpr[x], i, 0); \
} while (0)
#define DIFROMREG(di, x) \
#define DIFROMREG(di, x) \
((di) = get_fpr64(&ctx->fpr[(x) & ~(cop1_64bit(xcp) == 0)], 0))
#define DITOREG(di, x) do { \
#define DITOREG(di, x) \
do { \
unsigned fpr, i; \
fpr = (x) & ~(cop1_64bit(xcp) == 0); \
set_fpr64(&ctx->fpr[fpr], 0, di); \
@ -1341,20 +1345,20 @@ static const unsigned char cmptab[8] = {
* Additional MIPS4 instructions
*/
#define DEF3OP(name, p, f1, f2, f3) \
static union ieee754##p fpemu_##p##_##name(union ieee754##p r, union ieee754##p s, \
union ieee754##p t) \
{ \
struct _ieee754_csr ieee754_csr_save; \
s = f1(s, t); \
ieee754_csr_save = ieee754_csr; \
s = f2(s, r); \
ieee754_csr_save.cx |= ieee754_csr.cx; \
ieee754_csr_save.sx |= ieee754_csr.sx; \
s = f3(s); \
ieee754_csr.cx |= ieee754_csr_save.cx; \
ieee754_csr.sx |= ieee754_csr_save.sx; \
return s; \
#define DEF3OP(name, p, f1, f2, f3) \
static union ieee754##p fpemu_##p##_##name(union ieee754##p r, \
union ieee754##p s, union ieee754##p t) \
{ \
struct _ieee754_csr ieee754_csr_save; \
s = f1(s, t); \
ieee754_csr_save = ieee754_csr; \
s = f2(s, r); \
ieee754_csr_save.cx |= ieee754_csr.cx; \
ieee754_csr_save.sx |= ieee754_csr.sx; \
s = f3(s); \
ieee754_csr.cx |= ieee754_csr_save.cx; \
ieee754_csr.sx |= ieee754_csr_save.sx; \
return s; \
}
static union ieee754dp fpemu_dp_recip(union ieee754dp d)

View File

@ -151,12 +151,12 @@ union ieee754dp ieee754dp_format(int sn, int xe, u64 xm)
case IEEE754_RZ:
return ieee754dp_zero(sn);
case IEEE754_RU: /* toward +Infinity */
if(sn == 0)
if (sn == 0)
return ieee754dp_min(0);
else
return ieee754dp_zero(1);
case IEEE754_RD: /* toward -Infinity */
if(sn == 0)
if (sn == 0)
return ieee754dp_zero(0);
else
return ieee754dp_min(1);

View File

@ -32,17 +32,17 @@
/* 3bit extended double precision sticky right shift */
#define XDPSRS(v,rs) \
((rs > (DP_MBITS+3))?1:((v) >> (rs)) | ((v) << (64-(rs)) != 0))
((rs > (DP_MBITS+3))?1:((v) >> (rs)) | ((v) << (64-(rs)) != 0))
#define XDPSRSX1() \
(xe++, (xm = (xm >> 1) | (xm & 1)))
(xe++, (xm = (xm >> 1) | (xm & 1)))
#define XDPSRS1(v) \
(((v) >> 1) | ((v) & 1))
(((v) >> 1) | ((v) & 1))
/* convert denormal to normalized with extended exponent */
#define DPDNORMx(m,e) \
while( (m >> DP_MBITS) == 0) { m <<= 1; e--; }
while ((m >> DP_MBITS) == 0) { m <<= 1; e--; }
#define DPDNORMX DPDNORMx(xm, xe)
#define DPDNORMY DPDNORMx(ym, ye)
@ -71,13 +71,13 @@ extern union ieee754dp ieee754dp_bestnan(union ieee754dp, union ieee754dp);
extern union ieee754dp ieee754dp_format(int, int, u64);
#define DPNORMRET2(s, e, m, name, a0, a1) \
{ \
union ieee754dp V = ieee754dp_format(s, e, m); \
if(TSTX()) \
return ieee754dp_xcpt(V, name, a0, a1); \
else \
return V; \
#define DPNORMRET2(s, e, m, name, a0, a1) \
{ \
union ieee754dp V = ieee754dp_format(s, e, m); \
if (TSTX()) \
return ieee754dp_xcpt(V, name, a0, a1); \
else \
return V; \
}
#define DPNORMRET1(s, e, m, name, a0) DPNORMRET2(s, e, m, name, a0, a0)

View File

@ -57,105 +57,105 @@
#define CLPAIR(x, y) ((x)*6+(y))
#define CLEARCX \
(ieee754_csr.cx = 0)
(ieee754_csr.cx = 0)
#define SETCX(x) \
(ieee754_csr.cx |= (x), ieee754_csr.sx |= (x))
(ieee754_csr.cx |= (x), ieee754_csr.sx |= (x))
#define SETANDTESTCX(x) \
(SETCX(x), ieee754_csr.mx & (x))
(SETCX(x), ieee754_csr.mx & (x))
#define TSTX() \
(ieee754_csr.cx & ieee754_csr.mx)
#define COMPXSP \
unsigned xm; int xe; int xs __maybe_unused; int xc
unsigned xm; int xe; int xs __maybe_unused; int xc
#define COMPYSP \
unsigned ym; int ye; int ys; int yc
unsigned ym; int ye; int ys; int yc
#define EXPLODESP(v, vc, vs, ve, vm) \
{\
vs = SPSIGN(v);\
ve = SPBEXP(v);\
vm = SPMANT(v);\
if(ve == SP_EMAX+1+SP_EBIAS){\
if(vm == 0)\
vc = IEEE754_CLASS_INF;\
else if(vm & SP_MBIT(SP_MBITS-1)) \
vc = IEEE754_CLASS_SNAN;\
else \
vc = IEEE754_CLASS_QNAN;\
} else if(ve == SP_EMIN-1+SP_EBIAS) {\
if(vm) {\
ve = SP_EMIN;\
vc = IEEE754_CLASS_DNORM;\
} else\
vc = IEEE754_CLASS_ZERO;\
} else {\
ve -= SP_EBIAS;\
vm |= SP_HIDDEN_BIT;\
vc = IEEE754_CLASS_NORM;\
}\
#define EXPLODESP(v, vc, vs, ve, vm) \
{ \
vs = SPSIGN(v); \
ve = SPBEXP(v); \
vm = SPMANT(v); \
if (ve == SP_EMAX+1+SP_EBIAS) { \
if (vm == 0) \
vc = IEEE754_CLASS_INF; \
else if (vm & SP_MBIT(SP_MBITS-1)) \
vc = IEEE754_CLASS_SNAN; \
else \
vc = IEEE754_CLASS_QNAN; \
} else if (ve == SP_EMIN-1+SP_EBIAS) { \
if (vm) { \
ve = SP_EMIN; \
vc = IEEE754_CLASS_DNORM; \
} else \
vc = IEEE754_CLASS_ZERO; \
} else { \
ve -= SP_EBIAS; \
vm |= SP_HIDDEN_BIT; \
vc = IEEE754_CLASS_NORM; \
} \
}
#define EXPLODEXSP EXPLODESP(x, xc, xs, xe, xm)
#define EXPLODEYSP EXPLODESP(y, yc, ys, ye, ym)
#define COMPXDP \
u64 xm; int xe; int xs __maybe_unused; int xc
u64 xm; int xe; int xs __maybe_unused; int xc
#define COMPYDP \
u64 ym; int ye; int ys; int yc
u64 ym; int ye; int ys; int yc
#define EXPLODEDP(v, vc, vs, ve, vm) \
{\
vm = DPMANT(v);\
vs = DPSIGN(v);\
ve = DPBEXP(v);\
if(ve == DP_EMAX+1+DP_EBIAS){\
if(vm == 0)\
vc = IEEE754_CLASS_INF;\
else if(vm & DP_MBIT(DP_MBITS-1)) \
vc = IEEE754_CLASS_SNAN;\
else \
vc = IEEE754_CLASS_QNAN;\
} else if(ve == DP_EMIN-1+DP_EBIAS) {\
if(vm) {\
ve = DP_EMIN;\
vc = IEEE754_CLASS_DNORM;\
} else\
vc = IEEE754_CLASS_ZERO;\
} else {\
ve -= DP_EBIAS;\
vm |= DP_HIDDEN_BIT;\
vc = IEEE754_CLASS_NORM;\
}\
#define EXPLODEDP(v, vc, vs, ve, vm) \
{ \
vm = DPMANT(v); \
vs = DPSIGN(v); \
ve = DPBEXP(v); \
if (ve == DP_EMAX+1+DP_EBIAS) { \
if (vm == 0) \
vc = IEEE754_CLASS_INF; \
else if (vm & DP_MBIT(DP_MBITS-1)) \
vc = IEEE754_CLASS_SNAN; \
else \
vc = IEEE754_CLASS_QNAN; \
} else if (ve == DP_EMIN-1+DP_EBIAS) { \
if (vm) { \
ve = DP_EMIN; \
vc = IEEE754_CLASS_DNORM; \
} else \
vc = IEEE754_CLASS_ZERO; \
} else { \
ve -= DP_EBIAS; \
vm |= DP_HIDDEN_BIT; \
vc = IEEE754_CLASS_NORM; \
} \
}
#define EXPLODEXDP EXPLODEDP(x, xc, xs, xe, xm)
#define EXPLODEYDP EXPLODEDP(y, yc, ys, ye, ym)
#define FLUSHDP(v, vc, vs, ve, vm) \
if(vc==IEEE754_CLASS_DNORM) {\
if(ieee754_csr.nod) {\
SETCX(IEEE754_INEXACT);\
vc = IEEE754_CLASS_ZERO;\
ve = DP_EMIN-1+DP_EBIAS;\
vm = 0;\
v = ieee754dp_zero(vs);\
}\
#define FLUSHDP(v, vc, vs, ve, vm) \
if (vc==IEEE754_CLASS_DNORM) { \
if (ieee754_csr.nod) { \
SETCX(IEEE754_INEXACT); \
vc = IEEE754_CLASS_ZERO; \
ve = DP_EMIN-1+DP_EBIAS; \
vm = 0; \
v = ieee754dp_zero(vs); \
} \
}
#define FLUSHSP(v, vc, vs, ve, vm) \
if(vc==IEEE754_CLASS_DNORM) {\
if(ieee754_csr.nod) {\
SETCX(IEEE754_INEXACT);\
vc = IEEE754_CLASS_ZERO;\
ve = SP_EMIN-1+SP_EBIAS;\
vm = 0;\
v = ieee754sp_zero(vs);\
}\
#define FLUSHSP(v, vc, vs, ve, vm) \
if (vc==IEEE754_CLASS_DNORM) { \
if (ieee754_csr.nod) { \
SETCX(IEEE754_INEXACT); \
vc = IEEE754_CLASS_ZERO; \
ve = SP_EMIN-1+SP_EBIAS; \
vm = 0; \
v = ieee754sp_zero(vs); \
} \
}
#define FLUSHXDP FLUSHDP(x, xc, xs, xe, xm)

View File

@ -152,12 +152,12 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm)
case IEEE754_RZ:
return ieee754sp_zero(sn);
case IEEE754_RU: /* toward +Infinity */
if(sn == 0)
if (sn == 0)
return ieee754sp_min(0);
else
return ieee754sp_zero(1);
case IEEE754_RD: /* toward -Infinity */
if(sn == 0)
if (sn == 0)
return ieee754sp_zero(0);
else
return ieee754sp_min(1);
@ -174,8 +174,7 @@ union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm)
/* Clear grs bits */
xm &= ~(SP_MBIT(3) - 1);
xe++;
}
else {
} else {
/* sticky right shift es bits
*/
SPXSRSXn(es);

View File

@ -31,23 +31,23 @@
#define assert(expr) ((void)0)
/* 3bit extended single precision sticky right shift */
#define SPXSRSXn(rs) \
(xe += rs, \
xm = (rs > (SP_MBITS+3))?1:((xm) >> (rs)) | ((xm) << (32-(rs)) != 0))
#define SPXSRSXn(rs) \
(xe += rs, \
xm = (rs > (SP_MBITS+3))?1:((xm) >> (rs)) | ((xm) << (32-(rs)) != 0))
#define SPXSRSX1() \
(xe++, (xm = (xm >> 1) | (xm & 1)))
(xe++, (xm = (xm >> 1) | (xm & 1)))
#define SPXSRSYn(rs) \
(ye+=rs, \
ym = (rs > (SP_MBITS+3))?1:((ym) >> (rs)) | ((ym) << (32-(rs)) != 0))
#define SPXSRSYn(rs) \
(ye+=rs, \
ym = (rs > (SP_MBITS+3))?1:((ym) >> (rs)) | ((ym) << (32-(rs)) != 0))
#define SPXSRSY1() \
(ye++, (ym = (ym >> 1) | (ym & 1)))
(ye++, (ym = (ym >> 1) | (ym & 1)))
/* convert denormal to normalized with extended exponent */
#define SPDNORMx(m,e) \
while( (m >> SP_MBITS) == 0) { m <<= 1; e--; }
while ((m >> SP_MBITS) == 0) { m <<= 1; e--; }
#define SPDNORMX SPDNORMx(xm, xe)
#define SPDNORMY SPDNORMx(ym, ye)
@ -77,13 +77,14 @@ extern union ieee754sp ieee754sp_bestnan(union ieee754sp, union ieee754sp);
extern union ieee754sp ieee754sp_format(int, int, unsigned);
#define SPNORMRET2(s, e, m, name, a0, a1) \
{ \
union ieee754sp V = ieee754sp_format(s, e, m); \
if(TSTX()) \
return ieee754sp_xcpt(V, name, a0, a1); \
else \
return V; \
#define SPNORMRET2(s, e, m, name, a0, a1) \
{ \
union ieee754sp V = ieee754sp_format(s, e, m); \
\
if (TSTX()) \
return ieee754sp_xcpt(V, name, a0, a1); \
else \
return V; \
}
#define SPNORMRET1(s, e, m, name, a0) SPNORMRET2(s, e, m, name, a0, a0)

View File

@ -38,14 +38,17 @@ static int __init debugfs_fpuemu(void)
if (!dir)
return -ENOMEM;
#define FPU_STAT_CREATE(M) \
do { \
d = debugfs_create_file(#M , S_IRUGO, dir, \
(void *)offsetof(struct mips_fpu_emulator_stats, M), \
&fops_fpuemu_stat); \
if (!d) \
return -ENOMEM; \
} while (0)
#define FPU_EMU_STAT_OFFSET(m) \
offsetof(struct mips_fpu_emulator_stats, m)
#define FPU_STAT_CREATE(m) \
do { \
d = debugfs_create_file(#m , S_IRUGO, dir, \
(void *)FPU_EMU_STAT_OFFSET(m), \
&fops_fpuemu_stat); \
if (!d) \
return -ENOMEM; \
} while (0)
FPU_STAT_CREATE(emulated);
FPU_STAT_CREATE(loads);