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_r600_instruction_alu_h
28 #define sfn_r600_instruction_alu_h
30 #include "sfn_instruction_base.h"
31 #include "sfn_alu_defines.h"
53 enum AluDstModifiers
{
80 class AluInstruction
: public Instruction
{
83 static const AluModifiers src_abs_flags
[2];
84 static const AluModifiers src_neg_flags
[3];
85 static const AluModifiers src_rel_flags
[3];
87 AluInstruction(EAluOp opcode
);
88 AluInstruction(EAluOp opcode
, PValue dest
,
89 std::vector
<PValue
> src0
,
90 const std::set
<AluModifiers
>& m_flags
);
92 AluInstruction(EAluOp opcode
, PValue dest
, PValue src0
,
93 const std::set
<AluModifiers
>& m_flags
);
95 AluInstruction(EAluOp opcode
, PValue dest
,
96 PValue src0
, PValue src1
,
97 const std::set
<AluModifiers
>& m_flags
);
99 AluInstruction(EAluOp opcode
, PValue dest
, PValue src0
, PValue src1
,
101 const std::set
<AluModifiers
>& m_flags
);
104 void set_flag(AluModifiers flag
);
105 unsigned n_sources() const;
107 PValue
dest() {return m_dest
;}
108 EAluOp
opcode() const {return m_opcode
;}
109 const Value
*dest() const {return m_dest
.get();}
110 Value
& src(unsigned i
) const {assert(i
< m_src
.size() && m_src
[i
]); return *m_src
[i
];}
111 PValue
*psrc(unsigned i
) {assert(i
< m_src
.size()); return &m_src
[i
];}
112 bool is_last() const {return m_flags
.test(alu_last_instr
);}
113 bool write() const {return m_flags
.test(alu_write
);}
114 bool flag(AluModifiers f
) const {return m_flags
.test(f
);}
115 void set_bank_swizzle(AluBankSwizzle swz
);
116 int bank_swizzle() const {return m_bank_swizzle
;}
117 ECFAluOpCode
cf_type() const {return m_cf_type
;}
118 void set_cf_type(ECFAluOpCode cf_type
){ m_cf_type
= cf_type
; }
120 void replace_values(const ValueSet
& candiates
, PValue new_value
) override
;
124 bool is_equal_to(const Instruction
& lhs
) const override
;
125 void do_print(std::ostream
& os
) const override
;
126 PValue
remap_one_registers(PValue reg
, std::vector
<rename_reg_pair
>& map
,
132 std::vector
<PValue
> m_src
;
134 AluDstModifiers m_omod
;
135 AluPredSel m_pred_sel
;
136 AluBankSwizzle m_bank_swizzle
;
137 ECFAluOpCode m_cf_type
;