3 * Copyright (c) 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_EXPORTINSTRUCTION_H
28 #define SFN_EXPORTINSTRUCTION_H
30 #include "sfn_instruction_base.h"
34 class WriteoutInstruction
: public Instruction
{
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
;}
40 WriteoutInstruction(instr_type t
, const GPRVector
& value
);
42 virtual void replace_values_child(const ValueSet
& candiates
, PValue new_value
);
43 virtual void remap_registers_child(std::vector
<rename_reg_pair
>& map
,
49 class ExportInstruction
: public WriteoutInstruction
{
57 ExportInstruction(unsigned loc
, const GPRVector
& value
, ExportType type
);
60 ExportType
export_type() const {return m_type
;}
62 unsigned location() const {return m_loc
;}
63 bool is_last_export() const {return m_is_last
;}
65 void update_output_map(OutputRegisterMap
& map
) const;
68 bool is_equal_to(const Instruction
& lhs
) const override
;
69 void do_print(std::ostream
& os
) const override
;
76 class WriteScratchInstruction
: public WriteoutInstruction
{
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
;}
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
;}
91 bool is_equal_to(const Instruction
& lhs
) const override
;
92 void do_print(std::ostream
& os
) const override
;
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
;
101 unsigned m_align_offset
;
102 unsigned m_writemask
;
107 class StreamOutIntruction
: public WriteoutInstruction
{
109 StreamOutIntruction(const GPRVector
& value
, int num_components
,
110 int array_base
, int comp_mask
, int out_buffer
,
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
;}
120 bool is_equal_to(const Instruction
& lhs
) const override
;
121 void do_print(std::ostream
& os
) const override
;
136 mem_write_ind_ack
= 3,
139 class MemRingOutIntruction
: public WriteoutInstruction
{
142 MemRingOutIntruction(ECFOpCode ring
, EMemWriteType type
,
143 const GPRVector
& value
, unsigned base_addr
,
144 unsigned ncomp
, PValue m_index
);
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
;
156 bool is_equal_to(const Instruction
& lhs
) const override
;
157 void do_print(std::ostream
& os
) const override
;
160 EMemWriteType m_type
;
161 unsigned m_base_address
;
170 #endif // SFN_EXPORTINSTRUCTION_H