nir: Make nir_build_alu() variants per 1-4 arg count.

This saves a bunch of generated code to pack up the extra NULLs to get to
4 args, and saves executing the conditions in nir_build_alu() to then skip
those NULLs.

Saves another 27kb on disk.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13916>
This commit is contained in:
Emma Anholt
2021-11-22 11:45:23 -08:00
committed by Marge Bot
parent e770ec1182
commit 06fe04b4d7
3 changed files with 73 additions and 5 deletions
+2 -5
View File
@@ -29,10 +29,7 @@ def src_decl_list(num_srcs):
return ', '.join('nir_ssa_def *src' + str(i) for i in range(num_srcs))
def src_list(num_srcs):
if num_srcs <= 4:
return ', '.join('src' + str(i) if i < num_srcs else 'NULL' for i in range(4))
else:
return ', '.join('src' + str(i) for i in range(num_srcs))
return ', '.join('src' + str(i) for i in range(num_srcs))
%>
% for name, opcode in sorted(opcodes.items()):
@@ -40,7 +37,7 @@ static inline nir_ssa_def *
nir_${name}(nir_builder *build, ${src_decl_list(opcode.num_inputs)})
{
% if opcode.num_inputs <= 4:
return nir_build_alu(build, nir_op_${name}, ${src_list(opcode.num_inputs)});
return nir_build_alu${opcode.num_inputs}(build, nir_op_${name}, ${src_list(opcode.num_inputs)});
% else:
nir_ssa_def *srcs[${opcode.num_inputs}] = {${src_list(opcode.num_inputs)}};
return nir_build_alu_src_arr(build, nir_op_${name}, srcs);