From 3bcf819b438938e500acbf602cbacc00a864181f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 24 Apr 2020 10:36:41 -0700 Subject: [PATCH] freedreno/ir3: Convert remaining disasm src prints to reginfo. More lines of code, but they're much more intelligible. Part-of: --- src/freedreno/ir3/disasm-a3xx.c | 152 +++++++++++++++++++------------- 1 file changed, 92 insertions(+), 60 deletions(-) diff --git a/src/freedreno/ir3/disasm-a3xx.c b/src/freedreno/ir3/disasm-a3xx.c index 2648fa1fa86..a14cde9f220 100644 --- a/src/freedreno/ir3/disasm-a3xx.c +++ b/src/freedreno/ir3/disasm-a3xx.c @@ -260,8 +260,14 @@ static void print_instr_cat1(struct disasm_ctx *ctx, instr_t *instr) else fprintf(ctx->out, "%s%c", full, type); } else { - print_reg_src(ctx, (reg_t)(cat1->src), type_size(cat1->src_type) == 32, - cat1->src_r, cat1->src_c, cat1->src_im, false, false, false); + struct reginfo src = { + .reg = (reg_t)cat1->src, + .full = type_size(cat1->src_type) == 32, + .r = cat1->src_r, + .c = cat1->src_c, + .im = cat1->src_im, + }; + print_src(ctx, &src); } if ((debug & PRINT_VERBOSE) && (cat1->must_be_0)) @@ -298,22 +304,33 @@ static void print_instr_cat2(struct disasm_ctx *ctx, instr_t *instr) print_reg_dst(ctx, (reg_t)(cat2->dst), cat2->full ^ cat2->dst_half, false); fprintf(ctx->out, ", "); - unsigned src1_r = cat2->repeat ? cat2->src1_r : 0; + struct reginfo src1 = { + .full = cat2->full, + .r = cat2->repeat ? cat2->src1_r : 0, + .im = cat2->src1_im, + .abs = cat2->src1_abs, + .neg = cat2->src1_neg, + }; + if (cat2->c1.src1_c) { - print_reg_src(ctx, (reg_t)(cat2->c1.src1), cat2->full, src1_r, - cat2->c1.src1_c, cat2->src1_im, cat2->src1_neg, - cat2->src1_abs, false); + src1.reg = (reg_t)(cat2->c1.src1); + src1.c = true; } else if (cat2->rel1.src1_rel) { - print_reg_src(ctx, (reg_t)(cat2->rel1.src1), cat2->full, src1_r, - cat2->rel1.src1_c, cat2->src1_im, cat2->src1_neg, - cat2->src1_abs, cat2->rel1.src1_rel); + src1.reg = (reg_t)(cat2->rel1.src1); + src1.c = cat2->rel1.src1_c; + src1.addr_rel = true; } else { - print_reg_src(ctx, (reg_t)(cat2->src1), cat2->full, src1_r, - false, cat2->src1_im, cat2->src1_neg, - cat2->src1_abs, false); + src1.reg = (reg_t)(cat2->src1); } + print_src(ctx, &src1); - unsigned src2_r = cat2->repeat ? cat2->src2_r : 0; + struct reginfo src2 = { + .r = cat2->repeat ? cat2->src2_r : 0, + .full = cat2->full, + .abs = cat2->src2_abs, + .neg = cat2->src2_neg, + .im = cat2->src2_im, + }; switch (_OPC(2, cat2->opc)) { case OPC_ABSNEG_F: case OPC_ABSNEG_S: @@ -334,18 +351,16 @@ static void print_instr_cat2(struct disasm_ctx *ctx, instr_t *instr) default: fprintf(ctx->out, ", "); if (cat2->c2.src2_c) { - print_reg_src(ctx, (reg_t)(cat2->c2.src2), cat2->full, src2_r, - cat2->c2.src2_c, cat2->src2_im, cat2->src2_neg, - cat2->src2_abs, false); + src2.reg = (reg_t)(cat2->c2.src2); + src2.c = true; } else if (cat2->rel2.src2_rel) { - print_reg_src(ctx, (reg_t)(cat2->rel2.src2), cat2->full, src2_r, - cat2->rel2.src2_c, cat2->src2_im, cat2->src2_neg, - cat2->src2_abs, cat2->rel2.src2_rel); + src2.reg = (reg_t)(cat2->rel2.src2); + src2.c = cat2->rel2.src2_c; + src2.addr_rel = true; } else { - print_reg_src(ctx, (reg_t)(cat2->src2), cat2->full, src2_r, - false, cat2->src2_im, cat2->src2_neg, - cat2->src2_abs, false); + src2.reg = (reg_t)(cat2->src2); } + print_src(ctx, &src2); break; } } @@ -358,39 +373,51 @@ static void print_instr_cat3(struct disasm_ctx *ctx, instr_t *instr) fprintf(ctx->out, " "); print_reg_dst(ctx, (reg_t)(cat3->dst), full ^ cat3->dst_half, false); fprintf(ctx->out, ", "); - unsigned src1_r = cat3->repeat ? cat3->src1_r : 0; + + struct reginfo src1 = { + .r = cat3->repeat ? cat3->src1_r : 0, + .full = full, + .neg = cat3->src1_neg, + }; if (cat3->c1.src1_c) { - print_reg_src(ctx, (reg_t)(cat3->c1.src1), full, - src1_r, cat3->c1.src1_c, false, cat3->src1_neg, - false, false); + src1.reg = (reg_t)(cat3->c1.src1); + src1.c = true; } else if (cat3->rel1.src1_rel) { - print_reg_src(ctx, (reg_t)(cat3->rel1.src1), full, - src1_r, cat3->rel1.src1_c, false, cat3->src1_neg, - false, cat3->rel1.src1_rel); + src1.reg = (reg_t)(cat3->rel1.src1); + src1.c = cat3->rel1.src1_c; + src1.addr_rel = true; } else { - print_reg_src(ctx, (reg_t)(cat3->src1), full, - src1_r, false, false, cat3->src1_neg, - false, false); + src1.reg = (reg_t)(cat3->src1); } + print_src(ctx, &src1); + fprintf(ctx->out, ", "); - unsigned src2_r = cat3->repeat ? cat3->src2_r : 0; - print_reg_src(ctx, (reg_t)cat3->src2, full, - src2_r, cat3->src2_c, false, cat3->src2_neg, - false, false); + struct reginfo src2 = { + .reg = (reg_t)cat3->src2, + .full = full, + .r = cat3->repeat ? cat3->src2_r : 0, + .c = cat3->src2_c, + .neg = cat3->src2_neg, + }; + print_src(ctx, &src2); + fprintf(ctx->out, ", "); + struct reginfo src3 = { + .r = cat3->src3_r, + .full = full, + .neg = cat3->src3_neg, + }; if (cat3->c2.src3_c) { - print_reg_src(ctx, (reg_t)(cat3->c2.src3), full, - cat3->src3_r, cat3->c2.src3_c, false, cat3->src3_neg, - false, false); + src3.reg = (reg_t)(cat3->c2.src3); + src3.c = true; } else if (cat3->rel2.src3_rel) { - print_reg_src(ctx, (reg_t)(cat3->rel2.src3), full, - cat3->src3_r, cat3->rel2.src3_c, false, cat3->src3_neg, - false, cat3->rel2.src3_rel); + src3.reg = (reg_t)(cat3->rel2.src3); + src3.c = cat3->rel2.src3_c; + src3.addr_rel = true; } else { - print_reg_src(ctx, (reg_t)(cat3->src3), full, - cat3->src3_r, false, false, cat3->src3_neg, - false, false); + src3.reg = (reg_t)(cat3->src3); } + print_src(ctx, &src3); } static void print_instr_cat4(struct disasm_ctx *ctx, instr_t *instr) @@ -401,19 +428,24 @@ static void print_instr_cat4(struct disasm_ctx *ctx, instr_t *instr) print_reg_dst(ctx, (reg_t)(cat4->dst), cat4->full ^ cat4->dst_half, false); fprintf(ctx->out, ", "); + struct reginfo src = { + .r = cat4->src_r, + .im = cat4->src_im, + .full = cat4->full, + .neg = cat4->src_neg, + .abs = cat4->src_abs, + }; if (cat4->c.src_c) { - print_reg_src(ctx, (reg_t)(cat4->c.src), cat4->full, - cat4->src_r, cat4->c.src_c, cat4->src_im, - cat4->src_neg, cat4->src_abs, false); + src.reg = (reg_t)(cat4->c.src); + src.c = true; } else if (cat4->rel.src_rel) { - print_reg_src(ctx, (reg_t)(cat4->rel.src), cat4->full, - cat4->src_r, cat4->rel.src_c, cat4->src_im, - cat4->src_neg, cat4->src_abs, cat4->rel.src_rel); + src.reg = (reg_t)(cat4->rel.src); + src.c = cat4->rel.src_c; + src.addr_rel = true; } else { - print_reg_src(ctx, (reg_t)(cat4->src), cat4->full, - cat4->src_r, false, cat4->src_im, - cat4->src_neg, cat4->src_abs, false); + src.reg = (reg_t)(cat4->src); } + print_src(ctx, &src); if ((debug & PRINT_VERBOSE) && (cat4->dummy1|cat4->dummy2)) fprintf(ctx->out, "\t{4: %x,%x}", cat4->dummy1, cat4->dummy2); @@ -539,14 +571,14 @@ static void print_instr_cat5(struct disasm_ctx *ctx, instr_t *instr) if (info[cat5->opc].src1) { fprintf(ctx->out, ", "); - print_reg_src(ctx, (reg_t)(cat5->src1), cat5->full, false, false, false, - false, false, false); + struct reginfo src = { .reg = (reg_t)(cat5->src1), .full = cat5->full }; + print_src(ctx, &src); } if (cat5->is_o || info[cat5->opc].src2) { fprintf(ctx->out, ", "); - print_reg_src(ctx, (reg_t)(cat5->src2), cat5->full, - false, false, false, false, false, false); + struct reginfo src = { .reg = (reg_t)(cat5->src2), .full = cat5->full }; + print_src(ctx, &src); } if (cat5->is_s2en_bindless) { if (!desc_indirect) { @@ -570,8 +602,8 @@ static void print_instr_cat5(struct disasm_ctx *ctx, instr_t *instr) if (desc_indirect) { fprintf(ctx->out, ", "); - print_reg_src(ctx, (reg_t)(cat5->s2en_bindless.src3), bindless, - false, false, false, false, false, false); + struct reginfo src = { .reg = (reg_t)(cat5->s2en_bindless.src3), .full = bindless }; + print_src(ctx, &src); } if (use_a1) -- 2.30.2