uint16_t mir_round_bytemask_up(uint16_t mask, unsigned bits);
void mir_set_bytemask(midgard_instruction *ins, uint16_t bytemask);
signed mir_upper_override(midgard_instruction *ins, unsigned inst_size);
+unsigned mir_components_for_type(nir_alu_type T);
/* MIR printing */
static void
mir_print_swizzle(unsigned *swizzle, nir_alu_type T)
{
- unsigned sz = nir_alu_type_get_type_size(T);
- unsigned comps = 128 / sz;
+ unsigned comps = mir_components_for_type(T);
printf(".");
static void
mir_print_embedded_constant(midgard_instruction *ins, unsigned src_idx)
{
- unsigned type_size = nir_alu_type_get_type_size(ins->dest_type);
midgard_vector_alu_src src;
assert(src_idx <= 1);
unsigned *swizzle = ins->swizzle[src_idx];
unsigned comp_mask = effective_writemask(&ins->alu, ins->mask);
unsigned num_comp = util_bitcount(comp_mask);
- unsigned max_comp = 64 / type_size;
+ unsigned max_comp = mir_components_for_type(ins->dest_type) >> 1;
bool first = true;
printf("#");
return mod != midgard_outmod_none;
}
+/* 128 / sz = exp2(log2(128 / sz))
+ * = exp2(log2(128) - log2(sz))
+ * = exp2(7 - log2(sz))
+ * = 1 << (7 - log2(sz))
+ */
+
+unsigned
+mir_components_for_type(nir_alu_type T)
+{
+ unsigned sz = nir_alu_type_get_type_size(T);
+ return 1 << (7 - util_logbase2(sz));
+}
+
uint16_t
mir_from_bytemask(uint16_t bytemask, unsigned bits)
{