r600/sfn: Move prepare_alu_src to sfn_fill_bytecode.cpp, rename to fill_alu_src_operands

Assisted-by: Copilot (auto mode)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41945>
This commit is contained in:
Gert Wollny 2026-04-30 18:35:38 +02:00 committed by Marge Bot
parent dfc387eb4e
commit f3cfcdae45
3 changed files with 36 additions and 32 deletions

View file

@ -63,7 +63,6 @@ public:
void clear_states(const uint32_t& states);
bool prepare_alu_dst(r600_bytecode_alu& alu, const AluInstr& ai);
void prepare_alu_src(r600_bytecode_alu& alu, const AluInstr& ai);
bool copy_dst(r600_bytecode_alu_dst& dst, const Register& d, bool write);
void emit_endif();
@ -328,7 +327,7 @@ AssemblerVisitor::emit_alu_op(const AluInstr& ai)
return;
}
prepare_alu_src(alu, ai);
fill_alu_src_operands(alu, ai, m_bc);
if (ai.has_lds_queue_read()) {
assert(m_bc.cf_last->nlds_read > 0);
@ -404,36 +403,6 @@ AssemblerVisitor::prepare_alu_dst(r600_bytecode_alu& alu, const AluInstr& ai)
return true;
}
void
AssemblerVisitor::prepare_alu_src(r600_bytecode_alu& alu, const AluInstr& ai)
{
EBufferIndexMode kcache_index_mode = bim_none;
PVirtualValue buffer_offset = nullptr;
for (unsigned i = 0; i < ai.n_sources(); ++i) {
buffer_offset = fill_alu_src(alu.src[i], ai.src(i), m_bc);
alu.src[i].neg = ai.has_source_mod(i, AluInstr::mod_neg);
if (!alu.is_op3)
alu.src[i].abs = ai.has_source_mod(i, AluInstr::mod_abs);
if (buffer_offset && kcache_index_mode == bim_none) {
auto idx_reg = buffer_offset->as_register();
if (idx_reg && idx_reg->has_flag(Register::addr_or_idx)) {
switch (idx_reg->sel()) {
case 1: kcache_index_mode = bim_zero; break;
case 2: kcache_index_mode = bim_one; break;
default:
UNREACHABLE("Unsupported index mode");
}
} else {
kcache_index_mode = bim_zero;
}
alu.src[i].kc_rel = kcache_index_mode;
}
}
}
void
AssemblerVisitor::visit(const AluGroup& group)
{

View file

@ -12,6 +12,7 @@
#include <optional>
#include "sfn_alu_defines.h"
#include "sfn_instr_alu.h"
#include "sfn_instr_export.h"
#include "sfn_instr_fetch.h"
#include "sfn_instr_mem.h"
@ -518,4 +519,33 @@ EncodeSourceVisitor::visit(const InlineConstant& value)
(void)value;
}
void
fill_alu_src_operands(r600_bytecode_alu& alu, const AluInstr& ai, r600_bytecode& bc)
{
EBufferIndexMode kcache_index_mode = bim_none;
PVirtualValue buffer_offset = nullptr;
for (unsigned i = 0; i < ai.n_sources(); ++i) {
buffer_offset = fill_alu_src(alu.src[i], ai.src(i), bc);
alu.src[i].neg = ai.has_source_mod(i, AluInstr::mod_neg);
if (!alu.is_op3)
alu.src[i].abs = ai.has_source_mod(i, AluInstr::mod_abs);
if (buffer_offset && kcache_index_mode == bim_none) {
auto idx_reg = buffer_offset->as_register();
if (idx_reg && idx_reg->has_flag(Register::addr_or_idx)) {
switch (idx_reg->sel()) {
case 1: kcache_index_mode = bim_zero; break;
case 2: kcache_index_mode = bim_one; break;
default:
UNREACHABLE("Unsupported index mode");
}
} else {
kcache_index_mode = bim_zero;
}
alu.src[i].kc_rel = kcache_index_mode;
}
}
}
} // namespace r600

View file

@ -12,6 +12,7 @@
namespace r600 {
class AluInstr;
class ExportInstr;
class FetchInstr;
class GDSInstr;
@ -50,6 +51,10 @@ PVirtualValue fill_alu_src(r600_bytecode_alu_src& src,
const VirtualValue& s,
r600_bytecode& bc);
void fill_alu_src_operands(r600_bytecode_alu& alu,
const AluInstr& ai,
r600_bytecode& bc);
} // namespace r600
#endif