r600/sfn: Move removing of unused variables
[mesa.git] / src / gallium / drivers / r600 / sfn / sfn_instruction_gds.h
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_GDSINSTR_H
28 #define SFN_GDSINSTR_H
29
30 #include "sfn_instruction_base.h"
31
32 #include <bitset>
33
34 namespace r600 {
35
36 class GDSInstr : public Instruction
37 {
38 public:
39 GDSInstr(ESDOp op, const GPRVector& dest, const PValue& value,
40 const PValue &uav_id, int uav_base);
41 GDSInstr(ESDOp op, const GPRVector& dest, const PValue& value,
42 const PValue& value2, const PValue &uav_id, int uav_base);
43 GDSInstr(ESDOp op, const GPRVector& dest, const PValue &uav_id, int uav_base);
44
45 ESDOp op() const {return m_op;}
46
47 int src_sel() const {
48 if (!m_src)
49 return 0;
50
51 assert(m_src->type() == Value::gpr);
52 return m_src->sel();
53 }
54
55 int src2_chan() const {
56 if (!m_src2)
57 return 0;
58
59 assert(m_src->type() == Value::gpr);
60 return m_src->chan();
61 }
62
63 int src_swizzle(int idx) const {assert(idx < 3); return m_src_swizzle[idx];}
64
65 int dest_sel() const {
66 return m_dest.sel();
67 }
68
69 int dest_swizzle(int i) const {
70 if (i < 4)
71 return m_dest_swizzle[i];
72 return 7;
73 }
74
75 void set_dest_swizzle(const std::array<int,4>& swz) {
76 m_dest_swizzle = swz;
77 }
78
79 PValue uav_id() const {return m_uav_id;}
80 int uav_base() const {return m_uav_base;}
81
82 private:
83
84 bool is_equal_to(const Instruction& lhs) const override;
85 void do_print(std::ostream& os) const override;
86
87 ESDOp m_op;
88
89 PValue m_src;
90 PValue m_src2;
91 GPRVector m_dest;
92 std::array <int, 4> m_dest_swizzle;
93 std::array <int, 3> m_src_swizzle;
94
95 EBufferIndexMode m_buffer_index_mode;
96 PValue m_uav_id;
97 int m_uav_base;
98 std::bitset<8> m_flags;
99
100 };
101
102 class RatInstruction : public Instruction {
103
104 public:
105 enum ERatOp {
106 NOP,
107 STORE_TYPED,
108 STORE_RAW,
109 STORE_RAW_FDENORM,
110 CMPXCHG_INT,
111 CMPXCHG_FLT,
112 CMPXCHG_FDENORM,
113 ADD,
114 SUB,
115 RSUB,
116 MIN_INT,
117 MIN_UINT,
118 MAX_INT,
119 MAX_UINT,
120 AND,
121 OR,
122 XOR,
123 MSKOR,
124 INC_UINT,
125 DEC_UINT,
126 NOP_RTN = 32,
127 XCHG_RTN = 34,
128 XCHG_FDENORM_RTN,
129 CMPXCHG_INT_RTN,
130 CMPXCHG_FLT_RTN,
131 CMPXCHG_FDENORM_RTN,
132 ADD_RTN,
133 SUB_RTN,
134 RSUB_RTN,
135 MIN_INT_RTN,
136 MIN_UINT_RTN,
137 MAX_INT_RTN,
138 MAX_UINT_RTN,
139 AND_RTN,
140 OR_RTN,
141 XOR_RTN,
142 MSKOR_RTN,
143 UINT_RTN,
144 UNSUPPORTED
145 };
146
147 RatInstruction(ECFOpCode cf_opcode, ERatOp rat_op,
148 const GPRVector& data, const GPRVector& index,
149 int rat_id, const PValue& rat_id_offset,
150 int burst_count, int comp_mask, int element_size,
151 bool ack);
152
153 PValue rat_id_offset() const { return m_rat_id_offset;}
154
155 ERatOp rat_op() const {return m_rat_op;}
156
157 int data_gpr() const {return m_data.sel();}
158 int index_gpr() const {return m_index.sel();}
159 int elm_size() const {return m_element_size;}
160
161 int comp_mask() const {return m_comp_mask;}
162
163 bool need_ack() const {return m_need_ack;}
164 int burst_count() const {return m_burst_count;}
165
166 static ERatOp opcode(nir_intrinsic_op opcode);
167
168 int data_swz(int chan) const {return m_data.chan_i(chan);}
169
170 private:
171
172 bool is_equal_to(const Instruction& lhs) const override;
173 void do_print(std::ostream& os) const override;
174
175 ECFOpCode m_cf_opcode;
176 ERatOp m_rat_op;
177
178 GPRVector m_data;
179 GPRVector m_index;
180
181 int m_rat_id;
182 PValue m_rat_id_offset;
183 int m_burst_count;
184 int m_comp_mask;
185 int m_element_size;
186
187 std::bitset<8> m_flags;
188
189 bool m_need_ack;
190
191 };
192
193 class GDSStoreTessFactor : public Instruction {
194 public:
195 GDSStoreTessFactor(GPRVector& value);
196 int sel() const {return m_value.sel();}
197 int chan(int i ) const {return m_value.chan_i(i);}
198
199 void replace_values(const ValueSet& candiates, PValue new_value) override;
200 private:
201 bool is_equal_to(const Instruction& lhs) const override;
202 void do_print(std::ostream& os) const override;
203
204 GPRVector m_value;
205 };
206
207 }
208
209 #endif // SFN_GDSINSTR_H