Exemplo n.º 1
0
bool ParameterizeCopyArray::
CanBeBlocked( 
     DepCompCopyArrayCollect::CopyArrayUnit& unit, int copydim)
{
   if (copydim == 0) return false;
   
   int k = 0; /* number of sweeping loop dimensions */
   for (int i = 0; i < copydim; ++i) {
      bool sweeping = false; /*QY: any sweeping loops*/
      for (DepCompCopyArrayCollect::CopyArrayUnit::NodeSet::const_iterator 
              p = unit.refs.begin(); !p.ReachEnd(); ++p) {
          int j = 0; /*number of sweeping loop dimensions per array dimension*/
          for (LoopTreeNode* loop = (*p)->GetInfo().stmt->EnclosingLoop(); 
               loop!=0 && loop != unit.root; loop = loop->EnclosingLoop()) {
            AstNodePtr ref = (*p)->GetInfo().orig;
            if (!ReferenceDimension(ref, loop->GetLoopInfo()->GetVar().GetVarName(),i)) { ++j; sweeping=true; break; }
          }
          if (j > 1) return false; /*QY: multiple loops sweeping a dimension*/
      }
      if (sweeping) ++k;
   }
   if (k == 0) return false; /* QY: no sweeping dimensions*/
   return true;
}