pan/mdg: Add opcode roundmode property
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 1 Jun 2020 18:06:44 +0000 (14:06 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 3 Jun 2020 15:36:57 +0000 (15:36 +0000)
When the output is rounded in a specified direction.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5285>

src/panfrost/midgard/helpers.h
src/panfrost/midgard/midgard_ops.c

index a7177ce2f2e80783038175a6e71e7be50dd8fa87..c11cdf65f0f048f680f9ad8f93f56331cb1af168 100644 (file)
 /* Does the op convert types between int- and float- space (i2f/f2u/etc) */
 #define OP_TYPE_CONVERT (1 << 4)
 
+/* Is this opcode the first in a f2x (rte, rtz, rtn, rtp) sequence? If so,
+ * takes a roundmode argument in the IR. This has the semantic of rounding the
+ * source (it's all fused in), which is why it doesn't necessarily make sense
+ * for i2f (though folding there might be necessary for OpenCL reasons). Comes
+ * up in format conversion, i.e. f2u_rte */
+#define MIDGARD_ROUNDS (1 << 5)
+
 /* Vector-independant shorthands for the above; these numbers are arbitrary and
  * not from the ISA. Convert to the above with unit_enum_to_midgard */
 
index 3055f0b93f537ccd59cd8cb7ddbe2a2f0580dd88..73e471c5e853251efe1a5b2b99f6c613c36a748b 100644 (file)
@@ -106,19 +106,19 @@ struct mir_op_props alu_opcode_props[256] = {
         [midgard_alu_op_fexp2]          = {"fexp2", UNIT_VLUT},
         [midgard_alu_op_flog2]          = {"flog2", UNIT_VLUT},
 
-        [midgard_alu_op_f2i_rte]        = {"f2i_rte", UNITS_ADD | OP_TYPE_CONVERT},
+        [midgard_alu_op_f2i_rte]        = {"f2i_rte", UNITS_ADD | OP_TYPE_CONVERT | MIDGARD_ROUNDS},
         [midgard_alu_op_f2i_rtz]        = {"f2i_rtz", UNITS_ADD | OP_TYPE_CONVERT},
         [midgard_alu_op_f2i_rtn]        = {"f2i_rtn", UNITS_ADD | OP_TYPE_CONVERT},
         [midgard_alu_op_f2i_rtp]        = {"f2i_rtp", UNITS_ADD | OP_TYPE_CONVERT},
-        [midgard_alu_op_f2u_rte]        = {"f2u_rte", UNITS_ADD | OP_TYPE_CONVERT},
+        [midgard_alu_op_f2u_rte]        = {"f2u_rte", UNITS_ADD | OP_TYPE_CONVERT | MIDGARD_ROUNDS},
         [midgard_alu_op_f2u_rtz]        = {"f2u_rtz", UNITS_ADD | OP_TYPE_CONVERT},
         [midgard_alu_op_f2u_rtn]        = {"f2u_rtn", UNITS_ADD | OP_TYPE_CONVERT},
         [midgard_alu_op_f2u_rtp]        = {"f2u_rtp", UNITS_ADD | OP_TYPE_CONVERT},
-        [midgard_alu_op_i2f_rte]        = {"i2f", UNITS_ADD | OP_TYPE_CONVERT},
+        [midgard_alu_op_i2f_rte]        = {"i2f_rte", UNITS_ADD | OP_TYPE_CONVERT},
         [midgard_alu_op_i2f_rtz]        = {"i2f_rtz", UNITS_ADD | OP_TYPE_CONVERT},
         [midgard_alu_op_i2f_rtn]        = {"i2f_rtn", UNITS_ADD | OP_TYPE_CONVERT},
         [midgard_alu_op_i2f_rtp]        = {"i2f_rtp", UNITS_ADD | OP_TYPE_CONVERT},
-        [midgard_alu_op_u2f_rte]        = {"u2f", UNITS_ADD | OP_TYPE_CONVERT},
+        [midgard_alu_op_u2f_rte]        = {"u2f_rte", UNITS_ADD | OP_TYPE_CONVERT},
         [midgard_alu_op_u2f_rtz]        = {"u2f_rtz", UNITS_ADD | OP_TYPE_CONVERT},
         [midgard_alu_op_u2f_rtn]        = {"u2f_rtn", UNITS_ADD | OP_TYPE_CONVERT},
         [midgard_alu_op_u2f_rtp]        = {"u2f_rtp", UNITS_ADD | OP_TYPE_CONVERT},