Lib/Target/Satisfy.cpp
/**
 * First pass for satisfy constraints: insert move-to-accumulator instructions
 */
First pass for satisfy constraints: insert move-to-accumulator instructions
First pass for satisfy constraints : insert move - to - accumulator instructions
Instr::List insertMoves_vc4(Instr::List &instrs) {
  assert(Platform::compiling_for_vc4());  
  Instr::List newInstrs(instrs.size() * 2);
  for (int i = 0; i < instrs.size(); i++) {
    using namespace Target::instr;
    Instr instr = instrs[i];
    if (instr.tag == ALU && instr.ALU.srcA.is_imm() &&
        instr.ALU.srcB.is_reg() && instr.ALU.srcB.reg().regfile() == REG_B) {
      newInstrs << mov(ACC0, instr.ALU.srcB)
                << instr.clone().src_b(ACC0);
    } else if (instr.tag == ALU && instr.ALU.srcB.is_imm() &&
               instr.ALU.srcA.is_reg() && instr.ALU.srcA.reg().regfile() == REG_B) {
      newInstrs << mov(ACC0, instr.ALU.srcA)
                << instr.clone().src_a(ACC0);
    } else if (hasRegFileConflict(instr)) {
       When an instruction uses two (different) registers that are mapped
       to the same register file, then remap one of them to an accumulator.
      newInstrs << mov(ACC0, instr.ALU.srcA)
                << instr.clone().src_a(ACC0);
    } else {
      newInstrs << instr;
    }
  }
  return newInstrs;
}
Instr :: List insertMoves_vc4 ( Instr :: List & instrs ) { assert ( Platform :: compiling_for_vc4 ( ) ) ; Instr :: List newInstrs ( instrs . size ( ) * 2 ) ; for ( int i = 0 ; i < instrs . size ( ) ; i ++ ) { using namespace Target :: instr ; Instr instr = instrs [ i ] ; if ( instr . tag == ALU && instr . ALU . srcA . is_imm ( ) && instr . ALU . srcB . is_reg ( ) && instr . ALU . srcB . reg ( ) . regfile ( ) == REG_B ) { newInstrs << mov ( ACC0 , instr . ALU . srcB ) << instr . clone ( ) . src_b ( ACC0 ) ; } else if ( instr . tag == ALU && instr . ALU . srcB . is_imm ( ) && instr . ALU . srcA . is_reg ( ) && instr . ALU . srcA . reg ( ) . regfile ( ) == REG_B ) { newInstrs << mov ( ACC0 , instr . ALU . srcA ) << instr . clone ( ) . src_a ( ACC0 ) ; } else if ( hasRegFileConflict ( instr ) ) { newInstrs << mov ( ACC0 , instr . ALU . srcA ) << instr . clone ( ) . src_a ( ACC0 ) ; } else { newInstrs << instr ; } } return newInstrs ; }
First pass for satisfy constraints: insert move-to-accumulator instructions
First pass for satisfy constraints : insert move - to - accumulator instructions
// Not an issue for v3d // Insert moves for an operation with a small immediate whose // register operand must reside in reg file B. // Insert moves for an operation with a small immediate whose // register operand must reside in reg file B. // Insert moves for operands that are mapped to the same reg file. // // When an instruction uses two (different) registers that are mapped // to the same register file, then remap one of them to an accumulator.