• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "sfn_instruction_block.h"
2 
3 namespace r600 {
4 
5 
InstructionBlock(unsigned nesting_depth,unsigned block_number)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 
emit(PInstruction instr)13 void InstructionBlock::emit(PInstruction instr)
14 {
15    m_block.push_back(instr);
16 }
17 
remap_registers(ValueRemapper & map)18 void InstructionBlock::remap_registers(ValueRemapper& map)
19 {
20    for(auto& i: m_block)
21       i->remap_registers(map);
22 }
23 
do_evalue_liveness(LiverangeEvaluator & eval) const24 void InstructionBlock::do_evalue_liveness(LiverangeEvaluator& eval) const
25 {
26    for(auto& i: m_block)
27       i->evalue_liveness(eval);
28 }
29 
is_equal_to(const Instruction & lhs) const30 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 
last_instruction()45 PInstruction InstructionBlock::last_instruction()
46 {
47    return m_block.size() ? *m_block.rbegin() : nullptr;
48 }
49 
do_print(std::ostream & os) const50 void InstructionBlock::do_print(std::ostream& os) const
51 {
52    std::string space(" ", 2 * m_nesting_depth);
53    for(auto& i: m_block)
54       os << space << *i << "\n";
55 }
56 
57 }
58