summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Herbst <kherbst@redhat.com>2018-04-26 21:49:32 +0200
committerJérôme Glisse <jglisse@redhat.com>2018-07-25 12:43:49 -0400
commitbcfbc6bb2358dc194ae6941f40372ff647758802 (patch)
tree45a1cdb0446e7fc1cd6354eb0f005836bbabaa72
parent3a5491ddedb09899558eb390a3b9e333aa9f05da (diff)
nir: add helper functions for rounding mode
For easier implementing of the new conversion opcodes.
-rw-r--r--src/compiler/nir/nir_opcodes_h.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opcodes_h.py b/src/compiler/nir/nir_opcodes_h.py
index 8ad17c84d4..9a89aabc32 100644
--- a/src/compiler/nir/nir_opcodes_h.py
+++ b/src/compiler/nir/nir_opcodes_h.py
@@ -39,6 +39,63 @@ typedef enum {
nir_num_opcodes = nir_last_opcode + 1
} nir_op;
+% for mode in [('rtne', '_rtne'), ('rtz', '_rtz'), ('ru', '_ru'), ('rd', '_rd'), ('undef', '')]:
+static inline bool
+nir_cvt_is_${mode[0]}(nir_op op)
+{
+ switch (op) {
+% for src_type in ['f', 'i', 'u']:
+% if src_type == 'f':
+<% dst_types = ['i', 'u', 'f'] %>
+% else:
+<% dst_types = ['f'] %>
+% endif
+% for dst_type in dst_types:
+% if dst_type == 'f':
+<% bit_sizes = [16, 32, 64] %>
+<% sat_modes = [''] %>
+% else:
+<% bit_sizes = [8, 16, 32, 64] %>
+<% sat_modes = ['_sat', ''] %>
+% endif
+% for bit_size in bit_sizes:
+% for sat_mode in sat_modes:
+ case nir_op_${src_type}2${dst_type}${bit_size}${mode[1]}${sat_mode}:
+% endfor
+% endfor
+% endfor
+% endfor
+ return true;
+ default:
+ return false;
+ }
+}
+% endfor
+
+static inline bool
+nir_cvt_is_sat(nir_op op)
+{
+ switch (op) {
+% for dst_type in ['i', 'u']:
+% for src_type in ['i', 'u', 'f']:
+% if src_type == 'f':
+<% rnd_modes = ['_rtne', '_rtz', '_ru', '_rd', ''] %>
+% else:
+<% rnd_modes = [''] %>
+% endif
+% for bit_size in [8, 16, 32, 64]:
+% for rnd_mode in rnd_modes:
+ case nir_op_${src_type}2${dst_type}${bit_size}${rnd_mode}_sat:
+% endfor
+% endfor
+% endfor
+% endfor
+ return true;
+ default:
+ return false;
+ }
+}
+
#endif /* _NIR_OPCODES_ */"""
from nir_opcodes import opcodes