1 /* -*- mesa-c++ -*- 2 * Copyright 2022 Collabora LTD 3 * Author: Gert Wollny <[email protected]> 4 * SPDX-License-Identifier: MIT 5 */ 6 7 #ifndef CONTROLFLOWINSTR_H 8 #define CONTROLFLOWINSTR_H 9 10 #include "sfn_instr_alu.h" 11 12 namespace r600 { 13 14 class ControlFlowInstr : public Instr { 15 public: 16 enum CFType { 17 cf_else, 18 cf_endif, 19 cf_loop_begin, 20 cf_loop_end, 21 cf_loop_break, 22 cf_loop_continue, 23 cf_wait_ack 24 }; 25 26 ControlFlowInstr(CFType type); 27 28 ControlFlowInstr(const ControlFlowInstr& orig) = default; 29 30 bool is_equal_to(const ControlFlowInstr& lhs) const; 31 32 void accept(ConstInstrVisitor& visitor) const override; 33 void accept(InstrVisitor& visitor) override; 34 cf_type()35 CFType cf_type() const { return m_type; } 36 37 int nesting_corr() const override; 38 39 static Instr::Pointer from_string(std::string type_str); 40 end_block()41 bool end_block() const override { return true; } 42 43 int nesting_offset() const override; 44 45 private: 46 bool do_ready() const override; 47 void do_print(std::ostream& os) const override; 48 49 CFType m_type; 50 }; 51 52 class IfInstr : public Instr { 53 public: 54 IfInstr(AluInstr *pred); 55 IfInstr(const IfInstr& orig); 56 57 bool is_equal_to(const IfInstr& lhs) const; 58 59 void set_predicate(AluInstr *new_predicate); 60 predicate()61 AluInstr *predicate() const { return m_predicate; } predicate()62 AluInstr *predicate() { return m_predicate; } 63 64 uint32_t slots() const override; 65 66 void accept(ConstInstrVisitor& visitor) const override; 67 void accept(InstrVisitor& visitor) override; 68 69 bool replace_source(PRegister old_src, PVirtualValue new_src) override; 70 71 static Instr::Pointer from_string(std::istream& is, ValueFactory& value_factory, bool is_cayman); 72 end_block()73 bool end_block() const override { return true; } nesting_offset()74 int nesting_offset() const override { return 1; } 75 76 private: 77 bool do_ready() const override; 78 void do_print(std::ostream& os) const override; 79 void forward_set_blockid(int id, int index) override; 80 void forward_set_scheduled() override; 81 82 AluInstr *m_predicate; 83 }; 84 85 } // namespace r600 86 87 #endif // CONTROLFLOWINSTR_H 88