1 /* -*- mesa-c++ -*- 2 * 3 * Copyright (c) 2018-2019 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 SFN_IFELSEINSTRUCTION_H 28 #define SFN_IFELSEINSTRUCTION_H 29 30 #include "sfn_instruction_alu.h" 31 32 namespace r600 { 33 34 class CFInstruction : public Instruction { 35 protected: 36 CFInstruction(instr_type type); 37 }; 38 39 class IfElseInstruction : public CFInstruction { 40 public: 41 IfElseInstruction(instr_type type); 42 43 }; 44 45 class IfInstruction : public IfElseInstruction { 46 public: 47 IfInstruction(AluInstruction *pred); pred()48 const AluInstruction& pred() const {return *m_pred;} 49 accept(InstructionVisitor & visitor)50 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} accept(ConstInstructionVisitor & visitor)51 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 52 53 private: 54 void do_evalue_liveness(LiverangeEvaluator& eval) const override; 55 bool is_equal_to(const Instruction& lhs) const override; 56 void do_print(std::ostream& os) const override; 57 std::shared_ptr<AluInstruction> m_pred; 58 }; 59 60 class ElseInstruction : public IfElseInstruction { 61 public: 62 ElseInstruction(IfInstruction *jump_src); 63 accept(InstructionVisitor & visitor)64 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} accept(ConstInstructionVisitor & visitor)65 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 66 67 private: 68 void do_evalue_liveness(LiverangeEvaluator& eval) const override; 69 bool is_equal_to(const Instruction& lhs) const override; 70 void do_print(std::ostream& os) const override; 71 72 IfElseInstruction *m_jump_src; 73 }; 74 75 class IfElseEndInstruction : public IfElseInstruction { 76 public: 77 IfElseEndInstruction(); 78 accept(InstructionVisitor & visitor)79 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} accept(ConstInstructionVisitor & visitor)80 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 81 82 private: 83 void do_evalue_liveness(LiverangeEvaluator& eval) const override; 84 bool is_equal_to(const Instruction& lhs) const override; 85 void do_print(std::ostream& os) const override; 86 }; 87 88 class LoopBeginInstruction: public CFInstruction { 89 public: 90 LoopBeginInstruction(); 91 accept(InstructionVisitor & visitor)92 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} accept(ConstInstructionVisitor & visitor)93 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 94 95 private: 96 void do_evalue_liveness(LiverangeEvaluator& eval) const override; 97 bool is_equal_to(const Instruction& lhs) const override; 98 void do_print(std::ostream& os) const override; 99 }; 100 101 class LoopEndInstruction: public CFInstruction { 102 public: 103 LoopEndInstruction(LoopBeginInstruction *start); 104 accept(InstructionVisitor & visitor)105 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} accept(ConstInstructionVisitor & visitor)106 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 107 108 private: 109 void do_evalue_liveness(LiverangeEvaluator& eval) const override; 110 bool is_equal_to(const Instruction& lhs) const override; 111 void do_print(std::ostream& os) const override; 112 LoopBeginInstruction *m_start; 113 }; 114 115 class LoopBreakInstruction: public CFInstruction { 116 public: 117 LoopBreakInstruction(); 118 accept(InstructionVisitor & visitor)119 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} accept(ConstInstructionVisitor & visitor)120 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 121 122 private: 123 void do_evalue_liveness(LiverangeEvaluator& eval) const override; 124 bool is_equal_to(const Instruction& lhs) const override; 125 void do_print(std::ostream& os) const override; 126 }; 127 128 class LoopContInstruction: public CFInstruction { 129 public: 130 LoopContInstruction(); 131 accept(InstructionVisitor & visitor)132 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} accept(ConstInstructionVisitor & visitor)133 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 134 135 private: 136 bool is_equal_to(const Instruction& lhs) const override; 137 void do_print(std::ostream& os) const override; 138 }; 139 140 } 141 142 #endif // SFN_IFELSEINSTRUCTION_H 143