mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-25 15:40:46 +02:00
aco: introduce helper to swap valu operands with modifiers
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23059>
This commit is contained in:
parent
28e2031e3a
commit
6a53af3fc8
4 changed files with 23 additions and 17 deletions
|
|
@ -160,8 +160,7 @@ emit_instruction(asm_context& ctx, std::vector<uint32_t>& out, Instruction* inst
|
|||
instr->opcode = aco_opcode::v_fma_f16;
|
||||
instr->format = (Format)((uint32_t)instr->format & ~(uint32_t)Format::VOP2);
|
||||
} else if (instr->opcode == aco_opcode::v_fmamk_f16) {
|
||||
std::swap(instr->operands[1], instr->operands[2]);
|
||||
instr->valu().opsel[1].swap(instr->valu().opsel[2]);
|
||||
instr->valu().swapOperands(1, 2);
|
||||
instr->opcode = aco_opcode::v_fma_f16;
|
||||
instr->format = (Format)((uint32_t)instr->format & ~(uint32_t)Format::VOP2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1402,6 +1402,8 @@ struct VALU_instruction : public Instruction {
|
|||
bitfield_array8<uint32_t, 15, 3> opsel_hi; /* VOP3P */
|
||||
bitfield_bool<uint32_t, 18> clamp; /* VOP3, VOP3P, SDWA, VINTERP_inreg */
|
||||
};
|
||||
|
||||
void swapOperands(unsigned idx0, unsigned idx1);
|
||||
};
|
||||
static_assert(sizeof(VALU_instruction) == sizeof(Instruction) + 4, "Unexpected padding");
|
||||
|
||||
|
|
@ -1718,6 +1720,22 @@ struct Pseudo_reduction_instruction : public Instruction {
|
|||
static_assert(sizeof(Pseudo_reduction_instruction) == sizeof(Instruction) + 4,
|
||||
"Unexpected padding");
|
||||
|
||||
inline void
|
||||
VALU_instruction::swapOperands(unsigned idx0, unsigned idx1)
|
||||
{
|
||||
if (this->isSDWA() && idx0 != idx1) {
|
||||
assert(idx0 < 2 && idx1 < 2);
|
||||
std::swap(this->sdwa().sel[0], this->sdwa().sel[1]);
|
||||
}
|
||||
assert(idx0 < 3 && idx1 < 3);
|
||||
std::swap(this->operands[idx0], this->operands[idx1]);
|
||||
this->neg[idx0].swap(this->neg[idx1]);
|
||||
this->abs[idx0].swap(this->abs[idx1]);
|
||||
this->opsel[idx0].swap(this->opsel[idx1]);
|
||||
this->opsel_lo[idx0].swap(this->opsel_lo[idx1]);
|
||||
this->opsel_hi[idx0].swap(this->opsel_hi[idx1]);
|
||||
}
|
||||
|
||||
extern thread_local aco::monotonic_buffer_resource* instruction_buffer;
|
||||
|
||||
struct instr_deleter_functor {
|
||||
|
|
|
|||
|
|
@ -1429,9 +1429,8 @@ label_instruction(opt_ctx& ctx, aco_ptr<Instruction>& instr)
|
|||
instr->operands[i] = op;
|
||||
continue;
|
||||
} else if (!instr->isVOP3() && can_swap_operands(instr, &instr->opcode)) {
|
||||
instr->operands[i] = instr->operands[0];
|
||||
instr->operands[0] = op;
|
||||
instr->valu().opsel[0].swap(instr->valu().opsel[i]);
|
||||
instr->operands[i] = op;
|
||||
instr->valu().swapOperands(0, i);
|
||||
continue;
|
||||
} else if (can_use_VOP3(ctx, instr)) {
|
||||
instr->format = asVOP3(instr->format);
|
||||
|
|
@ -4829,12 +4828,7 @@ select_instruction(opt_ctx& ctx, aco_ptr<Instruction>& instr)
|
|||
if (i != 0) {
|
||||
if (!can_swap_operands(instr, &instr->opcode, 0, i))
|
||||
continue;
|
||||
std::swap(instr->operands[0], instr->operands[i]);
|
||||
instr->valu().neg[0].swap(instr->valu().neg[i]);
|
||||
instr->valu().abs[0].swap(instr->valu().abs[i]);
|
||||
instr->valu().opsel[0].swap(instr->valu().opsel[i]);
|
||||
instr->valu().opsel_lo[0].swap(instr->valu().opsel_lo[i]);
|
||||
instr->valu().opsel_hi[0].swap(instr->valu().opsel_hi[i]);
|
||||
instr->valu().swapOperands(0, i);
|
||||
}
|
||||
|
||||
if (!can_use_DPP(ctx.program->gfx_level, instr, info.is_dpp8()))
|
||||
|
|
|
|||
|
|
@ -522,12 +522,7 @@ try_combine_dpp(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
|
|||
if (i != 0) {
|
||||
if (!can_swap_operands(instr, &instr->opcode, 0, i))
|
||||
continue;
|
||||
std::swap(instr->operands[0], instr->operands[i]);
|
||||
instr->valu().neg[0].swap(instr->valu().neg[i]);
|
||||
instr->valu().abs[0].swap(instr->valu().abs[i]);
|
||||
instr->valu().opsel[0].swap(instr->valu().opsel[i]);
|
||||
instr->valu().opsel_lo[0].swap(instr->valu().opsel_lo[i]);
|
||||
instr->valu().opsel_hi[0].swap(instr->valu().opsel_hi[i]);
|
||||
instr->valu().swapOperands(0, i);
|
||||
}
|
||||
|
||||
if (!can_use_DPP(ctx.program->gfx_level, instr, dpp8))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue