• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
op()45    ESDOp op() const {return m_op;}
46 
src_sel()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 
src2_chan()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 
src_swizzle(int idx)63    int src_swizzle(int idx) const {assert(idx < 3); return m_src_swizzle[idx];}
64 
dest_sel()65    int dest_sel() const {
66       return m_dest.sel();
67    }
68 
dest_swizzle(int i)69    int dest_swizzle(int i) const {
70       if (i < 4)
71          return m_dest_swizzle[i];
72       return 7;
73    }
74 
set_dest_swizzle(const std::array<int,4> & swz)75    void set_dest_swizzle(const std::array<int,4>& swz) {
76       m_dest_swizzle = swz;
77    }
78 
uav_id()79    PValue uav_id() const {return m_uav_id;}
uav_base()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 
rat_id_offset()153    PValue rat_id_offset() const { return m_rat_id_offset;}
rat_id()154    int  rat_id() const { return m_rat_id;}
155 
rat_op()156    ERatOp rat_op() const {return m_rat_op;}
157 
data_gpr()158    int data_gpr() const {return m_data.sel();}
index_gpr()159    int index_gpr() const {return m_index.sel();}
elm_size()160    int elm_size() const {return m_element_size;}
161 
comp_mask()162    int comp_mask() const {return m_comp_mask;}
163 
need_ack()164    bool need_ack() const {return m_need_ack;}
burst_count()165    int burst_count() const {return m_burst_count;}
166 
167    static ERatOp opcode(nir_intrinsic_op opcode);
168 
data_swz(int chan)169    int data_swz(int chan) const {return m_data.chan_i(chan);}
170 
cf_opcode()171    ECFOpCode cf_opcode() const { return m_cf_opcode;}
172 
set_ack()173    void set_ack() {m_need_ack = true; }
174 
175 private:
176 
177    bool is_equal_to(const Instruction& lhs) const override;
178    void do_print(std::ostream& os) const override;
179 
180    ECFOpCode m_cf_opcode;
181    ERatOp m_rat_op;
182 
183    GPRVector m_data;
184    GPRVector m_index;
185 
186    int m_rat_id;
187    PValue m_rat_id_offset;
188    int m_burst_count;
189    int m_comp_mask;
190    int m_element_size;
191 
192    std::bitset<8> m_flags;
193 
194    bool m_need_ack;
195 
196 };
197 
198 class GDSStoreTessFactor : public Instruction {
199 public:
200       GDSStoreTessFactor(GPRVector& value);
sel()201       int sel() const {return m_value.sel();}
chan(int i)202       int chan(int i ) const {return m_value.chan_i(i);}
203 
204       void replace_values(const ValueSet& candiates, PValue new_value) override;
205 private:
206       bool is_equal_to(const Instruction& lhs) const override;
207       void do_print(std::ostream& os) const override;
208 
209       GPRVector m_value;
210 };
211 
212 }
213 
214 #endif // SFN_GDSINSTR_H
215