mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 10:30:08 +01:00
nir/algebraic: add support for custom arguments
Those are passed as an optional argument and are declared as a list of (type, name) tuples. At the moment this can only be used for conditions. Signed-off-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26214>
This commit is contained in:
parent
2701e634c1
commit
8c73b1eb90
1 changed files with 11 additions and 4 deletions
|
|
@ -1168,8 +1168,12 @@ static const nir_algebraic_table ${pass_name}_table = {
|
|||
};
|
||||
|
||||
bool
|
||||
${pass_name}(nir_shader *shader)
|
||||
{
|
||||
${pass_name}(
|
||||
nir_shader *shader
|
||||
% for type, name in params:
|
||||
, ${type} ${name}
|
||||
% endfor
|
||||
) {
|
||||
bool progress = false;
|
||||
bool condition_flags[${len(condition_list)}];
|
||||
const nir_shader_compiler_options *options = shader->options;
|
||||
|
|
@ -1192,12 +1196,14 @@ ${pass_name}(nir_shader *shader)
|
|||
|
||||
|
||||
class AlgebraicPass(object):
|
||||
def __init__(self, pass_name, transforms):
|
||||
# params is a list of `("type", "name")` tuples
|
||||
def __init__(self, pass_name, transforms, params=[]):
|
||||
self.xforms = []
|
||||
self.opcode_xforms = defaultdict(lambda : [])
|
||||
self.pass_name = pass_name
|
||||
self.expression_cond = {}
|
||||
self.variable_cond = {}
|
||||
self.params = params
|
||||
|
||||
error = False
|
||||
|
||||
|
|
@ -1263,7 +1269,8 @@ class AlgebraicPass(object):
|
|||
expression_cond = sorted(self.expression_cond.items(), key=lambda kv: kv[1]),
|
||||
variable_cond = sorted(self.variable_cond.items(), key=lambda kv: kv[1]),
|
||||
get_c_opcode=get_c_opcode,
|
||||
itertools=itertools)
|
||||
itertools=itertools,
|
||||
params=self.params)
|
||||
|
||||
# The replacement expression isn't necessarily exact if the search expression is exact.
|
||||
def ignore_exact(*expr):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue