summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-10-17 19:50:36 -0700
committerEmil Velikov <[email protected]>2017-11-10 16:29:27 +0000
commitb9ddb51c19aa7975b92287d2cf5fde81e0b2346b (patch)
tree9bdfb15834d322c14e2383ef00383d45cfca0ed4
parentd1060ba31f47eab396d9a9f06bf3ca723be4d8ad (diff)
intel/eu/reg: Add a subscript() helper
This is similar to the identically named fs_reg helper. Reviewed-by: Iago Toral Quiroga <[email protected]> Cc: [email protected] (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 d68d64f0037..9d63717fb45 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)
{