mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 13:58:04 +02:00
pan/mdg: improve input modifier printing
Signed-off-by: Italo Nicola <italonicola@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9461>
This commit is contained in:
parent
baea01816a
commit
7f0bf3d82d
4 changed files with 25 additions and 41 deletions
|
|
@ -215,10 +215,10 @@ static char *outmod_names_int[4] = {
|
|||
};
|
||||
|
||||
static char *srcmod_names_int[4] = {
|
||||
"sext(",
|
||||
"zext(",
|
||||
"",
|
||||
"("
|
||||
".sext",
|
||||
".zext",
|
||||
".replicate",
|
||||
".lshift",
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
@ -498,39 +498,23 @@ print_vector_constants(FILE *fp, unsigned src_binary,
|
|||
}
|
||||
|
||||
static void
|
||||
print_srcmod(FILE *fp, bool is_int, unsigned mod, bool scalar)
|
||||
print_srcmod(FILE *fp, bool is_int, bool expands, unsigned mod, bool scalar)
|
||||
{
|
||||
/* Modifiers change meaning depending on the op's context */
|
||||
|
||||
midgard_int_mod int_mod = mod;
|
||||
|
||||
if (is_int) {
|
||||
if (scalar && mod == 2) {
|
||||
fprintf(fp, "unk2");
|
||||
}
|
||||
|
||||
fprintf(fp, "%s", srcmod_names_int[int_mod]);
|
||||
if (expands)
|
||||
fprintf(fp, "%s", srcmod_names_int[mod]);
|
||||
} else {
|
||||
if (mod & MIDGARD_FLOAT_MOD_NEG)
|
||||
fprintf(fp, "-");
|
||||
|
||||
if (mod & MIDGARD_FLOAT_MOD_ABS)
|
||||
fprintf(fp, "abs(");
|
||||
fprintf(fp, ".abs");
|
||||
if (mod & MIDGARD_FLOAT_MOD_NEG)
|
||||
fprintf(fp, ".neg");
|
||||
if (expands)
|
||||
fprintf(fp, ".widen");
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
@ -540,8 +524,6 @@ print_vector_src(FILE *fp, unsigned src_binary,
|
|||
|
||||
validate_expand_mode(src->expand_mode, mode);
|
||||
|
||||
print_srcmod(fp, is_int, src->mod, false);
|
||||
|
||||
bool half = INPUT_EXPANDS(src->expand_mode);
|
||||
|
||||
//register
|
||||
|
|
@ -565,7 +547,7 @@ print_vector_src(FILE *fp, unsigned src_binary,
|
|||
print_swizzle_vec2(fp, src->swizzle, rep_hi, rep_lo, half);
|
||||
}
|
||||
|
||||
print_srcmod_end(fp, is_int, src->mod, bits);
|
||||
print_srcmod(fp, is_int, INPUT_EXPANDS(src->expand_mode), src->mod, false);
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
|
|
@ -794,7 +776,6 @@ print_scalar_src(FILE *fp, bool is_int, unsigned src_binary, unsigned reg)
|
|||
{
|
||||
midgard_scalar_alu_src *src = (midgard_scalar_alu_src *)&src_binary;
|
||||
|
||||
print_srcmod(fp, is_int, src->mod, true);
|
||||
print_reg(fp, reg, src->full ? 32 : 16);
|
||||
|
||||
unsigned c = src->component;
|
||||
|
|
@ -806,7 +787,7 @@ print_scalar_src(FILE *fp, bool is_int, unsigned src_binary, unsigned reg)
|
|||
|
||||
fprintf(fp, ".%c", components[c]);
|
||||
|
||||
print_srcmod_end(fp, is_int, src->mod, src->full ? 32 : 16);
|
||||
print_srcmod(fp, is_int, !src->full, src->mod, true);
|
||||
}
|
||||
|
||||
static uint16_t
|
||||
|
|
|
|||
|
|
@ -235,13 +235,16 @@ typedef enum {
|
|||
midgard_shrink_mode_none = 2
|
||||
} midgard_shrink_mode;
|
||||
|
||||
/* Only used if midgard_src_expand_mode is set to one of midgard_src_expand_*. */
|
||||
typedef enum {
|
||||
midgard_int_sign_extend = 0,
|
||||
midgard_int_zero_extend = 1,
|
||||
midgard_int_normal = 2,
|
||||
midgard_int_shift = 3
|
||||
midgard_int_replicate = 2,
|
||||
midgard_int_left_shift = 3
|
||||
} midgard_int_mod;
|
||||
|
||||
/* Unlike midgard_int_mod, fload modifiers are applied after the expansion happens, so
|
||||
* they don't depend on midgard_src_expand_mode. */
|
||||
#define MIDGARD_FLOAT_MOD_ABS (1 << 0)
|
||||
#define MIDGARD_FLOAT_MOD_NEG (1 << 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ mir_get_imod(bool shift, nir_alu_type T, bool half, bool scalar)
|
|||
if (!half) {
|
||||
assert(!shift);
|
||||
/* Sign-extension, really... */
|
||||
return scalar ? 0 : midgard_int_normal;
|
||||
return scalar ? 0 : midgard_int_replicate;
|
||||
}
|
||||
|
||||
if (shift)
|
||||
return midgard_int_shift;
|
||||
return midgard_int_left_shift;
|
||||
|
||||
if (nir_alu_type_get_base_type(T) == nir_type_int)
|
||||
return midgard_int_sign_extend;
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ mir_print_constant_component(FILE *fp, const midgard_constants *consts, unsigned
|
|||
|
||||
if (half && mod == midgard_int_zero_extend)
|
||||
v = consts->u32[c];
|
||||
else if (half && mod == midgard_int_shift)
|
||||
else if (half && mod == midgard_int_left_shift)
|
||||
v = (uint64_t)consts->u32[c] << 32;
|
||||
else
|
||||
v = consts->i32[c];
|
||||
|
|
@ -95,7 +95,7 @@ mir_print_constant_component(FILE *fp, const midgard_constants *consts, unsigned
|
|||
} else if (is_uint || is_hex) {
|
||||
uint64_t v;
|
||||
|
||||
if (half && mod == midgard_int_shift)
|
||||
if (half && mod == midgard_int_left_shift)
|
||||
v = (uint64_t)consts->u32[c] << 32;
|
||||
else
|
||||
v = consts->u32[c];
|
||||
|
|
@ -117,7 +117,7 @@ mir_print_constant_component(FILE *fp, const midgard_constants *consts, unsigned
|
|||
|
||||
if (half && mod == midgard_int_zero_extend)
|
||||
v = consts->u16[c];
|
||||
else if (half && mod == midgard_int_shift)
|
||||
else if (half && mod == midgard_int_left_shift)
|
||||
v = (uint32_t)consts->u16[c] << 16;
|
||||
else
|
||||
v = consts->i16[c];
|
||||
|
|
@ -126,7 +126,7 @@ mir_print_constant_component(FILE *fp, const midgard_constants *consts, unsigned
|
|||
} else if (is_uint || is_hex) {
|
||||
uint32_t v;
|
||||
|
||||
if (half && mod == midgard_int_shift)
|
||||
if (half && mod == midgard_int_left_shift)
|
||||
v = (uint32_t)consts->u16[c] << 16;
|
||||
else
|
||||
v = consts->u16[c];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue