Exemple #1
0
  private int[][] getDDVec(Table<Declaration, SubscriptExpr> arrayRefs, int loopDepth) {
    if (arrayRefs == null) return new int[0][0];

    int numEdges = 0;
    Stack<DDEdge> wl = WorkArea.<DDEdge>getStack("g<SubscriptExpr>etDDVec");

    Enumeration<DDEdge> k = graph.getEdges();
    while (k.hasMoreElements()) { // Check out every array variable in the loop nest.
      DDEdge edge = k.nextElement();
      if (edge.isSpatial()) continue;

      if (edge.isLoopIndependentDependency()) continue;

      if (edge.representsAllInput()) continue;

      wl.push(edge);
      numEdges++;
    }

    int[][] DDVector = new int[numEdges][loopDepth];

    int i = 0;
    while (!wl.empty()) {
      DDEdge edge = wl.pop();
      if (trace) System.out.println("   edge " + edge);

      // Find dependence distance.

      for (int level = 1; level <= loopDepth; level++)
        DDVector[i][level - 1] = edge.getDistance(level);

      if (trace) {
        System.out.print(i);
        System.out.print(" ");
        System.out.println(edge);
      }

      i++;
    }

    WorkArea.<DDEdge>returnStack(wl);

    return DDVector;
  }