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 50 AluInstr *split(std::vector<AluInstr *>& out_block, AluInstr *last_lds_instr); 51 bool is_equal_to(const LDSReadInstr& lhs) const; 52 53 static auto from_string(std::istream& is, ValueFactory& value_factory) -> Pointer; 54 55 bool remove_unused_components(); 56 57 private: 58 59 bool do_ready() const override; 60 61 void do_print(std::ostream& os) const override; 62 63 AluInstr::SrcValues m_address; 64 std::vector<PRegister, Allocator<PRegister>> m_dest_value; 65 }; 66 67 class LDSAtomicInstr : public Instr { 68 public: 69 using SrcValues = AluInstr::SrcValues; 70 71 LDSAtomicInstr(ESDOp op, PRegister dest, PVirtualValue address, const SrcValues& src); 72 address()73 auto address() const { return m_address;} dest()74 auto dest() const { return m_dest;} src0()75 auto src0() const { return m_srcs[0];} src1()76 auto src1() const { return m_srcs.size() > 1 ? m_srcs[1] : nullptr;} 77 address()78 PVirtualValue address() { return m_address;} dest()79 PRegister dest() { return m_dest;} src0()80 PVirtualValue src0() { return m_srcs[0];} src1()81 PVirtualValue src1() { return m_srcs.size() > 1 ? m_srcs[1] : nullptr;} 82 op()83 unsigned op() const {return m_opcode;} 84 85 void accept(ConstInstrVisitor& visitor) const override; 86 void accept(InstrVisitor& visitor) override; 87 88 AluInstr *split(std::vector<AluInstr *>& out_block, AluInstr *last_lds_instr); 89 bool is_equal_to(const LDSAtomicInstr& lhs) const; 90 91 static auto from_string(std::istream& is, ValueFactory& value_factory) -> Pointer; 92 bool replace_source(PRegister old_src, PVirtualValue new_src) override; 93 94 private: 95 bool do_ready() const override; 96 void do_print(std::ostream& os) const override; 97 98 ESDOp m_opcode; 99 PVirtualValue m_address{nullptr}; 100 PRegister m_dest{nullptr}; 101 SrcValues m_srcs; 102 }; 103 104 } 105 106 #endif // LDSINSTR_H 107