Mesa (master): nir/lower_int64: Add a level of wrapper functions
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jan 22 19:12:48 UTC 2021
Module: Mesa
Branch: master
Commit: 70b4524de57cdbef9c0c5fb6f06994c7e39ec7d9
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=70b4524de57cdbef9c0c5fb6f06994c7e39ec7d9
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Mon Oct 26 10:41:41 2020 -0500
nir/lower_int64: Add a level of wrapper functions
We're about to start lowering a few intrinsics so we need support more
than just ALU.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7329>
---
src/compiler/nir/nir_lower_int64.c | 42 ++++++++++++++++++++++++--------------
1 file changed, 27 insertions(+), 15 deletions(-)
diff --git a/src/compiler/nir/nir_lower_int64.c b/src/compiler/nir/nir_lower_int64.c
index ff2c1d97196..049aca61272 100644
--- a/src/compiler/nir/nir_lower_int64.c
+++ b/src/compiler/nir/nir_lower_int64.c
@@ -874,10 +874,8 @@ nir_lower_int64_op_to_options_mask(nir_op opcode)
}
static nir_ssa_def *
-lower_int64_alu_instr(nir_builder *b, nir_instr *instr, void *_state)
+lower_int64_alu_instr(nir_builder *b, nir_alu_instr *alu)
{
- nir_alu_instr *alu = nir_instr_as_alu(instr);
-
nir_ssa_def *src[4];
for (unsigned i = 0; i < nir_op_infos[alu->op].num_inputs; i++)
src[i] = nir_ssa_for_alu_src(b, alu, i);
@@ -995,16 +993,9 @@ lower_int64_alu_instr(nir_builder *b, nir_instr *instr, void *_state)
}
static bool
-should_lower_int64_alu_instr(const nir_instr *instr, const void *_data)
+should_lower_int64_alu_instr(const nir_alu_instr *alu,
+ const nir_shader_compiler_options *options)
{
- const nir_shader_compiler_options *options =
- (const nir_shader_compiler_options *)_data;
-
- if (instr->type != nir_instr_type_alu)
- return false;
-
- const nir_alu_instr *alu = nir_instr_as_alu(instr);
-
switch (alu->op) {
case nir_op_i2b1:
case nir_op_i2i8:
@@ -1075,11 +1066,32 @@ should_lower_int64_alu_instr(const nir_instr *instr, const void *_data)
return (options->lower_int64_options & mask) != 0;
}
+static bool
+should_lower_int64_instr(const nir_instr *instr, const void *_options)
+{
+ switch (instr->type) {
+ case nir_instr_type_alu:
+ return should_lower_int64_alu_instr(nir_instr_as_alu(instr), _options);
+ default:
+ return false;
+ }
+}
+
+static nir_ssa_def *
+lower_int64_instr(nir_builder *b, nir_instr *instr, void *_options)
+{
+ switch (instr->type) {
+ case nir_instr_type_alu:
+ return lower_int64_alu_instr(b, nir_instr_as_alu(instr));
+ default:
+ return NULL;
+ }
+}
+
bool
nir_lower_int64(nir_shader *shader)
{
- return nir_shader_lower_instructions(shader,
- should_lower_int64_alu_instr,
- lower_int64_alu_instr,
+ return nir_shader_lower_instructions(shader, should_lower_int64_instr,
+ lower_int64_instr,
(void *)shader->options);
}
More information about the mesa-commit
mailing list