diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-05-21 12:24:42 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-05-21 17:49:14 +0000 |
commit | 3cfe2fc1b19120ada25e4b4cd1134418162f3d9f (patch) | |
tree | 0e7cac9f5c9b87cae9909d350b17025b76dac0fb /src/panfrost | |
parent | d4a42a78d89e4de356b514a569d87c6106b9145f (diff) |
pan/mdg: Identify scalar integer mods
Symmetric with vector mods, except for normal which is packed as
sign-extend. (flag 2 never seen in the wild)
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5151>
Diffstat (limited to 'src/panfrost')
-rw-r--r-- | src/panfrost/midgard/disassemble.c | 76 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard.h | 3 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_emit.c | 3 |
3 files changed, 39 insertions, 43 deletions
diff --git a/src/panfrost/midgard/disassemble.c b/src/panfrost/midgard/disassemble.c index 2a8e6c7ce94..30939b21d9c 100644 --- a/src/panfrost/midgard/disassemble.c +++ b/src/panfrost/midgard/disassemble.c @@ -341,24 +341,13 @@ print_scalar_constant(FILE *fp, unsigned src_binary, midgard_scalar_alu *alu) { midgard_scalar_alu_src *src = (midgard_scalar_alu_src *)&src_binary; - unsigned mod = 0; - assert(consts != NULL); - if (!midgard_is_integer_op(alu->op)) { - if (src->abs) - mod |= MIDGARD_FLOAT_MOD_ABS; - if (src->negate) - mod |= MIDGARD_FLOAT_MOD_NEG; - } else { - mod = midgard_int_normal; - } - fprintf(fp, "#"); mir_print_constant_component(fp, consts, src->component, src->full ? midgard_reg_mode_32 : midgard_reg_mode_16, - false, mod, alu->op); + false, src->mod, alu->op); } static void @@ -401,25 +390,46 @@ print_vector_constants(FILE *fp, unsigned src_binary, } static void -print_vector_src(FILE *fp, unsigned src_binary, - midgard_reg_mode mode, unsigned reg, - midgard_dest_override override, bool is_int) +print_srcmod(FILE *fp, bool is_int, unsigned mod, bool scalar) { - midgard_vector_alu_src *src = (midgard_vector_alu_src *)&src_binary; - /* Modifiers change meaning depending on the op's context */ - midgard_int_mod int_mod = src->mod; + midgard_int_mod int_mod = mod; if (is_int) { + if (scalar && mod == 2) { + fprintf(fp, "unk2"); + } + fprintf(fp, "%s", srcmod_names_int[int_mod]); } else { - if (src->mod & MIDGARD_FLOAT_MOD_NEG) + if (mod & MIDGARD_FLOAT_MOD_NEG) fprintf(fp, "-"); - if (src->mod & MIDGARD_FLOAT_MOD_ABS) + if (mod & MIDGARD_FLOAT_MOD_ABS) fprintf(fp, "abs("); } +} + +static void +print_srcmod_end(FILE *fp, bool is_int, unsigned mod, unsigned bits) +{ + /* Since we wrapped with a function-looking thing */ + + if (is_int && mod == midgard_int_shift) + fprintf(fp, ") << %u", bits); + else if ((is_int && (mod != midgard_int_normal)) + || (!is_int && mod & MIDGARD_FLOAT_MOD_ABS)) + fprintf(fp, ")"); +} + +static void +print_vector_src(FILE *fp, unsigned src_binary, + midgard_reg_mode mode, unsigned reg, + midgard_dest_override override, bool is_int) +{ + midgard_vector_alu_src *src = (midgard_vector_alu_src *)&src_binary; + print_srcmod(fp, is_int, src->mod, false); //register unsigned bits = bits_for_mode_halved(mode, src->half); @@ -440,13 +450,7 @@ print_vector_src(FILE *fp, unsigned src_binary, print_swizzle_vec2(fp, src->swizzle, src->rep_high, src->rep_low, src->half); } - /* Since we wrapped with a function-looking thing */ - - if (is_int && int_mod == midgard_int_shift) - fprintf(fp, ") << %u", bits); - else if ((is_int && (int_mod != midgard_int_normal)) - || (!is_int && src->mod & MIDGARD_FLOAT_MOD_ABS)) - fprintf(fp, ")"); + print_srcmod_end(fp, is_int, src->mod, bits); } static uint16_t @@ -670,16 +674,11 @@ print_vector_field(FILE *fp, const char *name, uint16_t *words, uint16_t reg_wor } static void -print_scalar_src(FILE *fp, unsigned src_binary, unsigned reg) +print_scalar_src(FILE *fp, bool is_int, unsigned src_binary, unsigned reg) { midgard_scalar_alu_src *src = (midgard_scalar_alu_src *)&src_binary; - if (src->negate) - fprintf(fp, "-"); - - if (src->abs) - fprintf(fp, "abs("); - + print_srcmod(fp, is_int, src->mod, true); print_reg(fp, reg, src->full ? 32 : 16); unsigned c = src->component; @@ -691,9 +690,7 @@ print_scalar_src(FILE *fp, unsigned src_binary, unsigned reg) fprintf(fp, ".%c", components[c]); - if (src->abs) - fprintf(fp, ")"); - + print_srcmod_end(fp, is_int, src->mod, src->full ? 32 : 16); } static uint16_t @@ -728,6 +725,7 @@ print_scalar_field(FILE *fp, const char *name, uint16_t *words, uint16_t reg_wor update_dest(reg_info->out_reg); print_reg(fp, reg_info->out_reg, full ? 32 : 16); unsigned c = alu_field->output_component; + bool is_int = midgard_is_integer_op(alu_field->op); if (full) { assert((c & 1) == 0); @@ -739,7 +737,7 @@ print_scalar_field(FILE *fp, const char *name, uint16_t *words, uint16_t reg_wor if (reg_info->src1_reg == 26) print_scalar_constant(fp, alu_field->src1, consts, alu_field); else - print_scalar_src(fp, alu_field->src1, reg_info->src1_reg); + print_scalar_src(fp, is_int, alu_field->src1, reg_info->src1_reg); fprintf(fp, ", "); @@ -750,7 +748,7 @@ print_scalar_field(FILE *fp, const char *name, uint16_t *words, uint16_t reg_wor } else if (reg_info->src2_reg == 26) { print_scalar_constant(fp, alu_field->src2, consts, alu_field); } else - print_scalar_src(fp, alu_field->src2, reg_info->src2_reg); + print_scalar_src(fp, is_int, alu_field->src2, reg_info->src2_reg); midg_stats.instruction_count++; fprintf(fp, "\n"); diff --git a/src/panfrost/midgard/midgard.h b/src/panfrost/midgard/midgard.h index 273e0735f24..9d6a6271fa7 100644 --- a/src/panfrost/midgard/midgard.h +++ b/src/panfrost/midgard/midgard.h @@ -275,8 +275,7 @@ midgard_vector_alu; typedef struct __attribute__((__packed__)) { - bool abs : 1; - bool negate : 1; + unsigned mod : 2; bool full : 1; /* 0 = half, 1 = full */ unsigned component : 3; } diff --git a/src/panfrost/midgard/midgard_emit.c b/src/panfrost/midgard/midgard_emit.c index 017c74e33bd..f69010c83a6 100644 --- a/src/panfrost/midgard/midgard_emit.c +++ b/src/panfrost/midgard/midgard_emit.c @@ -72,8 +72,7 @@ vector_to_scalar_source(unsigned u, bool is_int, bool is_full, if (is_int) { /* TODO */ } else { - s.abs = v.mod & MIDGARD_FLOAT_MOD_ABS; - s.negate = v.mod & MIDGARD_FLOAT_MOD_NEG; + s.mod = v.mod; } unsigned o; |