aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/math-emu/cp1emu.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2015-04-03 18:24:56 -0400
committerRalf Baechle <ralf@linux-mips.org>2015-04-07 19:09:10 -0400
commit2cfcf8a8313bd9bdb54d62ca4ea581f130869aca (patch)
treeb52d5d5a25e23c309be29d475884a0665a0bddbe /arch/mips/math-emu/cp1emu.c
parent4a7c2371823a4d35eb4d4f5802c472469934c57d (diff)
MIPS: math-emu: Remove `modeindex' macro
Commit 56a64733 [MIPS: math-emu: Switch to using the MIPS rounding modes.] removed the distinction between hardware and emulator rounding mode encodings, the hardware encoding is now used in emulation as well. Complement the change and remove the `modeindex' macro previously used for indexing into encoding translation tables, it now does nothing and only obfuscates code by reinserting the value extracted from FCSR. Adjust comments accordingly. Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/9680/ 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.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index 3c5b1c8d73ee..fc6ce90d21f8 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -65,9 +65,6 @@ static int fpux_emu(struct pt_regs *,
65#define FPCREG_RID 0 /* $0 = revision id */ 65#define FPCREG_RID 0 /* $0 = revision id */
66#define FPCREG_CSR 31 /* $31 = csr */ 66#define FPCREG_CSR 31 /* $31 = csr */
67 67
68/* Determine rounding mode from the RM bits of the FCSR */
69#define modeindex(v) ((v) & FPU_CSR_RM)
70
71/* convert condition code register number to csr bit */ 68/* convert condition code register number to csr bit */
72const unsigned int fpucondbit[8] = { 69const unsigned int fpucondbit[8] = {
73 FPU_CSR_COND0, 70 FPU_CSR_COND0,
@@ -1051,7 +1048,6 @@ emul:
1051 /* cop control register rd -> gpr[rt] */ 1048 /* cop control register rd -> gpr[rt] */
1052 if (MIPSInst_RD(ir) == FPCREG_CSR) { 1049 if (MIPSInst_RD(ir) == FPCREG_CSR) {
1053 value = ctx->fcr31; 1050 value = ctx->fcr31;
1054 value = (value & ~FPU_CSR_RM) | modeindex(value);
1055 pr_debug("%p gpr[%d]<-csr=%08x\n", 1051 pr_debug("%p gpr[%d]<-csr=%08x\n",
1056 (void *) (xcp->cp0_epc), 1052 (void *) (xcp->cp0_epc),
1057 MIPSInst_RT(ir), value); 1053 MIPSInst_RT(ir), value);
@@ -1078,12 +1074,8 @@ emul:
1078 (void *) (xcp->cp0_epc), 1074 (void *) (xcp->cp0_epc),
1079 MIPSInst_RT(ir), value); 1075 MIPSInst_RT(ir), value);
1080 1076
1081 /* 1077 /* Don't write reserved bits. */
1082 * Don't write reserved bits, 1078 ctx->fcr31 = value & ~FPU_CSR_RSVD;
1083 * and convert to ieee library modes
1084 */
1085 ctx->fcr31 = (value & ~(FPU_CSR_RSVD | FPU_CSR_RM)) |
1086 modeindex(value);
1087 } 1079 }
1088 if ((ctx->fcr31 >> 5) & ctx->fcr31 & FPU_CSR_ALL_E) { 1080 if ((ctx->fcr31 >> 5) & ctx->fcr31 & FPU_CSR_ALL_E) {
1089 return SIGFPE; 1081 return SIGFPE;
@@ -1675,7 +1667,7 @@ copcsr:
1675 1667
1676 oldrm = ieee754_csr.rm; 1668 oldrm = ieee754_csr.rm;
1677 SPFROMREG(fs, MIPSInst_FS(ir)); 1669 SPFROMREG(fs, MIPSInst_FS(ir));
1678 ieee754_csr.rm = modeindex(MIPSInst_FUNC(ir)); 1670 ieee754_csr.rm = MIPSInst_FUNC(ir);
1679 rv.w = ieee754sp_tint(fs); 1671 rv.w = ieee754sp_tint(fs);
1680 ieee754_csr.rm = oldrm; 1672 ieee754_csr.rm = oldrm;
1681 rfmt = w_fmt; 1673 rfmt = w_fmt;
@@ -1699,7 +1691,7 @@ copcsr:
1699 1691
1700 oldrm = ieee754_csr.rm; 1692 oldrm = ieee754_csr.rm;
1701 SPFROMREG(fs, MIPSInst_FS(ir)); 1693 SPFROMREG(fs, MIPSInst_FS(ir));
1702 ieee754_csr.rm = modeindex(MIPSInst_FUNC(ir)); 1694 ieee754_csr.rm = MIPSInst_FUNC(ir);
1703 rv.l = ieee754sp_tlong(fs); 1695 rv.l = ieee754sp_tlong(fs);
1704 ieee754_csr.rm = oldrm; 1696 ieee754_csr.rm = oldrm;
1705 rfmt = l_fmt; 1697 rfmt = l_fmt;
@@ -1852,7 +1844,7 @@ dcopuop:
1852 1844
1853 oldrm = ieee754_csr.rm; 1845 oldrm = ieee754_csr.rm;
1854 DPFROMREG(fs, MIPSInst_FS(ir)); 1846 DPFROMREG(fs, MIPSInst_FS(ir));
1855 ieee754_csr.rm = modeindex(MIPSInst_FUNC(ir)); 1847 ieee754_csr.rm = MIPSInst_FUNC(ir);
1856 rv.w = ieee754dp_tint(fs); 1848 rv.w = ieee754dp_tint(fs);
1857 ieee754_csr.rm = oldrm; 1849 ieee754_csr.rm = oldrm;
1858 rfmt = w_fmt; 1850 rfmt = w_fmt;
@@ -1876,7 +1868,7 @@ dcopuop:
1876 1868
1877 oldrm = ieee754_csr.rm; 1869 oldrm = ieee754_csr.rm;
1878 DPFROMREG(fs, MIPSInst_FS(ir)); 1870 DPFROMREG(fs, MIPSInst_FS(ir));
1879 ieee754_csr.rm = modeindex(MIPSInst_FUNC(ir)); 1871 ieee754_csr.rm = MIPSInst_FUNC(ir);
1880 rv.l = ieee754dp_tlong(fs); 1872 rv.l = ieee754dp_tlong(fs);
1881 ieee754_csr.rm = oldrm; 1873 ieee754_csr.rm = oldrm;
1882 rfmt = l_fmt; 1874 rfmt = l_fmt;
@@ -2081,10 +2073,8 @@ int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
2081 xcp->cp0_epc += dec_insn.pc_inc; /* Skip NOPs */ 2073 xcp->cp0_epc += dec_insn.pc_inc; /* Skip NOPs */
2082 else { 2074 else {
2083 /* 2075 /*
2084 * The 'ieee754_csr' is an alias of 2076 * The 'ieee754_csr' is an alias of ctx->fcr31.
2085 * ctx->fcr31. No need to copy ctx->fcr31 to 2077 * No need to copy ctx->fcr31 to ieee754_csr.
2086 * ieee754_csr. But ieee754_csr.rm is ieee
2087 * library modes. (not mips rounding mode)
2088 */ 2078 */
2089 sig = cop1Emulate(xcp, ctx, dec_insn, fault_addr); 2079 sig = cop1Emulate(xcp, ctx, dec_insn, fault_addr);
2090 } 2080 }