From 0b6625d825f437a33bc885a9b21e3d5dd0aa65df Mon Sep 17 00:00:00 2001 From: "Kristian H. Kristensen" Date: Thu, 10 Oct 2019 13:44:14 -0700 Subject: [PATCH] freedreno/ir3: Use third register for offset for LDL and LDLV Before, offset held the offset, which can be either immediate or a register. Use a third register to hold the offset so that we can use a register. Signed-off-by: Kristian H. Kristensen --- src/freedreno/ir3/ir3.c | 14 +++++++++----- src/freedreno/ir3/ir3.h | 4 ++-- src/freedreno/ir3/ir3_compiler_nir.c | 10 ++++++---- src/freedreno/ir3/ir3_cp.c | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/freedreno/ir3/ir3.c b/src/freedreno/ir3/ir3.c index 68e83f7495e..72809c4a548 100644 --- a/src/freedreno/ir3/ir3.c +++ b/src/freedreno/ir3/ir3.c @@ -794,17 +794,21 @@ static int emit_cat6(struct ir3_instruction *instr, void *ptr, return 0; } else if (instr->cat6.src_offset || (instr->opc == OPC_LDG) || (instr->opc == OPC_LDL)) { + struct ir3_register *src3 = instr->regs[3]; instr_cat6a_t *cat6a = ptr; cat6->src_off = true; cat6a->src1 = reg(src1, info, instr->repeat, IR3_REG_IMMED); cat6a->src1_im = !!(src1->flags & IR3_REG_IMMED); - if (src2) { - cat6a->src2 = reg(src2, info, instr->repeat, IR3_REG_IMMED); - cat6a->src2_im = !!(src2->flags & IR3_REG_IMMED); - } - cat6a->off = instr->cat6.src_offset; + + /* Num components */ + cat6a->src2 = reg(src2, info, instr->repeat, IR3_REG_IMMED); + cat6a->src2_im = true; + + /* Offset */ + iassert(src3->flags & IR3_REG_IMMED); + cat6a->off = reg(src3, info, instr->repeat, IR3_REG_IMMED); } else { instr_cat6b_t *cat6b = ptr; diff --git a/src/freedreno/ir3/ir3.h b/src/freedreno/ir3/ir3.h index 9d2a8d73528..224ed4e5c66 100644 --- a/src/freedreno/ir3/ir3.h +++ b/src/freedreno/ir3/ir3.h @@ -1407,8 +1407,8 @@ ir3_SAM(struct ir3_block *block, opc_t opc, type_t type, /* cat6 instructions: */ INSTR2(LDLV) -INSTR2(LDG) -INSTR2(LDL) +INSTR3(LDG) +INSTR3(LDL) INSTR3(STG) INSTR3(STL) INSTR1(RESINFO) diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 6ed24e41e2f..aa9eaca7bdd 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -752,9 +752,9 @@ emit_intrinsic_load_ubo(struct ir3_context *ctx, nir_intrinsic_instr *intr, for (int i = 0; i < intr->num_components; i++) { struct ir3_instruction *load = - ir3_LDG(b, addr, 0, create_immed(b, 1), 0); + ir3_LDG(b, addr, 0, create_immed(b, 1), 0, /* num components */ + create_immed(b, off + i * 4), 0); load->cat6.type = TYPE_U32; - load->cat6.src_offset = off + i * 4; /* byte offset */ dst[i] = load; } } @@ -787,8 +787,10 @@ emit_intrinsic_load_shared(struct ir3_context *ctx, nir_intrinsic_instr *intr, offset = ir3_get_src(ctx, &intr->src[0])[0]; base = nir_intrinsic_base(intr); - ldl = ir3_LDL(b, offset, 0, create_immed(b, intr->num_components), 0); - ldl->cat6.src_offset = base; + ldl = ir3_LDL(b, offset, 0, + create_immed(b, intr->num_components), 0, + create_immed(b, base), 0); + ldl->cat6.type = utype_dst(intr->dest); ldl->regs[0]->wrmask = MASK(intr->num_components); diff --git a/src/freedreno/ir3/ir3_cp.c b/src/freedreno/ir3/ir3_cp.c index 1baf11971a8..704ddf99937 100644 --- a/src/freedreno/ir3/ir3_cp.c +++ b/src/freedreno/ir3/ir3_cp.c @@ -210,7 +210,7 @@ static bool valid_flags(struct ir3_instruction *instr, unsigned n, if (is_store(instr) && (n == 1)) return false; - if ((instr->opc == OPC_LDL) && (n != 1)) + if ((instr->opc == OPC_LDL) && (n == 0)) return false; if ((instr->opc == OPC_STL) && (n != 2)) -- 2.30.2