• 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_INSTRUCTION_FETCH_H
28 #define SFN_INSTRUCTION_FETCH_H
29 
30 #include "sfn_instruction_base.h"
31 
32 namespace r600 {
33 
34 class FetchInstruction : public Instruction {
35 public:
36 
37    FetchInstruction(EVFetchInstr vc_opcode,
38                     EVFetchType fetch_type,
39                     EVTXDataFormat data_format,
40                     EVFetchNumFormat num_format,
41                     EVFetchEndianSwap endian_swap,
42                     const PValue src,
43                     const GPRVector dst,
44                     uint32_t offset,
45                     bool is_mega_fetch,
46                     uint32_t mega_fetch_count,
47                     uint32_t buffer_id,
48                     uint32_t semantic_id,
49 
50                     EBufferIndexMode buffer_index_mode,
51                     bool uncached,
52                     bool indexed,
53                     int array_base,
54                     int array_size,
55                     int elm_size,
56                     PValue buffer_offset,
57                     const std::array<int, 4>& dest_swizzle);
58 
59    FetchInstruction(EVFetchInstr op,
60                     EVFetchType type,
61                     GPRVector dst,
62                     PValue src, int offset,
63                     int buffer_id, PValue buffer_offset,
64                     EBufferIndexMode cp_rel,
65                     bool use_const_field = false);
66 
67    FetchInstruction(GPRVector dst,
68                     PValue src,
69                     int buffer_id,
70                     PValue buffer_offset,
71                     EVTXDataFormat format,
72                     EVFetchNumFormat num_format);
73 
74    FetchInstruction(GPRVector dst,
75                     PValue src,
76                     int buffer_id,
77                     EBufferIndexMode cp_rel);
78 
79    FetchInstruction(GPRVector dst, PValue src, int scratch_size);
80 
81    void replace_values(const ValueSet& candiates, PValue new_value) override;
vc_opcode()82    EVFetchInstr vc_opcode() const { return m_vc_opcode;}
fetch_type()83    EVFetchType fetch_type() const { return m_fetch_type;}
84 
data_format()85    EVTXDataFormat data_format() const { return m_data_format;}
num_format()86    EVFetchNumFormat num_format() const { return m_num_format;}
endian_swap()87    EVFetchEndianSwap endian_swap() const { return m_endian_swap;}
88 
src()89    const Value& src() const { return *m_src;}
dst()90    const GPRVector& dst() const { return m_dst;}
offset()91    uint32_t offset() const { return m_offset;}
92 
is_mega_fetchconst()93    bool is_mega_fetchconst() { return m_is_mega_fetch;}
mega_fetch_count()94    uint32_t mega_fetch_count() const { return m_mega_fetch_count;}
95 
buffer_id()96    uint32_t buffer_id() const { return m_buffer_id;}
semantic_id()97    uint32_t semantic_id() const { return m_semantic_id;}
buffer_index_mode()98    EBufferIndexMode buffer_index_mode() const{ return m_buffer_index_mode;}
99 
is_signed()100    bool is_signed() const { return m_flags.test(vtx_format_comp_signed);}
use_const_fields()101    bool use_const_fields() const { return m_flags.test(vtx_use_const_field);}
102 
srf_mode_no_zero()103    bool srf_mode_no_zero() const { return m_flags.test(vtx_srf_mode);}
104 
set_flag(EVFetchFlagShift flag)105    void set_flag(EVFetchFlagShift flag) {m_flags.set(flag);}
106 
uncached()107    bool uncached() const {return m_uncached; }
indexed()108    bool indexed() const {return m_indexed; }
array_base()109    int array_base()const {return m_array_base; }
array_size()110    int array_size() const {return m_array_size; }
elm_size()111    int elm_size() const {return m_elm_size; }
112 
set_buffer_offset(PValue buffer_offset)113    void set_buffer_offset(PValue buffer_offset) {
114       m_buffer_offset = buffer_offset;
115       add_remappable_src_value(&m_buffer_offset);
116    }
buffer_offset()117    PValue buffer_offset() const { return m_buffer_offset; }
118 
119    void set_dest_swizzle(const std::array<int,4>& swz);
120    void set_format(EVTXDataFormat fmt);
121 
swz(int idx)122    int swz(int idx) const { return m_dest_swizzle[idx];}
123 
use_tc()124    bool use_tc() const {return m_flags.test(vtx_use_tc);}
125 
use_vpm()126    bool use_vpm() const {return m_flags.test(vtx_vpm);}
127 
128    void prelude_append(Instruction *instr);
129 
130    const std::vector<PInstruction>& prelude() const;
131 
has_prelude()132    bool has_prelude() const {return !m_prelude.empty();}
133 
134 private:
135    bool is_equal_to(const Instruction& lhs) const override;
136    void do_print(std::ostream& os) const override;
137 
138    EVFetchInstr m_vc_opcode;
139    EVFetchType m_fetch_type;
140 
141    EVTXDataFormat m_data_format;
142    EVFetchNumFormat m_num_format;
143    EVFetchEndianSwap m_endian_swap;
144 
145    PValue m_src;
146    GPRVector m_dst;
147    uint32_t m_offset;
148 
149    bool m_is_mega_fetch;
150    uint32_t m_mega_fetch_count;
151 
152    uint32_t m_buffer_id;
153    uint32_t m_semantic_id;
154 
155    EBufferIndexMode m_buffer_index_mode;
156    std::bitset<16> m_flags;
157    bool m_uncached;
158    bool m_indexed;
159    int m_array_base;
160    int m_array_size;
161    int m_elm_size;
162    PValue m_buffer_offset;
163    std::array<int, 4> m_dest_swizzle;
164    std::vector<PInstruction> m_prelude;
165 };
166 
167 class LoadFromScratch: public FetchInstruction {
168 public:
169    LoadFromScratch(GPRVector dst, PValue src, int scratch_size);
170 };
171 
172 class FetchGDSOpResult : public FetchInstruction {
173 public:
174    FetchGDSOpResult(const GPRVector dst, const PValue src);
175 };
176 
177 class FetchTCSIOParam : public FetchInstruction {
178 public:
179    FetchTCSIOParam(GPRVector dst, PValue src, int offset);
180 };
181 
182 }
183 
184 #endif // SFN_INSTRUCTION_FETCH_H
185