[Mesa-dev] [PATCH v3 09/48] intel/eu/reg: Add a subscript() helper

Jason Ekstrand jason at jlekstrand.net
Wed Oct 25 23:25:40 UTC 2017


This is similar to the identically named fs_reg helper.

Cc: mesa-stable at lists.freedesktop.org
---
 src/intel/compiler/brw_reg.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/intel/compiler/brw_reg.h b/src/intel/compiler/brw_reg.h
index d68d64f..9d63717 100644
--- a/src/intel/compiler/brw_reg.h
+++ b/src/intel/compiler/brw_reg.h
@@ -896,6 +896,22 @@ spread(struct brw_reg reg, unsigned s)
    }
 }
 
+/**
+ * Reinterpret each channel of register \p reg as a vector of values of the
+ * given smaller type and take the i-th subcomponent from each.
+ */
+static inline struct brw_reg
+subscript(struct brw_reg reg, enum brw_reg_type type, unsigned i)
+{
+   if (reg.file == IMM)
+      return reg;
+
+   unsigned scale = type_sz(reg.type) / type_sz(type);
+   assert(scale >= 1 && i < scale);
+
+   return suboffset(retype(spread(reg, scale), type), i);
+}
+
 static inline struct brw_reg
 vec16(struct brw_reg reg)
 {
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list