• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
36 public:
37    enum CFType {
38       cf_else,
39       cf_endif,
40       cf_loop_begin,
41       cf_loop_end,
42       cf_loop_break,
43       cf_loop_continue,
44       cf_stream_write,
45       cf_wait_ack
46    };
47 
48    ControlFlowInstr(CFType type);
49 
50    ControlFlowInstr(const ControlFlowInstr& orig) = default;
51 
52    bool is_equal_to(const ControlFlowInstr& lhs) const;
53 
54    void accept(ConstInstrVisitor& visitor) const override;
55    void accept(InstrVisitor& visitor) override;
56 
cf_type()57    CFType cf_type() const { return m_type;}
58 
59    int nesting_corr() const override;
60 
61    static Instr::Pointer from_string(std::string type_str);
62 
end_block()63    bool end_block() const override { return true;}
64 
65    int nesting_offset() const override;
66 
67 private:
68    bool do_ready() const override;
69    void do_print(std::ostream& os) const override;
70 
71    CFType m_type;
72 };
73 
74 class IfInstr : public Instr {
75 public:
76 
77    IfInstr(AluInstr *pred);
78    IfInstr(const IfInstr& orig);
79 
80    bool is_equal_to(const IfInstr& lhs) const;
81 
82    void set_predicate(AluInstr *new_predicate);
83 
predicate()84    AluInstr *predicate() const { return m_predicate; }
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);
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 }
106 
107 #endif // CONTROLFLOWINSTR_H
108