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 CONTROLFLOWINSTR_H 28 #define CONTROLFLOWINSTR_H 29 30 #include "sfn_instr_alu.h" 31 32 namespace r600 { 33 34 class ControlFlowInstr : public Instr { 35 public: 36 enum CFType { 37 cf_else, 38 cf_endif, 39 cf_loop_begin, 40 cf_loop_end, 41 cf_loop_break, 42 cf_loop_continue, 43 cf_wait_ack 44 }; 45 46 ControlFlowInstr(CFType type); 47 48 ControlFlowInstr(const ControlFlowInstr& orig) = default; 49 50 bool is_equal_to(const ControlFlowInstr& lhs) const; 51 52 void accept(ConstInstrVisitor& visitor) const override; 53 void accept(InstrVisitor& visitor) override; 54 cf_type()55 CFType cf_type() const { return m_type; } 56 57 int nesting_corr() const override; 58 59 static Instr::Pointer from_string(std::string type_str); 60 end_block()61 bool end_block() const override { return true; } 62 63 int nesting_offset() const override; 64 65 private: 66 bool do_ready() const override; 67 void do_print(std::ostream& os) const override; 68 69 CFType m_type; 70 }; 71 72 class IfInstr : public Instr { 73 public: 74 IfInstr(AluInstr *pred); 75 IfInstr(const IfInstr& orig); 76 77 bool is_equal_to(const IfInstr& lhs) const; 78 79 void set_predicate(AluInstr *new_predicate); 80 predicate()81 AluInstr *predicate() const { return m_predicate; } predicate()82 AluInstr *predicate() { return m_predicate; } 83 84 uint32_t slots() const override; 85 86 void accept(ConstInstrVisitor& visitor) const override; 87 void accept(InstrVisitor& visitor) override; 88 89 bool replace_source(PRegister old_src, PVirtualValue new_src) override; 90 91 static Instr::Pointer from_string(std::istream& is, ValueFactory& value_factory, bool is_cayman); 92 end_block()93 bool end_block() const override { return true; } nesting_offset()94 int nesting_offset() const override { return 1; } 95 96 private: 97 bool do_ready() const override; 98 void do_print(std::ostream& os) const override; 99 void forward_set_blockid(int id, int index) override; 100 void forward_set_scheduled() override; 101 102 AluInstr *m_predicate; 103 }; 104 105 } // namespace r600 106 107 #endif // CONTROLFLOWINSTR_H 108