Esempio n. 1
0
// renomme les registres redefini par la suite
// list est une liste de registre utilisable
void Basic_block::register_rename(list <int> list){
  // on commence par la fin
  Instruction* it = get_last_instruction();

  while(!list.empty() && it != get_first_instruction()) {
    Instruction* it2 = it->get_prev();

    if (it->get_reg_dst() != NULL) {  
      // si it écrit dans un registre
      int num = it->get_reg_dst()->get_reg();

      while (true /*it2 != get_first_instruction()*/) {
	if (it2->writes_in(num)){
	  cout << "Trouve entre i" << it->get_index() << " et i" << it2->get_index() << "\n";
	  int tmp = list.front();
	  list.pop_front();
	  // OPRegister* reg= (dynamic_cast< OPRegister * > (it->get_op1()));
	  renomme(num /*reg->get_reg() */, it, get_first_instruction(), tmp);
	  break;
	}
	  
	if(it2 == get_first_instruction())
	  break;
	it2 = it2->get_prev();
	if(it2 == get_first_instruction())
	  break;
      }
    }
    
    // Iteration
    it = it->get_prev();
  }
}
Esempio n. 2
0
/* permet de tester des choses sur un bloc de base, par exemple permet d'afficher les BB successeurs et prédécesseurs (commentaire),  là ne fait rien qu'afficher le BB */
void Basic_block::test(){
  /*  cout << "\ntest du BB " << get_index() << endl;
      display();

   
      cout << "\tnb de successeur : " << get_nb_succ() << endl;
      int nbsucc = get_nb_succ() ;
      if (nbsucc >= 1 && get_successor1())
      cout << "\tsucc1 : " << get_successor1()-> get_index();
      if (nbsucc >= 2 && get_successor2())
      cout << " \tsucc2 : " << get_successor2()-> get_index();
      cout << endl << "\tnb de predecesseurs : " << get_nb_pred() << endl ;
  
      int size=(int)_pred.size();
      for (int i = 0; i < size; i++){
      if (get_predecessor(i) != NULL)
      cout << "\tpred "<< i <<  " : " << get_predecessor(i)-> get_index() << "; ";
      }
   
      cout << endl;
  */
  
  comput_pred_succ_dep();
  for(Instruction *i = get_first_instruction() ; i != get_last_instruction() ; i=i->get_next()) {
    printf("->\t");
    i->print_succ_dep();
  }
}
Esempio n. 3
0
void Basic_block::reset_pred_succ_dep(){

  Instruction *ic=get_first_instruction();
  while (ic){
    ic -> reset_pred_succ_dep();
    ic = ic -> get_next();
  }
  dep_done = false;
  return;
}
Esempio n. 4
0
Instruction* Basic_block::get_instruction_at_index(int index){
  Instruction *inst;
   
  if(index >= get_nb_inst()){
    return NULL;
  }
   
  inst=get_first_instruction();

  for(int i=0; i<index; i++, inst=inst->get_next());

  return inst;
}