void Function::comput_basic_block(){ Node *debut, *current, *prev; current=_head; debut=_head; prev = NULL; int ind=0; Line *l=NULL; Instruction *i=NULL; cout<< "comput BB" <<endl; cout<<"head :"<<_head->get_lineContent()<<endl; cout<<"tail :"<<_end->get_lineContent()<<endl; // A REMPLIR while(current != NULL) { l = current->get_line(); if(l->type_line() == line_Instru) break; current = current->get_next(); } debut = current; while(current != _end) { l = current->get_line(); if(l->type_line() == line_Lab) { if(prev->get_next() != debut) { add_BB(debut, prev, ind++); debut = current; } } else if(l->type_line() == line_Instru) { i = (dynamic_cast< Instruction * > (l)); if(i->get_type() == BR) { add_BB(debut, current->get_next(), ind++); current = current->get_next(); debut = current->get_next(); } } prev = current; current = current->get_next(); } cout<<"end comput BB"<<endl; }
void Function::comput_basic_block(){ Line *debut, *current, *prev; current=_head; debut=_head; prev = NULL; int ind=0; Line *l=NULL; Instruction *i=NULL; Line * b; cout<< "comput BB" <<endl; cout<<"head :"<<_head->get_content()<<endl; cout<<"tail :"<<_end->get_content()<<endl; //ne pas enlever la ligne ci-dessous if (BB_computed) return; while(current != NULL){ if(current->isLabel()){ if(prev != NULL){ if(prev->isInst()){ add_BB(debut, prev, NULL, ind); ind++; debut = current; current = current->get_next(); } prev = NULL; } else{ debut = current; current = current ->get_next(); } continue; } if(current->get_type() == BR){ if(current->get_next() != NULL && (current->get_next()->isInst())){ add_BB(debut, current->get_next(), current, ind); ind++; current = current->get_next()->get_next(); while(current != NULL) { if(current->isLabel() || current->isInst()){ break; } current = current->get_next(); } debut = current; prev = NULL; } else{ current = current ->get_next(); } continue; } prev = current; current = current->get_next(); } cout<<"end comput Basic Block"<<endl; BB_computed = true; return; }