コード例 #1
0
ファイル: Metric.java プロジェクト: imr/Electric-VLSI
  /**
   * Method that calculates how much a node overlaps with another node
   *
   * @param node1
   * @param node2
   * @return The size of the overlapping area
   */
  public double overlap(ProxyNode node1, ProxyNode node2) {
    // Check if both nodes are close enough in the x-dimension to overlap
    double X1 = node1.getPlacementX();
    double X2 = node2.getPlacementX();
    double width1 = node1.width / 2;
    double width2 = node2.width / 2;
    double distX = Math.abs(X1 - X2);
    double minDistX = width1 + width2;

    if (distX < minDistX) {
      // Check if both nodes are close enough in the y-dimension to overlap
      double Y1 = node1.getPlacementY();
      double Y2 = node2.getPlacementY();
      double height1 = node1.height / 2;
      double height2 = node2.height / 2;
      double distY = Math.abs(Y1 - Y2);
      double minDistY = height1 + height2;

      if (distY < minDistY) {
        double minX1 = X1 - width1;
        double minX2 = X2 - width2;
        double maxX1 = X1 + width1;
        double maxX2 = X2 + width2;
        double minY1 = Y1 - height1;
        double minY2 = Y2 - height2;
        double maxY1 = Y1 + height1;
        double maxY2 = Y2 + height2;

        return (Math.min(maxX2, maxX1) - Math.max(minX1, minX2))
            * (Math.min(maxY2, maxY1) - Math.max(minY1, minY2));
      }
    }

    return 0;
  }
コード例 #2
0
ファイル: GraphUtil.java プロジェクト: rjsingh/graal
 public static void checkRedundantProxy(ProxyNode vpn) {
   AbstractBeginNode proxyPoint = vpn.proxyPoint();
   if (proxyPoint instanceof LoopExitNode) {
     LoopExitNode exit = (LoopExitNode) proxyPoint;
     LoopBeginNode loopBegin = exit.loopBegin();
     ValueNode vpnValue = vpn.value();
     for (ValueNode v : loopBegin.stateAfter().values()) {
       ValueNode v2 = v;
       if (loopBegin.isPhiAtMerge(v2)) {
         v2 = ((PhiNode) v2).valueAt(loopBegin.forwardEnd());
       }
       if (vpnValue == v2) {
         Collection<PhiNode> phiUsages = vpn.usages().filter(PhiNode.class).snapshot();
         Collection<ProxyNode> proxyUsages = vpn.usages().filter(ProxyNode.class).snapshot();
         vpn.graph().replaceFloating(vpn, vpnValue);
         for (PhiNode phi : phiUsages) {
           checkRedundantPhi(phi);
         }
         for (ProxyNode proxy : proxyUsages) {
           checkRedundantProxy(proxy);
         }
         return;
       }
     }
   }
 }
コード例 #3
0
ファイル: Metric.java プロジェクト: imr/Electric-VLSI
  /**
   * Method that calculates the size of the area cover by a set of nodes. (i.e. the size of the area
   * of the bounding box of all cells)
   *
   * @param nodes
   * @return The size of the used rectangular area
   */
  public double area(List<ProxyNode> nodes) {
    double minX = Double.MAX_VALUE,
        minY = Double.MAX_VALUE,
        maxX = -Double.MAX_VALUE,
        maxY = -Double.MAX_VALUE;

    for (ProxyNode node : nodes) {
      double currMinX = node.getPlacementX() - node.width / 2;
      double currMinY = node.getPlacementY() - node.height / 2;
      double currMaxX = node.getPlacementX() + node.width / 2;
      double currMaxY = node.getPlacementY() + node.height / 2;

      if (currMinX < minX) minX = currMinX;
      if (currMinY < minY) minY = currMinY;
      if (currMaxX > maxX) maxX = currMaxX;
      if (currMaxY > maxY) maxY = currMaxY;
    }

    return (maxX - minX) * (maxY - minY);
  }