summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/r600/sfn/sfn_instruction_block.cpp
blob: 212499faf8fe4e81ec384d9581551ce01be88353 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "sfn_instruction_block.h"

namespace r600 {


InstructionBlock::InstructionBlock(unsigned nesting_depth, unsigned block_number):
   Instruction(block),
   m_block_number(block_number),
   m_nesting_depth(nesting_depth)
{
}

void InstructionBlock::emit(PInstruction instr)
{
   m_block.push_back(instr);
}

void InstructionBlock::remap_registers(ValueRemapper& map)
{
   for(auto& i: m_block)
      i->remap_registers(map);
}

void InstructionBlock::do_evalue_liveness(LiverangeEvaluator& eval) const
{
   for(auto& i: m_block)
      i->evalue_liveness(eval);
}

bool InstructionBlock::is_equal_to(const Instruction& lhs) const
{
   assert(lhs.type() == block);
   auto& l = static_cast<const InstructionBlock&>(lhs);

   if (m_block.size() != l.m_block.size())
      return false;

   if (m_block_number != l.m_block_number)
      return false;

   return std::equal(m_block.begin(), m_block.end(), l.m_block.begin(),
                     [](PInstruction ri, PInstruction li) {return *ri == *li;});
}

PInstruction InstructionBlock::last_instruction()
{
   return m_block.size() ? *m_block.rbegin() : nullptr;
}

void InstructionBlock::do_print(std::ostream& os) const
{
   std::string space(" ", 2 * m_nesting_depth);
   for(auto& i: m_block)
      os << space << *i << "\n";
}

}