• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* -*- mesa-c++  -*-
2  *
3  * Copyright (c) 2022 Collabora LTD
4  *
5  * Author: Gert Wollny <gert.wollny@collabora.com>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * on the rights to use, copy, modify, merge, publish, distribute, sub
11  * license, and/or sell copies of the Software, and to permit persons to whom
12  * the Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the next
15  * paragraph) shall be included in all copies or substantial portions of the
16  * Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24  * USE OR OTHER DEALINGS IN THE SOFTWARE.
25  */
26 
27 #ifndef ALUGROUP_H
28 #define ALUGROUP_H
29 
30 #include "sfn_alu_readport_validation.h"
31 #include "sfn_instr_alu.h"
32 
33 namespace r600 {
34 
35 class AluGroup : public Instr {
36 public:
37    using Slots = std::array<AluInstr *, 5>;
38 
39    AluGroup();
40 
41    using iterator = Slots::iterator;
42    using const_iterator = Slots::const_iterator;
43 
44    bool add_instruction(AluInstr *instr);
45    bool add_trans_instructions(AluInstr *instr);
46    bool add_vec_instructions(AluInstr *instr);
47 
48    bool is_equal_to(const AluGroup& other) const;
49 
50    void accept(ConstInstrVisitor& visitor) const override;
51    void accept(InstrVisitor& visitor) override;
52 
begin()53    auto begin() { return m_slots.begin(); }
end()54    auto end() { return m_slots.begin() + s_max_slots; }
begin()55    auto begin() const { return m_slots.begin(); }
end()56    auto end() const { return m_slots.begin() + s_max_slots; }
57 
end_group()58    bool end_group() const override { return true; }
59 
60    void set_scheduled() override;
61    bool replace_source(PRegister old_src, PVirtualValue new_src) override;
62 
set_nesting_depth(int depth)63    void set_nesting_depth(int depth) { m_nesting_depth = depth; }
64 
65    void fix_last_flag();
66 
67    static void set_chipclass(r600_chip_class chip_class);
68 
69    int free_slots() const;
70 
addr()71    auto addr() const { return std::make_pair(m_addr_used, m_addr_is_index); }
72 
73    uint32_t slots() const override;
74 
75    AluInstr::SrcValues get_kconsts() const;
76 
has_lds_group_start()77    bool has_lds_group_start() const
78    {
79       return m_slots[0] ? m_slots[0]->has_alu_flag(alu_lds_group_start) : false;
80    }
81 
82    bool index_mode_load();
83 
84    bool has_lds_group_end() const;
85 
readport_reserer()86    const auto& readport_reserer() const { return m_readports_evaluator; }
set_readport_reserer(const AluReadportReservation & rr)87    void set_readport_reserer(const AluReadportReservation& rr)
88    {
89       m_readports_evaluator = rr;
90    };
91 
92    void update_readport_reserver();
93 
has_t()94    static bool has_t() { return s_max_slots == 5; }
95 
addr_for_src()96    bool addr_for_src() const { return m_addr_for_src; }
has_kill_op()97    bool has_kill_op() const { return m_has_kill_op; }
98 
set_origin(AluInstr * o)99    void set_origin(AluInstr *o) { m_origin = o;}
100 
as_alu_group()101    AluGroup *as_alu_group() override { return this;}
102 
103 private:
104    void forward_set_blockid(int id, int index) override;
105    bool do_ready() const override;
106    void do_print(std::ostream& os) const override;
107 
108    bool update_indirect_access(AluInstr *instr);
109    bool try_readport(AluInstr *instr, AluBankSwizzle cycle);
110 
111    Slots m_slots;
112 
113    AluReadportReservation m_readports_evaluator;
114 
115    static int s_max_slots;
116    static r600_chip_class s_chip_class;
117 
118    PRegister m_addr_used{nullptr};
119 
120    int m_param_used{-1};
121 
122    int m_nesting_depth{0};
123    bool m_has_lds_op{false};
124    bool m_addr_is_index{false};
125    bool m_addr_for_src{false};
126    bool m_has_kill_op{false};
127    AluInstr *m_origin{nullptr};
128 };
129 
130 } // namespace r600
131 
132 #endif // ALUGROUP_H
133