unsigned src2 = ins->src[1];
unsigned src3 = ins->src[2];
+ midgard_reg_mode m32 = midgard_reg_mode_32;
if (src2 != ~0) {
- struct phys_reg src = index_to_reg(ctx, l, src2, mir_srcsize(ins, 1));
+ struct phys_reg src = index_to_reg(ctx, l, src2, m32);
unsigned component = src.offset / src.size;
assert(component * src.size == src.offset);
ins->load_store.arg_1 |= midgard_ldst_reg(src.reg, component);
}
if (src3 != ~0) {
- struct phys_reg src = index_to_reg(ctx, l, src3, mir_srcsize(ins, 2));
+ struct phys_reg src = index_to_reg(ctx, l, src3, m32);
unsigned component = src.offset / src.size;
assert(component * src.size == src.offset);
ins->load_store.arg_2 |= midgard_ldst_reg(src.reg, component);
midgard_reg_mode
mir_srcsize(midgard_instruction *ins, unsigned i)
{
+ if (ins->type == TAG_LOAD_STORE_4) {
+ if (OP_HAS_ADDRESS(ins->load_store.op)) {
+ if (i == 1)
+ return midgard_reg_mode_64;
+ else if (i == 2) {
+ bool zext = ins->load_store.arg_1 & 0x80;
+ return zext ? midgard_reg_mode_32 : midgard_reg_mode_64;
+ }
+ }
+ }
+
/* TODO: 16-bit textures/ldst */
if (ins->type == TAG_TEXTURE_4 || ins->type == TAG_LOAD_STORE_4)
return midgard_reg_mode_32;