3 * Copyright (c) 2018-2019 Collabora LTD
5 * Author: Gert Wollny <gert.wollny@collabora.com>
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:
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
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.
27 #ifndef SFN_GDSINSTR_H
28 #define SFN_GDSINSTR_H
30 #include "sfn_instruction_base.h"
36 class GDSInstr
: public Instruction
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
);
45 ESDOp
op() const {return m_op
;}
51 assert(m_src
->type() == Value::gpr
);
55 int src2_chan() const {
59 assert(m_src
->type() == Value::gpr
);
63 int src_swizzle(int idx
) const {assert(idx
< 3); return m_src_swizzle
[idx
];}
65 int dest_sel() const {
69 int dest_swizzle(int i
) const {
71 return m_dest_swizzle
[i
];
75 void set_dest_swizzle(const std::array
<int,4>& swz
) {
79 PValue
uav_id() const {return m_uav_id
;}
80 int uav_base() const {return m_uav_base
;}
84 bool is_equal_to(const Instruction
& lhs
) const override
;
85 void do_print(std::ostream
& os
) const override
;
92 std::array
<int, 4> m_dest_swizzle
;
93 std::array
<int, 3> m_src_swizzle
;
95 EBufferIndexMode m_buffer_index_mode
;
98 std::bitset
<8> m_flags
;
102 class RatInstruction
: public Instruction
{
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
,
153 PValue
rat_id_offset() const { return m_rat_id_offset
;}
154 int rat_id() const { return m_rat_id
;}
156 ERatOp
rat_op() const {return m_rat_op
;}
158 int data_gpr() const {return m_data
.sel();}
159 int index_gpr() const {return m_index
.sel();}
160 int elm_size() const {return m_element_size
;}
162 int comp_mask() const {return m_comp_mask
;}
164 bool need_ack() const {return m_need_ack
;}
165 int burst_count() const {return m_burst_count
;}
167 static ERatOp
opcode(nir_intrinsic_op opcode
);
169 int data_swz(int chan
) const {return m_data
.chan_i(chan
);}
173 bool is_equal_to(const Instruction
& lhs
) const override
;
174 void do_print(std::ostream
& os
) const override
;
176 ECFOpCode m_cf_opcode
;
183 PValue m_rat_id_offset
;
188 std::bitset
<8> m_flags
;
194 class GDSStoreTessFactor
: public Instruction
{
196 GDSStoreTessFactor(GPRVector
& value
);
197 int sel() const {return m_value
.sel();}
198 int chan(int i
) const {return m_value
.chan_i(i
);}
200 void replace_values(const ValueSet
& candiates
, PValue new_value
) override
;
202 bool is_equal_to(const Instruction
& lhs
) const override
;
203 void do_print(std::ostream
& os
) const override
;
210 #endif // SFN_GDSINSTR_H