Révision | daa88e0aca90434de7bb9a927c40aaf71d1f5112 (tree) |
---|---|
l'heure | 2020-03-16 00:12:47 |
Auteur | Richard Henderson <richard.henderson@lina...> |
Commiter | Yoshinori Sato |
target/rx: Replace operand with prt_ldmi in disassembler
This has consistency with prt_ri(). It loads all data before
beginning output. It uses exactly one call to prt() to emit
the full instruction.
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Message-Id: <20190607091116.49044-20-ysato@users.sourceforge.jp>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
@@ -135,18 +135,18 @@ static void rx_index_addr(DisasContext *ctx, char out[8], int ld, int mi) | ||
135 | 135 | sprintf(out, "%u", dsp << (mi < 3 ? mi : 4 - mi)); |
136 | 136 | } |
137 | 137 | |
138 | -static void operand(DisasContext *ctx, int ld, int mi, int rs, int rd) | |
138 | +static void prt_ldmi(DisasContext *ctx, const char *insn, | |
139 | + int ld, int mi, int rs, int rd) | |
139 | 140 | { |
140 | 141 | static const char sizes[][4] = {".b", ".w", ".l", ".uw", ".ub"}; |
141 | 142 | char dsp[8]; |
142 | 143 | |
143 | 144 | if (ld < 3) { |
144 | 145 | rx_index_addr(ctx, dsp, ld, mi); |
145 | - prt("%s[r%d]%s", dsp, rs, sizes[mi]); | |
146 | + prt("%s\t%s[r%d]%s, r%d", insn, dsp, rs, sizes[mi], rd); | |
146 | 147 | } else { |
147 | - prt("r%d", rs); | |
148 | + prt("%s\tr%d, r%d", insn, rs, rd); | |
148 | 149 | } |
149 | - prt(", r%d", rd); | |
150 | 150 | } |
151 | 151 | |
152 | 152 | static void prt_ir(DisasContext *ctx, const char *insn, int imm, int rd) |
@@ -416,8 +416,7 @@ static bool trans_AND_ir(DisasContext *ctx, arg_AND_ir *a) | ||
416 | 416 | /* and rs,rd */ |
417 | 417 | static bool trans_AND_mr(DisasContext *ctx, arg_AND_mr *a) |
418 | 418 | { |
419 | - prt("and\t"); | |
420 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
419 | + prt_ldmi(ctx, "and", a->ld, a->mi, a->rs, a->rd); | |
421 | 420 | return true; |
422 | 421 | } |
423 | 422 |
@@ -440,8 +439,7 @@ static bool trans_OR_ir(DisasContext *ctx, arg_OR_ir *a) | ||
440 | 439 | /* or rs,rd */ |
441 | 440 | static bool trans_OR_mr(DisasContext *ctx, arg_OR_mr *a) |
442 | 441 | { |
443 | - prt("or\t"); | |
444 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
442 | + prt_ldmi(ctx, "or", a->ld, a->mi, a->rs, a->rd); | |
445 | 443 | return true; |
446 | 444 | } |
447 | 445 |
@@ -463,8 +461,7 @@ static bool trans_XOR_ir(DisasContext *ctx, arg_XOR_ir *a) | ||
463 | 461 | /* xor rs,rd */ |
464 | 462 | static bool trans_XOR_mr(DisasContext *ctx, arg_XOR_mr *a) |
465 | 463 | { |
466 | - prt("xor\t"); | |
467 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
464 | + prt_ldmi(ctx, "xor", a->ld, a->mi, a->rs, a->rd); | |
468 | 465 | return true; |
469 | 466 | } |
470 | 467 |
@@ -479,8 +476,7 @@ static bool trans_TST_ir(DisasContext *ctx, arg_TST_ir *a) | ||
479 | 476 | /* tst rs, rd */ |
480 | 477 | static bool trans_TST_mr(DisasContext *ctx, arg_TST_mr *a) |
481 | 478 | { |
482 | - prt("tst\t"); | |
483 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
479 | + prt_ldmi(ctx, "tst", a->ld, a->mi, a->rs, a->rd); | |
484 | 480 | return true; |
485 | 481 | } |
486 | 482 |
@@ -548,8 +544,7 @@ static bool trans_ADD_irr(DisasContext *ctx, arg_ADD_irr *a) | ||
548 | 544 | /* add dsp[rs], rd */ |
549 | 545 | static bool trans_ADD_mr(DisasContext *ctx, arg_ADD_mr *a) |
550 | 546 | { |
551 | - prt("add\t"); | |
552 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
547 | + prt_ldmi(ctx, "add", a->ld, a->mi, a->rs, a->rd); | |
553 | 548 | return true; |
554 | 549 | } |
555 | 550 |
@@ -573,8 +568,7 @@ static bool trans_CMP_ir(DisasContext *ctx, arg_CMP_ir *a) | ||
573 | 568 | /* cmp dsp[rs], rs2 */ |
574 | 569 | static bool trans_CMP_mr(DisasContext *ctx, arg_CMP_mr *a) |
575 | 570 | { |
576 | - prt("cmp\t"); | |
577 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
571 | + prt_ldmi(ctx, "cmp", a->ld, a->mi, a->rs, a->rd); | |
578 | 572 | return true; |
579 | 573 | } |
580 | 574 |
@@ -589,8 +583,7 @@ static bool trans_SUB_ir(DisasContext *ctx, arg_SUB_ir *a) | ||
589 | 583 | /* sub dsp[rs], rd */ |
590 | 584 | static bool trans_SUB_mr(DisasContext *ctx, arg_SUB_mr *a) |
591 | 585 | { |
592 | - prt("sub\t"); | |
593 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
586 | + prt_ldmi(ctx, "sub", a->ld, a->mi, a->rs, a->rd); | |
594 | 587 | return true; |
595 | 588 | } |
596 | 589 |
@@ -611,8 +604,7 @@ static bool trans_SBB_rr(DisasContext *ctx, arg_SBB_rr *a) | ||
611 | 604 | /* sbb dsp[rs], rd */ |
612 | 605 | static bool trans_SBB_mr(DisasContext *ctx, arg_SBB_mr *a) |
613 | 606 | { |
614 | - prt("sbb\t"); | |
615 | - operand(ctx, a->ld, RX_IM_LONG, a->rs, a->rd); | |
607 | + prt_ldmi(ctx, "sbb", a->ld, RX_IM_LONG, a->rs, a->rd); | |
616 | 608 | return true; |
617 | 609 | } |
618 | 610 |
@@ -640,8 +632,7 @@ static bool trans_MAX_ir(DisasContext *ctx, arg_MAX_ir *a) | ||
640 | 632 | /* max dsp[rs], rd */ |
641 | 633 | static bool trans_MAX_mr(DisasContext *ctx, arg_MAX_mr *a) |
642 | 634 | { |
643 | - prt("max\t"); | |
644 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
635 | + prt_ldmi(ctx, "max", a->ld, a->mi, a->rs, a->rd); | |
645 | 636 | return true; |
646 | 637 | } |
647 | 638 |
@@ -656,8 +647,7 @@ static bool trans_MIN_ir(DisasContext *ctx, arg_MIN_ir *a) | ||
656 | 647 | /* min dsp[rs], rd */ |
657 | 648 | static bool trans_MIN_mr(DisasContext *ctx, arg_MIN_mr *a) |
658 | 649 | { |
659 | - prt("max\t"); | |
660 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
650 | + prt_ldmi(ctx, "min", a->ld, a->mi, a->rs, a->rd); | |
661 | 651 | return true; |
662 | 652 | } |
663 | 653 |
@@ -673,8 +663,7 @@ static bool trans_MUL_ir(DisasContext *ctx, arg_MUL_ir *a) | ||
673 | 663 | /* mul dsp[rs], rd */ |
674 | 664 | static bool trans_MUL_mr(DisasContext *ctx, arg_MUL_mr *a) |
675 | 665 | { |
676 | - prt("mul\t"); | |
677 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
666 | + prt_ldmi(ctx, "mul", a->ld, a->mi, a->rs, a->rd); | |
678 | 667 | return true; |
679 | 668 | } |
680 | 669 |
@@ -696,8 +685,7 @@ static bool trans_EMUL_ir(DisasContext *ctx, arg_EMUL_ir *a) | ||
696 | 685 | /* emul dsp[rs], rd */ |
697 | 686 | static bool trans_EMUL_mr(DisasContext *ctx, arg_EMUL_mr *a) |
698 | 687 | { |
699 | - prt("emul\t"); | |
700 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
688 | + prt_ldmi(ctx, "emul", a->ld, a->mi, a->rs, a->rd); | |
701 | 689 | return true; |
702 | 690 | } |
703 | 691 |
@@ -712,8 +700,7 @@ static bool trans_EMULU_ir(DisasContext *ctx, arg_EMULU_ir *a) | ||
712 | 700 | /* emulu dsp[rs], rd */ |
713 | 701 | static bool trans_EMULU_mr(DisasContext *ctx, arg_EMULU_mr *a) |
714 | 702 | { |
715 | - prt("emulu\t"); | |
716 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
703 | + prt_ldmi(ctx, "emulu", a->ld, a->mi, a->rs, a->rd); | |
717 | 704 | return true; |
718 | 705 | } |
719 | 706 |
@@ -728,8 +715,7 @@ static bool trans_DIV_ir(DisasContext *ctx, arg_DIV_ir *a) | ||
728 | 715 | /* div dsp[rs], rd */ |
729 | 716 | static bool trans_DIV_mr(DisasContext *ctx, arg_DIV_mr *a) |
730 | 717 | { |
731 | - prt("div\t"); | |
732 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
718 | + prt_ldmi(ctx, "div", a->ld, a->mi, a->rs, a->rd); | |
733 | 719 | return true; |
734 | 720 | } |
735 | 721 |
@@ -744,8 +730,7 @@ static bool trans_DIVU_ir(DisasContext *ctx, arg_DIVU_ir *a) | ||
744 | 730 | /* divu dsp[rs], rd */ |
745 | 731 | static bool trans_DIVU_mr(DisasContext *ctx, arg_DIVU_mr *a) |
746 | 732 | { |
747 | - prt("divu\t"); | |
748 | - operand(ctx, a->ld, a->mi, a->rs, a->rd); | |
733 | + prt_ldmi(ctx, "divu", a->ld, a->mi, a->rs, a->rd); | |
749 | 734 | return true; |
750 | 735 | } |
751 | 736 |
@@ -1089,8 +1074,7 @@ static bool trans_FADD_ir(DisasContext *ctx, arg_FADD_ir *a) | ||
1089 | 1074 | /* fadd rs, rd */ |
1090 | 1075 | static bool trans_FADD_mr(DisasContext *ctx, arg_FADD_mr *a) |
1091 | 1076 | { |
1092 | - prt("fadd\t"); | |
1093 | - operand(ctx, a->ld, RX_IM_LONG, a->rs, a->rd); | |
1077 | + prt_ldmi(ctx, "fadd", a->ld, RX_IM_LONG, a->rs, a->rd); | |
1094 | 1078 | return true; |
1095 | 1079 | } |
1096 | 1080 |
@@ -1105,8 +1089,7 @@ static bool trans_FCMP_ir(DisasContext *ctx, arg_FCMP_ir *a) | ||
1105 | 1089 | /* fcmp rs, rd */ |
1106 | 1090 | static bool trans_FCMP_mr(DisasContext *ctx, arg_FCMP_mr *a) |
1107 | 1091 | { |
1108 | - prt("fcmp\t"); | |
1109 | - operand(ctx, a->ld, RX_IM_LONG, a->rs, a->rd); | |
1092 | + prt_ldmi(ctx, "fcmp", a->ld, RX_IM_LONG, a->rs, a->rd); | |
1110 | 1093 | return true; |
1111 | 1094 | } |
1112 | 1095 |
@@ -1121,8 +1104,7 @@ static bool trans_FSUB_ir(DisasContext *ctx, arg_FSUB_ir *a) | ||
1121 | 1104 | /* fsub rs, rd */ |
1122 | 1105 | static bool trans_FSUB_mr(DisasContext *ctx, arg_FSUB_mr *a) |
1123 | 1106 | { |
1124 | - prt("fsub\t"); | |
1125 | - operand(ctx, a->ld, RX_IM_LONG, a->rs, a->rd); | |
1107 | + prt_ldmi(ctx, "fsub", a->ld, RX_IM_LONG, a->rs, a->rd); | |
1126 | 1108 | return true; |
1127 | 1109 | } |
1128 | 1110 |
@@ -1130,8 +1112,7 @@ static bool trans_FSUB_mr(DisasContext *ctx, arg_FSUB_mr *a) | ||
1130 | 1112 | /* ftoi rs, rd */ |
1131 | 1113 | static bool trans_FTOI(DisasContext *ctx, arg_FTOI *a) |
1132 | 1114 | { |
1133 | - prt("ftoi\t"); | |
1134 | - operand(ctx, a->ld, RX_IM_LONG, a->rs, a->rd); | |
1115 | + prt_ldmi(ctx, "ftoi", a->ld, RX_IM_LONG, a->rs, a->rd); | |
1135 | 1116 | return true; |
1136 | 1117 | } |
1137 | 1118 |
@@ -1146,8 +1127,7 @@ static bool trans_FMUL_ir(DisasContext *ctx, arg_FMUL_ir *a) | ||
1146 | 1127 | /* fmul rs, rd */ |
1147 | 1128 | static bool trans_FMUL_mr(DisasContext *ctx, arg_FMUL_mr *a) |
1148 | 1129 | { |
1149 | - prt("fmul\t"); | |
1150 | - operand(ctx, a->ld, RX_IM_LONG, a->rs, a->rd); | |
1130 | + prt_ldmi(ctx, "fmul", a->ld, RX_IM_LONG, a->rs, a->rd); | |
1151 | 1131 | return true; |
1152 | 1132 | } |
1153 | 1133 |
@@ -1162,8 +1142,7 @@ static bool trans_FDIV_ir(DisasContext *ctx, arg_FDIV_ir *a) | ||
1162 | 1142 | /* fdiv rs, rd */ |
1163 | 1143 | static bool trans_FDIV_mr(DisasContext *ctx, arg_FDIV_mr *a) |
1164 | 1144 | { |
1165 | - prt("fdiv\t"); | |
1166 | - operand(ctx, a->ld, RX_IM_LONG, a->rs, a->rd); | |
1145 | + prt_ldmi(ctx, "fdiv", a->ld, RX_IM_LONG, a->rs, a->rd); | |
1167 | 1146 | return true; |
1168 | 1147 | } |
1169 | 1148 |
@@ -1171,8 +1150,7 @@ static bool trans_FDIV_mr(DisasContext *ctx, arg_FDIV_mr *a) | ||
1171 | 1150 | /* round rs, rd */ |
1172 | 1151 | static bool trans_ROUND(DisasContext *ctx, arg_ROUND *a) |
1173 | 1152 | { |
1174 | - prt("round\t"); | |
1175 | - operand(ctx, a->ld, RX_IM_LONG, a->rs, a->rd); | |
1153 | + prt_ldmi(ctx, "round", a->ld, RX_IM_LONG, a->rs, a->rd); | |
1176 | 1154 | return true; |
1177 | 1155 | } |
1178 | 1156 |
@@ -1180,8 +1158,7 @@ static bool trans_ROUND(DisasContext *ctx, arg_ROUND *a) | ||
1180 | 1158 | /* itof dsp[rs], rd */ |
1181 | 1159 | static bool trans_ITOF(DisasContext *ctx, arg_ITOF *a) |
1182 | 1160 | { |
1183 | - prt("itof\t"); | |
1184 | - operand(ctx, a->ld, RX_IM_LONG, a->rs, a->rd); | |
1161 | + prt_ldmi(ctx, "itof", a->ld, RX_IM_LONG, a->rs, a->rd); | |
1185 | 1162 | return true; |
1186 | 1163 | } |
1187 | 1164 |