summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2017-10-17 19:50:36 -0700
committerAndres Gomez <agomez@igalia.com>2017-11-21 18:16:44 +0200
commit73342c304d608e1a0180d19c5de50b177e27bdf7 (patch)
tree718587dd1cd2aa24955d80292be23aef96c4ff4c
parent00ccd7856e5c3640e2a496a36b4094d1ae893fb6 (diff)
downloadmesa-73342c304d608e1a0180d19c5de50b177e27bdf7.tar.gz
intel/eu/reg: Add a subscript() helper
This is similar to the identically named fs_reg helper. Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Cc: mesa-stable@lists.freedesktop.org (cherry picked from commit 10e4feed39120072f38274b95e884422f72f360f)
-rw-r--r--src/intel/compiler/brw_reg.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/intel/compiler/brw_reg.h b/src/intel/compiler/brw_reg.h
index 17a51fbd655..917f37147f1 100644
--- a/src/intel/compiler/brw_reg.h
+++ b/src/intel/compiler/brw_reg.h
@@ -945,6 +945,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)
{