return o;
}
+/* Tansform an expanded writemask (duplicated 8-bit format) into its condensed
+ * form (one bit per component) */
+
+static inline unsigned
+condense_writemask(unsigned expanded_mask,
+ unsigned bits_per_component)
+{
+ if (bits_per_component == 8)
+ unreachable("XXX TODO: sort out how 8-bit constant encoding works");
+
+ unsigned slots_per_component = bits_per_component / 16;
+ unsigned max_comp = (16 * 8) / bits_per_component;
+ unsigned condensed_mask = 0;
+
+ for (unsigned i = 0; i < max_comp; i++) {
+ if (expanded_mask & (1 << (i * slots_per_component)))
+ condensed_mask |= (1 << i);
+ }
+
+ return condensed_mask;
+}
+
/* Coerce structs to integer */
static inline unsigned