r600/sfn: factor out common code for readport validation

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36860>
This commit is contained in:
Gert Wollny
2025-08-20 15:18:17 +02:00
committed by Marge Bot
parent c4a3e8981d
commit a1b7b524f8
4 changed files with 22 additions and 35 deletions
@@ -71,6 +71,22 @@ public:
void visit(const UniformValue& value) override;
};
bool
AluReadportReservation::update_from_sources(const std::array<PVirtualValue, 3>& src,
const unsigned int nsrc)
{
AluBankSwizzle bs = alu_vec_012;
while (bs != alu_vec_unknown) {
AluReadportReservation rpr = *this;
if (rpr.schedule_vec_src(src, nsrc, bs) == nsrc) {
*this = rpr;
return true;
}
++bs;
}
return false;
}
unsigned
AluReadportReservation::schedule_vec_src(const std::array<PVirtualValue, 3>& src,
int nsrc,
@@ -17,6 +17,9 @@ public:
AluReadportReservation(const AluReadportReservation& orig) = default;
AluReadportReservation& operator=(const AluReadportReservation& orig) = default;
bool update_from_sources(const std::array<PVirtualValue, 3>& src,
const unsigned int nsrc);
unsigned schedule_vec_src(const std::array<PVirtualValue, 3>& src,
int nsrc,
AluBankSwizzle swz);
+2 -23
View File
@@ -717,18 +717,7 @@ AluInstr::check_readport_validation(PRegister old_src, PVirtualValue new_src) co
for (unsigned i = 0; i < nsrc; ++i, ++ireg)
src[i] = old_src->equal_to(**ireg) ? new_src : *ireg;
AluBankSwizzle bs = alu_vec_012;
while (bs != alu_vec_unknown) {
AluReadportReservation rpr = rpr_sum;
if (rpr.schedule_vec_src(src, nsrc, bs) == nsrc) {
rpr_sum = rpr;
break;
}
++bs;
}
if (bs == alu_vec_unknown)
success = false;
success &= rpr_sum.update_from_sources(src, nsrc);
}
return success;
}
@@ -883,17 +872,7 @@ AluInstr::split(ValueFactory& vf, AluGroup& group)
for (unsigned i = 0; i < nsrc; ++i, ++ireg)
src[i] = *ireg;
AluBankSwizzle bs = alu_vec_012;
while (bs != alu_vec_unknown) {
AluReadportReservation rpr = rr;
if (rpr.schedule_vec_src(src, nsrc, bs) == nsrc) {
rr = rpr;
break;
}
++bs;
}
if (bs == alu_vec_unknown) {
if (!rr.update_from_sources(src, nsrc)) {
if (group.empty())
UNREACHABLE("multi-slot ALU op violated readpport configuration");
else
@@ -335,18 +335,7 @@ bool AluGroup::replace_source(PRegister old_src, PVirtualValue new_src)
return old_src->equal_to(*s) ? new_src : s;
});
AluBankSwizzle bs = alu_vec_012;
while (bs != alu_vec_unknown) {
AluReadportReservation rpr = rpr_sum;
unsigned nsrc = srcs.size();
if (rpr.schedule_vec_src(test_src, nsrc, bs) == nsrc) {
rpr_sum = rpr;
break;
}
++bs;
}
if (bs == alu_vec_unknown)
if (!rpr_sum.update_from_sources(test_src, srcs.size()))
return false;
}