summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/panfrost/midgard/helpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/panfrost/midgard/helpers.h')
-rw-r--r--src/gallium/drivers/panfrost/midgard/helpers.h27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/gallium/drivers/panfrost/midgard/helpers.h b/src/gallium/drivers/panfrost/midgard/helpers.h
index dc2de15931b..441c7285887 100644
--- a/src/gallium/drivers/panfrost/midgard/helpers.h
+++ b/src/gallium/drivers/panfrost/midgard/helpers.h
@@ -71,6 +71,9 @@
/* Is the op commutative? */
#define OP_COMMUTES (1 << 3)
+/* Does the op convert types between int- and float- space (i2f/f2u/etc) */
+#define OP_TYPE_CONVERT (1 << 4)
+
/* Vector-independant shorthands for the above; these numbers are arbitrary and
* not from the ISA. Convert to the above with unit_enum_to_midgard */
@@ -207,11 +210,11 @@ static struct {
[midgard_alu_op_fexp2] = {"fexp2", UNIT_VLUT},
[midgard_alu_op_flog2] = {"flog2", UNIT_VLUT},
- [midgard_alu_op_f2i] = {"f2i", UNITS_ADD},
- [midgard_alu_op_f2u] = {"f2u", UNITS_ADD},
- [midgard_alu_op_f2u8] = {"f2u8", UNITS_ADD},
- [midgard_alu_op_i2f] = {"i2f", UNITS_ADD},
- [midgard_alu_op_u2f] = {"u2f", UNITS_ADD},
+ [midgard_alu_op_f2i] = {"f2i", UNITS_ADD | OP_TYPE_CONVERT},
+ [midgard_alu_op_f2u] = {"f2u", UNITS_ADD | OP_TYPE_CONVERT},
+ [midgard_alu_op_f2u8] = {"f2u8", UNITS_ADD | OP_TYPE_CONVERT},
+ [midgard_alu_op_i2f] = {"i2f", UNITS_ADD | OP_TYPE_CONVERT},
+ [midgard_alu_op_u2f] = {"u2f", UNITS_ADD | OP_TYPE_CONVERT},
[midgard_alu_op_fsin] = {"fsin", UNIT_VLUT},
[midgard_alu_op_fcos] = {"fcos", UNIT_VLUT},
@@ -262,7 +265,7 @@ static struct {
/* Is this opcode that of an integer (regardless of signedness)? Instruction
* names authoritatively determine types */
-static bool
+static inline bool
midgard_is_integer_op(int op)
{
const char *name = alu_opcode_props[op].name;
@@ -272,3 +275,15 @@ midgard_is_integer_op(int op)
return (name[0] == 'i') || (name[0] == 'u');
}
+
+/* Does this opcode *write* an integer? Same as is_integer_op, unless it's a
+ * conversion between int<->float in which case we do the opposite */
+
+static inline bool
+midgard_is_integer_out_op(int op)
+{
+ bool is_int = midgard_is_integer_op(op);
+ bool is_conversion = alu_opcode_props[op].props & OP_TYPE_CONVERT;
+
+ return is_int ^ is_conversion;
+}