nir: add const_index parameters to system value builder function
authorKarol Herbst <kherbst@redhat.com>
Thu, 19 Jul 2018 09:42:08 +0000 (11:42 +0200)
committerKarol Herbst <kherbst@redhat.com>
Wed, 14 Nov 2018 01:09:11 +0000 (02:09 +0100)
this allows to replace some nir_load_system_value calls with the specific
system value constructor

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Karol Herbst <kherbst@redhat.com>
src/compiler/nir/nir_builder_opcodes_h.py

index e600093e9f6375d0ccb58a4147ae33e1c1db1692..34b8c4371e1164deed1f5293e83a85b2eaf73c4d 100644 (file)
@@ -55,11 +55,28 @@ nir_load_system_value(nir_builder *build, nir_intrinsic_op op, int index)
    return &load->dest.ssa;
 }
 
+<%
+def sysval_decl_list(opcode):
+   res = ''
+   if opcode.indices:
+      res += ', unsigned ' + opcode.indices[0].lower()
+   return res
+
+def sysval_arg_list(opcode):
+   args = []
+   if opcode.indices:
+      args.append(opcode.indices[0].lower())
+   else:
+      args.append('0')
+   return ', '.join(args)
+%>
+
 % for name, opcode in filter(lambda v: v[1].sysval, sorted(INTR_OPCODES.items())):
 static inline nir_ssa_def *
-nir_${name}(nir_builder *build)
+nir_${name}(nir_builder *build${sysval_decl_list(opcode)})
 {
-   return nir_load_system_value(build, nir_intrinsic_${name}, 0);
+   return nir_load_system_value(build, nir_intrinsic_${name},
+                                ${sysval_arg_list(opcode)});
 }
 % endfor