Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. void populate_map(MapOrInfo &current_map, std::vector<FullProcInfo> &proc_infos)
  2. {
  3.    std::vector<FullProcInfo> this_tier;
  4.    std::vector<FullProcInfo> next_tier;
  5.    
  6.    uint32 ThisSigMask = uint32(-1);
  7.    for (auto iter = proc_infos.begin(); iter != proc_infos.end(); ++iter)
  8.    {
  9.       const FullProcInfo &procInfo = *iter;
  10.  
  11.       ThisSigMask &= procInfo.InstructionMask;
  12.    }
  13.    assert(ThisSigMask != 0);
  14.    current_map.Mask = ThisSigMask;
  15.  
  16.    while (proc_infos.size())
  17.    {
  18.       uint32 NewMask;
  19.       bool SetNewMask = false;
  20.       for (auto iter = proc_infos.begin(); iter != proc_infos.end();)
  21.       {
  22.          const FullProcInfo &procInfo = *iter;
  23.  
  24.          if (!SetNewMask || NewMask == (procInfo.RefMask & ThisSigMask))
  25.          {
  26.             NewMask = (procInfo.RefMask & ThisSigMask);
  27.             SetNewMask = true;
  28.             next_tier.push_back(procInfo);
  29.             iter = proc_infos.erase(iter);
  30.          }
  31.          else
  32.          {
  33.             ++iter;
  34.          }
  35.       }
  36.  
  37.       if (next_tier.size())
  38.       {
  39.          auto &next_map = current_map.Map[NewMask];
  40.          if (next_tier.size() == 1)
  41.          {
  42.             next_map.Info = next_tier.front().ProcInfo;
  43.          }
  44.          else
  45.          {
  46.             next_map.init_map();
  47.             populate_map(next_map, next_tier);
  48.          }
  49.          next_tier.clear();
  50.       }
  51.    }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement