aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/math-emu/cp1emu.c
diff options
context:
space:
mode:
authorPaul Burton <paul.burton@imgtec.com>2014-02-13 06:26:41 -0500
committerRalf Baechle <ralf@linux-mips.org>2014-03-26 18:09:09 -0400
commitbbd426f542cb61f2322e15dab4507f2661090c06 (patch)
tree66cc94a921b0342a4a412646d549562a578fc257 /arch/mips/math-emu/cp1emu.c
parent490b004febb3fe9aca7330a729b29fe935be3b31 (diff)
MIPS: Simplify FP context access
This patch replaces the fpureg_t typedef with a "union fpureg" enabling easier access to 32 & 64 bit values. This allows the access macros used in cp1emu.c to be simplified somewhat. It will also make it easier to expand the width of the FP registers as will be done in a future patch in order to support the 128 bit registers introduced with MSA. No behavioural change is intended by this patch. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Reviewed-by: Qais Yousef <qais.yousef@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/6532/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/math-emu/cp1emu.c')
-rw-r--r--arch/mips/math-emu/cp1emu.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index 506925b2c3f3..196cf1ab65af 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -876,20 +876,28 @@ static inline int cop1_64bit(struct pt_regs *xcp)
876#endif 876#endif
877} 877}
878 878
879#define SIFROMREG(si, x) ((si) = cop1_64bit(xcp) || !(x & 1) ? \ 879#define SIFROMREG(si, x) do { \
880 (int)ctx->fpr[x] : (int)(ctx->fpr[x & ~1] >> 32)) 880 if (cop1_64bit(xcp)) \
881 (si) = get_fpr32(&ctx->fpr[x], 0); \
882 else \
883 (si) = get_fpr32(&ctx->fpr[(x) & ~1], (x) & 1); \
884} while (0)
881 885
882#define SITOREG(si, x) (ctx->fpr[x & ~(cop1_64bit(xcp) == 0)] = \ 886#define SITOREG(si, x) do { \
883 cop1_64bit(xcp) || !(x & 1) ? \ 887 if (cop1_64bit(xcp)) \
884 ctx->fpr[x & ~1] >> 32 << 32 | (u32)(si) : \ 888 set_fpr32(&ctx->fpr[x], 0, si); \
885 ctx->fpr[x & ~1] << 32 >> 32 | (u64)(si) << 32) 889 else \
890 set_fpr32(&ctx->fpr[(x) & ~1], (x) & 1, si); \
891} while (0)
886 892
887#define SIFROMHREG(si, x) ((si) = (int)(ctx->fpr[x] >> 32)) 893#define SIFROMHREG(si, x) ((si) = get_fpr32(&ctx->fpr[x], 1))
888#define SITOHREG(si, x) (ctx->fpr[x] = \ 894#define SITOHREG(si, x) set_fpr32(&ctx->fpr[x], 1, si)
889 ctx->fpr[x] << 32 >> 32 | (u64)(si) << 32)
890 895
891#define DIFROMREG(di, x) ((di) = ctx->fpr[x & ~(cop1_64bit(xcp) == 0)]) 896#define DIFROMREG(di, x) \
892#define DITOREG(di, x) (ctx->fpr[x & ~(cop1_64bit(xcp) == 0)] = (di)) 897 ((di) = get_fpr64(&ctx->fpr[(x) & ~(cop1_64bit(xcp) == 0)], 0))
898
899#define DITOREG(di, x) \
900 set_fpr64(&ctx->fpr[(x) & ~(cop1_64bit(xcp) == 0)], 0, di)
893 901
894#define SPFROMREG(sp, x) SIFROMREG((sp).bits, x) 902#define SPFROMREG(sp, x) SIFROMREG((sp).bits, x)
895#define SPTOREG(sp, x) SITOREG((sp).bits, x) 903#define SPTOREG(sp, x) SITOREG((sp).bits, x)
@@ -1960,15 +1968,18 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
1960 1968
1961#if defined(__mips64) 1969#if defined(__mips64)
1962 case l_fmt:{ 1970 case l_fmt:{
1971 u64 bits;
1972 DIFROMREG(bits, MIPSInst_FS(ir));
1973
1963 switch (MIPSInst_FUNC(ir)) { 1974 switch (MIPSInst_FUNC(ir)) {
1964 case fcvts_op: 1975 case fcvts_op:
1965 /* convert long to single precision real */ 1976 /* convert long to single precision real */
1966 rv.s = ieee754sp_flong(ctx->fpr[MIPSInst_FS(ir)]); 1977 rv.s = ieee754sp_flong(bits);
1967 rfmt = s_fmt; 1978 rfmt = s_fmt;
1968 goto copcsr; 1979 goto copcsr;
1969 case fcvtd_op: 1980 case fcvtd_op:
1970 /* convert long to double precision real */ 1981 /* convert long to double precision real */
1971 rv.d = ieee754dp_flong(ctx->fpr[MIPSInst_FS(ir)]); 1982 rv.d = ieee754dp_flong(bits);
1972 rfmt = d_fmt; 1983 rfmt = d_fmt;
1973 goto copcsr; 1984 goto copcsr;
1974 default: 1985 default: