<p dir="ltr"><br>
On Apr 12, 2016 1:06 AM, "Samuel Iglesias Gonsálvez" <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>> wrote:<br>
><br>
> Some instructions (like flrp in i965) cannot be lowered depending on the<br>
> bit size because it doesn't support all bit sizes.<br>
><br>
> If the bit size field is defined in nir_opt_algebraic.py, take it into<br>
> account.</p>
<p dir="ltr">I'm sorry I keep punting on this patch. I've never really like tacking yet another argument on to the end of the expression but for a long time i couldn't cone up with anything better. How about this: Add a bit_size field to nir_search_value and allow you to write 'flrp@64' to indicate a 64-bit destination on an ALU op, 'x@64' to indicate a 64-bit "variable", and '1.0@64' to indicate a 64-bit constant. Then it could be used both to check for a particular bit-size in the search expression and to allow you to specify a bit-size when constructing a value in case it's ambiguous.</p>
<p dir="ltr">If you're amenable to the idea, I'll hack on it a bit on Monday. I've been meaning to add a bit-size validator to nir_algebraic.py for some time now anyway.</p>
<p dir="ltr">--Jason</p>
<p dir="ltr">> Signed-off-by: Samuel Iglesias Gonsálvez <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
> ---<br>
> src/compiler/nir/nir_algebraic.py | 11 ++++++++++-<br>
> 1 file changed, 10 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py<br>
> index 53a7907..f3630e0 100644<br>
> --- a/src/compiler/nir/nir_algebraic.py<br>
> +++ b/src/compiler/nir/nir_algebraic.py<br>
> @@ -180,6 +180,11 @@ class SearchAndReplace(object):<br>
> else:<br>
> self.condition = 'true'<br>
><br>
> + if len(transform) > 3:<br>
> + self.bit_size = transform[3]<br>
> + else:<br>
> + self.bit_size = 0<br>
> +<br>
> if self.condition not in condition_list:<br>
> condition_list.append(self.condition)<br>
> self.condition_index = condition_list.index(self.condition)<br>
> @@ -208,6 +213,7 @@ struct transform {<br>
> const nir_search_expression *search;<br>
> const nir_search_value *replace;<br>
> unsigned condition_offset;<br>
> + unsigned bit_size;<br>
> };<br>
><br>
> struct opt_state {<br>
> @@ -226,7 +232,7 @@ struct opt_state {<br>
><br>
> static const struct transform ${pass_name}_${opcode}_xforms[] = {<br>
> % for xform in xform_list:<br>
> - { &${<a href="http://xform.search.name">xform.search.name</a>}, ${xform.replace.c_ptr}, ${xform.condition_index} },<br>
> + { &${<a href="http://xform.search.name">xform.search.name</a>}, ${xform.replace.c_ptr}, ${xform.condition_index}, ${xform.bit_size}},<br>
> % endfor<br>
> };<br>
> % endfor<br>
> @@ -249,6 +255,9 @@ ${pass_name}_block(nir_block *block, void *void_state)<br>
> case nir_op_${opcode}:<br>
> for (unsigned i = 0; i < ARRAY_SIZE(${pass_name}_${opcode}_xforms); i++) {<br>
> const struct transform *xform = &${pass_name}_${opcode}_xforms[i];<br>
> + if (xform->bit_size != 0 &&<br>
> + alu->dest.dest.ssa.bit_size != xform->bit_size)<br>
> + continue;<br>
> if (state->condition_flags[xform->condition_offset] &&<br>
> nir_replace_instr(alu, xform->search, xform->replace,<br>
> state->mem_ctx)) {<br>
> --<br>
> 2.5.0<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>