nir/opt_vectorize: Add a callback for filtering of vectorizing.
[mesa.git] / src / gallium / drivers / r600 / sfn / sfn_instruction_export.h
1 /* -*- mesa-c++ -*-
2 *
3 * Copyright (c) 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_EXPORTINSTRUCTION_H
28 #define SFN_EXPORTINSTRUCTION_H
29
30 #include "sfn_instruction_base.h"
31
32 namespace r600 {
33
34 class WriteoutInstruction: public Instruction {
35 public:
36 void replace_values(const ValueSet& candiates, PValue new_value) override;
37 const GPRVector& gpr() const {return m_value;}
38 const GPRVector *gpr_ptr() const {return &m_value;}
39 protected:
40 WriteoutInstruction(instr_type t, const GPRVector& value);
41 private:
42 virtual void replace_values_child(const ValueSet& candiates, PValue new_value);
43 virtual void remap_registers_child(std::vector<rename_reg_pair>& map,
44 ValueMap& values);
45
46 GPRVector m_value;
47 };
48
49 class ExportInstruction : public WriteoutInstruction {
50 public:
51 enum ExportType {
52 et_pixel,
53 et_pos,
54 et_param
55 };
56
57 ExportInstruction(unsigned loc, const GPRVector& value, ExportType type);
58 void set_last();
59
60 ExportType export_type() const {return m_type;}
61
62 unsigned location() const {return m_loc;}
63 bool is_last_export() const {return m_is_last;}
64
65 void update_output_map(OutputRegisterMap& map) const;
66
67 private:
68 bool is_equal_to(const Instruction& lhs) const override;
69 void do_print(std::ostream& os) const override;
70
71 ExportType m_type;
72 unsigned m_loc;
73 bool m_is_last;
74 };
75
76 class WriteScratchInstruction : public WriteoutInstruction {
77 public:
78
79 WriteScratchInstruction(unsigned loc, const GPRVector& value, int align,
80 int align_offset, int writemask);
81 WriteScratchInstruction(const PValue& address, const GPRVector& value,
82 int align, int align_offset, int writemask, int array_size);
83 unsigned location() const {return m_loc;}
84
85 int write_mask() const { return m_writemask;}
86 int address() const { assert(m_address); return m_address->sel();}
87 bool indirect() const { return !!m_address;}
88 int array_size() const { return m_array_size;}
89
90 private:
91 bool is_equal_to(const Instruction& lhs) const override;
92 void do_print(std::ostream& os) const override;
93
94 void replace_values_child(const ValueSet& candiates, PValue new_value) override;
95 void remap_registers_child(std::vector<rename_reg_pair>& map,
96 ValueMap& values)override;
97
98 unsigned m_loc;
99 PValue m_address;
100 unsigned m_align;
101 unsigned m_align_offset;
102 unsigned m_writemask;
103 int m_array_size;
104 };
105
106
107 class StreamOutIntruction: public WriteoutInstruction {
108 public:
109 StreamOutIntruction(const GPRVector& value, int num_components,
110 int array_base, int comp_mask, int out_buffer,
111 int stream);
112 int element_size() const { return m_element_size;}
113 int burst_count() const { return m_burst_count;}
114 int array_base() const { return m_array_base;}
115 int array_size() const { return m_array_size;}
116 int comp_mask() const { return m_writemask;}
117 unsigned op() const;
118
119 private:
120 bool is_equal_to(const Instruction& lhs) const override;
121 void do_print(std::ostream& os) const override;
122
123 int m_element_size;
124 int m_burst_count;
125 int m_array_base;
126 int m_array_size;
127 int m_writemask;
128 int m_output_buffer;
129 int m_stream;
130 };
131
132 enum EMemWriteType {
133 mem_write = 0,
134 mem_write_ind = 1,
135 mem_write_ack = 2,
136 mem_write_ind_ack = 3,
137 };
138
139 class MemRingOutIntruction: public WriteoutInstruction {
140 public:
141
142 MemRingOutIntruction(ECFOpCode ring, EMemWriteType type,
143 const GPRVector& value, unsigned base_addr,
144 unsigned ncomp, PValue m_index);
145
146 unsigned op() const{return m_ring_op;}
147 unsigned ncomp() const;
148 unsigned addr() const {return m_base_address;}
149 EMemWriteType type() const {return m_type;}
150 unsigned index_reg() const {return m_index->sel();}
151 unsigned array_base() const {return m_base_address; }
152 void replace_values_child(const ValueSet& candiates, PValue new_value) override;
153 void remap_registers_child(std::vector<rename_reg_pair>& map,
154 ValueMap& values) override;
155 void patch_ring(int stream);
156 private:
157 bool is_equal_to(const Instruction& lhs) const override;
158 void do_print(std::ostream& os) const override;
159
160 ECFOpCode m_ring_op;
161 EMemWriteType m_type;
162 unsigned m_base_address;
163 unsigned m_num_comp;
164 PValue m_index;
165
166 };
167
168 }
169
170
171 #endif // SFN_EXPORTINSTRUCTION_H