diff options
Diffstat (limited to 'src/gallium/drivers/freedreno/ir3/ir3.c')
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3.c | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/src/gallium/drivers/freedreno/ir3/ir3.c b/src/gallium/drivers/freedreno/ir3/ir3.c index dd5fb2fbbe5..d1a73ddc727 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3.c +++ b/src/gallium/drivers/freedreno/ir3/ir3.c @@ -68,10 +68,17 @@ void ir3_destroy(struct ir3 *shader) #define iassert(cond) do { \ if (!(cond)) { \ - assert(cond); \ + debug_assert(cond); \ return -1; \ } } while (0) +#define iassert_type(reg, full) do { \ + if ((full)) { \ + iassert(!((reg)->flags & IR3_REG_HALF)); \ + } else { \ + iassert((reg)->flags & IR3_REG_HALF); \ + } } while (0); + static uint32_t reg(struct ir3_register *reg, struct ir3_info *info, uint32_t repeat, uint32_t valid_flags) { @@ -142,11 +149,6 @@ static int emit_cat0(struct ir3_instruction *instr, void *ptr, return 0; } -static uint32_t type_flags(type_t type) -{ - return (type_size(type) == 32) ? 0 : IR3_REG_HALF; -} - static int emit_cat1(struct ir3_instruction *instr, void *ptr, struct ir3_info *info) { @@ -155,9 +157,9 @@ static int emit_cat1(struct ir3_instruction *instr, void *ptr, instr_cat1_t *cat1 = ptr; iassert(instr->regs_count == 2); - iassert(!((dst->flags ^ type_flags(instr->cat1.dst_type)) & IR3_REG_HALF)); - iassert((src->flags & IR3_REG_IMMED) || - !((src->flags ^ type_flags(instr->cat1.src_type)) & IR3_REG_HALF)); + iassert_type(dst, type_size(instr->cat1.dst_type) == 32); + if (!(src->flags & IR3_REG_IMMED)) + iassert_type(src, type_size(instr->cat1.src_type) == 32); if (src->flags & IR3_REG_IMMED) { cat1->iim_val = src->iim_val; @@ -425,7 +427,7 @@ static int emit_cat5(struct ir3_instruction *instr, void *ptr, struct ir3_register *src3 = instr->regs[3]; instr_cat5_t *cat5 = ptr; - iassert(!((dst->flags ^ type_flags(instr->cat5.type)) & IR3_REG_HALF)); + iassert_type(dst, type_size(instr->cat5.type) == 32) assume(src1 || !src2); assume(src2 || !src3); @@ -477,6 +479,7 @@ static int emit_cat6(struct ir3_instruction *instr, void *ptr, { struct ir3_register *dst, *src1, *src2; instr_cat6_t *cat6 = ptr; + bool type_full = type_size(instr->cat6.type) == 32; cat6->type = instr->cat6.type; cat6->opc = instr->opc; @@ -485,6 +488,36 @@ static int emit_cat6(struct ir3_instruction *instr, void *ptr, cat6->g = !!(instr->flags & IR3_INSTR_G); cat6->opc_cat = 6; + switch (instr->opc) { + case OPC_RESINFO: + case OPC_RESFMT: + iassert_type(instr->regs[0], type_full); /* dst */ + iassert_type(instr->regs[1], type_full); /* src1 */ + break; + case OPC_L2G: + case OPC_G2L: + iassert_type(instr->regs[0], true); /* dst */ + iassert_type(instr->regs[1], true); /* src1 */ + break; + case OPC_STG: + case OPC_STL: + case OPC_STP: + case OPC_STI: + case OPC_STLW: + case OPC_STIB: + /* no dst, so regs[0] is dummy */ + iassert_type(instr->regs[1], true); /* dst */ + iassert_type(instr->regs[2], type_full); /* src1 */ + iassert_type(instr->regs[3], true); /* src2 */ + break; + default: + iassert_type(instr->regs[0], type_full); /* dst */ + iassert_type(instr->regs[1], true); /* src1 */ + if (instr->regs_count > 2) + iassert_type(instr->regs[2], true); /* src1 */ + break; + } + /* the "dst" for a store instruction is (from the perspective * of data flow in the shader, ie. register use/def, etc) in * fact a register that is read by the instruction, rather @@ -628,7 +661,7 @@ static int emit_cat6(struct ir3_instruction *instr, void *ptr, cat6->src_off = false; - cat6b->src1 = reg(src1, info, instr->repeat, IR3_REG_IMMED); + cat6b->src1 = reg(src1, info, instr->repeat, IR3_REG_IMMED | IR3_REG_HALF); cat6b->src1_im = !!(src1->flags & IR3_REG_IMMED); if (src2) { cat6b->src2 = reg(src2, info, instr->repeat, IR3_REG_IMMED); |