i965: Add a brw_hw_type_to_reg_type() function
authorMatt Turner <mattst88@gmail.com>
Thu, 27 Jul 2017 00:50:22 +0000 (17:50 -0700)
committerMatt Turner <mattst88@gmail.com>
Mon, 21 Aug 2017 21:05:23 +0000 (14:05 -0700)
Will be used in later commits.

Reviewed-by: Scott D Phillips <scott.d.phillips@intel.com>
src/intel/compiler/brw_reg_type.c
src/intel/compiler/brw_reg_type.h

index f223f3949dc160576d0763ad6a37c8efadc11e1d..7dbff8f08f22df6f09454a147761a1dc4e8a9fd9 100644 (file)
@@ -69,6 +69,31 @@ brw_reg_type_to_hw_type(const struct gen_device_info *devinfo,
    }
 }
 
+/**
+ * Convert the hardware representation into a brw_reg_type enumeration value.
+ *
+ * The hardware encoding may depend on whether the value is an immediate.
+ */
+enum brw_reg_type
+brw_hw_type_to_reg_type(const struct gen_device_info *devinfo,
+                        enum brw_reg_file file, unsigned hw_type)
+{
+   if (file == BRW_IMMEDIATE_VALUE) {
+      for (enum brw_reg_type i = 0; i <= BRW_REGISTER_TYPE_LAST; i++) {
+         if (gen4_hw_type[i].imm_type == hw_type) {
+            return i;
+         }
+      }
+   } else {
+      for (enum brw_reg_type i = 0; i <= BRW_REGISTER_TYPE_LAST; i++) {
+         if (gen4_hw_type[i].reg_type == hw_type) {
+            return i;
+         }
+      }
+   }
+   unreachable("not reached");
+}
+
 /**
  * Return the element size given a hardware register type and file.
  *
index 3e654eedc47fb93130647ca8a51641e1841eb107..a21bad5b158d91bef51b56a63fc9c38c6efa6fe3 100644 (file)
@@ -63,6 +63,10 @@ unsigned
 brw_reg_type_to_hw_type(const struct gen_device_info *devinfo,
                         enum brw_reg_file file, enum brw_reg_type type);
 
+enum brw_reg_type
+brw_hw_type_to_reg_type(const struct gen_device_info *devinfo,
+                        enum brw_reg_file file, unsigned hw_type);
+
 #define brw_element_size(devinfo, inst, operand)                             \
    brw_hw_reg_type_to_size(devinfo,                                          \
                            brw_inst_ ## operand ## _reg_file(devinfo, inst), \