unsigned instructions;
};
-static void print_reg(struct disasm_ctx *ctx, reg_t reg, bool full, bool r,
+static const char *float_imms[] = {
+ "0.0",
+ "0.5",
+ "1.0",
+ "2.0",
+ "e",
+ "pi",
+ "1/pi",
+ "1/log2(e)",
+ "log2(e)",
+ "1/log2(10)",
+ "log2(10)",
+ "4.0",
+};
+
+static void print_reg(struct disasm_ctx *ctx, reg_t reg, bool full,
+ bool is_float, bool r,
bool c, bool im, bool neg, bool abs, bool addr_rel)
{
const char type = c ? 'c' : 'r';
fprintf(ctx->out, "(r)");
if (im) {
- fprintf(ctx->out, "%d", reg.iim_val);
+ if (is_float && full && reg.iim_val < ARRAY_SIZE(float_imms)) {
+ fprintf(ctx->out, "(%s)", float_imms[reg.iim_val]);
+ } else {
+ fprintf(ctx->out, "%d", reg.iim_val);
+ }
} else if (addr_rel) {
/* I would just use %+d but trying to make it diff'able with
* libllvm-a3xx...
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]);
+ }
}
}
static void print_reg_dst(struct disasm_ctx *ctx, reg_t reg, bool full, bool addr_rel)
{
reg = idxreg(regidx(reg) + ctx->repeatidx);
- print_reg(ctx, reg, full, false, false, false, false, false, addr_rel);
+ print_reg(ctx, reg, full, false, false, false, false, false, false, addr_rel);
}
/* TODO switch to using reginfo struct everywhere, since more readable
bool full;
bool r;
bool c;
+ bool f; /* src reg is interpreted as float, used for printing immediates */
bool im;
bool neg;
bool abs;
if (info->r)
reg = idxreg(regidx(info->reg) + ctx->repeatidx);
- print_reg(ctx, reg, info->full, info->r, info->c, info->im,
+ print_reg(ctx, reg, info->full, info->f, info->r, info->c, info->im,
info->neg, info->abs, info->addr_rel);
}
static void print_instr_cat0(struct disasm_ctx *ctx, instr_t *instr)
{
+ static const struct {
+ const char *suffix;
+ int nsrc;
+ bool idx;
+ } brinfo[7] = {
+ [BRANCH_PLAIN] = { "r", 1, false },
+ [BRANCH_OR] = { "rao", 2, false },
+ [BRANCH_AND] = { "raa", 2, false },
+ [BRANCH_CONST] = { "rac", 0, true },
+ [BRANCH_ANY] = { "any", 1, false },
+ [BRANCH_ALL] = { "all", 1, false },
+ [BRANCH_X] = { "rax", 0, false },
+ };
instr_cat0_t *cat0 = &instr->cat0;
- switch (cat0->opc) {
+ switch (instr_opc(instr, ctx->gpu_id)) {
case OPC_KILL:
- case OPC_IF:
- fprintf(ctx->out, " %sp0.%c", cat0->inv ? "!" : "",
- component[cat0->comp]);
+ case OPC_PREDT:
+ case OPC_PREDF:
+ fprintf(ctx->out, " %sp0.%c", cat0->inv0 ? "!" : "",
+ component[cat0->comp0]);
break;
- case OPC_BR:
- fprintf(ctx->out, " %sp0.%c, #%d", cat0->inv ? "!" : "",
- component[cat0->comp], cat0->a3xx.immed);
+ case OPC_B:
+ fprintf(ctx->out, "%s", brinfo[cat0->brtype].suffix);
+ if (brinfo[cat0->brtype].idx) {
+ fprintf(ctx->out, ".%u", cat0->idx);
+ }
+ if (brinfo[cat0->brtype].nsrc >= 1) {
+ fprintf(ctx->out, " %sp0.%c,", cat0->inv0 ? "!" : "",
+ component[cat0->comp0]);
+ }
+ if (brinfo[cat0->brtype].nsrc >= 2) {
+ fprintf(ctx->out, " %sp0.%c,", cat0->inv1 ? "!" : "",
+ component[cat0->comp1]);
+ }
+ fprintf(ctx->out, " #%d", cat0->a3xx.immed);
break;
case OPC_JUMP:
case OPC_CALL:
+ case OPC_BKT:
+ case OPC_GETONE:
+ case OPC_SHPS:
fprintf(ctx->out, " #%d", cat0->a3xx.immed);
break;
}
- if ((debug & PRINT_VERBOSE) && (cat0->dummy2|cat0->dummy3|cat0->dummy4))
- fprintf(ctx->out, "\t{0: %x,%x,%x}", cat0->dummy2, cat0->dummy3, cat0->dummy4);
+ if ((debug & PRINT_VERBOSE) && (cat0->dummy3|cat0->dummy4))
+ fprintf(ctx->out, "\t{0: %x,%x}", cat0->dummy3, cat0->dummy4);
}
static void print_instr_cat1(struct disasm_ctx *ctx, instr_t *instr)
static void print_instr_cat2(struct disasm_ctx *ctx, instr_t *instr)
{
instr_cat2_t *cat2 = &instr->cat2;
+ int opc = _OPC(2, cat2->opc);
static const char *cond[] = {
"lt",
"le",
"?6?",
};
- switch (_OPC(2, cat2->opc)) {
+ switch (opc) {
case OPC_CMPS_F:
case OPC_CMPS_U:
case OPC_CMPS_S:
struct reginfo src1 = {
.full = cat2->full,
.r = cat2->repeat ? cat2->src1_r : 0,
+ .f = is_cat2_float(opc),
.im = cat2->src1_im,
.abs = cat2->src1_abs,
.neg = cat2->src1_neg,
struct reginfo src2 = {
.r = cat2->repeat ? cat2->src2_r : 0,
.full = cat2->full,
+ .f = is_cat2_float(opc),
.abs = cat2->src2_abs,
.neg = cat2->src2_neg,
.im = cat2->src2_im,
};
- switch (_OPC(2, cat2->opc)) {
+ switch (opc) {
case OPC_ABSNEG_F:
case OPC_ABSNEG_S:
case OPC_CLZ_B:
instr_cat6_t *cat6 = &instr->cat6;
char sd = 0, ss = 0; /* dst/src address space */
bool nodst = false;
- struct reginfo dst, src1, src2;
+ struct reginfo dst, src1, src2, ssbo;
int src1off = 0, dstoff = 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:
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[");
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) {
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) {
/* 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;
+ struct reginfo dstoff_reg = {
+ .reg = (reg_t) cat6->c.off,
+ .full = true
+ };
fprintf(ctx->out, "+");
print_src(ctx, &dstoff_reg);
} else if (dstoff)
{
instr_cat6_a6xx_t *cat6 = &instr->cat6_a6xx;
struct reginfo src1, src2, ssbo;
- bool uses_type = _OPC(6, cat6->opc) != OPC_LDC;
+ uint32_t opc = _OPC(6, cat6->opc);
+ bool uses_type = opc != OPC_LDC;
static const struct {
bool indirect;
bool bindless;
- bool uniform;
+ const char *name;
} desc_features[8] = {
- [CAT6_IMM] = { false },
- [CAT6_BINDLESS_IMM] = { .bindless = true, },
+ [CAT6_IMM] = {
+ .name = "imm"
+ },
+ [CAT6_UNIFORM] = {
+ .indirect = true,
+ .name = "uniform"
+ },
+ [CAT6_NONUNIFORM] = {
+ .indirect = true,
+ .name = "nonuniform"
+ },
+ [CAT6_BINDLESS_IMM] = {
+ .bindless = true,
+ .name = "imm"
+ },
[CAT6_BINDLESS_UNIFORM] = {
.bindless = true,
.indirect = true,
- .uniform = true,
+ .name = "uniform"
},
[CAT6_BINDLESS_NONUNIFORM] = {
.bindless = true,
.indirect = true,
+ .name = "nonuniform"
},
};
bool indirect_ssbo = desc_features[cat6->desc_mode].indirect;
bool bindless = desc_features[cat6->desc_mode].bindless;
- bool uniform = desc_features[cat6->desc_mode].uniform;
bool type_full = cat6->type != TYPE_U16;
}
fprintf(ctx->out, ".%u", cat6->type_size + 1);
+ fprintf(ctx->out, ".%s", desc_features[cat6->desc_mode].name);
if (bindless)
fprintf(ctx->out, ".base%d", cat6->base);
- if (uniform)
- fprintf(ctx->out, ".uniform");
fprintf(ctx->out, " ");
src2.reg = (reg_t)(cat6->src2);
print_src(ctx, &src2);
fprintf(ctx->out, ", ");
- src1.reg = (reg_t)(cat6->src1);
- src1.full = true; // XXX
- print_src(ctx, &src1);
- fprintf(ctx->out, ", ");
+ if (opc != OPC_RESINFO) {
+ src1.reg = (reg_t)(cat6->src1);
+ src1.full = true; // XXX
+ print_src(ctx, &src1);
+ fprintf(ctx->out, ", ");
+ }
+
ssbo.reg = (reg_t)(cat6->ssbo);
ssbo.im = !indirect_ssbo;
ssbo.full = true;
#define OPC(cat, opc, name) [(opc)] = { (cat), (opc), #name, print_instr_cat##cat }
/* category 0: */
OPC(0, OPC_NOP, nop),
- OPC(0, OPC_BR, br),
+ OPC(0, OPC_B, b),
OPC(0, OPC_JUMP, jump),
OPC(0, OPC_CALL, call),
OPC(0, OPC_RET, ret),
OPC(0, OPC_CHMASK, chmask),
OPC(0, OPC_CHSH, chsh),
OPC(0, OPC_FLOW_REV, flow_rev),
- OPC(0, OPC_IF, if),
- OPC(0, OPC_ELSE, else),
- OPC(0, OPC_ENDIF, endif),
+ OPC(0, OPC_PREDT, predt),
+ OPC(0, OPC_PREDF, predf),
+ OPC(0, OPC_PREDE, prede),
+ OPC(0, OPC_BKT, bkt),
+ OPC(0, OPC_STKS, stks),
+ OPC(0, OPC_STKR, stkr),
+ OPC(0, OPC_XSET, xset),
+ OPC(0, OPC_XCLR, xclr),
+ OPC(0, OPC_GETONE, getone),
+ OPC(0, OPC_DBG, dbg),
+ OPC(0, OPC_SHPS, shps),
+ OPC(0, OPC_SHPE, shpe),
/* category 1: */
OPC(1, OPC_MOV, ),
}
if (instr->jmp_tgt)
fprintf(ctx->out, "(jp)");
+ if ((instr->opc_cat == 0) && instr->cat0.eq)
+ fprintf(ctx->out, "(eq)");
if (instr_sat(instr))
fprintf(ctx->out, "(sat)");
if (ctx->repeat)