Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ResourceAllocation.h"
- #include "InterferenceGraph.h"
- #include "Constants.h"
- #include "Instruction.h"
- // REGISTAR = BOJA !!!
- bool doResourceAllocation(stack<Variable*>* simplificationStack, InterferenceGraph* ig)
- {
- list<Regs> regs; //lista boja
- regs.push_back(reg3);
- regs.push_back(reg2);
- regs.push_back(reg1);
- regs.push_back(reg0);
- Variables listaObojenih;
- simplificationStack->top()->assigment = regs.back(); //prvi obojimo bezuslovno
- listaObojenih.push_back(simplificationStack->top()); //sacuvamo ga u listu obojenih
- simplificationStack->pop(); //i izbacimo iz steka
- while(!simplificationStack->empty())
- {
- int vrsta = 0;
- for(auto i = (*ig).variables->begin(); i != (*ig).variables->end(); i++)
- {
- if(!simplificationStack->empty())
- {
- if((*i)->name == simplificationStack->top()->name)
- {
- vrsta = (*i)->pos; //u kojoj vrsti matrice je tekuci cvor
- bool smetnja = false;
- auto j = (*ig).variables->rbegin();//za poredjenje, da se proveri smetnja(__INTERFERENCE__)
- Variable *temp = simplificationStack->top();
- if((*ig).values[vrsta][(*j)->pos] == __INTERFERENCE__) smetnja = true;
- if(!smetnja)
- {
- temp->assigment = regs.back(); //ako nema smetnje
- }
- else
- {
- if(!regs.empty()) //ako ima smetnje i ima jos boja(registara)
- {
- regs.pop_back();
- temp->assigment = regs.back();
- }
- else return false; //ako nema registara
- }
- simplificationStack->pop();
- listaObojenih.push_back(temp);
- j++; //povecava iterator za poredjenje
- }
- }
- }
- }
- return true;
- }
- Instructions* removeMove(Instructions* instrs)
- {
- return instrs;
- }
Add Comment
Please, Sign In to add comment