return s;
}
+/* Composes two swizzles */
+static inline unsigned
+pan_compose_swizzle(unsigned left, unsigned right)
+{
+ unsigned out = 0;
+
+ for (unsigned c = 0; c < 4; ++c) {
+ unsigned s = (left >> (2*c)) & 0x3;
+ unsigned q = (right >> (2*s)) & 0x3;
+
+ out |= (q << (2*c));
+ }
+
+ return out;
+}
+
+/* Applies a swizzle to an ALU source */
+
+static inline unsigned
+vector_alu_apply_swizzle(unsigned src, unsigned swizzle)
+{
+ midgard_vector_alu_src s =
+ vector_alu_from_unsigned(src);
+
+ s.swizzle = pan_compose_swizzle(s.swizzle, swizzle);
+
+ return vector_alu_srco_unsigned(s);
+}
+
#endif
compose_swizzle(unsigned swizzle, unsigned mask,
struct phys_reg reg, struct phys_reg dst)
{
- unsigned out = 0;
-
- for (unsigned c = 0; c < 4; ++c) {
- unsigned s = (swizzle >> (2*c)) & 0x3;
- unsigned q = (reg.swizzle >> (2*s)) & 0x3;
-
- out |= (q << (2*c));
- }
+ unsigned out = pan_compose_swizzle(swizzle, reg.swizzle);
/* Based on the register mask, we need to adjust over. E.g if we're
* writing to yz, a base swizzle of xy__ becomes _xy_. Save the