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_r600_instr_h
28 #define sfn_r600_instr_h
30 #include "sfn_value_gpr.h"
31 #include "sfn_defines.h"
33 #include "gallium/drivers/r600/r600_isa.h"
42 struct rename_reg_pair
{
48 class LiverangeEvaluator
;
54 ValueRemapper(std::vector
<rename_reg_pair
>& m
,
57 void remap(PValue
& v
);
58 void remap(GPRVector
& v
);
60 PValue
remap_one_registers(PValue
& reg
);
62 std::vector
<rename_reg_pair
>& m_map
;
67 using OutputRegisterMap
= std::map
<unsigned, const GPRVector
*>;
98 typedef std::shared_ptr
<Instruction
> Pointer
;
100 friend bool operator == (const Instruction
& lhs
, const Instruction
& rhs
);
102 Instruction(instr_type t
);
104 virtual ~Instruction();
106 instr_type
type() const { return m_type
;}
108 void print(std::ostream
& os
) const;
110 virtual void replace_values(const ValueSet
& candiates
, PValue new_value
);
112 void evalue_liveness(LiverangeEvaluator
& eval
) const;
114 void remap_registers(ValueRemapper
& map
);
118 void add_remappable_src_value(PValue
*v
);
119 void add_remappable_src_value(GPRVector
*v
);
120 void add_remappable_dst_value(PValue
*v
);
121 void add_remappable_dst_value(GPRVector
*v
);
125 virtual void do_evalue_liveness(LiverangeEvaluator
& eval
) const;
127 virtual bool is_equal_to(const Instruction
& lhs
) const = 0;
131 virtual void do_print(std::ostream
& os
) const = 0;
133 std::vector
<PValue
*> m_mappable_src_registers
;
134 std::vector
<GPRVector
*> m_mappable_src_vectors
;
135 std::vector
<PValue
*> m_mappable_dst_registers
;
136 std::vector
<GPRVector
*> m_mappable_dst_vectors
;
139 using PInstruction
=Instruction::Pointer
;
141 inline std::ostream
& operator << (std::ostream
& os
, const Instruction
& instr
)
147 bool operator == (const Instruction
& lhs
, const Instruction
& rhs
);