summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_opcodes_c.py
diff options
context:
space:
mode:
authorJose Maria Casanova Crespo <[email protected]>2017-07-01 07:58:26 +0200
committerJose Maria Casanova Crespo <[email protected]>2017-12-06 08:57:18 +0100
commit1f440d00d2b6ae6f74fb850ea5acec1f1b5efa58 (patch)
tree46460eeeeeeefe82036e98926071b06ba92e441e /src/compiler/nir/nir_opcodes_c.py
parent2af63683bc61e1efb8f634697770d314ef07c882 (diff)
nir: Handle fp16 rounding modes at nir_type_conversion_op
nir_type_conversion enables new operations to handle rounding modes to convert to fp16 values. Two new opcodes are enabled nir_op_f2f16_rtne and nir_op_f2f16_rtz. The undefined behaviour doesn't has any effect and uses the original nir_op_f2f16 operation. v2: Indentation fixed (Jason Ekstrand) v3: Use explicit case for undefined rounding and assert if rounding mode is used for non 16-bit float conversions (Jason Ekstrand) Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_opcodes_c.py')
-rw-r--r--src/compiler/nir/nir_opcodes_c.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_opcodes_c.py b/src/compiler/nir/nir_opcodes_c.py
index 02bb4738ed8..c19185534af 100644
--- a/src/compiler/nir/nir_opcodes_c.py
+++ b/src/compiler/nir/nir_opcodes_c.py
@@ -30,7 +30,7 @@ template = Template("""
#include "nir.h"
nir_op
-nir_type_conversion_op(nir_alu_type src, nir_alu_type dst)
+nir_type_conversion_op(nir_alu_type src, nir_alu_type dst, nir_rounding_mode rnd)
{
nir_alu_type src_base = (nir_alu_type) nir_alu_type_get_base_type(src);
nir_alu_type dst_base = (nir_alu_type) nir_alu_type_get_base_type(dst);
@@ -64,7 +64,20 @@ nir_type_conversion_op(nir_alu_type src, nir_alu_type dst)
switch (dst_bit_size) {
% for dst_bits in [16, 32, 64]:
case ${dst_bits}:
+% if src_t == 'float' and dst_t == 'float' and dst_bits == 16:
+ switch(rnd) {
+% for rnd_t in ['rtne', 'rtz', 'undef']:
+ case nir_rounding_mode_${rnd_t}:
+ return ${'nir_op_{0}2{1}{2}_{3}'.format(src_t[0], dst_t[0],
+ dst_bits, rnd_t)};
+% endfor
+ default:
+ unreachable("Invalid 16-bit nir rounding mode");
+ }
+% else:
+ assert(rnd == nir_rounding_mode_undef);
return ${'nir_op_{0}2{1}{2}'.format(src_t[0], dst_t[0], dst_bits)};
+% endif
% endfor
default:
unreachable("Invalid nir alu bit size");