Mesa (master): spirv: Implement NoSignedWrap and NoUnsignedWrap decorations
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 26 23:02:40 UTC 2019
Module: Mesa
Branch: master
Commit: 5a143965b8f4119501e973d15f7f72673b3ce416
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5a143965b8f4119501e973d15f7f72673b3ce416
Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date: Fri May 17 22:52:42 2019 -0700
spirv: Implement NoSignedWrap and NoUnsignedWrap decorations
When handling the specified ALU operations, check for the decorations
and set nir_alu_instr no_signed_wrap and no_unsigned_wrap flags accordingly.
v2: Add a glsl_base_type_is_unsigned_integer() helper. (Karol)
v3: Rename helper to glsl_base_type_is_uint().
v4: Use two flags, so we don't need the helper anymore. (Connor)
v5: Pass alu directly to handle function. (Jason)
Reviewed-by: Karol Herbst <kherbst at redhat.com> [v3]
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
---
src/compiler/spirv/vtn_alu.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c
index f7fb82774bd..f60d7cddafc 100644
--- a/src/compiler/spirv/vtn_alu.c
+++ b/src/compiler/spirv/vtn_alu.c
@@ -377,6 +377,24 @@ handle_rounding_mode(struct vtn_builder *b, struct vtn_value *val, int member,
}
}
+static void
+handle_no_wrap(struct vtn_builder *b, struct vtn_value *val, int member,
+ const struct vtn_decoration *dec, void *_alu)
+{
+ nir_alu_instr *alu = _alu;
+ switch (dec->decoration) {
+ case SpvDecorationNoSignedWrap:
+ alu->no_signed_wrap = true;
+ break;
+ case SpvDecorationNoUnsignedWrap:
+ alu->no_unsigned_wrap = true;
+ break;
+ default:
+ /* Do nothing. */
+ break;
+ }
+}
+
void
vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
const uint32_t *w, unsigned count)
@@ -651,6 +669,21 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
} /* default */
}
+ switch (opcode) {
+ case SpvOpIAdd:
+ case SpvOpIMul:
+ case SpvOpISub:
+ case SpvOpShiftLeftLogical:
+ case SpvOpSNegate: {
+ nir_alu_instr *alu = nir_instr_as_alu(val->ssa->def->parent_instr);
+ vtn_foreach_decoration(b, val, handle_no_wrap, alu);
+ break;
+ }
+ default:
+ /* Do nothing. */
+ break;
+ }
+
b->nb.exact = b->exact;
}
More information about the mesa-commit
mailing list