return mask;
}
+
+uint64_t
+bi_get_immediate(bi_instruction *ins, unsigned index)
+{
+ unsigned v = ins->src[index];
+ assert(v & BIR_INDEX_CONSTANT);
+ unsigned shift = v & ~BIR_INDEX_CONSTANT;
+ uint64_t shifted = ins->constant.u64 >> shift;
+
+ /* Mask off the accessed part */
+ unsigned sz = nir_alu_type_get_type_size(ins->src_types[index]);
+
+ if (sz == 64)
+ return shifted;
+ else
+ return shifted & ((1ull << sz) - 1);
+}
+
+bool
+bi_writes_component(bi_instruction *ins, unsigned comp)
+{
+ /* TODO: Do we want something less coarse? */
+ if (bi_class_props[ins->type] & BI_VECTOR)
+ return true;
+
+ nir_alu_type T = ins->dest_type;
+ unsigned size = nir_alu_type_get_type_size(T);
+ return ins->writemask & (0xF << (comp * (size / 8)));
+}