Lib/Target/Satisfy.cpp
/**
 * Second pass satisfy constraints: insert NOPs
 */
Second pass satisfy constraints: insert NOPs
Second pass satisfy constraints : insert NOPs
Instr::List insertNops(Instr::List &instrs) {
  Instr::List newInstrs(instrs.size() * 2);
  Instr prev = Instr::nop();
  for (int i = 0; i < instrs.size(); i++) {
    Instr instr = instrs[i];
    For vc4, if an rf-register is set, you must wait one cycle before the value is available.
    If an rf-register is set, and used immediately in the next instruction, insert a NOP in between.
    v3d does not have this restriction.
    if (Platform::compiling_for_vc4()) {
      Reg dst = prev.dst_reg();
      if (dst.tag != NONE) {
        bool needNop = dst.tag == REG_A || dst.tag == REG_B;  rf-registers only
        if (needNop && instr.is_src_reg(dst)) {
          newInstrs << Instr::nop();
        }
      }
    }
    newInstrs << instr;                                           Put current instruction into the new sequence
    Insert NOPs in branch delay slots
    if (instr.tag == BRL || instr.tag == END) {
      for (int j = 0; j < 3; j++)
        newInstrs << Instr::nop();
      prev = Instr::nop();
    }
    if (instr.tag != LAB) prev = instr;                           Update previous instruction
  }
  return newInstrs;
}
Instr :: List insertNops ( Instr :: List & instrs ) { Instr :: List newInstrs ( instrs . size ( ) * 2 ) ; Instr prev = Instr :: nop ( ) ; for ( int i = 0 ; i < instrs . size ( ) ; i ++ ) { Instr instr = instrs [ i ] ; if ( Platform :: compiling_for_vc4 ( ) ) { Reg dst = prev . dst_reg ( ) ; if ( dst . tag != NONE ) { bool needNop = dst . tag == REG_A || dst . tag == REG_B ; if ( needNop && instr . is_src_reg ( dst ) ) { newInstrs << Instr :: nop ( ) ; } } } newInstrs << instr ; if ( instr . tag == BRL || instr . tag == END ) { for ( int j = 0 ; j < 3 ; j ++ ) newInstrs << Instr :: nop ( ) ; prev = Instr :: nop ( ) ; } if ( instr . tag != LAB ) prev = instr ; } return newInstrs ; }
Second pass satisfy constraints: insert NOPs
Second pass satisfy constraints : insert NOPs
//  // For vc4, if an rf-register is set, you must wait one cycle before the value is available. // // If an rf-register is set, and used immediately in the next instruction, insert a NOP in between. // // v3d does not have this restriction. // // rf-registers only // Put current instruction into the new sequence //  // Insert NOPs in branch delay slots // // Update previous instruction