r600/sfn: Handle MOVA_INT in sfn assembler
authorGert Wollny <gert.wollny@collabora.com>
Thu, 26 Jan 2023 16:11:02 +0000 (17:11 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 28 Apr 2023 13:13:54 +0000 (13:13 +0000)
To properly emit ALU clauses we have to make sure the backend doesn't
add instructions for the address emission.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21347>

src/gallium/drivers/r600/sfn/sfn_assembler.cpp
src/gallium/drivers/r600/sfn/sfn_instr_alu.h

index 0fc2cbd..3d59b73 100644 (file)
@@ -110,7 +110,7 @@ public:
    std::set<int> vtx_fetch_results;
    std::set<int> tex_fetch_results;
 
-   PRegister m_last_addr{nullptr};
+   const VirtualValue *m_last_addr{nullptr};
 
    unsigned m_max_color_exports{0};
    int m_loop_nesting{0};
@@ -288,6 +288,16 @@ AssamblerVisitor::emit_alu_op(const AluInstr& ai)
    if (m_legacy_math_rules)
        opcode = translate_for_mathrules(opcode);
 
+   if (opcode == op1_mova_int) {
+      m_bc->ar_loaded = 1;
+      m_last_addr = ai.psrc(0);
+      m_bc->ar_chan = m_last_addr->chan();
+      m_bc->ar_reg = m_last_addr->sel();
+      // TODO: this must be deducted correctly or in the scheduler
+      // we have to inject nop instructions to fix the aliasing problem
+      r600_load_ar(m_bc, true);
+   }
+
    auto hw_opcode = opcode_map.find(opcode);
 
    if (hw_opcode == opcode_map.end()) {
@@ -399,8 +409,6 @@ AssamblerVisitor::emit_alu_op(const AluInstr& ai)
 
    m_result = !r600_bytecode_add_alu_type(m_bc, &alu, type);
 
-   if (ai.opcode() == op1_mova_int)
-      m_bc->ar_loaded = 0;
 
    if (ai.opcode() == op1_set_cf_idx0)
       m_bc->index_loaded[0] = 1;
index 20b8a29..5982d70 100644 (file)
@@ -115,6 +115,7 @@ public:
 
    int dest_chan() const { return m_dest ? m_dest->chan() : m_fallback_chan; }
 
+   const VirtualValue *psrc(unsigned i) const { return i < m_src.size() ? m_src[i] : nullptr; }
    PVirtualValue psrc(unsigned i) { return i < m_src.size() ? m_src[i] : nullptr; }
    VirtualValue& src(unsigned i)
    {