X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=sim%2Fmips%2Fdsp.igen;h=491cfb00116006fe4c1810397095d77b97359862;hb=d5fb0879a5c2008b43d057d7a0ee09bb3b500be2;hp=9c39b7160fd0a5d779bdda059d2be47b42a8db9a;hpb=01f0fe5e0450edf168c1f612feb93cf588e4e7ea;p=deliverable%2Fbinutils-gdb.git diff --git a/sim/mips/dsp.igen b/sim/mips/dsp.igen index 9c39b7160f..491cfb0011 100644 --- a/sim/mips/dsp.igen +++ b/sim/mips/dsp.igen @@ -1,7 +1,7 @@ // -*- C -*- // Simulator definition for the MIPS DSP ASE. -// Copyright (C) 2005 Free Software Foundation, Inc. +// Copyright (C) 2005, 2007 Free Software Foundation, Inc. // Contributed by MIPS Technologies, Inc. Written by Chao-ying Fu. // // This file is part of GDB, the GNU debugger. @@ -16,17 +16,18 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// You should have received a copy of the GNU General Public License +// along with GAS; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA +// 02110-1301, USA. -// op: 0 = ADD, 1 = SUB +// op: 0 = ADD, 1 = SUB, 2 = MUL // sat: 0 = no saturation, 1 = saturation :function:::void:do_ph_op:int rd, int rs, int rt, int op, int sat { int i; - signed32 h0; + signed32 h0 = 0; signed16 h1, h2; unsigned32 v1 = GPR[rs]; unsigned32 v2 = GPR[rt]; @@ -37,17 +38,22 @@ h2 = (signed16)(v2 & 0xffff); if (op == 0) // ADD h0 = (signed32)h1 + (signed32)h2; - else // SUB + else if (op == 1) // SUB h0 = (signed32)h1 - (signed32)h2; - if (((h0 & 0x10000) >> 1) != (h0 & 0x8000)) + else // MUL + h0 = (signed32)h1 * (signed32)h2; + if (h0 > (signed32)0x7fff || h0 < (signed32)0xffff8000) { - DSPCR |= DSPCR_OUFLAG4; + if (op == 0 || op == 1) // ADD, SUB + DSPCR |= DSPCR_OUFLAG4; + else if (op == 2) // MUL + DSPCR |= DSPCR_OUFLAG5; if (sat == 1) { - if (h0 & 0x10000) - h0 = 0x8000; - else + if (h0 > (signed32)0x7fff) h0 = 0x7fff; + else + h0 = 0x8000; } } result |= ((unsigned32)((unsigned16)h0) << i); @@ -69,10 +75,10 @@ h0 = (signed64)h1 + (signed64)h2; else // SUB h0 = (signed64)h1 - (signed64)h2; - if (((h0 & 0x100000000) >> 1) != (h0 & 0x80000000)) + if (((h0 & 0x100000000LL) >> 1) != (h0 & 0x80000000)) { DSPCR |= DSPCR_OUFLAG4; - if (h0 & 0x100000000) + if (h0 & 0x100000000LL) h0 = 0x80000000; else h0 = 0x7fffffff; @@ -193,9 +199,10 @@ } else // right { - if (sat == 1 && shift != 0) - h0 += (1 << (shift - 1)); - h0 = h0 >> shift; + if (sat == 1 && shift != 0 && (h0 & (1 << (shift-1)))) + h0 = (h0 >> shift) + 1; + else + h0 = h0 >> shift; } result |= ((unsigned32)((unsigned16)h0) << i); @@ -246,9 +253,10 @@ { unsigned32 result = GPR[rt]; signed32 h0 = (signed32)result; - if (shift != 0) - h0 += (1 << (shift - 1)); - h0 = h0 >> shift; + if (shift != 0 && (h0 & (1 << (shift-1)))) + h0 = (h0 >> shift) + 1; + else + h0 = h0 >> shift; GPR[rd] = EXTEND32 (h0); } @@ -773,14 +781,13 @@ do_qb_muleu (SD_, RD, RS, RT, 1); } -011111,5.RS,5.RT,5.RD,11111,010000:SPECIAL3:32::MULQ_RS.PH -"mulq_rs.ph r, r, r" -*dsp: +// round: 0 = no rounding, 1 = rounding +:function:::void:do_ph_mulq:int rd, int rs, int rt, int round { int i; unsigned32 result = 0; - unsigned32 v1 = GPR[RS]; - unsigned32 v2 = GPR[RT]; + unsigned32 v1 = GPR[rs]; + unsigned32 v2 = GPR[rt]; signed16 h1, h2; signed32 prod; for (i = 0; i < 32; i += 16, v1 >>= 16, v2 >>= 16) @@ -793,11 +800,21 @@ prod = 0x7fffffff; } else - prod = (((signed32)h1 * (signed32)h2) << 1) + (signed32)0x8000; - + { + prod = ((signed32)h1 * (signed32)h2) << 1; + if (round == 1) + prod += (signed32)0x8000; + } result |= (((unsigned32)prod >> 16) << i); } - GPR[RD] = EXTEND32 (result); + GPR[rd] = EXTEND32 (result); +} + +011111,5.RS,5.RT,5.RD,11111,010000:SPECIAL3:32::MULQ_RS.PH +"mulq_rs.ph r, r, r" +*dsp: +{ + do_ph_mulq (SD_, RD, RS, RT, 1); } // loc: 0 = phl, 1 = phr @@ -1649,64 +1666,6 @@ DSPCR |= (pos & DSPCR_POS_MASK) << DSPCR_POS_SHIFT; } -000000,000,2.AC,00000,5.RD,00000,010000:SPECIAL:32::MFHIdsp -"mfhi r":AC == 0 -"mfhi r, ac" -*mips32: -*mips32r2: -*mips64: -*mips64r2: -*dsp: -{ - if (AC == 0) - do_mfhi (SD_, RD); - else - GPR[RD] = DSPHI(AC); -} - -000000,000,2.AC,00000,5.RD,00000,010010:SPECIAL:32::MFLOdsp -"mflo r":AC == 0 -"mflo r, ac" -*mips32: -*mips32r2: -*mips64: -*mips64r2: -*dsp: -{ - if (AC == 0) - do_mflo (SD_, RD); - else - GPR[RD] = DSPLO(AC); -} - -000000,5.RS,00000,000,2.AC,00000,010001:SPECIAL:32::MTHIdsp -"mthi r":AC == 0 -"mthi r, ac" -*mips32: -*mips32r2: -*mips64: -*mips64r2: -*dsp: -{ - if (AC == 0) - check_mt_hilo (SD_, HIHISTORY); - DSPHI(AC) = GPR[RS]; -} - -000000,5.RS,00000,000,2.AC,00000,010011:SPECIAL:32::MTLOdsp -"mtlo r":AC == 0 -"mtlo r, ac" -*mips32: -*mips32r2: -*mips64: -*mips64r2: -*dsp: -{ - if (AC == 0) - check_mt_hilo (SD_, LOHISTORY); - DSPLO(AC) = GPR[RS]; -} - 011111,5.RS,10.MASK10,10011,111000:SPECIAL3:32::WRDSP "wrdsp r":MASK10 == 1111111111 "wrdsp r, "