• 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_instr_alu.h"
31 #include "sfn_alu_readport_validation.h"
32 
33 namespace r600 {
34 
35 class AluGroup : public Instr
36 {
37 public:
38    using Slots = std::array<AluInstr *, 5>;
39 
40    AluGroup();
41 
42    using iterator = Slots::iterator;
43    using const_iterator = Slots::const_iterator;
44 
45    bool add_instruction(AluInstr *instr);
46    bool add_trans_instructions(AluInstr *instr);
47    bool add_vec_instructions(AluInstr *instr);
48 
49    bool is_equal_to(const AluGroup& other) const;
50 
51    void accept(ConstInstrVisitor& visitor) const override;
52    void accept(InstrVisitor& visitor) override;
53 
begin()54    auto begin() {return m_slots.begin(); }
end()55    auto end() {return m_slots.begin() + s_max_slots; }
begin()56    auto begin() const {return m_slots.begin(); }
end()57    auto end() const {return m_slots.begin() + s_max_slots; }
58 
end_group()59    bool end_group() const override { return true; }
60 
61    void set_scheduled() 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 { return m_slots[0] ?
78             m_slots[0]->has_alu_flag(alu_lds_group_start) : false;}
79 
80    bool has_lds_group_end() const;
81 
readport_reserer()82    const auto& readport_reserer() const { return m_readports_evaluator; }
set_readport_reserer(const AluReadportReservation & rr)83    void set_readport_reserer(const AluReadportReservation& rr) {
84        m_readports_evaluator = rr;
85    };
86 
has_t()87    static bool has_t() { return s_max_slots == 5;}
88 
addr_for_src()89    bool addr_for_src() const { return m_addr_for_src;}
has_kill_op()90    bool has_kill_op() const {return m_has_kill_op;}
91 
92 private:
93    void forward_set_blockid(int id, int index) override;
94    bool do_ready() const override;
95    void do_print(std::ostream& os) const override;
96 
97    bool update_indirect_access(AluInstr *instr);
98    bool try_readport(AluInstr *instr, AluBankSwizzle cycle);
99 
100    Slots m_slots;
101 
102    AluReadportReservation m_readports_evaluator;
103 
104    static int s_max_slots;
105    static r600_chip_class s_chip_class;
106 
107    PRegister m_addr_used{nullptr};
108 
109    int m_param_used{-1};
110 
111    int m_nesting_depth{0};
112    bool m_has_lds_op{false};
113    bool m_addr_is_index{false};
114    bool m_addr_for_src{false};
115    bool m_has_kill_op{false};
116 };
117 
118 
119 }
120 
121 #endif // ALUGROUP_H
122