kernel_memory_dump

SPPuRV vezba 12 - Graf Smetnji SPPURV1 SPPURV 1

May 20th, 2015
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include "ResourceAllocation.h"
  2. #include "InterferenceGraph.h"
  3. #include "Constants.h"
  4. #include "Instruction.h"
  5.  
  6. // REGISTAR = BOJA !!!
  7.  
  8. bool doResourceAllocation(stack<Variable*>* simplificationStack, InterferenceGraph* ig)
  9. {
  10.     list<Regs> regs; //lista boja
  11.     regs.push_back(reg3);
  12.     regs.push_back(reg2);
  13.     regs.push_back(reg1);
  14.     regs.push_back(reg0);
  15.  
  16.     Variables listaObojenih;
  17.  
  18.     simplificationStack->top()->assigment = regs.back(); //prvi obojimo bezuslovno
  19.     listaObojenih.push_back(simplificationStack->top()); //sacuvamo ga u listu obojenih
  20.     simplificationStack->pop();              //i izbacimo iz steka
  21.  
  22.     while(!simplificationStack->empty())
  23.     {
  24.         int vrsta = 0;
  25.         for(auto i = (*ig).variables->begin(); i != (*ig).variables->end(); i++)
  26.         {
  27.             if(!simplificationStack->empty())
  28.             {
  29.                 if((*i)->name == simplificationStack->top()->name)
  30.                 {
  31.                     vrsta = (*i)->pos; //u kojoj vrsti matrice je tekuci cvor
  32.                     bool smetnja = false;
  33.                     auto j = (*ig).variables->rbegin();//za poredjenje, da se proveri smetnja(__INTERFERENCE__)
  34.                     Variable *temp = simplificationStack->top();
  35.                     if((*ig).values[vrsta][(*j)->pos] == __INTERFERENCE__)  smetnja = true;
  36.                     if(!smetnja)
  37.                     {
  38.                         temp->assigment = regs.back(); //ako nema smetnje
  39.                     }
  40.                     else
  41.                     {
  42.                         if(!regs.empty()) //ako ima smetnje i ima jos boja(registara)
  43.                         {
  44.                             regs.pop_back();
  45.                             temp->assigment = regs.back();
  46.                         }
  47.                         else return false; //ako nema registara
  48.                     }
  49.                     simplificationStack->pop();
  50.                     listaObojenih.push_back(temp);
  51.                     j++; //povecava iterator za poredjenje
  52.                 }          
  53.             }
  54.         }
  55.     }
  56.     return true;
  57. }
  58.  
  59.  
  60. Instructions* removeMove(Instructions* instrs)
  61. {
  62.         return instrs;
  63. }
Add Comment
Please, Sign In to add comment