nir/opt_vectorize: Add a callback for filtering of vectorizing.
[mesa.git] / src / gallium / drivers / r600 / sfn / sfn_instruction_block.cpp
1 #include "sfn_instruction_block.h"
2
3 namespace r600 {
4
5
6 InstructionBlock::InstructionBlock(unsigned nesting_depth, unsigned block_number):
7 Instruction(block),
8 m_block_number(block_number),
9 m_nesting_depth(nesting_depth)
10 {
11 }
12
13 void InstructionBlock::emit(PInstruction instr)
14 {
15 m_block.push_back(instr);
16 }
17
18 void InstructionBlock::remap_registers(ValueRemapper& map)
19 {
20 for(auto& i: m_block)
21 i->remap_registers(map);
22 }
23
24 void InstructionBlock::do_evalue_liveness(LiverangeEvaluator& eval) const
25 {
26 for(auto& i: m_block)
27 i->evalue_liveness(eval);
28 }
29
30 bool InstructionBlock::is_equal_to(const Instruction& lhs) const
31 {
32 assert(lhs.type() == block);
33 auto& l = static_cast<const InstructionBlock&>(lhs);
34
35 if (m_block.size() != l.m_block.size())
36 return false;
37
38 if (m_block_number != l.m_block_number)
39 return false;
40
41 return std::equal(m_block.begin(), m_block.end(), l.m_block.begin(),
42 [](PInstruction ri, PInstruction li) {return *ri == *li;});
43 }
44
45 void InstructionBlock::do_print(std::ostream& os) const
46 {
47 std::string space(" ", 2 * m_nesting_depth);
48 for(auto& i: m_block)
49 os << space << *i << "\n";
50 }
51
52 }