freedreno/ir3: split out regmask
[mesa.git] / src / freedreno / ir3 / disasm-a3xx.c
index 3db422f0d6fcf4675438a0a0ff5ec9a7d35d1e34..d6a1c15e09cee1e0657ead8b55512c82f3a48efa 100644 (file)
@@ -147,6 +147,13 @@ static void print_reg(struct disasm_ctx *ctx, reg_t reg, bool full,
                fprintf(ctx->out, "p0.%c", component[reg.comp]);
        } else {
                fprintf(ctx->out, "%s%c%d.%c", full ? "" : "h", type, reg.num, component[reg.comp]);
+               if (0 && full && !c) {
+                       reg_t hr0 = reg;
+                       hr0.iim_val *= 2;
+                       reg_t hr1 = hr0;
+                       hr1.iim_val += 1;
+                       fprintf(ctx->out, " (hr%d.%c,hr%d.%c)", hr0.num, component[hr0.comp], hr1.num, component[hr1.comp]);
+               }
        }
 }
 
@@ -673,12 +680,13 @@ static void print_instr_cat6_a3xx(struct disasm_ctx *ctx, instr_t *instr)
        instr_cat6_t *cat6 = &instr->cat6;
        char sd = 0, ss = 0;  /* dst/src address space */
        bool nodst = false;
-       struct reginfo dst, src1, src2;
-       int src1off = 0, dstoff = 0;
+       struct reginfo dst, src1, src2, ssbo;
+       int src1off = 0;
 
        memset(&dst, 0, sizeof(dst));
        memset(&src1, 0, sizeof(src1));
        memset(&src2, 0, sizeof(src2));
+       memset(&ssbo, 0, sizeof(ssbo));
 
        switch (_OPC(6, cat6->opc)) {
        case OPC_RESINFO:
@@ -852,8 +860,8 @@ static void print_instr_cat6_a3xx(struct disasm_ctx *ctx, instr_t *instr)
                        print_src(ctx, &src3);  /* 64b byte offset.. */
 
                        if (debug & PRINT_VERBOSE) {
-                               fprintf(ctx->out, " (pad0=%x, pad3=%x, mustbe0=%x)", cat6->ldgb.pad0,
-                                               cat6->ldgb.pad3, cat6->ldgb.mustbe0);
+                               fprintf(ctx->out, " (pad0=%x, mustbe0=%x)", cat6->ldgb.pad0,
+                                               cat6->ldgb.mustbe0);
                        }
                } else { /* ss == 'l' */
                        fprintf(ctx->out, "l[");
@@ -862,19 +870,24 @@ static void print_instr_cat6_a3xx(struct disasm_ctx *ctx, instr_t *instr)
                        print_src(ctx, &src2);  /* value */
 
                        if (debug & PRINT_VERBOSE) {
-                               fprintf(ctx->out, " (src3=%x, pad0=%x, pad3=%x, mustbe0=%x)",
+                               fprintf(ctx->out, " (src3=%x, pad0=%x, src_ssbo_im=%x, mustbe0=%x)",
                                                cat6->ldgb.src3, cat6->ldgb.pad0,
-                                               cat6->ldgb.pad3, cat6->ldgb.mustbe0);
+                                               cat6->ldgb.src_ssbo_im, cat6->ldgb.mustbe0);
                        }
                }
 
                return;
        } else if (_OPC(6, cat6->opc) == OPC_RESINFO) {
                dst.reg  = (reg_t)(cat6->ldgb.dst);
+               ssbo.reg = (reg_t)(cat6->ldgb.src_ssbo);
+               ssbo.im  = cat6->ldgb.src_ssbo_im;
 
                print_src(ctx, &dst);
                fprintf(ctx->out, ", ");
-               fprintf(ctx->out, "g[%u]", cat6->ldgb.src_ssbo);
+
+               fprintf(ctx->out, "g[");
+               print_src(ctx, &ssbo);
+               fprintf(ctx->out, "]");
 
                return;
        } else if (_OPC(6, cat6->opc) == OPC_LDGB) {
@@ -883,17 +896,23 @@ static void print_instr_cat6_a3xx(struct disasm_ctx *ctx, instr_t *instr)
                src1.im  = cat6->ldgb.src1_im;
                src2.reg = (reg_t)(cat6->ldgb.src2);
                src2.im  = cat6->ldgb.src2_im;
+               ssbo.reg = (reg_t)(cat6->ldgb.src_ssbo);
+               ssbo.im  = cat6->ldgb.src_ssbo_im;
                dst.reg  = (reg_t)(cat6->ldgb.dst);
 
                print_src(ctx, &dst);
                fprintf(ctx->out, ", ");
-               fprintf(ctx->out, "g[%u], ", cat6->ldgb.src_ssbo);
+
+               fprintf(ctx->out, "g[");
+               print_src(ctx, &ssbo);
+               fprintf(ctx->out, "], ");
+
                print_src(ctx, &src1);
                fprintf(ctx->out, ", ");
                print_src(ctx, &src2);
 
                if (debug & PRINT_VERBOSE)
-                       fprintf(ctx->out, " (pad0=%x, pad3=%x, mustbe0=%x)", cat6->ldgb.pad0, cat6->ldgb.pad3, cat6->ldgb.mustbe0);
+                       fprintf(ctx->out, " (pad0=%x, ssbo_im=%x, mustbe0=%x)", cat6->ldgb.pad0, cat6->ldgb.src_ssbo_im, cat6->ldgb.mustbe0);
 
                return;
        } else if (_OPC(6, cat6->opc) == OPC_LDG && cat6->a.src1_im && cat6->a.src2_im) {
@@ -917,12 +936,6 @@ static void print_instr_cat6_a3xx(struct disasm_ctx *ctx, instr_t *instr)
 
                return;
        }
-       if (cat6->dst_off) {
-               dst.reg = (reg_t)(cat6->c.dst);
-               dstoff  = cat6->c.off;
-       } else {
-               dst.reg = (reg_t)(cat6->d.dst);
-       }
 
        if (cat6->src_off) {
                src1.reg = (reg_t)(cat6->a.src1);
@@ -941,15 +954,23 @@ static void print_instr_cat6_a3xx(struct disasm_ctx *ctx, instr_t *instr)
                if (sd)
                        fprintf(ctx->out, "%c[", sd);
                /* note: dst might actually be a src (ie. address to store to) */
-               print_src(ctx, &dst);
-               if (cat6->dst_off && cat6->g) {
-                       struct reginfo dstoff_reg = {0};
-                       dstoff_reg.reg = (reg_t) cat6->c.off;
-                       dstoff_reg.full  = true;
-                       fprintf(ctx->out, "+");
-                       print_src(ctx, &dstoff_reg);
-               } else if (dstoff)
-                       fprintf(ctx->out, "%+d", dstoff);
+               if (cat6->dst_off) {
+                       dst.reg = (reg_t)(cat6->c.dst);
+                       print_src(ctx, &dst);
+                       if (cat6->g) {
+                               struct reginfo dstoff_reg = {
+                                       .reg = (reg_t) cat6->c.off,
+                                       .full  = true
+                               };
+                               fprintf(ctx->out, "+");
+                               print_src(ctx, &dstoff_reg);
+                       } else if (cat6->c.off || cat6->c.off_high) {
+                               fprintf(ctx->out, "%+d", ((uint32_t)cat6->c.off_high << 8) | cat6->c.off);
+                       }
+               } else {
+                       dst.reg = (reg_t)(cat6->d.dst);
+                       print_src(ctx, &dst);
+               }
                if (sd)
                        fprintf(ctx->out, "]");
                fprintf(ctx->out, ", ");
@@ -1243,6 +1264,9 @@ static const struct opc_info {
        OPC(5, OPC_DSYPP_1,      dsypp.1),
        OPC(5, OPC_RGETPOS,      rgetpos),
        OPC(5, OPC_RGETINFO,     rgetinfo),
+       /* macros are needed here for ir3_print */
+       OPC(5, OPC_DSXPP_MACRO,  dsxpp.macro),
+       OPC(5, OPC_DSYPP_MACRO,  dsypp.macro),
 
 
        /* category 6: */