pan/bi: Pass 'first' through disassembler

Required to decode the registers of the first instruction of a clause
correctly.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6793>
This commit is contained in:
Alyssa Rosenzweig 2020-09-20 09:29:08 -04:00 committed by Marge Bot
parent 4d3d5a66c9
commit bdb33f7529
3 changed files with 18 additions and 18 deletions

View File

@ -144,7 +144,7 @@ static void dump_header(FILE *fp, struct bifrost_header header, bool verbose)
}
}
static struct bifrost_reg_ctrl DecodeRegCtrl(FILE *fp, struct bifrost_regs regs)
static struct bifrost_reg_ctrl DecodeRegCtrl(FILE *fp, struct bifrost_regs regs, bool first)
{
struct bifrost_reg_ctrl decoded = {};
unsigned ctrl;
@ -220,9 +220,9 @@ static unsigned GetRegToWrite(enum bifrost_reg_write_unit unit, struct bifrost_r
}
}
static void dump_regs(FILE *fp, struct bifrost_regs srcs)
static void dump_regs(FILE *fp, struct bifrost_regs srcs, bool first)
{
struct bifrost_reg_ctrl ctrl = DecodeRegCtrl(fp, srcs);
struct bifrost_reg_ctrl ctrl = DecodeRegCtrl(fp, srcs, first);
fprintf(fp, "# ");
if (ctrl.read_reg0)
fprintf(fp, "port 0: r%d ", get_reg0(srcs));
@ -251,9 +251,9 @@ static void dump_regs(FILE *fp, struct bifrost_regs srcs)
}
void
bi_disasm_dest_fma(FILE *fp, struct bifrost_regs *next_regs)
bi_disasm_dest_fma(FILE *fp, struct bifrost_regs *next_regs, bool first)
{
struct bifrost_reg_ctrl next_ctrl = DecodeRegCtrl(fp, *next_regs);
struct bifrost_reg_ctrl next_ctrl = DecodeRegCtrl(fp, *next_regs, first);
if (next_ctrl.fma_write_unit != REG_WRITE_NONE)
fprintf(fp, "r%u:t0", GetRegToWrite(next_ctrl.fma_write_unit, *next_regs));
else
@ -261,9 +261,9 @@ bi_disasm_dest_fma(FILE *fp, struct bifrost_regs *next_regs)
}
void
bi_disasm_dest_add(FILE *fp, struct bifrost_regs *next_regs)
bi_disasm_dest_add(FILE *fp, struct bifrost_regs *next_regs, bool first)
{
struct bifrost_reg_ctrl next_ctrl = DecodeRegCtrl(fp, *next_regs);
struct bifrost_reg_ctrl next_ctrl = DecodeRegCtrl(fp, *next_regs, first);
if (next_ctrl.add_write_unit != REG_WRITE_NONE)
fprintf(fp, "r%u:t1", GetRegToWrite(next_ctrl.add_write_unit, *next_regs));
else
@ -703,11 +703,11 @@ static bool dump_clause(FILE *fp, uint32_t *words, unsigned *size, unsigned offs
if (verbose) {
fprintf(fp, "# regs: %016" PRIx64 "\n", instrs->reg_bits);
dump_regs(fp, regs);
dump_regs(fp, regs, i == 0);
}
bi_disasm_fma(fp, instrs[i].fma_bits, &regs, &next_regs, header.datareg, offset, &consts);
bi_disasm_add(fp, instrs[i].add_bits, &regs, &next_regs, header.datareg, offset, &consts);
bi_disasm_fma(fp, instrs[i].fma_bits, &regs, &next_regs, header.datareg, offset, &consts, i == 0);
bi_disasm_add(fp, instrs[i].add_bits, &regs, &next_regs, header.datareg, offset, &consts, i == 0);
}
fprintf(fp, "}\n");

View File

@ -50,12 +50,12 @@ struct bi_constants {
};
void
bi_disasm_fma(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts);
bi_disasm_fma(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool first);
void bi_disasm_add(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts);
void bi_disasm_add(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool first);
void bi_disasm_dest_fma(FILE *fp, struct bifrost_regs *next_regs);
void bi_disasm_dest_add(FILE *fp, struct bifrost_regs *next_regs);
void bi_disasm_dest_fma(FILE *fp, struct bifrost_regs *next_regs, bool first);
void bi_disasm_dest_add(FILE *fp, struct bifrost_regs *next_regs, bool first);
void dump_src(FILE *fp, unsigned src, struct bifrost_regs srcs, struct bi_constants *consts, bool isFMA);

View File

@ -64,7 +64,7 @@ def decode_op(instructions, is_fma):
# Generate checks in order
template = """void
bi_disasm_${unit}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts)
bi_disasm_${unit}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool first)
{
% for (i, (name, (emask, ebits), derived)) in enumerate(options):
% if len(derived) > 0:
@ -76,7 +76,7 @@ bi_disasm_${unit}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bif
% else:
${"else " if i > 0 else ""}if (unlikely(((bits & ${hex(emask)}) == ${hex(ebits)})))
% endif
bi_disasm_${name}(fp, bits, srcs, next_regs, staging_register, branch_offset, consts);
bi_disasm_${name}(fp, bits, srcs, next_regs, staging_register, branch_offset, consts, first);
% endfor
else
fprintf(fp, "INSTR_INVALID_ENC ${unit} %X\\n", bits);
@ -89,7 +89,7 @@ bi_disasm_${unit}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bif
# state. Sync prototypes to avoid moves when calling.
disasm_op_template = Template("""static void
bi_disasm_${c_name}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts)
bi_disasm_${c_name}(FILE *fp, unsigned bits, struct bifrost_regs *srcs, struct bifrost_regs *next_regs, unsigned staging_register, unsigned branch_offset, struct bi_constants *consts, bool first)
{
${body.strip()}
}
@ -316,7 +316,7 @@ def disasm_op(name, op):
body += disasm_mod(mod, skip_mods)
body += ' fputs(" ", fp);\n'
body += ' bi_disasm_dest_{}(fp, next_regs);\n'.format('fma' if is_fma else 'add')
body += ' bi_disasm_dest_{}(fp, next_regs, first);\n'.format('fma' if is_fma else 'add')
# Next up, each source. Source modifiers are inserterd here