1 #include "sfn_instruction_lds.h"
5 void LDSReadInstruction::do_print(std::ostream
& os
) const
8 for (unsigned i
= 0; i
< m_address
.size(); ++i
)
9 os
<< *m_dest_value
[i
] << " ";
11 for (unsigned i
= 0; i
< m_address
.size(); ++i
)
12 os
<< *m_address
[i
] << " ";
15 LDSReadInstruction::LDSReadInstruction(std::vector
<PValue
>& address
, std::vector
<PValue
>& value
):
16 Instruction(lds_read
),
20 assert(address
.size() == value
.size());
22 for (unsigned i
= 0; i
< address
.size(); ++i
) {
23 add_remappable_src_value(&m_address
[i
]);
24 add_remappable_dst_value(&m_dest_value
[i
]);
28 void LDSReadInstruction::replace_values(const ValueSet
& candiates
, PValue new_value
)
30 for (auto& c
: candiates
) {
31 for (auto& d
: m_dest_value
) {
36 for (auto& a
: m_address
) {
43 bool LDSReadInstruction::is_equal_to(const Instruction
& lhs
) const
45 auto& other
= static_cast<const LDSReadInstruction
&>(lhs
);
46 return m_address
== other
.m_address
&&
47 m_dest_value
== other
.m_dest_value
;
50 LDSWriteInstruction::LDSWriteInstruction(PValue address
, unsigned idx_offset
, PValue value0
):
51 LDSWriteInstruction::LDSWriteInstruction(address
, idx_offset
, value0
, PValue())
56 LDSWriteInstruction::LDSWriteInstruction(PValue address
, unsigned idx_offset
, PValue value0
, PValue value1
):
57 Instruction(lds_write
),
61 m_idx_offset(idx_offset
)
63 add_remappable_src_value(&m_address
);
64 add_remappable_src_value(&m_value0
);
66 add_remappable_src_value(&m_value1
);
70 void LDSWriteInstruction::do_print(std::ostream
& os
) const
72 os
<< "LDS Write" << num_components()
73 << " " << address() << ", " << value0();
74 if (num_components() > 1)
75 os
<< ", " << value1();
78 void LDSWriteInstruction::replace_values(const ValueSet
& candiates
, PValue new_value
)
80 for (auto c
: candiates
) {
82 m_address
= new_value
;
92 bool LDSWriteInstruction::is_equal_to(const Instruction
& lhs
) const
94 auto& other
= static_cast<const LDSWriteInstruction
&>(lhs
);
99 if (*m_value1
!= *other
.m_value1
)
106 return (m_value0
!= other
.m_value0
&&
107 *m_address
!= *other
.m_address
);