• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiónc6d94ad98b04ff805bc35c37573fad7db1eb313b (tree)
Tiempo2020-01-12 00:51:49
AutorRichard Henderson <richard.henderson@lina...>
CommiterYoshinori Sato

Log Message

target/rx: Disassemble rx_index_addr into a string

We were eliding all zero indexes. It is only ld==0 that does
not have an index in the instruction. This also allows us to
avoid breaking the final print into multiple pieces.

Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Message-Id: <20190607091116.49044-19-ysato@users.sourceforge.jp>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Cambiar Resumen

Diferencia incremental

--- a/target/rx/disas.c
+++ b/target/rx/disas.c
@@ -107,49 +107,42 @@ static const char psw[] = {
107107 'i', 'u', 0, 0, 0, 0, 0, 0,
108108 };
109109
110-static uint32_t rx_index_addr(int ld, int size, DisasContext *ctx)
110+static void rx_index_addr(DisasContext *ctx, char out[8], int ld, int mi)
111111 {
112- bfd_byte buf[2];
112+ uint32_t addr = ctx->addr;
113+ uint8_t buf[2];
114+ uint16_t dsp;
115+
113116 switch (ld) {
114117 case 0:
115- return 0;
118+ /* No index; return empty string. */
119+ out[0] = '\0';
120+ return;
116121 case 1:
117- ctx->dis->read_memory_func(ctx->addr, buf, 1, ctx->dis);
118122 ctx->addr += 1;
119- return ((uint8_t)buf[0]) << size;
123+ ctx->dis->read_memory_func(addr, buf, 1, ctx->dis);
124+ dsp = buf[0];
125+ break;
120126 case 2:
121- ctx->dis->read_memory_func(ctx->addr, buf, 2, ctx->dis);
122127 ctx->addr += 2;
123- return lduw_le_p(buf) << size;
128+ ctx->dis->read_memory_func(addr, buf, 2, ctx->dis);
129+ dsp = lduw_le_p(buf);
130+ break;
131+ default:
132+ g_assert_not_reached();
124133 }
125- g_assert_not_reached();
134+
135+ sprintf(out, "%u", dsp << (mi < 3 ? mi : 4 - mi));
126136 }
127137
128138 static void operand(DisasContext *ctx, int ld, int mi, int rs, int rd)
129139 {
130- int dsp;
131140 static const char sizes[][4] = {".b", ".w", ".l", ".uw", ".ub"};
141+ char dsp[8];
142+
132143 if (ld < 3) {
133- switch (mi) {
134- case 4:
135- /* dsp[rs].ub */
136- dsp = rx_index_addr(ld, RX_MEMORY_BYTE, ctx);
137- break;
138- case 3:
139- /* dsp[rs].uw */
140- dsp = rx_index_addr(ld, RX_MEMORY_WORD, ctx);
141- break;
142- default:
143- /* dsp[rs].b */
144- /* dsp[rs].w */
145- /* dsp[rs].l */
146- dsp = rx_index_addr(ld, mi, ctx);
147- break;
148- }
149- if (dsp > 0) {
150- prt("%d", dsp);
151- }
152- prt("[r%d]%s", rs, sizes[mi]);
144+ rx_index_addr(ctx, dsp, ld, mi);
145+ prt("%s[r%d]%s", dsp, rs, sizes[mi]);
153146 } else {
154147 prt("r%d", rs);
155148 }
@@ -235,7 +228,7 @@ static bool trans_MOV_ra(DisasContext *ctx, arg_MOV_ra *a)
235228 /* mov.[bwl] rs,rd */
236229 static bool trans_MOV_mm(DisasContext *ctx, arg_MOV_mm *a)
237230 {
238- int dsp;
231+ char dspd[8], dsps[8];
239232
240233 prt("mov.%c\t", size[a->sz]);
241234 if (a->lds == 3 && a->ldd == 3) {
@@ -244,29 +237,15 @@ static bool trans_MOV_mm(DisasContext *ctx, arg_MOV_mm *a)
244237 return true;
245238 }
246239 if (a->lds == 3) {
247- prt("r%d, ", a->rd);
248- dsp = rx_index_addr(a->ldd, a->sz, ctx);
249- if (dsp > 0) {
250- prt("%d", dsp);
251- }
252- prt("[r%d]", a->rs);
240+ rx_index_addr(ctx, dspd, a->ldd, a->sz);
241+ prt("r%d, %s[r%d]", a->rs, dspd, a->rd);
253242 } else if (a->ldd == 3) {
254- dsp = rx_index_addr(a->lds, a->sz, ctx);
255- if (dsp > 0) {
256- prt("%d", dsp);
257- }
258- prt("[r%d], r%d", a->rs, a->rd);
243+ rx_index_addr(ctx, dsps, a->lds, a->sz);
244+ prt("%s[r%d], r%d", dsps, a->rs, a->rd);
259245 } else {
260- dsp = rx_index_addr(a->lds, a->sz, ctx);
261- if (dsp > 0) {
262- prt("%d", dsp);
263- }
264- prt("[r%d], ", a->rs);
265- dsp = rx_index_addr(a->ldd, a->sz, ctx);
266- if (dsp > 0) {
267- prt("%d", dsp);
268- }
269- prt("[r%d]", a->rd);
246+ rx_index_addr(ctx, dsps, a->lds, a->sz);
247+ rx_index_addr(ctx, dspd, a->ldd, a->sz);
248+ prt("%s[r%d], %s[r%d]", dsps, a->rs, dspd, a->rd);
270249 }
271250 return true;
272251 }
@@ -357,12 +336,10 @@ static bool trans_PUSH_r(DisasContext *ctx, arg_PUSH_r *a)
357336 /* push dsp[rs] */
358337 static bool trans_PUSH_m(DisasContext *ctx, arg_PUSH_m *a)
359338 {
360- prt("push\t");
361- int dsp = rx_index_addr(a->ld, a->sz, ctx);
362- if (dsp > 0) {
363- prt("%d", dsp);
364- }
365- prt("[r%d]", a->rs);
339+ char dsp[8];
340+
341+ rx_index_addr(ctx, dsp, a->ld, a->sz);
342+ prt("push\t%s[r%d]", dsp, a->rs);
366343 return true;
367344 }
368345
@@ -389,17 +366,13 @@ static bool trans_XCHG_rr(DisasContext *ctx, arg_XCHG_rr *a)
389366 /* xchg dsp[rs].<mi>,rd */
390367 static bool trans_XCHG_mr(DisasContext *ctx, arg_XCHG_mr *a)
391368 {
392- int dsp;
393369 static const char msize[][4] = {
394370 "b", "w", "l", "ub", "uw",
395371 };
372+ char dsp[8];
396373
397- prt("xchg\t");
398- dsp = rx_index_addr(a->ld, a->mi, ctx);
399- if (dsp > 0) {
400- prt("%d", dsp);
401- }
402- prt("[r%d].%s, r%d", a->rs, msize[a->mi], a->rd);
374+ rx_index_addr(ctx, dsp, a->ld, a->mi);
375+ prt("xchg\t%s[r%d].%s, r%d", dsp, a->rs, msize[a->mi], a->rd);
403376 return true;
404377 }
405378
@@ -552,13 +525,10 @@ static bool trans_ADC_rr(DisasContext *ctx, arg_ADC_rr *a)
552525 /* adc dsp[rs], rd */
553526 static bool trans_ADC_mr(DisasContext *ctx, arg_ADC_mr *a)
554527 {
555- int dsp;
556- prt("adc\t");
557- dsp = rx_index_addr(a->ld, 2, ctx);
558- if (dsp > 0) {
559- prt("%d", dsp);
560- }
561- prt("[r%d], r%d", a->rs, a->rd);
528+ char dsp[8];
529+
530+ rx_index_addr(ctx, dsp, a->ld, 2);
531+ prt("adc\t%s[r%d], r%d", dsp, a->rs, a->rd);
562532 return true;
563533 }
564534
@@ -1217,25 +1187,17 @@ static bool trans_ITOF(DisasContext *ctx, arg_ITOF *a)
12171187
12181188 #define BOP_IM(name, reg) \
12191189 do { \
1220- int dsp; \
1221- prt("b%s\t#%d, ", #name, a->imm); \
1222- dsp = rx_index_addr(a->ld, RX_MEMORY_BYTE, ctx); \
1223- if (dsp > 0) { \
1224- prt("%d", dsp); \
1225- } \
1226- prt("[r%d]", reg); \
1190+ char dsp[8]; \
1191+ rx_index_addr(ctx, dsp, a->ld, RX_MEMORY_BYTE); \
1192+ prt("b%s\t#%d, %s[r%d]", #name, a->imm, dsp, reg); \
12271193 return true; \
12281194 } while (0)
12291195
12301196 #define BOP_RM(name) \
12311197 do { \
1232- int dsp; \
1233- prt("b%s\tr%d, ", #name, a->rd); \
1234- dsp = rx_index_addr(a->ld, RX_MEMORY_BYTE, ctx); \
1235- if (dsp > 0) { \
1236- prt("%d", dsp); \
1237- } \
1238- prt("[r%d]", a->rs); \
1198+ char dsp[8]; \
1199+ rx_index_addr(ctx, dsp, a->ld, RX_MEMORY_BYTE); \
1200+ prt("b%s\tr%d, %s[r%d]", #name, a->rd, dsp, a->rs); \
12391201 return true; \
12401202 } while (0)
12411203
@@ -1346,12 +1308,10 @@ static bool trans_BNOT_ir(DisasContext *ctx, arg_BNOT_ir *a)
13461308 /* bmcond #imm, dsp[rd] */
13471309 static bool trans_BMCnd_im(DisasContext *ctx, arg_BMCnd_im *a)
13481310 {
1349- int dsp = rx_index_addr(a->ld, RX_MEMORY_BYTE, ctx);
1350- prt("bm%s\t#%d, ", cond[a->cd], a->imm);
1351- if (dsp > 0) {
1352- prt("%d", dsp);
1353- }
1354- prt("[%d]", a->rd);
1311+ char dsp[8];
1312+
1313+ rx_index_addr(ctx, dsp, a->ld, RX_MEMORY_BYTE);
1314+ prt("bm%s\t#%d, %s[r%d]", cond[a->cd], a->imm, dsp, a->rd);
13551315 return true;
13561316 }
13571317
@@ -1443,16 +1403,12 @@ static bool trans_WAIT(DisasContext *ctx, arg_WAIT *a)
14431403 /* sccnd.[bwl] dsp:[rd] */
14441404 static bool trans_SCCnd(DisasContext *ctx, arg_SCCnd *a)
14451405 {
1446- int dsp;
1447- prt("sc%s.%c\t", cond[a->cd], size[a->sz]);
14481406 if (a->ld < 3) {
1449- dsp = rx_index_addr(a->sz, a->ld, ctx);
1450- if (dsp > 0) {
1451- prt("%d", dsp);
1452- }
1453- prt("[r%d]", a->rd);
1407+ char dsp[8];
1408+ rx_index_addr(ctx, dsp, a->sz, a->ld);
1409+ prt("sc%s.%c\t%s[r%d]", cond[a->cd], size[a->sz], dsp, a->rd);
14541410 } else {
1455- prt("r%d", a->rd);
1411+ prt("sc%s.%c\tr%d", cond[a->cd], size[a->sz], a->rd);
14561412 }
14571413 return true;
14581414 }