mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 01:50:10 +01:00
freedreno/isa: encode: switch bitmask_t to BITSET_WORD's
This commit changes the underlying basetype of bitmask_t to a BITSET_WORD based one. Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11321>
This commit is contained in:
parent
9dc2ef7200
commit
dbb9d3d0e3
2 changed files with 36 additions and 14 deletions
|
|
@ -298,7 +298,7 @@ __cat3_src_case(struct encode_state *s, struct ir3_register *reg)
|
|||
void *
|
||||
isa_assemble(struct ir3_shader_variant *v)
|
||||
{
|
||||
uint64_t *ptr, *instrs;
|
||||
BITSET_WORD *ptr, *instrs;
|
||||
const struct ir3_info *info = &v->info;
|
||||
struct ir3 *shader = v->ir;
|
||||
|
||||
|
|
@ -311,7 +311,9 @@ isa_assemble(struct ir3_shader_variant *v)
|
|||
.instr = instr,
|
||||
};
|
||||
|
||||
*(instrs++) = encode__instruction(&s, NULL, instr);
|
||||
const bitmask_t encoded = encode__instruction(&s, NULL, instr);
|
||||
store_instruction(instrs, encoded);
|
||||
instrs += BITMASK_WORDS;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -374,11 +374,24 @@ struct encode_state;
|
|||
|
||||
struct bitset_params;
|
||||
|
||||
static uint64_t
|
||||
static bitmask_t
|
||||
pack_field(unsigned low, unsigned high, uint64_t val)
|
||||
{
|
||||
val &= ((UINT64_C(1) << (1 + high - low)) - 1);
|
||||
return val << low;
|
||||
bitmask_t field, mask;
|
||||
|
||||
BITSET_ZERO(field.bitset);
|
||||
|
||||
if (!val)
|
||||
return field;
|
||||
|
||||
BITSET_ZERO(mask.bitset);
|
||||
BITSET_SET_RANGE(mask.bitset, 0, high - low);
|
||||
|
||||
field = uint64_t_to_bitmask(val);
|
||||
BITSET_AND(field.bitset, field.bitset, mask.bitset);
|
||||
BITSET_SHL(field.bitset, low);
|
||||
|
||||
return field;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -387,7 +400,7 @@ pack_field(unsigned low, unsigned high, uint64_t val)
|
|||
*/
|
||||
|
||||
%for root in s.encode_roots():
|
||||
static uint64_t encode${root.get_c_name()}(struct encode_state *s, struct bitset_params *p, ${root.encode.type} src);
|
||||
static bitmask_t encode${root.get_c_name()}(struct encode_state *s, struct bitset_params *p, ${root.encode.type} src);
|
||||
%endfor
|
||||
|
||||
## TODO before the expr evaluators, we should generate extract_FOO() for
|
||||
|
|
@ -430,7 +443,8 @@ ${s.expr_name(leaf.get_root(), expr)}(struct encode_state *s, struct bitset_para
|
|||
<% field = s.resolve_simple_field(leaf, fieldname) %>
|
||||
% if field is not None and field.get_c_typename() == 'TYPE_BITSET':
|
||||
{ ${encode_params(leaf, field)}
|
||||
${fieldname} = ${s.expr_extractor(leaf, fieldname, '&bp')};
|
||||
const bitmask_t tmp = ${s.expr_extractor(leaf, fieldname, '&bp')};
|
||||
${fieldname} = bitmask_to_uint64_t(tmp);
|
||||
}
|
||||
% else:
|
||||
${fieldname} = ${s.expr_extractor(leaf, fieldname, 'p')};
|
||||
|
|
@ -489,7 +503,9 @@ ${s.expr_name(leaf.get_root(), expr)}(struct encode_state *s, struct bitset_para
|
|||
</%def>
|
||||
|
||||
<%def name="encode_bitset(root, leaf)">
|
||||
uint64_t fld, val = ${hex(leaf.get_pattern().match)};
|
||||
bitmask_t val = uint64_t_to_bitmask(${hex(leaf.get_pattern().match)});
|
||||
uint64_t fld;
|
||||
|
||||
(void)fld;
|
||||
<% visited_exprs = [] %>
|
||||
%for case in s.bitset_cases(leaf):
|
||||
|
|
@ -515,12 +531,15 @@ ${s.expr_name(leaf.get_root(), expr)}(struct encode_state *s, struct bitset_para
|
|||
${case_pre(root, expr)}
|
||||
% if f.field.get_c_typename() == 'TYPE_BITSET':
|
||||
{ ${encode_params(leaf, f.field)}
|
||||
fld = encode${isa.roots[f.field.type].get_c_name()}(s, &bp, ${s.extractor(leaf, f.field.name)}); }
|
||||
bitmask_t tmp = encode${isa.roots[f.field.type].get_c_name()}(s, &bp, ${s.extractor(leaf, f.field.name)});
|
||||
fld = bitmask_to_uint64_t(tmp);
|
||||
}
|
||||
% else:
|
||||
fld = ${s.extractor(leaf, f.field.name)};
|
||||
% endif
|
||||
val |= pack_field(${f.field.low}, ${f.field.high}, fld); /* ${f.field.name} */
|
||||
${case_post(root, expr)}
|
||||
const bitmask_t packed = pack_field(${f.field.low}, ${f.field.high}, fld); /* ${f.field.name} */
|
||||
BITSET_OR(val.bitset, val.bitset, packed.bitset);
|
||||
${case_post(root, expr)}
|
||||
% endfor
|
||||
% endfor
|
||||
|
||||
|
|
@ -538,7 +557,8 @@ ${s.expr_name(leaf.get_root(), expr)}(struct encode_state *s, struct bitset_para
|
|||
continue
|
||||
%>
|
||||
${case_pre(root, expr)}
|
||||
val |= pack_field(${f.field.low}, ${f.field.high}, ${f.field.val});
|
||||
const bitmask_t packed = pack_field(${f.field.low}, ${f.field.high}, ${f.field.val});
|
||||
BITSET_OR(val.bitset, val.bitset, packed.bitset);
|
||||
${case_post(root, None)}
|
||||
% endfor
|
||||
{} /* in case no unconditional field to close out last '} else' */
|
||||
|
|
@ -553,7 +573,7 @@ ${s.expr_name(leaf.get_root(), expr)}(struct encode_state *s, struct bitset_para
|
|||
|
||||
%for root in s.encode_roots():
|
||||
|
||||
static uint64_t
|
||||
static bitmask_t
|
||||
encode${root.get_c_name()}(struct encode_state *s, struct bitset_params *p, ${root.encode.type} src)
|
||||
{
|
||||
% if root.encode.case_prefix is not None:
|
||||
|
|
@ -572,7 +592,7 @@ encode${root.get_c_name()}(struct encode_state *s, struct bitset_params *p, ${ro
|
|||
break;
|
||||
}
|
||||
mesa_loge("Unhandled ${root.name} encode case: 0x%x\\n", ${root.get_c_name()}_case(s, src));
|
||||
return 0;
|
||||
return uint64_t_to_bitmask(0);
|
||||
% else: # single case bitset, no switch
|
||||
% for leaf in s.encode_leafs(root):
|
||||
${encode_bitset(root, leaf)}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue