Ejemplo n.º 1
0
int main(int argc, char * argv[]){

	if (argc < 2) {
	  cout << "erreur : pas de fichier assembleur" << endl;
	}	  
	Program prog(argv[1]);
	Function* functmp;
	list <Function*> myfunc; 
	list <Basic_block*> myBB;

	cout<<"Le programme a "<<prog.size()<<" lignes\n"<<endl;

	prog.comput_function();
	cout<<"nombre de fonctions : "<<prog.nbr_func()<<endl;

	list<Function*>::iterator itfct;
	list<Basic_block*>::iterator itbb;
	Basic_block *bb;
	int i, j;
	list<int> frees;
	Dfg *d;
	Cfg *c;
	
	std::ostringstream *oss ;
	for(itfct=prog.function_list_begin(), i=0;
	    itfct!=prog.function_list_end(); itfct++, i++){
	   functmp=*itfct;
	    cout<<"------------Function DISPLAY----------\n" <<endl;
	    functmp->display();
	   functmp->comput_basic_block();
	   functmp->comput_label();
	   functmp->comput_succ_pred_BB();
	   
	   oss=new std::ostringstream;
	   
	   (*oss)<<"./tmp/func_"<<i<<".dot";
	   c=new Cfg(functmp->get_BB(0), functmp->nbr_BB());
	   c->restitution(NULL, oss->str());
	   
	   cout<<"========== Function "<<i<<"==========="<<endl;
	   cout<<"============================"<<endl;
	   
	   functmp ->compute_live_var();
	   j=0;
	   int total1 = 0, total2 = 0, total3 = 0, total4 = 0;
	   for(itbb=functmp->bb_list_begin(); 
	       itbb!=functmp->bb_list_end(); itbb++, j++){
	      bb=*itbb;
	      bb->link_instructions();
	      bb->comput_pred_succ_dep();

	      total1 += bb->nb_cycles();
	      d = new Dfg(bb);
	      d->scheduling(false);
	      d->apply_scheduling();
	      total2 += bb->nb_cycles();

	      bb->reg_rename();
	      // il faut annuler le calcul des dépendances et le refaire
	      bb->reset_pred_succ_dep();
	      bb->comput_pred_succ_dep();
	      total3 += bb->nb_cycles();

	      d= new Dfg(bb);
	      d->scheduling(false);
	      d->apply_scheduling();

	      total4 += bb->nb_cycles();
	      //return 0;
	   }
	   printf("Nombres de cycles : \n");
	   printf(" BASIC  | SCHEDULED | RENAMED | RE-SCHEDULED\n");
	   printf("   %d   |    %d     |    %d   |     %d      \n", total1, total2, total3, total4);
	}
	    
	
	

	
}
Ejemplo n.º 2
0
int main ( int argc, char ** argv ) {

  Program p2(argv[1]) ;
  p2.display() ;
  p2.comput_function();
  cout << "nb function " << p2.nbr_func();
  Function * fct = p2.get_function(0);
  fct -> comput_basic_block();
  fct -> comput_label();
  fct -> comput_succ_pred_BB();
  if (fct -> nbr_BB() > 0) {
    Basic_block * BB = fct -> get_BB(0);
    BB ->display();
    Dfg * dfg = new Dfg(BB);
    dfg->restitute(NULL,"./tmp/graph_dfg0.dot", true);
    cout << "temps critique : "<< dfg->get_critical_path() << endl;
    
    //
    dfg->compute_nb_descendant();
    dfg->display_nb_descendant();
    dfg->scheduling();
    dfg->display_sheduled_instr();
    cout << "temps critique scheduler : " << dfg->nb_cycles2() << "\n\n\n";
    //
    
  }
  if (fct -> nbr_BB()  > 1){
    Basic_block * BB = fct -> get_BB(1);
    BB ->display();
    Dfg *  dfg = new Dfg(BB);
    dfg->restitute(NULL,"./tmp/graph_dfg1.dot", true);
    cout << "temps critique : "<< dfg->get_critical_path() << endl;
    
  }
  if (fct -> nbr_BB()  > 2){
    Basic_block * BB = fct -> get_BB(2);
    BB ->display();
    Dfg *  dfg = new Dfg(BB);
    dfg->restitute(NULL,"./tmp/graph_dfg2.dot", true);
    cout << "temps critique : "<< dfg->get_critical_path() << endl;
  }
}