• 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 LDSINSTR_H
28 #define LDSINSTR_H
29 
30 #include "sfn_instr_alu.h"
31 #include "sfn_valuefactory.h"
32 
33 namespace r600 {
34 
35 class LDSReadInstr : public Instr {
36 public:
37    LDSReadInstr(std::vector<PRegister, Allocator<PRegister>>& value,
38                 AluInstr::SrcValues& address);
39 
num_values()40    unsigned num_values() const { return m_dest_value.size(); }
address(unsigned i)41    auto address(unsigned i) const { return m_address[i]; }
dest(unsigned i)42    auto dest(unsigned i) const { return m_dest_value[i]; }
43 
address(unsigned i)44    auto address(unsigned i) { return m_address[i]; }
dest(unsigned i)45    auto dest(unsigned i) { return m_dest_value[i]; }
46 
47    void accept(ConstInstrVisitor& visitor) const override;
48    void accept(InstrVisitor& visitor) override;
49    bool replace_dest(PRegister new_dest, AluInstr *move_instr) override;
50 
51    AluInstr *split(std::vector<AluInstr *>& out_block, AluInstr *last_lds_instr);
52 
53    bool is_equal_to(const LDSReadInstr& lhs) const;
54 
55    static auto from_string(std::istream& is, ValueFactory& value_factory) -> Pointer;
56 
57    bool remove_unused_components();
58 
59 private:
60    bool do_ready() const override;
61 
62    void do_print(std::ostream& os) const override;
63 
64    AluInstr::SrcValues m_address;
65    std::vector<PRegister, Allocator<PRegister>> m_dest_value;
66 };
67 
68 class LDSAtomicInstr : public Instr {
69 public:
70    using SrcValues = AluInstr::SrcValues;
71 
72    LDSAtomicInstr(ESDOp op, PRegister dest, PVirtualValue address, const SrcValues& src);
73 
address()74    auto address() const { return m_address; }
dest()75    auto dest() const { return m_dest; }
src0()76    auto src0() const { return m_srcs[0]; }
src1()77    auto src1() const { return m_srcs.size() > 1 ? m_srcs[1] : nullptr; }
78 
address()79    PVirtualValue address() { return m_address; }
dest()80    PRegister dest() { return m_dest; }
src0()81    PVirtualValue src0() { return m_srcs[0]; }
src1()82    PVirtualValue src1() { return m_srcs.size() > 1 ? m_srcs[1] : nullptr; }
83 
op()84    unsigned op() const { return m_opcode; }
85 
86    void accept(ConstInstrVisitor& visitor) const override;
87    void accept(InstrVisitor& visitor) override;
88 
89    AluInstr *split(std::vector<AluInstr *>& out_block, AluInstr *last_lds_instr);
90    bool is_equal_to(const LDSAtomicInstr& lhs) const;
91 
92    static auto from_string(std::istream& is, ValueFactory& value_factory) -> Pointer;
93    bool replace_source(PRegister old_src, PVirtualValue new_src) override;
94 
95 private:
96    bool do_ready() const override;
97    void do_print(std::ostream& os) const override;
98 
99    ESDOp m_opcode;
100    PVirtualValue m_address{nullptr};
101    PRegister m_dest{nullptr};
102    SrcValues m_srcs;
103 };
104 
105 } // namespace r600
106 
107 #endif // LDSINSTR_H
108