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 32namespace r600 { 33 34class CFInstruction : public Instruction { 35protected: 36 CFInstruction(instr_type type); 37}; 38 39class IfElseInstruction : public CFInstruction { 40public: 41 IfElseInstruction(instr_type type); 42 43}; 44 45class IfInstruction : public IfElseInstruction { 46public: 47 IfInstruction(AluInstruction *pred); 48 const AluInstruction& pred() const {return *m_pred;} 49 50 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} 51 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 52 53private: 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 60class ElseInstruction : public IfElseInstruction { 61public: 62 ElseInstruction(IfInstruction *jump_src); 63 64 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} 65 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 66 67private: 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 75class IfElseEndInstruction : public IfElseInstruction { 76public: 77 IfElseEndInstruction(); 78 79 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} 80 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 81 82private: 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 88class LoopBeginInstruction: public CFInstruction { 89public: 90 LoopBeginInstruction(); 91 92 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} 93 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 94 95private: 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 101class LoopEndInstruction: public CFInstruction { 102public: 103 LoopEndInstruction(LoopBeginInstruction *start); 104 105 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} 106 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 107 108private: 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 115class LoopBreakInstruction: public CFInstruction { 116public: 117 LoopBreakInstruction(); 118 119 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} 120 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 121 122private: 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 128class LoopContInstruction: public CFInstruction { 129public: 130 LoopContInstruction(); 131 132 bool accept(InstructionVisitor& visitor) override {return visitor.visit(*this);} 133 bool accept(ConstInstructionVisitor& visitor) const override {return visitor.visit(*this);} 134 135private: 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