xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/r600/sfn/sfn_instr_alugroup.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /* -*- mesa-c++  -*-
2  * Copyright 2022 Collabora LTD
3  * Author: Gert Wollny <[email protected]>
4  * SPDX-License-Identifier: MIT
5  */
6 
7 #ifndef ALUGROUP_H
8 #define ALUGROUP_H
9 
10 #include "sfn_alu_readport_validation.h"
11 #include "sfn_instr_alu.h"
12 
13 namespace r600 {
14 
15 class AluGroup : public Instr {
16 public:
17    using Slots = std::array<AluInstr *, 5>;
18 
19    AluGroup();
20 
21    using iterator = Slots::iterator;
22    using const_iterator = Slots::const_iterator;
23 
24    bool add_instruction(AluInstr *instr);
25    bool add_trans_instructions(AluInstr *instr);
26    bool add_vec_instructions(AluInstr *instr);
27 
28    bool is_equal_to(const AluGroup& other) const;
29 
30    void accept(ConstInstrVisitor& visitor) const override;
31    void accept(InstrVisitor& visitor) override;
32 
begin()33    auto begin() { return m_slots.begin(); }
end()34    auto end() { return m_slots.begin() + s_max_slots; }
begin()35    auto begin() const { return m_slots.begin(); }
end()36    auto end() const { return m_slots.begin() + s_max_slots; }
37 
end_group()38    bool end_group() const override { return true; }
39 
40    void set_scheduled() override;
41    bool replace_source(PRegister old_src, PVirtualValue new_src) override;
42 
set_nesting_depth(int depth)43    void set_nesting_depth(int depth) { m_nesting_depth = depth; }
44 
45    void fix_last_flag();
46 
47    static void set_chipclass(r600_chip_class chip_class);
48 
49    int free_slots() const;
50 
addr()51    auto addr() const { return std::make_pair(m_addr_used, m_addr_is_index); }
52 
53    uint32_t slots() const override;
54 
55    AluInstr::SrcValues get_kconsts() const;
56 
has_lds_group_start()57    bool has_lds_group_start() const
58    {
59       return m_slots[0] ? m_slots[0]->has_alu_flag(alu_lds_group_start) : false;
60    }
61 
62    bool index_mode_load();
63 
64    bool has_lds_group_end() const;
65 
readport_reserer()66    const auto& readport_reserer() const { return m_readports_evaluator; }
set_readport_reserer(const AluReadportReservation & rr)67    void set_readport_reserer(const AluReadportReservation& rr)
68    {
69       m_readports_evaluator = rr;
70    };
71 
72    void update_readport_reserver();
73 
has_t()74    static bool has_t() { return s_max_slots == 5; }
75 
addr_for_src()76    bool addr_for_src() const { return m_addr_for_src; }
has_kill_op()77    bool has_kill_op() const { return m_has_kill_op; }
78 
set_origin(AluInstr * o)79    void set_origin(AluInstr *o) { m_origin = o;}
80 
as_alu_group()81    AluGroup *as_alu_group() override { return this;}
82 
83 private:
84    void forward_set_blockid(int id, int index) override;
85    bool do_ready() const override;
86    void do_print(std::ostream& os) const override;
87 
88    bool update_indirect_access(AluInstr *instr);
89    bool try_readport(AluInstr *instr, AluBankSwizzle cycle);
90 
91    Slots m_slots;
92 
93    AluReadportReservation m_readports_evaluator;
94 
95    static int s_max_slots;
96    static r600_chip_class s_chip_class;
97 
98    PRegister m_addr_used{nullptr};
99 
100    int m_param_used{-1};
101 
102    int m_nesting_depth{0};
103    bool m_has_lds_op{false};
104    bool m_addr_is_index{false};
105    bool m_addr_for_src{false};
106    bool m_has_kill_op{false};
107    AluInstr *m_origin{nullptr};
108 };
109 
110 } // namespace r600
111 
112 #endif // ALUGROUP_H
113