Commit 923617a396249fcac8710048f9db76345246f999

Authored by ths
1 parent 4759513b

Improved debug output for the MIPS opcode decoder.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2801 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 77 additions and 85 deletions
target-mips/translate.c
@@ -540,7 +540,7 @@ enum { @@ -540,7 +540,7 @@ enum {
540 BS_EXCP = 3, /* We reached an exception condition */ 540 BS_EXCP = 3, /* We reached an exception condition */
541 }; 541 };
542 542
543 -#if defined MIPS_DEBUG_DISAS 543 +#ifdef MIPS_DEBUG_DISAS
544 #define MIPS_DEBUG(fmt, args...) \ 544 #define MIPS_DEBUG(fmt, args...) \
545 do { \ 545 do { \
546 if (loglevel & CPU_LOG_TB_IN_ASM) { \ 546 if (loglevel & CPU_LOG_TB_IN_ASM) { \
@@ -710,7 +710,7 @@ OP_ST_TABLE(uxc1); @@ -710,7 +710,7 @@ OP_ST_TABLE(uxc1);
710 static void gen_ldst (DisasContext *ctx, uint32_t opc, int rt, 710 static void gen_ldst (DisasContext *ctx, uint32_t opc, int rt,
711 int base, int16_t offset) 711 int base, int16_t offset)
712 { 712 {
713 - const char *opn = "unk"; 713 + const char *opn = "ldst";
714 714
715 if (base == 0) { 715 if (base == 0) {
716 GEN_LOAD_IMM_TN(T0, offset); 716 GEN_LOAD_IMM_TN(T0, offset);
@@ -849,7 +849,7 @@ static void gen_ldst (DisasContext *ctx, uint32_t opc, int rt, @@ -849,7 +849,7 @@ static void gen_ldst (DisasContext *ctx, uint32_t opc, int rt,
849 opn = "sc"; 849 opn = "sc";
850 break; 850 break;
851 default: 851 default:
852 - MIPS_INVAL("load/store"); 852 + MIPS_INVAL(opn);
853 generate_exception(ctx, EXCP_RI); 853 generate_exception(ctx, EXCP_RI);
854 return; 854 return;
855 } 855 }
@@ -860,7 +860,7 @@ static void gen_ldst (DisasContext *ctx, uint32_t opc, int rt, @@ -860,7 +860,7 @@ static void gen_ldst (DisasContext *ctx, uint32_t opc, int rt,
860 static void gen_flt_ldst (DisasContext *ctx, uint32_t opc, int ft, 860 static void gen_flt_ldst (DisasContext *ctx, uint32_t opc, int ft,
861 int base, int16_t offset) 861 int base, int16_t offset)
862 { 862 {
863 - const char *opn = "unk"; 863 + const char *opn = "flt_ldst";
864 864
865 if (base == 0) { 865 if (base == 0) {
866 GEN_LOAD_IMM_TN(T0, offset); 866 GEN_LOAD_IMM_TN(T0, offset);
@@ -896,7 +896,7 @@ static void gen_flt_ldst (DisasContext *ctx, uint32_t opc, int ft, @@ -896,7 +896,7 @@ static void gen_flt_ldst (DisasContext *ctx, uint32_t opc, int ft,
896 opn = "sdc1"; 896 opn = "sdc1";
897 break; 897 break;
898 default: 898 default:
899 - MIPS_INVAL("float load/store"); 899 + MIPS_INVAL(opn);
900 generate_exception(ctx, EXCP_RI); 900 generate_exception(ctx, EXCP_RI);
901 return; 901 return;
902 } 902 }
@@ -908,7 +908,7 @@ static void gen_arith_imm (DisasContext *ctx, uint32_t opc, int rt, @@ -908,7 +908,7 @@ static void gen_arith_imm (DisasContext *ctx, uint32_t opc, int rt,
908 int rs, int16_t imm) 908 int rs, int16_t imm)
909 { 909 {
910 uint32_t uimm; 910 uint32_t uimm;
911 - const char *opn = "unk"; 911 + const char *opn = "imm arith";
912 912
913 if (rt == 0 && opc != OPC_ADDI && opc != OPC_DADDI) { 913 if (rt == 0 && opc != OPC_ADDI && opc != OPC_DADDI) {
914 /* if no destination, treat it as a NOP 914 /* if no destination, treat it as a NOP
@@ -1073,7 +1073,7 @@ static void gen_arith_imm (DisasContext *ctx, uint32_t opc, int rt, @@ -1073,7 +1073,7 @@ static void gen_arith_imm (DisasContext *ctx, uint32_t opc, int rt,
1073 break; 1073 break;
1074 #endif 1074 #endif
1075 default: 1075 default:
1076 - MIPS_INVAL("imm arith"); 1076 + MIPS_INVAL(opn);
1077 generate_exception(ctx, EXCP_RI); 1077 generate_exception(ctx, EXCP_RI);
1078 return; 1078 return;
1079 } 1079 }
@@ -1085,7 +1085,7 @@ static void gen_arith_imm (DisasContext *ctx, uint32_t opc, int rt, @@ -1085,7 +1085,7 @@ static void gen_arith_imm (DisasContext *ctx, uint32_t opc, int rt,
1085 static void gen_arith (DisasContext *ctx, uint32_t opc, 1085 static void gen_arith (DisasContext *ctx, uint32_t opc,
1086 int rd, int rs, int rt) 1086 int rd, int rs, int rt)
1087 { 1087 {
1088 - const char *opn = "unk"; 1088 + const char *opn = "arith";
1089 1089
1090 if (rd == 0 && opc != OPC_ADD && opc != OPC_SUB 1090 if (rd == 0 && opc != OPC_ADD && opc != OPC_SUB
1091 && opc != OPC_DADD && opc != OPC_DSUB) { 1091 && opc != OPC_DADD && opc != OPC_DSUB) {
@@ -1223,7 +1223,7 @@ static void gen_arith (DisasContext *ctx, uint32_t opc, @@ -1223,7 +1223,7 @@ static void gen_arith (DisasContext *ctx, uint32_t opc,
1223 break; 1223 break;
1224 #endif 1224 #endif
1225 default: 1225 default:
1226 - MIPS_INVAL("arith"); 1226 + MIPS_INVAL(opn);
1227 generate_exception(ctx, EXCP_RI); 1227 generate_exception(ctx, EXCP_RI);
1228 return; 1228 return;
1229 } 1229 }
@@ -1235,7 +1235,7 @@ static void gen_arith (DisasContext *ctx, uint32_t opc, @@ -1235,7 +1235,7 @@ static void gen_arith (DisasContext *ctx, uint32_t opc,
1235 /* Arithmetic on HI/LO registers */ 1235 /* Arithmetic on HI/LO registers */
1236 static void gen_HILO (DisasContext *ctx, uint32_t opc, int reg) 1236 static void gen_HILO (DisasContext *ctx, uint32_t opc, int reg)
1237 { 1237 {
1238 - const char *opn = "unk"; 1238 + const char *opn = "hilo";
1239 1239
1240 if (reg == 0 && (opc == OPC_MFHI || opc == OPC_MFLO)) { 1240 if (reg == 0 && (opc == OPC_MFHI || opc == OPC_MFLO)) {
1241 /* Treat as a NOP */ 1241 /* Treat as a NOP */
@@ -1264,7 +1264,7 @@ static void gen_HILO (DisasContext *ctx, uint32_t opc, int reg) @@ -1264,7 +1264,7 @@ static void gen_HILO (DisasContext *ctx, uint32_t opc, int reg)
1264 opn = "mtlo"; 1264 opn = "mtlo";
1265 break; 1265 break;
1266 default: 1266 default:
1267 - MIPS_INVAL("HILO"); 1267 + MIPS_INVAL(opn);
1268 generate_exception(ctx, EXCP_RI); 1268 generate_exception(ctx, EXCP_RI);
1269 return; 1269 return;
1270 } 1270 }
@@ -1274,7 +1274,7 @@ static void gen_HILO (DisasContext *ctx, uint32_t opc, int reg) @@ -1274,7 +1274,7 @@ static void gen_HILO (DisasContext *ctx, uint32_t opc, int reg)
1274 static void gen_muldiv (DisasContext *ctx, uint32_t opc, 1274 static void gen_muldiv (DisasContext *ctx, uint32_t opc,
1275 int rs, int rt) 1275 int rs, int rt)
1276 { 1276 {
1277 - const char *opn = "unk"; 1277 + const char *opn = "mul/div";
1278 1278
1279 GEN_LOAD_REG_TN(T0, rs); 1279 GEN_LOAD_REG_TN(T0, rs);
1280 GEN_LOAD_REG_TN(T1, rt); 1280 GEN_LOAD_REG_TN(T1, rt);
@@ -1330,7 +1330,7 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, @@ -1330,7 +1330,7 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,
1330 opn = "msubu"; 1330 opn = "msubu";
1331 break; 1331 break;
1332 default: 1332 default:
1333 - MIPS_INVAL("mul/div"); 1333 + MIPS_INVAL(opn);
1334 generate_exception(ctx, EXCP_RI); 1334 generate_exception(ctx, EXCP_RI);
1335 return; 1335 return;
1336 } 1336 }
@@ -1340,7 +1340,7 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc, @@ -1340,7 +1340,7 @@ static void gen_muldiv (DisasContext *ctx, uint32_t opc,
1340 static void gen_cl (DisasContext *ctx, uint32_t opc, 1340 static void gen_cl (DisasContext *ctx, uint32_t opc,
1341 int rd, int rs) 1341 int rd, int rs)
1342 { 1342 {
1343 - const char *opn = "unk"; 1343 + const char *opn = "CLx";
1344 if (rd == 0) { 1344 if (rd == 0) {
1345 /* Treat as a NOP */ 1345 /* Treat as a NOP */
1346 MIPS_DEBUG("NOP"); 1346 MIPS_DEBUG("NOP");
@@ -1367,7 +1367,7 @@ static void gen_cl (DisasContext *ctx, uint32_t opc, @@ -1367,7 +1367,7 @@ static void gen_cl (DisasContext *ctx, uint32_t opc,
1367 break; 1367 break;
1368 #endif 1368 #endif
1369 default: 1369 default:
1370 - MIPS_INVAL("CLx"); 1370 + MIPS_INVAL(opn);
1371 generate_exception(ctx, EXCP_RI); 1371 generate_exception(ctx, EXCP_RI);
1372 return; 1372 return;
1373 } 1373 }
@@ -1431,7 +1431,7 @@ static void gen_trap (DisasContext *ctx, uint32_t opc, @@ -1431,7 +1431,7 @@ static void gen_trap (DisasContext *ctx, uint32_t opc,
1431 /* Never trap: treat as NOP */ 1431 /* Never trap: treat as NOP */
1432 return; 1432 return;
1433 default: 1433 default:
1434 - MIPS_INVAL("TRAP"); 1434 + MIPS_INVAL("trap");
1435 generate_exception(ctx, EXCP_RI); 1435 generate_exception(ctx, EXCP_RI);
1436 return; 1436 return;
1437 } 1437 }
@@ -1462,7 +1462,7 @@ static void gen_trap (DisasContext *ctx, uint32_t opc, @@ -1462,7 +1462,7 @@ static void gen_trap (DisasContext *ctx, uint32_t opc,
1462 gen_op_ne(); 1462 gen_op_ne();
1463 break; 1463 break;
1464 default: 1464 default:
1465 - MIPS_INVAL("TRAP"); 1465 + MIPS_INVAL("trap");
1466 generate_exception(ctx, EXCP_RI); 1466 generate_exception(ctx, EXCP_RI);
1467 return; 1467 return;
1468 } 1468 }
@@ -1499,12 +1499,13 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc, @@ -1499,12 +1499,13 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc,
1499 int bcond = 0; 1499 int bcond = 0;
1500 1500
1501 if (ctx->hflags & MIPS_HFLAG_BMASK) { 1501 if (ctx->hflags & MIPS_HFLAG_BMASK) {
  1502 +#ifdef MIPS_DEBUG_DISAS
1502 if (loglevel & CPU_LOG_TB_IN_ASM) { 1503 if (loglevel & CPU_LOG_TB_IN_ASM) {
1503 fprintf(logfile, 1504 fprintf(logfile,
1504 "Branch in delay slot at PC 0x" TARGET_FMT_lx "\n", 1505 "Branch in delay slot at PC 0x" TARGET_FMT_lx "\n",
1505 ctx->pc); 1506 ctx->pc);
1506 } 1507 }
1507 - MIPS_INVAL("branch/jump in bdelay slot"); 1508 +#endif
1508 generate_exception(ctx, EXCP_RI); 1509 generate_exception(ctx, EXCP_RI);
1509 return; 1510 return;
1510 } 1511 }
@@ -1553,6 +1554,7 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc, @@ -1553,6 +1554,7 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc,
1553 if (offset != 0 && offset != 16) { 1554 if (offset != 0 && offset != 16) {
1554 /* Hint = 0 is JR/JALR, hint 16 is JR.HB/JALR.HB, the 1555 /* Hint = 0 is JR/JALR, hint 16 is JR.HB/JALR.HB, the
1555 others are reserved. */ 1556 others are reserved. */
  1557 + MIPS_INVAL("jump hint");
1556 generate_exception(ctx, EXCP_RI); 1558 generate_exception(ctx, EXCP_RI);
1557 return; 1559 return;
1558 } 1560 }
@@ -1610,12 +1612,12 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc, @@ -1610,12 +1612,12 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc,
1610 return; 1612 return;
1611 case OPC_J: 1613 case OPC_J:
1612 ctx->hflags |= MIPS_HFLAG_B; 1614 ctx->hflags |= MIPS_HFLAG_B;
1613 - MIPS_DEBUG("j %08x", btarget); 1615 + MIPS_DEBUG("j " TARGET_FMT_lx, btarget);
1614 break; 1616 break;
1615 case OPC_JAL: 1617 case OPC_JAL:
1616 blink = 31; 1618 blink = 31;
1617 ctx->hflags |= MIPS_HFLAG_B; 1619 ctx->hflags |= MIPS_HFLAG_B;
1618 - MIPS_DEBUG("jal %08x", btarget); 1620 + MIPS_DEBUG("jal " TARGET_FMT_lx, btarget);
1619 break; 1621 break;
1620 case OPC_JR: 1622 case OPC_JR:
1621 ctx->hflags |= MIPS_HFLAG_BR; 1623 ctx->hflags |= MIPS_HFLAG_BR;
@@ -1635,70 +1637,70 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc, @@ -1635,70 +1637,70 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc,
1635 switch (opc) { 1637 switch (opc) {
1636 case OPC_BEQ: 1638 case OPC_BEQ:
1637 gen_op_eq(); 1639 gen_op_eq();
1638 - MIPS_DEBUG("beq %s, %s, %08x", 1640 + MIPS_DEBUG("beq %s, %s, " TARGET_FMT_lx,
1639 regnames[rs], regnames[rt], btarget); 1641 regnames[rs], regnames[rt], btarget);
1640 goto not_likely; 1642 goto not_likely;
1641 case OPC_BEQL: 1643 case OPC_BEQL:
1642 gen_op_eq(); 1644 gen_op_eq();
1643 - MIPS_DEBUG("beql %s, %s, %08x", 1645 + MIPS_DEBUG("beql %s, %s, " TARGET_FMT_lx,
1644 regnames[rs], regnames[rt], btarget); 1646 regnames[rs], regnames[rt], btarget);
1645 goto likely; 1647 goto likely;
1646 case OPC_BNE: 1648 case OPC_BNE:
1647 gen_op_ne(); 1649 gen_op_ne();
1648 - MIPS_DEBUG("bne %s, %s, %08x", 1650 + MIPS_DEBUG("bne %s, %s, " TARGET_FMT_lx,
1649 regnames[rs], regnames[rt], btarget); 1651 regnames[rs], regnames[rt], btarget);
1650 goto not_likely; 1652 goto not_likely;
1651 case OPC_BNEL: 1653 case OPC_BNEL:
1652 gen_op_ne(); 1654 gen_op_ne();
1653 - MIPS_DEBUG("bnel %s, %s, %08x", 1655 + MIPS_DEBUG("bnel %s, %s, " TARGET_FMT_lx,
1654 regnames[rs], regnames[rt], btarget); 1656 regnames[rs], regnames[rt], btarget);
1655 goto likely; 1657 goto likely;
1656 case OPC_BGEZ: 1658 case OPC_BGEZ:
1657 gen_op_gez(); 1659 gen_op_gez();
1658 - MIPS_DEBUG("bgez %s, %08x", regnames[rs], btarget); 1660 + MIPS_DEBUG("bgez %s, " TARGET_FMT_lx, regnames[rs], btarget);
1659 goto not_likely; 1661 goto not_likely;
1660 case OPC_BGEZL: 1662 case OPC_BGEZL:
1661 gen_op_gez(); 1663 gen_op_gez();
1662 - MIPS_DEBUG("bgezl %s, %08x", regnames[rs], btarget); 1664 + MIPS_DEBUG("bgezl %s, " TARGET_FMT_lx, regnames[rs], btarget);
1663 goto likely; 1665 goto likely;
1664 case OPC_BGEZAL: 1666 case OPC_BGEZAL:
1665 gen_op_gez(); 1667 gen_op_gez();
1666 - MIPS_DEBUG("bgezal %s, %08x", regnames[rs], btarget); 1668 + MIPS_DEBUG("bgezal %s, " TARGET_FMT_lx, regnames[rs], btarget);
1667 blink = 31; 1669 blink = 31;
1668 goto not_likely; 1670 goto not_likely;
1669 case OPC_BGEZALL: 1671 case OPC_BGEZALL:
1670 gen_op_gez(); 1672 gen_op_gez();
1671 blink = 31; 1673 blink = 31;
1672 - MIPS_DEBUG("bgezall %s, %08x", regnames[rs], btarget); 1674 + MIPS_DEBUG("bgezall %s, " TARGET_FMT_lx, regnames[rs], btarget);
1673 goto likely; 1675 goto likely;
1674 case OPC_BGTZ: 1676 case OPC_BGTZ:
1675 gen_op_gtz(); 1677 gen_op_gtz();
1676 - MIPS_DEBUG("bgtz %s, %08x", regnames[rs], btarget); 1678 + MIPS_DEBUG("bgtz %s, " TARGET_FMT_lx, regnames[rs], btarget);
1677 goto not_likely; 1679 goto not_likely;
1678 case OPC_BGTZL: 1680 case OPC_BGTZL:
1679 gen_op_gtz(); 1681 gen_op_gtz();
1680 - MIPS_DEBUG("bgtzl %s, %08x", regnames[rs], btarget); 1682 + MIPS_DEBUG("bgtzl %s, " TARGET_FMT_lx, regnames[rs], btarget);
1681 goto likely; 1683 goto likely;
1682 case OPC_BLEZ: 1684 case OPC_BLEZ:
1683 gen_op_lez(); 1685 gen_op_lez();
1684 - MIPS_DEBUG("blez %s, %08x", regnames[rs], btarget); 1686 + MIPS_DEBUG("blez %s, " TARGET_FMT_lx, regnames[rs], btarget);
1685 goto not_likely; 1687 goto not_likely;
1686 case OPC_BLEZL: 1688 case OPC_BLEZL:
1687 gen_op_lez(); 1689 gen_op_lez();
1688 - MIPS_DEBUG("blezl %s, %08x", regnames[rs], btarget); 1690 + MIPS_DEBUG("blezl %s, " TARGET_FMT_lx, regnames[rs], btarget);
1689 goto likely; 1691 goto likely;
1690 case OPC_BLTZ: 1692 case OPC_BLTZ:
1691 gen_op_ltz(); 1693 gen_op_ltz();
1692 - MIPS_DEBUG("bltz %s, %08x", regnames[rs], btarget); 1694 + MIPS_DEBUG("bltz %s, " TARGET_FMT_lx, regnames[rs], btarget);
1693 goto not_likely; 1695 goto not_likely;
1694 case OPC_BLTZL: 1696 case OPC_BLTZL:
1695 gen_op_ltz(); 1697 gen_op_ltz();
1696 - MIPS_DEBUG("bltzl %s, %08x", regnames[rs], btarget); 1698 + MIPS_DEBUG("bltzl %s, " TARGET_FMT_lx, regnames[rs], btarget);
1697 goto likely; 1699 goto likely;
1698 case OPC_BLTZAL: 1700 case OPC_BLTZAL:
1699 gen_op_ltz(); 1701 gen_op_ltz();
1700 blink = 31; 1702 blink = 31;
1701 - MIPS_DEBUG("bltzal %s, %08x", regnames[rs], btarget); 1703 + MIPS_DEBUG("bltzal %s, " TARGET_FMT_lx, regnames[rs], btarget);
1702 not_likely: 1704 not_likely:
1703 ctx->hflags |= MIPS_HFLAG_BC; 1705 ctx->hflags |= MIPS_HFLAG_BC;
1704 gen_op_set_bcond(); 1706 gen_op_set_bcond();
@@ -1706,7 +1708,7 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc, @@ -1706,7 +1708,7 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc,
1706 case OPC_BLTZALL: 1708 case OPC_BLTZALL:
1707 gen_op_ltz(); 1709 gen_op_ltz();
1708 blink = 31; 1710 blink = 31;
1709 - MIPS_DEBUG("bltzall %s, %08x", regnames[rs], btarget); 1711 + MIPS_DEBUG("bltzall %s, " TARGET_FMT_lx, regnames[rs], btarget);
1710 likely: 1712 likely:
1711 ctx->hflags |= MIPS_HFLAG_BL; 1713 ctx->hflags |= MIPS_HFLAG_BL;
1712 gen_op_set_bcond(); 1714 gen_op_set_bcond();
@@ -1718,7 +1720,7 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc, @@ -1718,7 +1720,7 @@ static void gen_compute_branch (DisasContext *ctx, uint32_t opc,
1718 return; 1720 return;
1719 } 1721 }
1720 } 1722 }
1721 - MIPS_DEBUG("enter ds: link %d cond %02x target %08x", 1723 + MIPS_DEBUG("enter ds: link %d cond %02x target " TARGET_FMT_lx,
1722 blink, ctx->hflags, btarget); 1724 blink, ctx->hflags, btarget);
1723 ctx->btarget = btarget; 1725 ctx->btarget = btarget;
1724 if (blink > 0) { 1726 if (blink > 0) {
@@ -4221,6 +4223,7 @@ static void gen_cp0 (DisasContext *ctx, uint32_t opc, int rt, int rd) @@ -4221,6 +4223,7 @@ static void gen_cp0 (DisasContext *ctx, uint32_t opc, int rt, int rd)
4221 case OPC_DERET: 4223 case OPC_DERET:
4222 opn = "deret"; 4224 opn = "deret";
4223 if (!(ctx->hflags & MIPS_HFLAG_DM)) { 4225 if (!(ctx->hflags & MIPS_HFLAG_DM)) {
  4226 + MIPS_INVAL(opn);
4224 generate_exception(ctx, EXCP_RI); 4227 generate_exception(ctx, EXCP_RI);
4225 } else { 4228 } else {
4226 save_cpu_state(ctx, 0); 4229 save_cpu_state(ctx, 0);
@@ -4238,11 +4241,7 @@ static void gen_cp0 (DisasContext *ctx, uint32_t opc, int rt, int rd) @@ -4238,11 +4241,7 @@ static void gen_cp0 (DisasContext *ctx, uint32_t opc, int rt, int rd)
4238 ctx->bstate = BS_EXCP; 4241 ctx->bstate = BS_EXCP;
4239 break; 4242 break;
4240 default: 4243 default:
4241 - if (loglevel & CPU_LOG_TB_IN_ASM) {  
4242 - fprintf(logfile, "Invalid CP0 opcode: %08x %03x %03x %03x\n",  
4243 - ctx->opcode, ctx->opcode >> 26, ctx->opcode & 0x3F,  
4244 - ((ctx->opcode >> 16) & 0x1F));  
4245 - } 4244 + MIPS_INVAL(opn);
4246 generate_exception(ctx, EXCP_RI); 4245 generate_exception(ctx, EXCP_RI);
4247 return; 4246 return;
4248 } 4247 }
@@ -4254,25 +4253,26 @@ static void gen_compute_branch1 (DisasContext *ctx, uint32_t op, @@ -4254,25 +4253,26 @@ static void gen_compute_branch1 (DisasContext *ctx, uint32_t op,
4254 int32_t cc, int32_t offset) 4253 int32_t cc, int32_t offset)
4255 { 4254 {
4256 target_ulong btarget; 4255 target_ulong btarget;
  4256 + const char *opn = "cp1 cond branch";
4257 4257
4258 btarget = ctx->pc + 4 + offset; 4258 btarget = ctx->pc + 4 + offset;
4259 4259
4260 switch (op) { 4260 switch (op) {
4261 case OPC_BC1F: 4261 case OPC_BC1F:
4262 gen_op_bc1f(cc); 4262 gen_op_bc1f(cc);
4263 - MIPS_DEBUG("bc1f " TARGET_FMT_lx, btarget); 4263 + opn = "bc1f";
4264 goto not_likely; 4264 goto not_likely;
4265 case OPC_BC1FL: 4265 case OPC_BC1FL:
4266 gen_op_bc1f(cc); 4266 gen_op_bc1f(cc);
4267 - MIPS_DEBUG("bc1fl " TARGET_FMT_lx, btarget); 4267 + opn = "bc1fl";
4268 goto likely; 4268 goto likely;
4269 case OPC_BC1T: 4269 case OPC_BC1T:
4270 gen_op_bc1t(cc); 4270 gen_op_bc1t(cc);
4271 - MIPS_DEBUG("bc1t " TARGET_FMT_lx, btarget); 4271 + opn = "bc1t";
4272 goto not_likely; 4272 goto not_likely;
4273 case OPC_BC1TL: 4273 case OPC_BC1TL:
4274 gen_op_bc1t(cc); 4274 gen_op_bc1t(cc);
4275 - MIPS_DEBUG("bc1tl " TARGET_FMT_lx, btarget); 4275 + opn = "bc1tl";
4276 likely: 4276 likely:
4277 ctx->hflags |= MIPS_HFLAG_BL; 4277 ctx->hflags |= MIPS_HFLAG_BL;
4278 gen_op_set_bcond(); 4278 gen_op_set_bcond();
@@ -4280,34 +4280,31 @@ static void gen_compute_branch1 (DisasContext *ctx, uint32_t op, @@ -4280,34 +4280,31 @@ static void gen_compute_branch1 (DisasContext *ctx, uint32_t op,
4280 break; 4280 break;
4281 case OPC_BC1FANY2: 4281 case OPC_BC1FANY2:
4282 gen_op_bc1fany2(cc); 4282 gen_op_bc1fany2(cc);
4283 - MIPS_DEBUG("bc1fany2 " TARGET_FMT_lx, btarget); 4283 + opn = "bc1fany2";
4284 goto not_likely; 4284 goto not_likely;
4285 case OPC_BC1TANY2: 4285 case OPC_BC1TANY2:
4286 gen_op_bc1tany2(cc); 4286 gen_op_bc1tany2(cc);
4287 - MIPS_DEBUG("bc1tany2 " TARGET_FMT_lx, btarget); 4287 + opn = "bc1tany2";
4288 goto not_likely; 4288 goto not_likely;
4289 case OPC_BC1FANY4: 4289 case OPC_BC1FANY4:
4290 gen_op_bc1fany4(cc); 4290 gen_op_bc1fany4(cc);
4291 - MIPS_DEBUG("bc1fany4 " TARGET_FMT_lx, btarget); 4291 + opn = "bc1fany4";
4292 goto not_likely; 4292 goto not_likely;
4293 case OPC_BC1TANY4: 4293 case OPC_BC1TANY4:
4294 gen_op_bc1tany4(cc); 4294 gen_op_bc1tany4(cc);
4295 - MIPS_DEBUG("bc1tany4 " TARGET_FMT_lx, btarget); 4295 + opn = "bc1tany4";
4296 not_likely: 4296 not_likely:
4297 ctx->hflags |= MIPS_HFLAG_BC; 4297 ctx->hflags |= MIPS_HFLAG_BC;
4298 gen_op_set_bcond(); 4298 gen_op_set_bcond();
4299 break; 4299 break;
4300 default: 4300 default:
4301 - MIPS_INVAL("cp1 branch"); 4301 + MIPS_INVAL(opn);
4302 generate_exception (ctx, EXCP_RI); 4302 generate_exception (ctx, EXCP_RI);
4303 return; 4303 return;
4304 } 4304 }
4305 -  
4306 - MIPS_DEBUG("enter ds: cond %02x target " TARGET_FMT_lx, 4305 + MIPS_DEBUG("%s: cond %02x target " TARGET_FMT_lx, opn,
4307 ctx->hflags, btarget); 4306 ctx->hflags, btarget);
4308 ctx->btarget = btarget; 4307 ctx->btarget = btarget;
4309 -  
4310 - return;  
4311 } 4308 }
4312 4309
4313 /* Coprocessor 1 (FPU) */ 4310 /* Coprocessor 1 (FPU) */
@@ -4325,18 +4322,19 @@ static void gen_compute_branch1 (DisasContext *ctx, uint32_t op, @@ -4325,18 +4322,19 @@ static void gen_compute_branch1 (DisasContext *ctx, uint32_t op,
4325 * FIXME: This is broken for R2, it needs to be checked at runtime, not 4322 * FIXME: This is broken for R2, it needs to be checked at runtime, not
4326 * at translation time. 4323 * at translation time.
4327 */ 4324 */
4328 -#define CHECK_FR(ctx, freg) do { \ 4325 +#define CHECK_FR(ctx, freg) do { \
4329 if (!((ctx)->CP0_Status & (1 << CP0St_FR)) && ((freg) & 1)) { \ 4326 if (!((ctx)->CP0_Status & (1 << CP0St_FR)) && ((freg) & 1)) { \
4330 - generate_exception (ctx, EXCP_RI); \  
4331 - return; \  
4332 - } \ 4327 + MIPS_INVAL("FPU mode"); \
  4328 + generate_exception (ctx, EXCP_RI); \
  4329 + return; \
  4330 + } \
4333 } while(0) 4331 } while(0)
4334 4332
4335 #define FOP(func, fmt) (((fmt) << 21) | (func)) 4333 #define FOP(func, fmt) (((fmt) << 21) | (func))
4336 4334
4337 static void gen_cp1 (DisasContext *ctx, uint32_t opc, int rt, int fs) 4335 static void gen_cp1 (DisasContext *ctx, uint32_t opc, int rt, int fs)
4338 { 4336 {
4339 - const char *opn = "unk"; 4337 + const char *opn = "cp1 move";
4340 4338
4341 switch (opc) { 4339 switch (opc) {
4342 case OPC_MFC1: 4340 case OPC_MFC1:
@@ -4390,11 +4388,7 @@ static void gen_cp1 (DisasContext *ctx, uint32_t opc, int rt, int fs) @@ -4390,11 +4388,7 @@ static void gen_cp1 (DisasContext *ctx, uint32_t opc, int rt, int fs)
4390 opn = "mthc1"; 4388 opn = "mthc1";
4391 break; 4389 break;
4392 default: 4390 default:
4393 - if (loglevel & CPU_LOG_TB_IN_ASM) {  
4394 - fprintf(logfile, "Invalid CP1 opcode: %08x %03x %03x %03x\n",  
4395 - ctx->opcode, ctx->opcode >> 26, ctx->opcode & 0x3F,  
4396 - ((ctx->opcode >> 16) & 0x1F));  
4397 - } 4391 + MIPS_INVAL(opn);
4398 generate_exception (ctx, EXCP_RI); 4392 generate_exception (ctx, EXCP_RI);
4399 return; 4393 return;
4400 } 4394 }
@@ -4440,7 +4434,7 @@ GEN_MOVCF(ps); @@ -4440,7 +4434,7 @@ GEN_MOVCF(ps);
4440 static void gen_farith (DisasContext *ctx, uint32_t op1, int ft, 4434 static void gen_farith (DisasContext *ctx, uint32_t op1, int ft,
4441 int fs, int fd, int cc) 4435 int fs, int fd, int cc)
4442 { 4436 {
4443 - const char *opn = "unk"; 4437 + const char *opn = "farith";
4444 const char *condnames[] = { 4438 const char *condnames[] = {
4445 "c.f", 4439 "c.f",
4446 "c.un", 4440 "c.un",
@@ -5041,11 +5035,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, int ft, @@ -5041,11 +5035,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, int ft,
5041 opn = condnames[func-48]; 5035 opn = condnames[func-48];
5042 break; 5036 break;
5043 default: 5037 default:
5044 - if (loglevel & CPU_LOG_TB_IN_ASM) {  
5045 - fprintf(logfile, "Invalid FP arith function: %08x %03x %03x %03x\n",  
5046 - ctx->opcode, ctx->opcode >> 26, ctx->opcode & 0x3F,  
5047 - ((ctx->opcode >> 16) & 0x1F));  
5048 - } 5038 + MIPS_INVAL(opn);
5049 generate_exception (ctx, EXCP_RI); 5039 generate_exception (ctx, EXCP_RI);
5050 return; 5040 return;
5051 } 5041 }
@@ -5059,7 +5049,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, int ft, @@ -5059,7 +5049,7 @@ static void gen_farith (DisasContext *ctx, uint32_t op1, int ft,
5059 static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc, int fd, 5049 static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc, int fd,
5060 int base, int index) 5050 int base, int index)
5061 { 5051 {
5062 - const char *opn = "unk"; 5052 + const char *opn = "extended float load/store";
5063 5053
5064 GEN_LOAD_REG_TN(T0, base); 5054 GEN_LOAD_REG_TN(T0, base);
5065 GEN_LOAD_REG_TN(T1, index); 5055 GEN_LOAD_REG_TN(T1, index);
@@ -5098,7 +5088,7 @@ static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc, int fd, @@ -5098,7 +5088,7 @@ static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc, int fd,
5098 opn = "suxc1"; 5088 opn = "suxc1";
5099 break; 5089 break;
5100 default: 5090 default:
5101 - MIPS_INVAL("extended float load/store"); 5091 + MIPS_INVAL(opn);
5102 generate_exception(ctx, EXCP_RI); 5092 generate_exception(ctx, EXCP_RI);
5103 return; 5093 return;
5104 } 5094 }
@@ -5108,7 +5098,7 @@ static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc, int fd, @@ -5108,7 +5098,7 @@ static void gen_flt3_ldst (DisasContext *ctx, uint32_t opc, int fd,
5108 static void gen_flt3_arith (DisasContext *ctx, uint32_t opc, int fd, 5098 static void gen_flt3_arith (DisasContext *ctx, uint32_t opc, int fd,
5109 int fr, int fs, int ft) 5099 int fr, int fs, int ft)
5110 { 5100 {
5111 - const char *opn = "unk"; 5101 + const char *opn = "flt3_arith";
5112 5102
5113 /* All of those work only on 64bit FPUs. */ 5103 /* All of those work only on 64bit FPUs. */
5114 CHECK_FR(ctx, fd | fr | fs | ft); 5104 CHECK_FR(ctx, fd | fr | fs | ft);
@@ -5173,11 +5163,8 @@ static void gen_flt3_arith (DisasContext *ctx, uint32_t opc, int fd, @@ -5173,11 +5163,8 @@ static void gen_flt3_arith (DisasContext *ctx, uint32_t opc, int fd,
5173 generate_exception (ctx, EXCP_RI); 5163 generate_exception (ctx, EXCP_RI);
5174 opn = "nmsub.ps"; 5164 opn = "nmsub.ps";
5175 break; 5165 break;
5176 - default:  
5177 - if (loglevel & CPU_LOG_TB_IN_ASM) {  
5178 - fprintf(logfile, "Invalid extended FP arith function: %08x %03x %03x\n",  
5179 - ctx->opcode, ctx->opcode >> 26, ctx->opcode & 0x3F);  
5180 - } 5166 + default:
  5167 + MIPS_INVAL(opn);
5181 generate_exception (ctx, EXCP_RI); 5168 generate_exception (ctx, EXCP_RI);
5182 return; 5169 return;
5183 } 5170 }
@@ -5459,7 +5446,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx) @@ -5459,7 +5446,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
5459 /* treat as noop */ 5446 /* treat as noop */
5460 break; 5447 break;
5461 default: /* Invalid */ 5448 default: /* Invalid */
5462 - MIPS_INVAL("REGIMM"); 5449 + MIPS_INVAL("regimm");
5463 generate_exception(ctx, EXCP_RI); 5450 generate_exception(ctx, EXCP_RI);
5464 break; 5451 break;
5465 } 5452 }
@@ -5494,7 +5481,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx) @@ -5494,7 +5481,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
5494 ctx->bstate = BS_STOP; 5481 ctx->bstate = BS_STOP;
5495 break; 5482 break;
5496 default: /* Invalid */ 5483 default: /* Invalid */
5497 - MIPS_INVAL("MFMC0"); 5484 + MIPS_INVAL("mfmc0");
5498 generate_exception(ctx, EXCP_RI); 5485 generate_exception(ctx, EXCP_RI);
5499 break; 5486 break;
5500 } 5487 }
@@ -5506,10 +5493,13 @@ static void decode_opc (CPUState *env, DisasContext *ctx) @@ -5506,10 +5493,13 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
5506 /* Shadow registers not implemented. */ 5493 /* Shadow registers not implemented. */
5507 GEN_LOAD_REG_TN(T0, rt); 5494 GEN_LOAD_REG_TN(T0, rt);
5508 GEN_STORE_TN_REG(rd, T0); 5495 GEN_STORE_TN_REG(rd, T0);
5509 - } else 5496 + } else {
  5497 + MIPS_INVAL("shadow register move");
5510 generate_exception(ctx, EXCP_RI); 5498 generate_exception(ctx, EXCP_RI);
  5499 + }
5511 break; 5500 break;
5512 default: 5501 default:
  5502 + MIPS_INVAL("cp0");
5513 generate_exception(ctx, EXCP_RI); 5503 generate_exception(ctx, EXCP_RI);
5514 break; 5504 break;
5515 } 5505 }
@@ -5539,7 +5529,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx) @@ -5539,7 +5529,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
5539 /* Treat as a noop */ 5529 /* Treat as a noop */
5540 break; 5530 break;
5541 5531
5542 - /* Floating point. */ 5532 + /* Floating point (COP1). */
5543 case OPC_LWC1: 5533 case OPC_LWC1:
5544 case OPC_LDC1: 5534 case OPC_LDC1:
5545 case OPC_SWC1: 5535 case OPC_SWC1:
@@ -5584,6 +5574,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx) @@ -5584,6 +5574,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
5584 (imm >> 8) & 0x7); 5574 (imm >> 8) & 0x7);
5585 break; 5575 break;
5586 default: 5576 default:
  5577 + MIPS_INVAL("cp1");
5587 generate_exception (ctx, EXCP_RI); 5578 generate_exception (ctx, EXCP_RI);
5588 break; 5579 break;
5589 } 5580 }
@@ -5635,6 +5626,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx) @@ -5635,6 +5626,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
5635 gen_flt3_arith(ctx, op1, sa, rs, rd, rt); 5626 gen_flt3_arith(ctx, op1, sa, rs, rd, rt);
5636 break; 5627 break;
5637 default: 5628 default:
  5629 + MIPS_INVAL("cp3");
5638 generate_exception (ctx, EXCP_RI); 5630 generate_exception (ctx, EXCP_RI);
5639 break; 5631 break;
5640 } 5632 }
@@ -5667,7 +5659,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx) @@ -5667,7 +5659,7 @@ static void decode_opc (CPUState *env, DisasContext *ctx)
5667 /* MDMX: Not implemented. */ 5659 /* MDMX: Not implemented. */
5668 #endif 5660 #endif
5669 default: /* Invalid */ 5661 default: /* Invalid */
5670 - MIPS_INVAL(""); 5662 + MIPS_INVAL("major opcode");
5671 generate_exception(ctx, EXCP_RI); 5663 generate_exception(ctx, EXCP_RI);
5672 break; 5664 break;
5673 } 5665 }
@@ -5764,7 +5756,7 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb, @@ -5764,7 +5756,7 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb,
5764 cpu_dump_state(env, logfile, fprintf, 0); 5756 cpu_dump_state(env, logfile, fprintf, 0);
5765 } 5757 }
5766 #endif 5758 #endif
5767 -#if defined MIPS_DEBUG_DISAS 5759 +#ifdef MIPS_DEBUG_DISAS
5768 if (loglevel & CPU_LOG_TB_IN_ASM) 5760 if (loglevel & CPU_LOG_TB_IN_ASM)
5769 fprintf(logfile, "\ntb %p super %d cond %04x\n", 5761 fprintf(logfile, "\ntb %p super %d cond %04x\n",
5770 tb, ctx.mem_idx, ctx.hflags); 5762 tb, ctx.mem_idx, ctx.hflags);